/* ---------- subject page (chapters + video player) ---------- */

/* Wider container override for the three-column layout */
.wrap--wide {
    max-width: 1800px
}

/* ---------- Three-column grid ---------- */
.subject-grid {
    display: grid;
    grid-template-columns: 250px 1fr 320px;
    gap: 32px;
    padding: 24px 0 110px;
    align-items: start
}

/* ---------- Left column: chapter nav ---------- */
.chapter-tabs {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.chapter-tab {
    font-size: 13px;
    letter-spacing: .04em;
    padding: 10px 18px;
    border: 1px solid var(--line);
    color: var(--soft);
    transition: all .2s
}

.chapter-tab:hover {
    border-color: var(--line-dark);
    color: var(--ink)
}

.chapter-tab.active {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink)
}

/* ---------- Center column: video area ---------- */
#video-area {
    min-width: 0
}

.video-player-area {
    display: contents
}

.main-video-player {
    grid-column: 2;
    grid-row: 1;
    aspect-ratio: 16/9;
    background: var(--ink);
    overflow: hidden
}

.main-video-player iframe {
    width: 100%;
    height: 100%;
    border: 0
}

.video-info {
    grid-column: 2;
    grid-row: 2
}

.video-info-topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px
}

.video-info-topbar h2 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(22px, 3vw, 30px);
    letter-spacing: -.01em
}

.video-badge {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--faint);
    white-space: nowrap
}

#main-video-desc {
    margin-top: 8px;
    color: var(--faint);
    font-size: 14px
}

/* ---------- Right column: lessons panel ---------- */
/*
  The lessons-section is rendered inside .video-player-area (the partial),
  but we pull it out into the third column of .subject-grid via CSS.
*/
/*
  display:contents on both #video-area and .video-player-area makes all
  inner elements (.main-video-player, .video-info, .lessons-section)
  participate directly in .subject-grid.
*/
#video-area {
    display: contents
}

.lessons-section {
    grid-column: 3;
    grid-row: 1 / span 2
}

.lessons-header {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line)
}

.lessons-header h3 {
    font-size: 13px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--faint);
    font-weight: 500
}

.lesson-list {
    display: flex;
    flex-direction: column;
    max-height: 640px;
    overflow-y: auto
}

.lesson-card {
    display: flex;
    gap: 12px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background .2s
}

.lesson-card:hover {
    background: var(--wash)
}

.lesson-card.active {
    background: var(--wash)
}

.lesson-card.active .lesson-body h4 {
    color: var(--accent)
}

.lesson-thumb {
    position: relative;
    width: 96px;
    aspect-ratio: 16/9;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--ink)
}

.lesson-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block
}

.lesson-thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--paper);
    background: rgba(28, 27, 23, .25)
}

.lesson-thumb-play svg {
    width: 18px;
    height: 18px
}

.lesson-body h4 {
    font-size: 13.5px;
    line-height: 1.35;
    transition: color .2s
}

.lesson-body p {
    margin-top: 4px;
    font-size: 12px;
    color: var(--faint)
}

/* ---------- Responsive: collapse to single column ---------- */
@media (max-width:900px) {
    .wrap--wide {
        max-width: 100%
    }

    .subject-grid {
        grid-template-columns: 1fr;
        gap: 20px
    }

    /* On mobile, #video-area contents should participate in the single-col grid */
    .chapter-tabs {
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding-bottom: 4px;
        grid-column: 1;
        grid-row: 1
    }

    .main-video-player {
        grid-column: 1;
        grid-row: 2
    }

    .video-info {
        grid-column: 1;
        grid-row: 3
    }

    .lessons-section {
        grid-column: 1;
        grid-row: 4
    }

    .lesson-list {
        max-height: none
    }

    .chapter-tab {
        white-space: nowrap;
        flex-shrink: 0
    }
}