/**
 * Playlist Block Styles
 * Responsive video playlist with carousel navigation
 */

.playlist-block {
    background: #252525;
    color: #ffffff;
    padding: 60px 20px;
    width: 100%;
    /* Guard against any child (carousel margins, portrait thumbs) pushing the
       page wider than the viewport on mobile. */
    overflow-x: hidden;
}

.playlist-block__container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.playlist-block__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    gap: 20px;
    flex-wrap: wrap;
}

.playlist-block__title {
    color: #ffffff !important;
    /* The theme's `body.page h2` rule sets margin:auto + max-width:1200px,
       which centers the heading inside the flex header. Pin it left so it
       lines up with the carousel cards / video. */
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: none !important;
}

/* Align the header (title + View All button) with the carousel cards,
   which are inset by the nav-arrow gutter (.playlist-block__carousel
   margin) on tablet/desktop. */
@media (min-width: 768px) {
    .playlist-block__header {
        margin-left: 60px;
        margin-right: 60px;
    }
}

.playlist-block__view-all-arrow {
    margin-left: 8px;
}

.playlist-block__view-all {
    display: inline-flex;
    align-items: center;
    padding: 14px 28px;
    background: transparent;
    border: 2px solid #f39c12;
    color: #f39c12;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.playlist-block__view-all:hover {
    background: #f39c12;
    color: #2a2a2a;
}

/* Player */
.playlist-block__player-wrapper {
    margin-bottom: 60px;
}

.playlist-block__player-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background: #1a1a1a;
    margin-bottom: 20px;
}

.playlist-block__player-container>div,
.playlist-block__player-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* Featured Video Play Button Overlay */
.playlist-block__featured-play-button img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    z-index: 10;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: all;
}

