/**
 * Google Reader Revenue Manager placements.
 *
 * Subscription UI is rendered by Google. Native CTA placements are stacked
 * over their associated content. The custom overlay styles at the end of
 * this file apply only in the admin "custom" display mode.
 *
 * @package Ct_Integration
 */

.rrm-inline-cta-container {
    display: block;
    width: 100%;
    max-width: 760px;
    margin: 1.5rem auto;
    clear: both;
}

.rrm-inline-cta-container[hidden],
.rrm-home-inline-cta[hidden] {
    display: none !important;
}

.rrm-inline-cta-container > [rrm-inline-cta],
.rrm-home-inline-cta [rrm-inline-cta] {
    display: block;
    width: 100%;
    min-width: 0;
}

/* Keep protected content in normal flow and position Google's native CTA over
   it. This lets Chart.js and lazy widgets determine the wrapper height while
   the CTA remains completely outside document flow. */
.premium-gated-wrapper {
    position: relative;
    isolation: isolate;
    display: block;
    min-width: 0;
    min-height: var(--rrm-overlay-min-height, 0);
}

.premium-gated-wrapper > .premium-gated-content {
    position: relative;
    z-index: 0;
    min-width: 0;
}

.premium-gated-wrapper > .rrm-inline-cta-container {
    position: absolute;
    z-index: 10;
    inset: 0;
    display: grid;
    place-items: center;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: clamp(0.75rem, 3vw, 2rem);
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, background-color 160ms ease;
}

.premium-gated-wrapper > .rrm-inline-cta-container > [rrm-inline-cta] {
    width: min(100%, 760px);
}

/* Activated only after the Google host has rendered. This keeps SDK failures
   fail-open rather than blocking content behind an empty overlay. */
.premium-gated-wrapper.rrm-overlay-active > .rrm-inline-cta-container {
    opacity: 1;
    pointer-events: auto;
    background: rgba(248, 250, 252, 0.9);
}

.premium-gated-wrapper.rrm-overlay-active > .premium-gated-content {
    pointer-events: none;
    user-select: none;
}

/* Chart.js needs a stable parent box only while the CTA overlays it; otherwise
   its responsive canvas can paint outside the element height and escape the
   overlay layer. When the overlay is inactive (subscriber or ineligible), the
   canvas sizes itself so no reserved whitespace is left below the chart. */
.premium-gated-wrapper.rrm-overlay-active .historical-chart-gated-content {
    min-height: clamp(340px, 52vw, 460px);
}

.historical-chart-gated-content > canvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
}

.rrm-home-inline-cta {
    background: #f8fafc;
}

