/* ==========================================================================
   Floating video-lesson player
   --------------------------------------------------------------------------
   A dock that sits above the page and outlives navigation between pages, so a
   lesson keeps playing while the student reads the written notes for it.

   z-index sits above the navbar (1000) and the syllabus sidebar (1000) but the
   dock is deliberately not full-screen: the page underneath stays usable.
   ========================================================================== */

#cs-video-dock {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 420px;
    z-index: 1200;
    background: #101317;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    color: #fff;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    overflow: hidden;
    display: none;
    /* Keep the dock inside the viewport when it is dragged near an edge. */
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
}
#cs-video-dock.is-open { display: block; }
#cs-video-dock.size-lg { width: 640px; }
#cs-video-dock.size-sm { width: 320px; }
#cs-video-dock.is-dragging { transition: none; user-select: none; }

/* ---- title bar --------------------------------------------------------- */
.csv-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 13px;
    background: #171b21;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: grab;
}
#cs-video-dock.is-dragging .csv-bar { cursor: grabbing; }
.csv-bar-text { flex: 1; min-width: 0; line-height: 1.25; }
.csv-bar-code {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--green, #2ecc71);
    font-weight: 700;
}
.csv-bar-title {
    font-size: 0.83rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.csv-btn {
    background: transparent;
    border: 0;
    color: #98a2b3;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.85rem;
    flex: none;
    transition: 0.15s;
}
.csv-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.csv-btn.is-on { color: var(--green, #2ecc71); background: rgba(46, 204, 113, 0.14); }

/* ---- video frame ------------------------------------------------------- */
.csv-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
#cs-video-frame { position: absolute; inset: 0; }
.csv-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Autoplay after a page change is not guaranteed; when the browser refuses,
   this is the one tap that gets it going again. */
.csv-resume {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(8, 10, 12, 0.82);
    cursor: pointer;
    text-align: center;
    padding: 16px;
    z-index: 2;
}
.csv-resume.is-shown { display: flex; }
.csv-resume i { font-size: 2.1rem; color: var(--green, #2ecc71); }
.csv-resume span { font-size: 0.82rem; color: #cbd5e1; }

/* ---- transport --------------------------------------------------------- */
.csv-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: #14181d;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.csv-pos { flex: 1; font-size: 0.7rem; color: #7d8794; padding-left: 6px; }
.csv-autoplay {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.66rem;
    color: #7d8794;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-right: 4px;
    cursor: pointer;
    user-select: none;
}

/* ---- queue ------------------------------------------------------------- */
.csv-queue { display: none; max-height: 260px; overflow-y: auto; background: #0c0e11; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.csv-queue.is-open { display: block; }
.csv-queue-topic {
    padding: 9px 13px 5px;
    font-size: 0.63rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #5b6673;
    font-weight: 700;
    position: sticky;
    top: 0;
    background: #0c0e11;
}
.csv-item {
    display: flex;
    align-items: baseline;
    gap: 9px;
    width: 100%;
    padding: 8px 13px;
    background: transparent;
    border: 0;
    border-left: 3px solid transparent;
    color: #c4cdd8;
    font-size: 0.79rem;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.csv-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.csv-item.is-current { border-left-color: var(--green, #2ecc71); background: rgba(46, 204, 113, 0.1); color: #fff; }
.csv-item-code { flex: none; width: 38px; font-size: 0.68rem; color: #6b7684; font-weight: 700; }
.csv-item.is-current .csv-item-code { color: var(--green, #2ecc71); }
.csv-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csv-item-dur { flex: none; font-size: 0.68rem; color: #6b7684; }
.csv-queue-foot { padding: 9px 13px 12px; font-size: 0.7rem; color: #5b6673; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.csv-queue-foot a { color: var(--green, #2ecc71); text-decoration: none; }

/* ---- minimised --------------------------------------------------------- */
#cs-video-dock.is-min .csv-stage,
#cs-video-dock.is-min .csv-controls,
#cs-video-dock.is-min .csv-queue { display: none; }
#cs-video-dock.is-min { width: 300px; }
/* The iframe must stay in the DOM while minimised or playback stops, so it is
   parked off-screen rather than hidden with display:none. */
#cs-video-dock.is-min .csv-stage {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
}

/* ---- launcher ---------------------------------------------------------- */
#cs-video-launch {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1199;
    display: none;
    align-items: center;
    gap: 9px;
    padding: 11px 17px;
    background: var(--navy, #1a1d23);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 30px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.32);
    font: 600 0.8rem 'Inter', 'Segoe UI', sans-serif;
    cursor: pointer;
}
#cs-video-launch.is-shown { display: flex; }
#cs-video-launch i { color: var(--green, #2ecc71); }
#cs-video-launch:hover { background: #23272f; }

/* ---- in-page "watch" buttons ------------------------------------------- */
.btn-watch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: #ff0033;
    color: #fff;
    border: 0;
    border-radius: 8px;
    font: 700 0.82rem 'Inter', 'Segoe UI', sans-serif;
    cursor: pointer;
    text-decoration: none;
}
.btn-watch:hover { background: #d9002b; }
.btn-watch.ghost { background: rgba(255, 0, 51, 0.08); color: #c9002a; border: 1px solid rgba(255, 0, 51, 0.25); }
.btn-watch.ghost:hover { background: rgba(255, 0, 51, 0.16); }

/* The syllabus lesson card gets a strip above the notes. */
.lesson-video-strip {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 18px;
    margin-bottom: 24px;
    background: #fff5f7;
    border: 1px solid rgba(255, 0, 51, 0.15);
    border-radius: 10px;
}
.lesson-video-strip .strip-text { flex: 1; min-width: 190px; font-size: 0.88rem; color: #6b4a52; }
.lesson-video-strip .strip-text strong { color: #1a1d23; display: block; font-size: 0.95rem; }

/* ---- soft navigation --------------------------------------------------- */
/* A thin progress line while a page is swapped in under the player. */
#cs-softnav-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--green, #2ecc71);
    z-index: 3000;
    opacity: 0;
    transition: width 0.2s ease, opacity 0.3s;
    pointer-events: none;
}
#cs-softnav-bar.is-busy { opacity: 1; }

/* ---- phones ------------------------------------------------------------ */
@media (max-width: 640px) {
    #cs-video-dock,
    #cs-video-dock.size-lg,
    #cs-video-dock.size-sm {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 14px 14px 0 0;
        /* Dragging a full-width sheet around a phone screen helps nobody. */
        transform: none !important;
    }
    #cs-video-dock.is-min { width: 100%; }
    .csv-bar { cursor: default; }
    /* The sheet must not swallow the page it is meant to sit beside. */
    .csv-queue { max-height: 30vh; }
    #cs-video-launch { right: 14px; bottom: 14px; padding: 10px 14px; }
}

@media print {
    #cs-video-dock, #cs-video-launch, #cs-softnav-bar, .lesson-video-strip { display: none !important; }
}
