/* ==========================================================================
   Selection / Playlist Carousel Page Styles
   Optimized for universal accessibility (young & old, mobile & desktop)
   ========================================================================== */

.selection-main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    min-height: calc(100vh - 72px);
    height: calc(100vh - 72px);
    padding: 8px 0 16px;
    box-sizing: border-box;
    overflow: hidden;
}

.playlist-section {
    width: 100%;
    max-width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    min-height: 0;
    justify-content: flex-start;
}

/* Header & Controls */
.playlist-header-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 4px clamp(20px, 3vw, 48px) 12px;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.playlist-title-group {
    flex: 1;
    min-width: 280px;
}

.playlist-kicker {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #818cf8;
    margin-bottom: 6px;
    display: block;
}

.playlist-title {
    font-family: 'Audiowide', sans-serif, system-ui;
    font-size: 2.25rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 8px 0;
    letter-spacing: 0.5px;
}

.playlist-subtitle {
    font-size: 0.98rem;
    color: #94a3b8;
    margin: 0;
    max-width: 720px;
    line-height: 1.5;
}

/* Controls */
.playlist-nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.playlist-counter {
    background: #141726;
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #e2e8f0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 9999px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    user-select: none;
}

.playlist-buttons-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Category Filters Bar */
.playlist-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 clamp(20px, 3vw, 48px) 8px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.category-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #131726;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9999px;
    color: #cbd5e1;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    outline: none;
}

.category-pill .pill-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.category-pill .pill-count {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 9999px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.category-pill:hover:not(.active) {
    background: #1b2034;
    border-color: rgba(99, 102, 241, 0.4);
    color: #ffffff;
    transform: translateY(-1px);
}

.category-pill.active {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    border-color: #818cf8;
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.category-pill.active .pill-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Accessibility / Senior Guide Hint */
.playlist-guide-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 clamp(20px, 3vw, 48px) 8px;
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    color: #c7d2fe;
    font-size: 0.82rem;
    line-height: 1.4;
    flex-shrink: 0;
}

.playlist-guide-hint strong {
    color: #ffffff;
}

.hint-bullet {
    font-size: 1rem;
    flex-shrink: 0;
}

.playlist-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 22px;
    background: #1c2136;
    border: 1.5px solid rgba(99, 102, 241, 0.5);
    border-radius: 12px;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    user-select: none;
    outline: none;
}

.playlist-nav-btn:hover:not(:disabled):not(.is-disabled) {
    background: #4f46e5;
    border-color: #818cf8;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
}

.playlist-nav-btn:active:not(:disabled):not(.is-disabled) {
    transform: scale(0.97);
}

.playlist-nav-btn:focus-visible {
    outline: 2px solid #818cf8;
    outline-offset: 2px;
}

.playlist-nav-btn:disabled,
.playlist-nav-btn.is-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.08);
    background: #111420;
    box-shadow: none;
    pointer-events: none;
}

/* Carousel Layout - Fills 90-100% Viewport Height */
#playlist-carousel {
    display: flex;
    gap: clamp(16px, 1.5vw, 24px);
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scroll-padding-left: clamp(20px, 3vw, 48px);
    padding: 6px clamp(20px, 3vw, 48px) 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

#playlist-carousel::-webkit-scrollbar {
    display: none;
}

/* Card sizing: Strictly 3 to 4 cards visible across the screen */
#playlist-carousel .carousel-item {
    width: clamp(500px, calc((100vw - 2 * clamp(20px, 3vw, 48px) - 3 * 24px) / 3.4), 780px);
    min-width: clamp(500px, calc((100vw - 2 * clamp(20px, 3vw, 48px) - 3 * 24px) / 3.4), 780px);
    max-width: 800px;
    height: clamp(600px, calc(92vh - 180px), 860px);
    min-height: 560px;
    background: #131724;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 14px !important;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    align-self: stretch;
    box-sizing: border-box;
    flex-shrink: 0;
}

#playlist-carousel .carousel-item.is-hidden {
    display: none !important;
}

/* On standard desktop screens (1024px - 1440px), show ~2.7 to 3 cards */
@media (max-width: 1440px) {
    #playlist-carousel .carousel-item {
        width: clamp(450px, calc((100vw - 2 * clamp(20px, 3vw, 36px) - 2 * 20px) / 2.75), 560px);
        min-width: clamp(450px, calc((100vw - 2 * clamp(20px, 3vw, 36px) - 2 * 20px) / 2.75), 560px);
    }
}

/* On tablet screens (769px - 1023px), show ~2 cards */
@media (max-width: 1023px) {
    #playlist-carousel .carousel-item {
        width: clamp(380px, calc((100vw - 64px) / 2.1), 460px);
        min-width: clamp(380px, calc((100vw - 64px) / 2.1), 460px);
    }
}

#playlist-carousel .carousel-item:hover {
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(-4px);
}

#playlist-carousel lazy-media-embed {
    width: 100%;
    height: 100% !important;
    min-height: 520px !important;
    flex: 1;
    border-radius: 14px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .selection-main {
        min-height: calc(100vh - 64px);
        height: auto;
        padding: 12px 0 32px;
        overflow: visible;
    }

    .playlist-header-container {
        padding: 0 16px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .playlist-title {
        font-size: 1.65rem;
    }

    .playlist-nav-controls {
        width: 100%;
        justify-content: space-between;
    }

    .playlist-btn-text {
        display: none;
    }

    .playlist-nav-btn {
        padding: 10px 14px;
        border-radius: 10px;
    }

    #playlist-carousel {
        padding: 8px 16px 20px;
        gap: 16px;
        flex: none;
    }

    #playlist-carousel .carousel-item {
        min-width: 88vw !important;
        max-width: 88vw !important;
        width: 88vw !important;
        height: 540px !important;
        min-height: 540px !important;
        padding: 12px !important;
    }

    #playlist-carousel lazy-media-embed {
        height: 100% !important;
        min-height: 100% !important;
    }
}
