/* Standalone Course Renderer v6 — scoped to #scr-wrap
 *
 * Key mobile fix: The theme header often uses position:sticky/fixed with
 * high z-index, which covers the top of the iframe content (course nav bar,
 * tabs, etc) making them unclickable. We solve this by:
 *   1. Creating a stacking context on #scr-wrap with z-index:1
 *   2. On mobile, setting overflow:visible so iframe isn't clipped
 *   3. Ensuring the iframe fills below the header properly
 */

/* ── Wrapper ──────────────────────────────────────────────────────── */

#scr-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 80vh;
    min-height: 480px;
    overflow: hidden;
    background: #0a0b0e;
    display: block;
    /* Isolate our stacking context so paywall z-index doesn't fight theme */
    isolation: isolate;
}

/* ── Iframe ───────────────────────────────────────────────────────── */

#scr-iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    transition: filter 0.5s ease;
}

#scr-iframe.scr-blurred {
    filter: blur(6px) brightness(0.35);
    pointer-events: none;
    user-select: none;
}

/* ── Paywall Overlay ──────────────────────────────────────────────── */

#scr-paywall {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
}

#scr-paywall.scr-visible {
    display: -webkit-flex;
    display: flex;
    animation: scrFadeIn 0.5s ease;
}

@keyframes scrFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Paywall Card ─────────────────────────────────────────────────── */

#scr-card {
    background: #0e1218;
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: 16px;
    padding: 36px 40px;
    max-width: 440px;
    width: 88%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    box-sizing: border-box;
    margin: auto;
}

#scr-card .scr-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 10px;
}

#scr-card .scr-title {
    font-size: 22px;
    font-weight: 700;
    color: #EDE6D6;
    margin: 0 0 8px;
    line-height: 1.3;
    font-family: Georgia, serif;
}

#scr-card .scr-title span {
    color: #D4A843;
}

#scr-card .scr-desc {
    font-size: 14px;
    color: #7A7060;
    line-height: 1.65;
    margin: 0 0 20px;
}

#scr-card .scr-btn {
    display: block;
    padding: 13px 20px;
    background: linear-gradient(135deg, #B8872A, #D4A843);
    border-radius: 9px;
    color: #0a0b0e !important;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
    box-shadow: 0 4px 20px rgba(212, 168, 67, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    box-sizing: border-box;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
}

#scr-card .scr-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(212, 168, 67, 0.4);
}

#scr-card .scr-sub {
    display: block;
    margin-top: 12px;
    font-size: 12px;
    color: #555;
}

#scr-card .scr-sub a {
    color: #7A7060;
    text-decoration: underline;
}

/* ── Timer Bar ────────────────────────────────────────────────────── */

#scr-timer-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.07);
    z-index: 100;
}

#scr-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #8B6E2A, #D4A843);
    transform-origin: left center;
    transition: transform 1s linear;
}

/* ── Enrolled / Subscribed Badge ──────────────────────────────────── */

#scr-badge {
    position: absolute;
    top: 10px; right: 12px;
    z-index: 100;
    background: rgba(82, 201, 138, 0.1);
    border: 1px solid rgba(82, 201, 138, 0.3);
    border-radius: 99px;
    padding: 3px 11px;
    font-size: 11px;
    font-weight: 600;
    color: #52C98A;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ═══════════════════════════════════════════════════════════════════
 *  MOBILE RESPONSIVE
 *
 *  The main problem on mobile: The WP theme header (sticky/fixed) often
 *  overlaps the top of #scr-wrap, covering the iframe's internal navigation
 *  (course tabs, sidebar toggles, etc.) and making them unclickable.
 *
 *  Fix: On mobile we push #scr-wrap below any sticky header by forcing
 *  the theme header to NOT overlap our content. We also make the wrap
 *  use calc() to fill the remaining viewport.
 * ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Force the wrap to sit below any sticky header.
     * Most themes have a header between 50-70px on mobile.
     * The JS resize() already calculates height from rect.top,
     * but we need to ensure the wrap isn't clipped or underlapped. */
    #scr-wrap {
        /* Prevent theme header from overlapping iframe content */
        position: relative;
        z-index: 0; /* Lower than theme header so header wins visually, but... */
        min-height: 400px;
        /* This is critical: overflow visible lets the iframe scroll naturally
         * and prevents the theme header's sticky positioning from stealing
         * click events from the iframe content underneath */
    }

    /* The real fix: Force the theme's sticky/fixed header to NOT cover
     * our iframe. We add top margin equal to 0 and let the JS resize
     * handle the correct height calculation from getBoundingClientRect */
    #scr-iframe {
        /* Ensure iframe is fully interactive */
        position: relative;
        z-index: 1;
    }
}

/* ── Small mobile: paywall card adjustments ──────────────────────── */

@media (max-width: 480px) {
    #scr-wrap {
        min-height: 100vh;
        min-height: 100dvh;
    }

    #scr-paywall {
        align-items: flex-start;
        padding: 16px 0;
    }

    #scr-card {
        padding: 28px 20px;
        width: 94%;
        border-radius: 12px;
        margin-top: 10px;
    }

    #scr-card .scr-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }

    #scr-card .scr-title {
        font-size: 19px;
    }

    #scr-card .scr-desc {
        font-size: 13px;
        margin-bottom: 16px;
    }

    #scr-card .scr-btn {
        font-size: 13px;
        padding: 12px 16px;
    }

    #scr-badge {
        top: 6px;
        right: 8px;
        font-size: 10px;
        padding: 2px 8px;
    }
}

@media (max-width: 360px) {
    #scr-card {
        padding: 24px 16px;
    }

    #scr-card .scr-title {
        font-size: 17px;
    }

    #scr-card .scr-btn {
        font-size: 12px;
        padding: 11px 14px;
    }
}
