/* =============================================
   Noir Melancholy / 3D Kinetic Lyrics Player & Cold Rain Engine
   ============================================= */

/* Rain Canvas Background */
#rain-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity;
}

body.lyrics-active #rain-canvas {
    opacity: 1;
}

/* Atmospheric Background Tint when Lyrics Player is Active */
body.lyrics-active .lofi-bg {
    filter: brightness(0.24) saturate(0.25) contrast(1.2) grayscale(30%) !important;
    transform: scale(1.06) !important;
}

/* Split-Screen Parallax on Desktop */
@media (min-width: 1150px) {
    .card-wrapper {
        transition: transform 0.85s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.5s ease;
    }
    body.lyrics-active .card-wrapper {
        transform: translateX(-190px) scale(0.95) perspective(1000px) rotateY(5deg);
        box-shadow: 0 35px 90px rgba(0, 0, 0, 0.95), 0 0 50px rgba(15, 23, 42, 0.5);
    }
}

/* =============================================
   3D Spatial Holographic Lyrics Stage (Right Panel)
   ============================================= */
#lyrics-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 520px;
    max-width: 95vw;
    height: 100vh;
    z-index: 45;
    background: radial-gradient(circle at 50% 50%, rgba(12, 10, 18, 0.92) 0%, rgba(4, 3, 7, 0.98) 100%);
    backdrop-filter: blur(32px) saturate(120%);
    -webkit-backdrop-filter: blur(32px) saturate(120%);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -30px 0 90px rgba(0, 0, 0, 0.95), inset 1px 0 2px rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease;
    opacity: 0;
    pointer-events: none;
    perspective: 1400px;
    transform-style: preserve-3d;
    overflow: hidden;
    box-sizing: border-box;
}

body.lyrics-active #lyrics-panel {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Ambient Ghostly Spotlight Glow */
#lyrics-panel::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 440px;
    height: 440px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(148, 163, 184, 0.09) 0%, rgba(30, 41, 59, 0.06) 50%, transparent 70%);
    filter: blur(75px);
    pointer-events: none;
    z-index: 1;
    animation: spotlightPulse 8s ease-in-out infinite alternate;
}

@keyframes spotlightPulse {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(1.25); opacity: 0.9; }
}

/* Panel Header */
.lyrics-header {
    padding: 1.5rem 2rem 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(8, 7, 12, 0.7);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.lyrics-song-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lyrics-song-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.lyrics-song-artist {
    font-size: 0.85rem;
    color: rgba(148, 163, 184, 0.8);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lyrics-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.lyrics-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    transform: scale(1.1) rotate(90deg);
}

/* =============================================
   3D Spatial Viewport & Kinetic Typography Track
   ============================================= */
.lyrics-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    perspective: 1400px;
    transform-style: preserve-3d;
    padding: 0 1.5rem;
    mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.85) 15%, black 35%, black 65%, rgba(0,0,0,0.85) 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.85) 15%, black 35%, black 65%, rgba(0,0,0,0.85) 85%, transparent 100%);
    z-index: 5;
    box-sizing: border-box;
}

.lyrics-track {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    transform: translate3d(0, 0, 0);
    transition: transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    padding: 0 1.25rem;
    transform-style: preserve-3d;
    will-change: transform;
    box-sizing: border-box;
}

/* Individual 3D Kinetic Lyric Line (Freeform in 3D Space) */
.lyric-line {
    width: 100%;
    max-width: 440px;
    text-align: center;
    padding: 0.6rem 1rem;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: -0.01em;
    color: rgba(203, 213, 225, 0.25);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    word-break: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
    transform-origin: center center;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.5s ease, 
                filter 0.5s ease, 
                color 0.4s ease;
    will-change: transform, opacity, filter;
    
    /* Default distant state */
    transform: perspective(1000px) translate3d(0, 50px, -120px) rotateX(-20deg) scale(0.85);
    filter: blur(3px);
    opacity: 0.2;
    background: transparent;
    border: none;
}

.lyric-line:hover {
    color: rgba(255, 255, 255, 0.8);
    filter: blur(0px);
}

