/* ──────────────────────────────────────────────────────────────
   Binge mode — a self-contained video-playlist overlay.
   Opened from a module card on the content home; queues that
   module's videos in course order and autoplays through them.
   Colors reference shared/v5-tokens.css; the module accent is
   injected per-open as --binge-accent.
   ────────────────────────────────────────────────────────────── */
.binge-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: color-mix(in srgb, var(--v5-ink, #0E0E10) 78%, transparent);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5vh 2.5vw;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.binge-overlay.is-open { opacity: 1; }

.binge-modal {
    --binge-accent: #2563EB;
    width: 100%;
    max-width: 1500px;
    /* a DEFINITE height so the 1fr stage row gets real height and the video
       (height:100%) fills the big left panel instead of collapsing to its
       controls bar. The playlist sits in the fixed-width right column. */
    height: 92vh;
    background: var(--v5-bg, #fff);
    border-radius: var(--v5-r, 14px);
    overflow: hidden;
    display: grid;
    /* video gets two thirds, the clickable title list gets one third.
       Rows: head, the video stage, then a thin prefs bar under the video. */
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}

.binge-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--v5-hairline, #E6E7EA);
}
.binge-badge {
    font-family: var(--v5-mono, monospace);
    font-weight: 600;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    color: #fff;
    background: var(--binge-accent);
    padding: 3px 8px;
    border-radius: 6px;
}
.binge-title {
    font-family: var(--v5-serif, Georgia, serif);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--v5-ink, #0E0E10);
    margin: 0;
}
.binge-now {
    font-family: var(--v5-mono, monospace);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--v5-muted, #6B7280);
    margin-left: auto;
}
.binge-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--v5-muted, #6B7280);
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
}
.binge-close:hover { color: var(--v5-ink, #0E0E10); background: var(--v5-hairline, #eee); }

.binge-stage {
    grid-column: 1;
    grid-row: 2;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}
/* Video-prefs bar (speed / captions), injected under the video on the left. */
.binge-prefs {
    grid-column: 1;
    grid-row: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.4rem 0.9rem;
    border-top: 1px solid var(--v5-hairline, #E6E7EA);
    background: var(--v5-surface, #fafafa);
}
.binge-stage video {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #000;
}

.binge-queue {
    grid-column: 2;
    grid-row: 2 / span 2;   /* the playlist holds the full-height right column */
    border-left: 1px solid var(--v5-hairline, #E6E7EA);
    overflow-y: auto;
    min-height: 0;
    padding: 0.5rem 0;
    background: var(--v5-surface, #fafafa);
}
.binge-section {
    font-family: var(--v5-mono, monospace);
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--v5-muted, #6B7280);
    padding: 0.7rem 1rem 0.35rem;
}
.binge-item {
    display: grid;
    grid-template-columns: 22px 64px 1fr;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 1rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.12s;
}
.binge-item:hover { background: var(--v5-hairline, #eef); }
.binge-item.is-active {
    background: color-mix(in srgb, var(--binge-accent) 10%, transparent);
    border-left-color: var(--binge-accent);
}
.binge-num {
    font-family: var(--v5-mono, monospace);
    font-size: 0.7rem;
    color: var(--v5-muted, #6B7280);
    text-align: center;
}
.binge-item.is-active .binge-num { color: var(--binge-accent); font-weight: 700; }
.binge-thumb {
    width: 64px;
    height: 38px;
    border-radius: 4px;
    object-fit: cover;
    background: #000;
    border: 1px solid var(--v5-hairline, #ddd);
}
.binge-name {
    font-family: var(--v5-sans, sans-serif);
    font-size: 0.8rem;
    line-height: 1.25;
    color: var(--v5-text, #222);
}
.binge-item.is-active .binge-name { color: var(--v5-ink, #000); font-weight: 600; }

/* "Binge" launcher button used on the module cards. */
.module-binge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: 1px solid var(--accent, #2563EB);
    color: var(--accent, #2563EB);
    border-radius: 99px;
    font-family: var(--v5-mono, monospace);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 9px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.module-binge:hover { background: var(--accent, #2563EB); color: #fff; }

@media (max-width: 820px) {
    .binge-modal {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr) auto auto;
        max-height: 95vh;
    }
    /* Single column: head, video, prefs, queue stacked (reset the desktop placement). */
    .binge-stage, .binge-prefs, .binge-queue { grid-column: 1; }
    .binge-stage { grid-row: 2; }
    .binge-prefs { grid-row: 3; }
    .binge-queue {
        grid-row: 4;
        border-left: none;
        border-top: 1px solid var(--v5-hairline, #E6E7EA);
        max-height: 38vh;
    }
}