.playlist-block__featured-play-icon {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.playlist-block__featured-play-button:hover {
    position: absolute;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    z-index: 10;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: all;
}

.playlist-block__featured-play-button.hidden {
    opacity: 0;
    pointer-events: none;
}

.playlist-block__player-description {
    color: #cccccc;
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

/* Carousel Container */
.playlist-block__carousel-container {
    position: relative;
    margin-bottom: 40px;
}

.playlist-block__carousel {
    overflow: hidden;
    margin: 0 60px;
    /* Space for nav buttons */
}

.playlist-block__carousel-track {
    display: flex;
    gap: 20px;
    transition: transform 0.4s ease;
}

/* Playlist Item */
.playlist-block__item {
    border: 1px solid #595959;
    flex: 0 0 calc(33.333% - 14px);
    /* 3 items per row with gaps */
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.playlist-block__item:hover {
    transform: translateY(-4px);
}

.playlist-block__item.is-active {
    border: 1px solid #ffffff;
}

.playlist-block__item-thumbnail {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 */
    overflow: hidden;
    background: #1a1a1a;
}

.playlist-block__item-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playlist-block__item-length {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff !important;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 2px;
}

.playlist-block__item-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.playlist-block__item-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: #ffffff !important;
    line-height: 1.3;
}

.playlist-block__item-description {
    font-size: 14px;
    line-height: 1.6;
    color: #cccccc;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Navigation Buttons */
.playlist-block__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px !important;
    height: 48px !important;
    border-radius: 50%;
    background: #007176;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    padding: 0;
}

.playlist-block__nav:hover {
    background: #007176;
    transform: translateY(-50%) scale(1.1);
}

.playlist-block__nav:active {
    transform: translateY(-50%) scale(0.95);
}

.playlist-block__nav--prev {
    left: 0;
}

.playlist-block__nav--next {
    right: 0;
}

.playlist-block__nav svg {
    width: 24px;
    height: 24px;
}

/* Pagination Dots */
.playlist-block__pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.playlist-block__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #555555;
    border: none;
    cursor: pointer;
    padding: 6px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
}

.playlist-block__dot:hover {
    background: #777777;
    transform: scale(1.2);
}

.playlist-block__dot.is-active {
    background: #ffffff;
    transform: scale(1.3);
}

/* Mobile Styles */
@media (max-width: 767px) {
    .playlist-block {
        padding: 40px 12px;
    }

    .playlist-block__header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 30px;
    }

    .playlist-block__title {
        font-size: 32px;
    }

    .playlist-block__view-all {
        /* Compact, content-width button on mobile — not a full-width bar. */
        width: auto;
        align-self: flex-start;
        padding: 10px 18px;
        font-size: 14px;
    }

    .playlist-block__player-wrapper {
        margin-bottom: 40px;
    }


    .playlist-block__player-description {
        font-size: 14px;
    }

    .playlist-block__carousel {
        /* Match the smaller mobile nav buttons so they sit in the gutter
           instead of overhanging toward the screen edge. */
        margin: 0 40px;
    }

    .playlist-block__item {
        flex: 0 0 100%;
        border: 1px solid #595959;
        /* 1 item per row on mobile */
    }

    .playlist-block__item-content {
        padding: 16px;
    }

    .playlist-block__item-title {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .playlist-block__item-description {
        font-size: 13px;
        -webkit-line-clamp: 4;
        line-clamp: 4;
    }

    .playlist-block__nav {
        /* !important to beat the base rule's `width/height: 48px !important`;
           a 32px button fits inside the 40px carousel gutter so the arrows
           never overhang toward the screen edge. */
        width: 32px !important;
        height: 32px !important;
    }

    .playlist-block__nav svg {
        width: 18px;
        height: 18px;
    }

    .playlist-block__featured-play-button {
        width: 36px;
        height: 36px;
    }
}

/* Tablet Styles */
@media (min-width: 768px) and (max-width: 1024px) {
    .playlist-block__title {
        font-size: 40px;
    }

    .playlist-block__item {
        flex: 0 0 calc(50% - 10px);
        /* 2 items on tablet */
    }
}

/* Large Desktop */
@media (min-width: 1400px) {
    .playlist-block__container {
        max-width: 1400px;
    }
}

/* Accessibility */
.playlist-block__nav:focus,
.playlist-block__dot:focus {
    outline: 2px solid #f39c12;
    outline-offset: 2px;
}

.playlist-block__item:focus-visible {
    outline: 2px solid #f39c12;
    outline-offset: 2px;
}

/* Loading State */
.playlist-block__player-container:empty::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #007176;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Print Styles */
@media print {

    .playlist-block__nav,
    .playlist-block__pagination {
        display: none;
    }

    .playlist-block__carousel {
        overflow: visible;
        margin: 0;
    }

    .playlist-block__carousel-track {
        flex-wrap: wrap;
    }

    .playlist-block__item {
        page-break-inside: avoid;
    }
}

/* =============================================================
   Vertical (9:16 / Shorts) Mode
   Triggered by .playlist-block--vertical on the root element.
   Featured player is capped to a phone-like width and centered;
   carousel cards become portrait and pack more per row.
   ============================================================= */

.playlist-block--vertical .playlist-block__player-container {
    /* 9:16 player, capped to a phone-like width and centered.
       Use aspect-ratio (sizes off the element's OWN width) rather than
       padding-bottom% (which sizes off the full-width parent and made the
       capped 400px player ~2100px tall). */
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 0;
    height: auto;
    aspect-ratio: 9 / 16;
}

.playlist-block--vertical .playlist-block__item-thumbnail {
    /* Portrait thumbnails; YouTube's 16:9 images crop via object-fit: cover */
    padding-bottom: 177.78%;
}

/* 4 cards per row on desktop */
.playlist-block--vertical .playlist-block__item {
    flex: 0 0 calc(25% - 15px);
}

/* 3 cards per row on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .playlist-block--vertical .playlist-block__item {
        flex: 0 0 calc(33.333% - 14px);
    }
}

/* 2 cards per row on mobile (overrides the 1-per-row horizontal mobile rule) */
@media (max-width: 767px) {
    .playlist-block--vertical .playlist-block__item {
        flex: 0 0 calc(50% - 10px);
    }
}

/* --- Vertical desktop: player left, scrolling playlist queue right --------- */
@media (min-width: 1024px) {
    .playlist-block--vertical {
        /* Width of the left-hand vertical player; the queue height is matched
           to the player's 9:16 height derived from this. ~half the 1200px
           container so the video reads as the feature, not an afterthought. */
        --pl-vplayer-w: 500px;
    }

    .playlist-block--vertical .playlist-block__stage {
        display: flex;
        gap: 32px;
        align-items: flex-start;
    }

    /* Title/View-All row aligns with the player's left edge (no card gutter
       here — the cards live in the right column). */
    .playlist-block--vertical .playlist-block__header {
        margin-left: 0;
        margin-right: 0;
    }

    /* Left column: the player */
    .playlist-block--vertical .playlist-block__player-wrapper {
        flex: 0 0 var(--pl-vplayer-w);
        width: var(--pl-vplayer-w);
        margin-bottom: 0;
    }

    .playlist-block--vertical .playlist-block__player-container {
        /* Fill the column (the column itself is already capped). */
        max-width: none;
    }

    .playlist-block--vertical .playlist-block__player-description {
        text-align: left;
    }

    /* Right column: the playlist queue */
    .playlist-block--vertical .playlist-block__carousel-container {
        flex: 1 1 auto;
        margin-bottom: 0;
        min-width: 0;
    }

    .playlist-block--vertical .playlist-block__carousel {
        margin: 0;
        overflow-x: hidden;
        overflow-y: auto;
        /* Match the 9:16 player height */
        max-height: calc(var(--pl-vplayer-w) * 16 / 9);
    }

    .playlist-block--vertical .playlist-block__carousel-track {
        /* Two-column grid of compact rows so cards aren't stretched across the
           whole right column. */
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        /* Defeat the horizontal-paging translate from the carousel JS. */
        transform: none !important;
    }

    /* Compact queue rows: small thumbnail left, title/length right */
    .playlist-block--vertical .playlist-block__item {
        flex-direction: row;
        align-items: stretch;
        /* Allow the grid cell to shrink; without this the content's min width
           forces a horizontal scrollbar. */
        min-width: 0;
    }

    .playlist-block--vertical .playlist-block__item:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.04);
    }

    .playlist-block--vertical .playlist-block__item-thumbnail {
        flex: 0 0 96px;
        width: 96px;
        padding-bottom: 0;
        height: auto;
        aspect-ratio: 9 / 16;
    }

    .playlist-block--vertical .playlist-block__item-content {
        padding: 8px 12px;
        justify-content: center;
        min-width: 0;
    }

    .playlist-block--vertical .playlist-block__item-title {
        font-size: 15px;
        margin-bottom: 0;
        /* Clamp long titles so they wrap within the cell instead of widening it. */
        overflow-wrap: anywhere;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Compact rows show title only; description is hidden to keep them tight. */
    .playlist-block--vertical .playlist-block__item-description {
        display: none;
    }

    /* No horizontal nav / dots in the scrolling-queue layout. !important so an
       inline `display: flex` written by the JS (updateNavigationButtons) can't
       re-show them — the layout, not JS state, decides this. */
    .playlist-block--vertical .playlist-block__nav,
    .playlist-block--vertical .playlist-block__pagination {
        display: none !important;
    }
}

/* =============================================================
   Dark Mode — Playlist Block
   The block is already dark (#252525 bg, white text). Dark mode
   deepens the surface slightly and strengthens contrast.
   ============================================================= */

[data-theme="dark"] .playlist-block {
    background: #1a1a1a;
}

[data-theme="dark"] .playlist-block__player-container,
[data-theme="dark"] .playlist-block__item-thumbnail {
    background: #111;
}

/* Playlist item cards: darken border and surface */
[data-theme="dark"] .playlist-block__item {
    border-color: var(--umbc-border, #3d3d3d);
    background: #222;
}

[data-theme="dark"] .playlist-block__item.is-active {
    border-color: #fdb515;
}

/* Inactive pagination dots */
[data-theme="dark"] .playlist-block__dot {
    background: #444;
}

[data-theme="dark"] .playlist-block__dot:hover {
    background: #666;
}

/* Active dot stays white — already readable on dark bg */