/* Word spans */
.lyric-word {
    display: inline-block;
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, filter 0.35s ease;
    margin: 0 3px;
    word-break: break-word;
    will-change: transform, opacity;
}

/* =============================================
   ACTIVE LINE: 3D PERSPECTIVE HERO (TILTED IN 3D SPACE)
   ============================================= */

/* Odd Active Line (Tilted Left-to-Right in 3D Perspective) */
.lyric-line.active:nth-child(odd) {
    font-size: clamp(1.35rem, 2.3vw, 1.7rem);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.015em;
    color: #ffffff;
    opacity: 1;
    filter: blur(0px);
    background: transparent;
    border: none;
    box-shadow: none;
    transform: perspective(1000px) translate3d(-12px, 0, 65px) rotateY(-13deg) rotateX(6deg) scale(1.06);
    animation: kinetic3DFloatOdd 5s ease-in-out infinite alternate;
}

/* Even Active Line (Tilted Right-to-Left in 3D Perspective) */
.lyric-line.active:nth-child(even) {
    font-size: clamp(1.35rem, 2.3vw, 1.7rem);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.015em;
    color: #ffffff;
    opacity: 1;
    filter: blur(0px);
    background: transparent;
    border: none;
    box-shadow: none;
    transform: perspective(1000px) translate3d(12px, 0, 65px) rotateY(13deg) rotateX(6deg) scale(1.06);
    animation: kinetic3DFloatEven 5s ease-in-out infinite alternate;
}

.lyric-line.active .lyric-word {
    color: #ffffff;
    -webkit-text-fill-color: #ffffff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.4), 0 4px 18px rgba(0, 0, 0, 0.85);
}

@keyframes kinetic3DFloatOdd {
    0% {
        transform: perspective(1000px) translate3d(-12px, 0, 65px) rotateY(-13deg) rotateX(6deg) scale(1.06);
    }
    50% {
        transform: perspective(1000px) translate3d(-18px, -4px, 75px) rotateY(-17deg) rotateX(4deg) scale(1.08);
    }
    100% {
        transform: perspective(1000px) translate3d(-8px, 3px, 68px) rotateY(-10deg) rotateX(8deg) scale(1.06);
    }
}

@keyframes kinetic3DFloatEven {
    0% {
        transform: perspective(1000px) translate3d(12px, 0, 65px) rotateY(13deg) rotateX(6deg) scale(1.06);
    }
    50% {
        transform: perspective(1000px) translate3d(18px, -4px, 75px) rotateY(17deg) rotateX(4deg) scale(1.08);
    }
    100% {
        transform: perspective(1000px) translate3d(8px, 3px, 68px) rotateY(10deg) rotateX(8deg) scale(1.06);
    }
}

/* =============================================
   PREVIOUS (PASSED) & UPCOMING 3D DEPTH STATES
   ============================================= */

/* Immediate previous line (Odd: drifts to Left, Even: drifts to Right) */
.lyric-line.passed-1:nth-child(odd) {
    color: rgba(203, 213, 225, 0.35);
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    transform: perspective(1000px) translate3d(-32px, -22px, -50px) rotateY(-18deg) rotateX(16deg) scale(0.92);
    filter: blur(1.2px);
    opacity: 0.45;
}
.lyric-line.passed-1:nth-child(even) {
    color: rgba(203, 213, 225, 0.35);
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    transform: perspective(1000px) translate3d(32px, -22px, -50px) rotateY(18deg) rotateX(16deg) scale(0.92);
    filter: blur(1.2px);
    opacity: 0.45;
}

/* 2nd previous line */
.lyric-line.passed-2:nth-child(odd) {
    color: rgba(148, 163, 184, 0.2);
    font-size: clamp(0.9rem, 1.4vw, 1.02rem);
    transform: perspective(1000px) translate3d(-52px, -48px, -120px) rotateY(-26deg) rotateX(28deg) scale(0.82);
    filter: blur(2.8px);
    opacity: 0.22;
}
.lyric-line.passed-2:nth-child(even) {
    color: rgba(148, 163, 184, 0.2);
    font-size: clamp(0.9rem, 1.4vw, 1.02rem);
    transform: perspective(1000px) translate3d(52px, -48px, -120px) rotateY(26deg) rotateX(28deg) scale(0.82);
    filter: blur(2.8px);
    opacity: 0.22;
}

