/* ===== MUSIC SUBPAGE — iTunes-like Library Browser ===== */

/* Category sections */
.library-category {
    margin-bottom: 48px;
}

.library-category:last-child {
    margin-bottom: 0;
}

.library-category-header {
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.library-category-header h3 {
    font-size: 20px;
    letter-spacing: 0.08em;
}

#videoGridFull.video-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    max-width: 900px;
}

#videoGridFull .video-card {
    aspect-ratio: 16 / 9;
}

/* Grid of album/book cards */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 20px;
    align-items: start;
}

/* Individual card (button) */
.library-card {
    background: transparent;
    border: 0;
    text-align: left;
    color: inherit;
    padding: 0;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.35s ease;
}

.library-card:hover {
    transform: translateY(-3px);
}

.library-card.active {
    opacity: 1;
}

.library-grid.has-active .library-card:not(.active) {
    opacity: 1;
    transform: scale(0.97);
}

.library-grid.has-active .library-card:not(.active) .library-cover {
    opacity: 0.55;
}

/* Cover image — naturalne proporcje, cała okładka widoczna */
.library-cover {
    width: 100%;
    height: auto;
    object-fit: contain;
    border: 1px solid var(--border);
    display: block;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}

.library-card:hover .library-cover {
    border-color: rgba(var(--accent-rgb), 0.45);
}

.library-card.active .library-cover {
    border-color: var(--gold);
    box-shadow: 0 10px 26px var(--shadow);
}

/* Card text */
.library-card-title {
    display: block;
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.library-card-year {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== DETAIL PANEL (iTunes-like expandable) ===== */

.library-detail {
    grid-column: 1 / -1;
    border: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border-left: 0;
    border-right: 0;
    max-height: 0;
    opacity: 0;
    transform: none;
    transform-origin: top center;
    position: relative;
    isolation: isolate;
    background:
        linear-gradient(110deg,
            rgba(var(--album-accent-rgb, 43, 70, 117), 0.16) 0%,
            rgba(240, 240, 230, 0.96) 52%,
            rgba(248, 248, 242, 0.98) 100%),
        radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.5), transparent 40%);
    background-size: 100% 100%, 100% 100%;
    background-position: center, center;
    transition: max-height 0.78s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.46s ease,
        border-color 0.46s ease,
        box-shadow 0.46s ease;
}

.library-detail.open {
    max-height: 1200px;
    opacity: 1;
    border-color: rgba(var(--accent-rgb), 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 24px 46px var(--shadow);
}

/* Arrow indicator pointing to active card */
.library-detail.open::before {
    content: "";
    width: 0;
    height: 0;
    position: absolute;
    left: var(--arrow-offset, 85px);
    top: 0;
    transform: translate(-50%, -100%);
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid rgba(var(--album-accent-rgb, 43, 70, 117), 0.2);
    filter: drop-shadow(0 -1px 0 var(--border));
    z-index: 4;
}

.library-detail::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--album-cover-image, none);
    background-size: cover;
    background-position: center;
    filter: blur(22px) saturate(1.15);
    transform: scale(1.08);
    opacity: 0;
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.52s ease;
}

.library-detail.open::after {
    opacity: 0.06;
}

.library-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(248, 248, 242, 0.48);
}

.library-detail-label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Detail content grid */
.library-detail-content {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 32px;
    padding: 24px clamp(28px, 7vw, 96px) 28px;
    max-width: 1320px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.36s ease, transform 0.36s ease;
}

/* Close button for detail panel */
.library-detail-close {
    position: absolute;
    top: 10px;
    transition: opacity 0.2s ease, transform 0.2s ease;
    right: 8px;
    background: none;
}

.library-detail.is-switching .library-detail-content {
    opacity: 0;
    transform: translateY(4px);
}

.library-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.library-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.library-meta-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    opacity: 1;
}

.library-meta-value {
    font-size: 14px;
    color: var(--text-primary);
}

.library-description {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin: 12px 0 0;
}

/* Track list */
.track-list {
    display: grid;
    gap: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
}

/* Single track row */
.track {
    width: 100%;
    background: none;
    border: 0;
    padding: 9px 10px;
    display: grid;
    grid-template-columns: 34px 1fr 20px;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    font-family: var(--font-paragraph);
    border-bottom: 1px solid var(--border);
}

.track:hover {
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--text-primary);
}

.track:last-of-type {
    border-bottom: 0;
}

.track .num {
    width: 24px;
    color: var(--text-secondary);
    font-size: 12px;
    flex-shrink: 0;
}

.track .track-title {
    flex: 1;
}

.track .track-expand-icon {
    color: var(--text-secondary);
    font-size: 16px;
    transition: transform 0.25s ease, color 0.25s ease;
    width: 20px;
    text-align: center;
}

.track[aria-expanded="true"] .track-expand-icon {
    transform: rotate(45deg);
    color: var(--gold);
}

/* Track details (expandable) */
.track-details {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.35s ease, padding 0.35s ease;
    padding: 0 10px 0 34px;
    font-size: 13px;
    color: var(--text-secondary);
}

.track-details.open {
    max-height: 80vh;
    overflow-y: auto;
    opacity: 1;
    padding: 8px 10px 14px 34px;
    border-bottom: 1px solid var(--border);
}

.track-lyrics {
    white-space: pre-wrap;
    line-height: 1.75;
    color: var(--text-primary);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13.5px;
}

.track-lyrics-empty {
    font-style: italic;
    opacity: 1;
    border-top: 0;
}

.library-meta-value {
    color: var(--text-primary);
}

.library-description {
    color: var(--text-secondary);
}

.library-meta-label {
    color: var(--text-secondary);
}

.track-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    margin-bottom: 10px;
}

.track-detail-item {
    font-size: 12px;
}

.track-detail-label {
    color: var(--text-secondary);
    opacity: 1;
}

/* Okładka i opis w szufladce */
.library-detail-cover {
    width: 100%;
    max-width: 260px;
    border: 1px solid var(--border);
    margin-bottom: 14px;
}

.library-detail-title {
    font-size: 22px;
    margin-bottom: 12px;
}

.library-description {
    font-size: 13.5px;
    line-height: 1.7;
    margin: 10px 0;
}

.library-performers {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.library-performers p {
    margin: 6px 0 0;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.track-empty {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 10px 0;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 900px) {
    #videoGridFull.video-grid {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }

    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .library-detail-content {
        grid-template-columns: 1fr;
        padding: 18px 18px 22px;
    }

    .library-detail.open::before {
        display: none;
    }

    .library-meta-grid {
        grid-template-columns: 1fr;
    }

    .track-details-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }
}
