/* ==========================================================================
   Picker panels: a sticky side list on wide screens (playlists, songs) that
   becomes a bottom sheet behind a "Playlist: ..." button on small screens.
   Used by Videos and Lyrics; behaviour in js/sheet.js.
   ========================================================================== */

.picker-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    align-items: start;
    gap: var(--space-6);
}

.picker-panel {
    position: sticky;
    top: var(--space-5);
    max-height: calc(100vh - 2 * var(--space-5));
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.picker-panel-head {
    display: none;
}

/* minmax(0, 1fr) keeps long titles from widening the list past the panel. */
.picker-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    padding: var(--space-4) var(--space-3);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.picker-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
}

.picker-group-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.picker-group-title .icon {
    color: var(--brand-text);
}

.picker-group-art {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: var(--shadow-xs);
}

.picker-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-height: 38px;
    padding: 6px var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 560;
    text-align: left;
    text-decoration: none;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.picker-item-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Song titles wrap instead of truncating, so "(Japanese Ver.)" stays readable. */
.picker-panel-wrap .picker-item-title {
    padding-block: 2px;
    white-space: normal;
    text-wrap: pretty;
}

.picker-item:hover {
    background: var(--brand-tint);
    color: var(--text);
}

.picker-item.is-active {
    background: var(--brand-gradient-strong);
    color: var(--on-brand);
    font-weight: 650;
    box-shadow: 0 6px 16px var(--brand-glow);
}

.picker-count {
    min-width: 22px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--brand-soft);
    color: var(--brand-text);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.picker-count:empty {
    display: none;
}

.picker-item.is-active .picker-count {
    background: rgba(255, 255, 255, 0.25);
    color: var(--on-brand);
}

.picker-toggle,
.sheet-scrim {
    display: none;
}

@media (max-width: 1180px) {
    .picker-layout {
        grid-template-columns: 220px minmax(0, 1fr);
        gap: var(--space-5);
    }
}

@media (max-width: 900px) {
    .picker-layout {
        grid-template-columns: 1fr;
    }

    .picker-toggle {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        width: 100%;
        min-height: 52px;
        margin-bottom: var(--space-5);
        padding: 0 var(--space-4);
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-lg);
        background: var(--surface);
        color: var(--text);
        box-shadow: var(--shadow-sm);
        text-align: left;
    }

    .picker-toggle-label {
        font-size: var(--text-xs);
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-faint);
    }

    .picker-toggle-value {
        flex: 1;
        min-width: 0;
        font-weight: 650;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .picker-panel {
        position: fixed;
        inset: auto 0 0 0;
        top: auto;
        z-index: 60;
        max-height: min(78vh, 640px);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        background: var(--surface);
        box-shadow: var(--shadow-lg);
        transform: translateY(102%);
        visibility: hidden;
        transition: transform var(--normal) var(--ease), visibility 0s linear var(--normal);
    }

    .picker-panel.is-open {
        transform: none;
        visibility: visible;
        transition: transform var(--normal) var(--ease);
    }

    .picker-panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-4) var(--space-4) 0 var(--space-5);
    }

    .picker-panel-title {
        font-weight: 700;
    }

    .picker-nav {
        padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
    }

    .sheet-scrim {
        position: fixed;
        inset: 0;
        z-index: 55;
        display: block;
        background: rgba(30, 10, 25, 0.38);
    }
}

/* Wide screens: room for longer playlist and song names. */
@media (min-width: 2100px) {
    .picker-layout {
        grid-template-columns: 300px minmax(0, 1fr);
    }
}