/* Far previous lines */
.lyric-line.passed-far {
    color: rgba(100, 116, 139, 0.1);
    transform: perspective(1000px) translate3d(0, -75px, -200px) rotateX(40deg) scale(0.7);
    filter: blur(5px);
    opacity: 0.1;
}

/* Immediate upcoming line (Odd: approaches from Left, Even: approaches from Right) */
.lyric-line.upcoming-1:nth-child(odd) {
    color: rgba(226, 232, 240, 0.65);
    font-size: clamp(1.08rem, 1.8vw, 1.25rem);
    font-weight: 500;
    transform: perspective(1000px) translate3d(-26px, 22px, -35px) rotateY(-15deg) rotateX(-10deg) scale(0.96);
    filter: blur(0.8px);
    opacity: 0.68;
}
.lyric-line.upcoming-1:nth-child(even) {
    color: rgba(226, 232, 240, 0.65);
    font-size: clamp(1.08rem, 1.8vw, 1.25rem);
    font-weight: 500;
    transform: perspective(1000px) translate3d(26px, 22px, -35px) rotateY(15deg) rotateX(-10deg) scale(0.96);
    filter: blur(0.8px);
    opacity: 0.68;
}

/* 2nd upcoming line */
.lyric-line.upcoming-2:nth-child(odd) {
    color: rgba(148, 163, 184, 0.35);
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    transform: perspective(1000px) translate3d(-48px, 48px, -95px) rotateY(-24deg) rotateX(-22deg) scale(0.86);
    filter: blur(2.2px);
    opacity: 0.35;
}
.lyric-line.upcoming-2:nth-child(even) {
    color: rgba(148, 163, 184, 0.35);
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    transform: perspective(1000px) translate3d(48px, 48px, -95px) rotateY(24deg) rotateX(-22deg) scale(0.86);
    filter: blur(2.2px);
    opacity: 0.35;
}

/* Far upcoming lines */
.lyric-line.upcoming-far {
    color: rgba(100, 116, 139, 0.12);
    transform: perspective(1000px) translate3d(0, 80px, -180px) rotateX(-35deg) scale(0.72);
    filter: blur(4.5px);
    opacity: 0.12;
}

/* =============================================
   Bottom Player Controls inside Lyrics Panel
   ============================================= */
.lyrics-footer {
    padding: 1.25rem 2rem 1.75rem 2rem;
    background: rgba(8, 7, 12, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.lyrics-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    font-family: monospace;
    color: rgba(148, 163, 184, 0.7);
}

.lyrics-seek-bar {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: height 0.2s ease;
}

.lyrics-seek-bar:hover {
    height: 8px;
}

.lyrics-seek-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #475569, #cbd5e1);
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(203, 213, 225, 0.4);
    transition: width 0.1s linear;
}

.lyrics-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lyrics-play-toggle {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #334155, #64748b);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lyrics-play-toggle:hover {
    transform: scale(1.08);
    background: linear-gradient(135deg, #475569, #94a3b8);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75);
}

.lyrics-volume-container {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(148, 163, 184, 0.7);
    font-size: 0.9rem;
}

.lyrics-volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    accent-color: #cbd5e1;
    cursor: pointer;
}

/* =============================================
   Mobile Responsiveness (Sliding 3D Bottom Sheet)
   ============================================= */
@media (max-width: 768px) {
    #lyrics-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 56vh;
        max-height: 56vh;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 32px 32px 0 0;
        transform: translateY(100%);
        box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.95);
    }

    body.lyrics-active #lyrics-panel {
        transform: translateY(0);
    }

    body.lyrics-active .card-wrapper {
        transform: translateY(-90px) scale(0.9);
        opacity: 0.65;
    }

    .lyric-line {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }

    .lyric-line.active:nth-child(odd),
    .lyric-line.active:nth-child(even) {
        font-size: 1.4rem;
        transform: perspective(1000px) translate3d(0, 0, 45px) rotateY(-8deg) rotateX(4deg) scale(1.05);
    }
}
