/* ============================================================
   WP Paywall Plugin – Frontend Styles (Enhanced)
   ============================================================ */

[hidden] {
    display: none !important;
}

/* ── Button base ─────────────────────────────────────────── */
#wppp-restricted-content-buy-button-link,
#wppp-restricted-content-print-button {
    text-decoration: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
}

@media print {
    #wppp-restricted-content-print-button {
        display: none !important;
    }
}

/* ── Paywall wrapper ─────────────────────────────────────── */
.wppp-paywall-wrapper {
    position: relative;
    margin-bottom: 2em;
}

/* ── Excerpt area ────────────────────────────────────────── */
.wppp-excerpt {
    margin-bottom: 1.25em;
    color: inherit;
}

/* ════════════════════════════════════════════════════════════
   BLUR MODE
   ════════════════════════════════════════════════════════════ */
.wppp-blur-mode .wppp-blurred-content {
    -webkit-filter: blur(6px);
    filter: blur(6px);
    user-select: none;
    pointer-events: none;
    max-height: 420px;
    overflow: hidden;
    position: relative;
}

/* Fade-to-white at bottom of blurred content */
.wppp-blur-mode .wppp-blurred-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 140px;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    pointer-events: none;
}

/* The overlay panel sits on top */
.wppp-blur-mode .wppp-paywall-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 24px 16px 32px;
}

/* ════════════════════════════════════════════════════════════
   PAYWALL BOX (both modes)
   ════════════════════════════════════════════════════════════ */
.wppp-paywall-box {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 28px 32px;
    text-align: center;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

/*
 * v2 paywall — neutral “editorial / product” (2024+): zinc surfaces, one accent
 * from settings on the top bar only; primary action = charcoal (not theme purple).
 * --wppp-cta: set on box via PHP (Settings CTA colour).
 */
.wppp-paywall-box--v2 {
    --wppp-surface: #fafafa;
    --wppp-ink: #0a0a0a;
    --wppp-muted: #737373;
    --wppp-border: rgba(0, 0, 0, 0.08);
    /* --wppp-cta: set inline from Settings → CTA Button Colour (PHP) */
    position: relative;
    max-width: 400px;
    padding: 0;
    text-align: left;
    border: 1px solid var(--wppp-border);
    border-radius: 24px;
    overflow: hidden;
    background: #fff;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 24px 48px -12px rgba(0, 0, 0, 0.12);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* Brand accent: thin top bar (matches CTA setting via inline --wppp-cta) */
.wppp-paywall-box--v2::before {
    content: "";
    display: block;
    height: 3px;
    width: 100%;
    background: var(--wppp-cta, #0073aa);
}

.wppp-paywall-box--v2 .wppp-paywall-box__head {
    text-align: center;
    padding: 1.75rem 1.5rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--wppp-border);
}

.wppp-paywall-box--v2 .wppp-paywall-box__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.75rem;
    border-radius: 12px;
    color: #525252;
    background: #f5f5f5;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.wppp-paywall-box--v2 .wppp-paywall-box__icon .wppp-paywall-box__icon-svg {
    display: block;
}

.wppp-paywall-box--v2 .wppp-paywall-headline {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.2;
    margin: 0 0 0.5rem;
    color: var(--wppp-ink);
}

.wppp-paywall-box--v2 .wppp-paywall-subtext {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--wppp-muted);
    margin: 0;
    font-weight: 400;
    max-width: 28ch;
    margin-left: auto;
    margin-right: auto;
}

.wppp-paywall-box--v2 .wppp-paywall-box__body {
    padding: 0;
    background: var(--wppp-surface);
}

.wppp-paywall-box--v2 .wppp-paywall-box__foot {
    padding: 0 1.25rem 1.5rem;
    background: #fff;
}

.wppp-paywall-box--v2 .wppp-paywall-box__foot .wppp-login-prompt {
    margin: 0;
    padding-top: 1.125rem;
    border-top: 1px solid var(--wppp-border);
    text-align: center;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--wppp-muted);
}

.wppp-paywall-box--v2 .wppp-paywall-box__foot .wppp-login-prompt a {
    color: var(--wppp-ink);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(0, 0, 0, 0.2);
    border: none;
}

.wppp-paywall-box--v2 .wppp-paywall-box__foot .wppp-login-prompt a:hover {
    text-decoration-color: var(--wppp-ink);
}

/* WooCommerce product list inside paywall */
.wppp-clearfix::after {
    content: "";
    display: table;
    clear: both;
}

.wppp-paywall-box--v2 .wppp-paywall-products {
    background: var(--wppp-surface) !important;
    padding: 1.25rem 1.25rem 1.5rem;
}