.rrm-home-inline-cta .subscription-widget {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

/* Entitled readers should not see subscription placements or ad containers.
   Covers legacy AdSense and the current Mediavine integration. */
.subscriber-mode .rrm-inline-cta-container,
.subscriber-mode .rrm-home-inline-cta,
.subscriber-mode .ct-custom-overlay-container,
.subscriber-mode .ct-custom-home-widget,
.subscriber-mode ins.adsbygoogle,
.subscriber-mode .adsbygoogle,
.subscriber-mode [data-ad-client],
.subscriber-mode [data-ad-slot],
.subscriber-mode .mv-ad-box,
.subscriber-mode .mv-video-target,
.subscriber-mode .mv-size-wrapper,
.subscriber-mode [id^="mv_slot"],
.subscriber-mode [id^="mvad-"],
.subscriber-mode [data-mediavine],
.subscriber-mode [class*="mv_slot"],
.subscriber-mode [class*="mediavine"] {
    display: none !important;
    visibility: hidden !important;
}

@media (max-width: 768px) {
    .rrm-inline-cta-container {
        margin: 1rem auto;
    }
}

/* ============================================================
   Custom paywall overlays (admin display mode "custom").
   Restored from 3503c4a4 (replaced by native RRM in c1f6a4a0) and adapted
   to the server-rendered .premium-gated-wrapper pairing. Placements are
   server-rendered [hidden] and shown by paywall.js only for confirmed
   non-subscribers, so failures stay fail-open. Every rule is scoped so RRM
   mode and the pricing page are unaffected.
   ============================================================ */

:root {
    --ct-paywall-blur: 7px;
    --ct-paywall-accent: #FF5231;
    --ct-paywall-accent-hover: #e5442a;
    --ct-paywall-ink: #0D3654;
}

.ct-custom-overlay-container {
    display: none;
}

.ct-custom-overlay-container[hidden],
.ct-custom-home-widget[hidden] {
    display: none !important;
}

.premium-gated-wrapper > .ct-custom-overlay-container {
    position: absolute;
    inset: 0;
    z-index: 10;
    margin: 0;
    justify-content: center;
    align-items: stretch;
    padding: clamp(0.75rem, 3vw, 2rem);
}

.premium-gated-wrapper.ct-custom-overlay-active > .ct-custom-overlay-container {
    display: flex;
}

.premium-gated-wrapper.ct-custom-overlay-active > .premium-gated-content {
    filter: blur(var(--ct-paywall-blur));
    -webkit-filter: blur(var(--ct-paywall-blur));
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.premium-gated-wrapper.ct-custom-overlay-active .historical-chart-gated-content {
    min-height: clamp(340px, 52vw, 460px);
}

.ct-custom-overlay-container .premium-content-overlay {
    background: rgba(255, 255, 255, 0.4);
    border: none;
    border-radius: 12px;
    padding: 1.5rem 1rem;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 10;
    animation: ct-paywall-fade-in 0.3s ease-in-out;
}

.ct-custom-overlay-container .premium-overlay-content {
    width: 100%;
    max-width: 300px;
    color: #495057;
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.ct-custom-overlay-container .premium-overlay-icon {
    color: #0D3654;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.ct-custom-overlay-container .premium-overlay-content h4 {
    margin: 0 0 0.5rem 0;
    color: #0D3654;
    font-size: 1.25rem;
    font-weight: 600;
}

.ct-custom-overlay-container .premium-overlay-content p {
    margin: 0 0 1.5rem 0;
    color: #6c757d;
    line-height: 1.5;
}

.ct-custom-overlay-container .premium-benefits-list {
    list-style: none;
    padding: 0;
    margin: 1rem auto;
    text-align: left;
    display: inline-block;
    max-width: 250px;
}

.ct-custom-overlay-container .premium-benefits-list li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 0.9rem;
    list-style: none;
}

.ct-custom-overlay-container .premium-benefits-list li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: #28a745;
    font-weight: bold;
}

/* CTA buttons (overlay card and homepage card). */
.ct-custom-overlay-container .ct-paywall-cta,
.ct-custom-home-widget .ct-paywall-cta {
    margin-top: 1rem;
    border: none;
    border-radius: 12px;
    background: var(--ct-paywall-accent);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ct-custom-overlay-container .ct-paywall-cta:hover,
.ct-custom-home-widget .ct-paywall-cta:hover {
    background: var(--ct-paywall-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 82, 49, 0.4);
}

.ct-custom-overlay-container .ct-paywall-cta:focus-visible,
.ct-custom-home-widget .ct-paywall-cta:focus-visible {
    outline: 2px solid var(--ct-paywall-ink);
    outline-offset: 2px;
}

/* "Already a subscriber?" sign-in link. */
.ct-custom-overlay-container .already-contributor-link {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.ct-custom-overlay-container .already-contributor-link button {
    color: #6c757d;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s ease;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.ct-custom-overlay-container .already-contributor-link button:hover {
    color: var(--ct-paywall-ink);
    text-decoration: underline;
}

.ct-custom-overlay-container .already-contributor-link button:focus-visible {
    outline: 2px solid var(--ct-paywall-ink);
    outline-offset: 2px;
    border-radius: 2px;
}

@keyframes ct-paywall-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Custom homepage pricing card. */
.ct-custom-home-widget.subscription-widget-section {
    background: #f8fafc;
    font-family: 'Montserrat', sans-serif;
}

.ct-custom-home-widget .subscription-widget {
    max-width: 500px;
    margin: 0 auto;
}

.ct-custom-home-widget .subscription-heading {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: #0D3654;
}

.ct-custom-home-widget .subscription-subheading {
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    color: #333333;
}

.ct-custom-home-widget .subscription-plan-card {
    background: #ffffff;
    border: 1px solid #d8dde1;
    border-radius: 12px;
    padding: 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0px 20px 50px rgba(18, 17, 39, 0.08);
}

.ct-custom-home-widget .subscription-plan-card.featured {
    border: 2px solid #FF5231;
}

.ct-custom-home-widget .featured-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #FF5231;
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 18px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.ct-custom-home-widget .plan-pricing {
    text-align: center;
    margin-bottom: 1.5rem;
}

.ct-custom-home-widget .price-display {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
}

.ct-custom-home-widget .price-display .currency {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #0D3654;
}

.ct-custom-home-widget .price-display .amount {
    font-family: 'Montserrat', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    color: #0D3654;
    line-height: 1;
}

.ct-custom-home-widget .one-time-label {
    margin-top: 0.75rem;
}

.ct-custom-home-widget .one-time-text {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    color: #0D3654;
    font-weight: 500;
}

.ct-custom-home-widget .plan-cta {
    margin-bottom: 1.5rem;
}

.ct-custom-home-widget .plan-subscribe-btn {
    padding: 14px 24px;
}

.ct-custom-home-widget .plan-features {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

.ct-custom-home-widget .plan-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    color: #333333;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f5f6;
}

.ct-custom-home-widget .plan-features li:last-child {
    border-bottom: none;
}

.ct-custom-home-widget .feature-check {
    color: #FF5231;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .ct-custom-overlay-container .premium-content-overlay {
        padding: 1.5rem;
    }

    .ct-custom-overlay-container .premium-overlay-content {
        max-width: 100%;
        padding: 1rem;
    }

    .ct-custom-overlay-container .premium-overlay-content h4 {
        font-size: 1.1rem;
    }

    .ct-custom-overlay-container .ct-paywall-cta {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }

    .ct-custom-overlay-container .already-contributor-link {
        margin-top: 0.75rem;
        padding-top: 0.5rem;
    }

    .ct-custom-overlay-container .already-contributor-link button {
        font-size: 0.8rem;
    }

    .ct-custom-home-widget .subscription-heading {
        font-size: 1.5rem;
    }

    .ct-custom-home-widget .subscription-subheading {
        font-size: 0.9rem;
    }

    .ct-custom-home-widget .subscription-plan-card {
        padding: 1.5rem;
    }

    .ct-custom-home-widget .price-display .amount {
        font-size: 2.5rem;
    }

    .ct-custom-home-widget .plan-features li {
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    .ct-custom-home-widget.subscription-widget-section {
        padding: 2rem 0;
    }

    .ct-custom-home-widget .featured-badge {
        font-size: 0.65rem;
        padding: 5px 12px;
    }
}
