/* =========================================================================
   Playlist queue rail — the watch page's replacement for the generic
   Watch Next "up next" card while ?playlist=<slug> is active.
   Desktop (>=992px): a sticky column beside the player, listing every video
   in the playlist with the current one highlighted.
   Mobile (<992px): collapsed to a single "Up next" preview; tapping the
   header opens the full list inline, above the description as the video's
   own related content follows below.
   Shares brand tokens with watch-next.css: #d20000, #231f20, #a6988a.
   ========================================================================= */

.pl-watch-row {
    display: flex;
    /* NOT stretch: .videobox itself is `display:flex;align-items:center`
       (custom.css), so if it were stretched taller than its own video it
       would center that video inside the extra space - padding the player
       instead of just leaving the rail alone. The rail's height is set to
       match the player in JS instead (below), one-directionally. */
    align-items: flex-start;
    gap: 24px;
}

.pl-watch-row__player {
    flex: 1 1 0;
    min-width: 0;
}

.pl-queue {
    flex: 0 0 340px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    /* custom.css sets a generic top/bottom padding on every <aside>/<section>
       (up to 3.5rem at wider breakpoints) — this is a real rail, not a page
       section, so it needs its own spacing from its children, not this. */
    padding: 0;
    background: #231f20;
    color: #fff;
    border-radius: 8px;
    overflow: hidden;
    position: sticky;
    top: 20px;
    /* Height is set inline by JS to match the player exactly (see the script
       at the bottom of this partial). This is just a sane fallback before
       that JS runs, and the ceiling for a very tall player on a short
       viewport. */
    max-height: calc(100vh - 40px);
}

.pl-queue__head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: 0;
    color: inherit;
    text-align: left;
    font: inherit;
    cursor: default;
}

.pl-queue__head-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pl-queue__playlist {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-queue__count {
    font-size: 12px;
    color: #a6988a;
}

/* Mobile-only single-line header ("Up next · 4 of 12") — hidden on desktop,
   where the two-line playlist name + position (above) is shown instead. */
.pl-queue__upnext-label {
    display: none;
    font-weight: 700;
    font-size: 15px;
}

.pl-queue__chevron {
    display: none; /* only meaningful as a toggle indicator on mobile */
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

/* Full list: always visible and scrollable on desktop. */
.pl-queue__list {
    list-style: none;
    margin: 0;
    padding: 0 8px 12px;
    /* fills whatever height .pl-queue was stretched to match the player,
       and scrolls internally once the videos don't all fit. min-height:0
       is what lets a flex child actually shrink below its content size. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* Same thin scrollbar treatment as .comment-section ul (custom.css) */
.pl-queue__list::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.pl-queue__list::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px transparent;
    box-shadow: inset 0 0 6px transparent;
    background-color: transparent;
}

.pl-queue__list::-webkit-scrollbar-thumb {
    background-color: #a6988a;
}

.pl-queue__preview {
    display: none; /* desktop shows the full list instead */
}

.pl-queue__item + .pl-queue__item {
    margin-top: 4px;
}

.pl-queue__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}

.pl-queue__row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.pl-queue__item.is-current .pl-queue__row {
    background: rgba(210, 0, 0, 0.18);
}

.pl-queue__num {
    flex: 0 0 20px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #a6988a;
}

.pl-queue__item.is-current .pl-queue__num {
    color: #d20000;
}

.pl-queue__thumb {
    position: relative;
    flex: 0 0 auto;
    width: 96px;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

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

.pl-queue__dur {
    position: absolute;
    right: 3px;
    bottom: 3px;
    padding: 1px 4px;
    font-size: 10px;
    line-height: 1.4;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
}

.pl-queue__title {
    font-size: 13px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Mobile: collapsed by default ------------------------------- */
@media (max-width: 991.98px) {
    .pl-watch-row {
        display: block;
    }

    .pl-queue {
        position: static;
        max-width: none;
        max-height: none; /* the desktop stretch-to-player cap doesn't apply here */
        margin-top: 14px;
    }

    .pl-queue__head {
        cursor: pointer;
    }

    .pl-queue__chevron {
        display: block;
    }

    .pl-queue.is-open .pl-queue__chevron {
        transform: rotate(180deg);
    }

    .pl-queue__playlist,
    .pl-queue__count {
        display: none; /* replaced by the single-line "Up next · N of M" label */
    }

    .pl-queue__upnext-label {
        display: block;
    }

    .pl-queue__preview {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 0 12px 12px;
        color: inherit;
        text-decoration: none;
    }

    .pl-queue__preview .pl-queue__thumb {
        width: 120px;
    }

    .pl-queue__preview-title {
        font-size: 13px;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Full list stays in the DOM (so the toggle works instantly) but
       collapsed until opened. A max-height/opacity transition (rather than
       display:none, which can't animate) gives the accordion a light
       expand/collapse instead of a hard cut. */
    .pl-queue__list {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        padding-top: 0;
        border-top: 1px solid transparent;
        transition: max-height 0.28s ease, opacity 0.2s ease;
    }

    .pl-queue.is-open .pl-queue__list {
        max-height: 60vh;
        opacity: 1;
        overflow-y: auto;
        padding-top: 8px;
        border-top-color: rgba(255, 255, 255, 0.12);
    }
}