.wppp-paywall-box--v2 .wppp-paywall-products ul.products {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* White product card; !important resists theme/Woo “purple slab” */
.wppp-paywall-box--v2 .wppp-paywall-products li.product {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100% !important;
    max-width: none !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    background-color: #fff !important;
    background-image: none !important;
    border: 1px solid var(--wppp-border) !important;
    border-radius: 16px;
    text-align: left;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product:hover {
    border-color: rgba(0, 0, 0, 0.12) !important;
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.1) !important;
}

/* ── Theme resets (Astra, Storefront, block themes): no dark disc / circular hero behind text ─ */
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-LoopProduct-link.woocommerce-loop-product__link,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-LoopProduct-link {
    display: block;
    margin: 0;
    text-decoration: none;
    order: 1 !important;
    position: static !important;
    background: transparent !important;
    color: #171717 !important;
    border-radius: 0 !important;
    min-height: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-LoopProduct-link::before,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-LoopProduct-link::after,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-loop-product__link::before,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-loop-product__link::after {
    content: none !important;
    display: none !important;
}

/* Thumbnail wrappers (often a circle or dark box in themes) */
.wppp-paywall-box--v2 .wppp-paywall-products li.product [class*="thumbnail"],
.wppp-paywall-box--v2 .wppp-paywall-products li.product [class*="thumbnail-wrap"],
.wppp-paywall-box--v2 .wppp-paywall-products li.product .astra-shop-thumbnail-wrap,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .astra-woo-shop-thumbnail-wrap,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .wp-block-woocommerce-product-image {
    width: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    background: #f0f0f0 !important;
    background-color: #f0f0f0 !important;
    overflow: hidden;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    aspect-ratio: 16 / 9;
    min-height: 0 !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-LoopProduct-link img,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .woocommerce-LoopProduct-link img {
    display: block;
    width: 100% !important;
    max-height: 160px;
    min-height: 0 !important;
    object-fit: cover;
    object-position: center;
    border-radius: 0 !important;
    margin: 0 !important;
    background: #e5e5e5 !important;
    aspect-ratio: 16 / 9;
    filter: none !important;
    opacity: 1 !important;
    box-shadow: none !important;
    border: 0 !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product .woocommerce-loop-product__title,
.wppp-paywall-box--v2 .wppp-paywall-products li.product h2.woocommerce-loop-product__title,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.woocommerce-LoopProduct-link .woocommerce-loop-product__title,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .woocommerce-loop-product__title a {
    font-size: 1.0625rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.02em;
    line-height: 1.35 !important;
    margin: 0 !important;
    padding: 0.9rem 1rem 0.35rem !important;
    color: #171717 !important;
    background: transparent !important;
    text-shadow: none !important;
    position: static !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product .price {
    display: block;
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    color: #171717 !important;
    margin: 0 0 0.75rem !important;
    padding: 0 1rem !important;
    letter-spacing: -0.02em;
    font-feature-settings: "tnum" 1, "lnum" 1;
    background: transparent !important;
    opacity: 1 !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product .price .amount,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .price .woocommerce-Price-amount,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .price bdi,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .price ins,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .price span {
    color: #171717 !important;
    background: transparent !important;
    opacity: 1 !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product .price del {
    font-size: 0.9em;
    font-weight: 500;
    opacity: 0.6;
    margin-right: 0.35em;
}

/* Add to cart: uses --wppp-cta from Settings (inline on .wppp-paywall-box--v2) */
.wppp-paywall-box--v2 .wppp-paywall-products li.product .button,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.button,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .add_to_cart_button {
    order: 2 !important;
    display: block !important;
    width: calc(100% - 2rem) !important;
    max-width: 100% !important;
    text-align: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    padding: 0.8125rem 1.5rem !important;
    margin: 0 1rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    line-height: 1.3 !important;
    border: 1px solid var(--wppp-cta, #0073aa) !important;
    border-radius: 9999px !important;
    color: #fff !important;
    text-decoration: none !important;
    text-transform: none !important;
    background: var(--wppp-cta, #0073aa) !important;
    background-color: var(--wppp-cta, #0073aa) !important;
    background-image: none !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) !important;
    transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product .button:hover,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.button:hover,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .add_to_cart_button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12) !important;
    filter: brightness(0.94);
    opacity: 1 !important;
    color: #fff !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product .button:focus,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.button:focus,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .add_to_cart_button:focus {
    outline: 2px solid var(--wppp-cta, #0073aa) !important;
    outline-offset: 2px;
    filter: none;
}

/* WooCommerce AJAX: “View cart” (a.added_to_cart) inserted after the button — keep it full-width under the CTA */
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.added_to_cart,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.wc-forward.added_to_cart {
    order: 3 !important;
    display: block !important;
    width: calc(100% - 2rem) !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: -0.35rem 1rem 1rem !important;
    padding: 0.35rem 0.5rem 0.5rem !important;
    text-align: center !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    text-decoration: none !important;
    color: var(--wppp-cta, #0073aa) !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    clear: both;
    float: none !important;
    position: static !important;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product a.added_to_cart:hover,
.wppp-paywall-box--v2 .wppp-paywall-products li.product a.wc-forward.added_to_cart:hover {
    text-decoration: underline !important;
    color: #171717 !important;
    filter: none;
    opacity: 1 !important;
}

/* Wrap inner columns when theme outputs default WC column structure */
.wppp-paywall-box--v2 .wppp-paywall-products li.product > *:not(a):not(.button):not(.added_to_cart):not(span.added_to_cart) {
    min-width: 0;
}

.wppp-paywall-box--v2 .wppp-paywall-products li.product .star-rating {
    display: none;
}

/* Theme “Uncategorized” / product meta (small) */
.wppp-paywall-box--v2 .wppp-paywall-products .woocommerce-loop-product__link + .ast-woo-product-category,
.wppp-paywall-box--v2 .wppp-paywall-products .product-category,
.wppp-paywall-box--v2 .wppp-paywall-products li.product .ast-loop-product__category {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 0.25rem;
    display: block;
}

/* Legacy box (non --v2) */
.wppp-paywall-headline {
    font-size: 1.35em;
    font-weight: 700;
    margin: 0 0 10px;
    color: #1a202c;
}

.wppp-paywall-box:not(.wppp-paywall-box--v2) .wppp-paywall-subtext {
    font-size: .95em;
    color: #4a5568;
    margin-bottom: 20px;
}

.wppp-paywall-box--v2 + .wppp-restricted-content-end,
#wppp-restricted-content .wppp-restricted-content-end {
    margin-top: 0.5rem;
}

/* ── CTA button ──────────────────────────────────────────── */
.wppp-cta-button {
    display: inline-block;
    padding: 12px 28px !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-weight: 600;
    font-size: 1em;
    text-decoration: none !important;
    cursor: pointer;
    border: none !important;
    transition: opacity .15s;
}
.wppp-cta-button:hover { opacity: .88; }

/* ── Login prompt ────────────────────────────────────────── */
.wppp-login-prompt {
    margin-top: 14px;
    font-size: .9em;
    color: #718096;
}
.wppp-login-prompt a { color: #0073aa; }

/* ════════════════════════════════════════════════════════════
   EXPIRY WARNING BANNER
   ════════════════════════════════════════════════════════════ */
.wppp-expiry-warning {
    background: #fffbeb;
    border: 1px solid #f6e05e;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 1.25em;
    font-size: .92em;
    color: #744210;
}
.wppp-expiry-warning a {
    color: #c05621;
    font-weight: 600;
}

/* ════════════════════════════════════════════════════════════
   PRODUCT CARD OVERLAY (add-to-cart spinner)
   ════════════════════════════════════════════════════════════ */
.wppp-overlay-backdrop {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #000;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}
.wppp-overlay-backdrop.wppp-opened {
    opacity: .6;
    pointer-events: auto;
}

/* ════════════════════════════════════════════════════════════
   CHECKOUT SUCCESS POPUP
   ════════════════════════════════════════════════════════════ */
.wppp-checkout-success-popup {
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: all;
    background-color: rgba(0,0,0,.8);
    user-select: auto;
    position: fixed;
    height: 100%; width: 100%;
    bottom: 0; left: 0;
    z-index: 9999;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    body.admin-bar .wppp-checkout-success-popup { height: calc(100vh - 32px); }
}

@keyframes wpppFadeInUp {
    from { opacity: 0; transform: translate3d(0, 100%, 0); }
    to   { opacity: 1; transform: none; }
}

.wppp-checkout-success-popup-dialog {
    animation: wpppFadeInUp 1.2s;
    border-radius: 25px;
    box-shadow: 2px 8px 23px 3px rgba(0,0,0,.2);
    background: #fff;
    max-width: 96%;
    max-height: 100%;
    pointer-events: all;
    position: absolute;
    margin: auto;
    left: 2%; right: 2%;
}

@media (min-width: 576px) {
    .wppp-checkout-success-popup-dialog { max-width: 640px; left: 0; right: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .wppp-checkout-success-popup-dialog { animation: none; }
}

.wppp-checkout-success-popup-dialog-container {
    width: 100%; max-width: 640px;
    max-height: 100vh;
    overflow: auto;
    display: flex;
    line-height: 1.5;
    box-sizing: border-box;
}

.wppp-checkout-success-popup-text {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    text-align: center;
}

/* ════════════════════════════════════════════════════════════
   NOT-LOGGED-IN legacy classes (kept for compat)
   ════════════════════════════════════════════════════════════ */
.wppp-not-logged-in-message {
    display: flex; align-items: center; justify-content: center;
}
.wppp-not-logged-in-message-container {
    display: flex; flex-direction: column;
    justify-content: flex-start; align-items: center; padding: 16px;
}
.wppp-not-logged-in-message-link-buttons { display: flex; }
