/* --- CSS VARIABLES & BASE SETUP --- */
:root {
    --color1: #1db954;
    --color2: #191414;
    --color3: #535353;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: white;
    overflow: hidden;
    cursor: none; /* Hidden for Kiosk / Ambient TV Mode */

    /* Ambient animated gradient background */
    background: linear-gradient(
        135deg,
        var(--color1) 0%,
        var(--color2) 50%,
        var(--color3) 100%
    );
    background-size: 300% 300%;
    animation: gradientBG 25s ease-in-out infinite;
    transition: background 1.5s ease-in-out;
}

/* Restore cursor when settings modal is open */
body.settings-open,
body.settings-open * {
    cursor: default !important;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* --- TOP PROGRESS BAR & PAUSED LABEL --- */
#progress-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.28);
    transition: opacity 0.3s ease;
    z-index: 1;
}

#paused-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

/* --- CORNER METADATA (LEFT: TIME, RIGHT: WEATHER) --- */
#datetime-container {
    position: absolute;
    top: 40px;
    left: 40px;
    display: flex;
    flex-direction: column;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 50;
    pointer-events: none;
}

#time-display {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

#date-display {
    font-size: 1.05rem;
    font-weight: 500;
    opacity: 0.85;
    margin-top: 2px;
}

#weather-container {
    position: absolute;
    top: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 50;
    pointer-events: none;
}

#weather-top {
    font-size: 2.2rem;
    font-weight: 700;
    display: flex;
    gap: 12px;
    align-items: center;
}

#weather-location {
    font-size: 1.05rem;
    font-weight: 500;
    opacity: 0.85;
    margin-top: 2px;
}

/* --- MAIN APP CONTAINER --- */
#app-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   1. CLASSIC MODE (NO LYRICS / PAUSED / TOGGLED OFF)
   Exact match to original centered design
   ============================================================ */
body.mode-classic #app-container {
    align-items: center;
    justify-content: center;
}

body.mode-classic .media-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    max-width: 800px;
    padding: 20px;
}

body.mode-classic .art-wrapper {
    order: 2;
    margin-bottom: 25px;
}

body.mode-classic #cover-art {
    width: 350px;
    height: 350px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    transition: transform 0.5s ease;
}

body.mode-classic .track-meta {
    display: contents;
}

body.mode-classic #track-title {
    order: 1;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    max-width: 90%;
    word-break: break-word;
}

body.mode-classic #artist-name {
    order: 3;
    font-size: 1.25rem;
    font-weight: 500;
    opacity: 0.9;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

body.mode-classic .mini-progress-info,
body.mode-classic .lyrics-section {
    display: none;
}

/* ============================================================
   2. LYRICS MODE (TIME-SYNCED KARAOKE VIEW)
   Split view: Left Media Info | Right Scrolling Synced Lyrics
   ============================================================ */
body.mode-lyrics #app-container {
    display: grid;
    grid-template-columns: 460px 1fr;
    height: 100vh;
    padding: 100px 60px 40px 60px;
    gap: 40px;
    align-items: center;
}

/* --- Left Column: Media Information --- */
body.mode-lyrics .media-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-align: left;
    max-width: 440px;
    padding-left: 20px;
}

body.mode-lyrics .art-wrapper {
    order: 1;
    margin-bottom: 28px;
    width: 100%;
}

body.mode-lyrics #cover-art {
    width: 360px;
    height: 360px;
    max-width: 100%;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 255, 255, 0.08);
}

body.mode-lyrics .track-meta {
    order: 2;
    width: 100%;
}

body.mode-lyrics #track-title {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 10px;
    text-transform: none;
    letter-spacing: -0.5px;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body.mode-lyrics #artist-name {
    font-size: 1.25rem;
    font-weight: 500;
    opacity: 0.85;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body.mode-lyrics .mini-progress-info {
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.6;
    letter-spacing: 0.5px;
}

/* --- Right Column: Scrolling Lyrics Pane --- */
body.mode-lyrics .lyrics-section {
    display: flex;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
}

#lyrics-container {
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    scrollbar-width: none;
    -ms-overflow-style: none;
    
    /* Top & bottom smooth gradient fade masks */
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 0, 0, 1) 20%,
        rgba(0, 0, 0, 1) 80%,
        transparent 100%
    );
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 0, 0, 1) 20%,
        rgba(0, 0, 0, 1) 80%,
        transparent 100%
    );
}

#lyrics-container::-webkit-scrollbar {
    display: none;
}

#lyrics-list {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding-top: 42vh;
    padding-bottom: 45vh;
    padding-left: 20px;
    padding-right: 40px;
}

/* Individual Lyric Line Styling */
.lyric-line {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.35);
    filter: blur(0.4px);
    transform: scale(0.96);
    transform-origin: left center;
    transition: 
        color 0.4s cubic-bezier(0.2, 0, 0, 1),
        font-size 0.4s cubic-bezier(0.2, 0, 0, 1),
        transform 0.4s cubic-bezier(0.2, 0, 0, 1),
        opacity 0.4s cubic-bezier(0.2, 0, 0, 1),
        filter 0.4s cubic-bezier(0.2, 0, 0, 1),
        text-shadow 0.4s cubic-bezier(0.2, 0, 0, 1);
    will-change: transform, color, opacity;
}

/* Active Highlight Line */
.lyric-line.active {
    color: #ffffff;
    font-size: 2.5rem;
    font-weight: 900;
    filter: blur(0);
    transform: scale(1.05);
    text-shadow: 
        0 0 20px rgba(255, 255, 255, 0.5),
        0 4px 15px rgba(0, 0, 0, 0.6);
}

/* Past / Sung Lines */
.lyric-line.past {
    color: rgba(255, 255, 255, 0.45);
    filter: blur(0.2px);
    transform: scale(0.98);
}

/* ============================================================
   3. SETTINGS MODAL & OVERLAY STYLING
   ============================================================ */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.settings-modal {
    background: rgba(26, 26, 30, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 20px;
    width: 480px;
    max-width: 90vw;
    padding: 30px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.7), 0 0 40px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 16px;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    transition: background 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.setting-item.slider-group {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.setting-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.setting-desc {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.setting-badge {
    background: rgba(29, 185, 84, 0.2);
    color: #1ed760;
    border: 1px solid rgba(29, 185, 84, 0.4);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: monospace;
}

/* --- iOS Toggle Switch --- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
    cursor: pointer !important;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 34px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

input:checked + .switch-slider {
    background-color: #1db954;
}

input:checked + .switch-slider:before {
    transform: translateX(22px);
}

/* --- Slider Styling --- */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

input[type="range"]#delay-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
    cursor: pointer !important;
    transition: background 0.2s;
}

input[type="range"]#delay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1ed760;
    box-shadow: 0 0 10px rgba(30, 215, 96, 0.6);
    cursor: pointer !important;
    transition: transform 0.15s ease;
}

input[type="range"]#delay-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    font-family: monospace;
    padding: 0 4px;
}

/* --- Preset Buttons --- */
.preset-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.preset-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer !important;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: white;
}

.preset-btn.active-preset {
    background: rgba(29, 185, 84, 0.25);
    border-color: #1ed760;
    color: #1ed760;
}

/* --- Footer & Hotkey Tip --- */
.settings-footer {
    display: flex;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 14px;
}

.hotkey-tip {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
}

kbd {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: inherit;
    color: white;
}

/* Responsive adjustments */
@media (max-width: 960px) {
    body.mode-lyrics #app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        padding: 80px 20px 20px 20px;
        gap: 20px;
    }

    body.mode-lyrics .media-container {
        align-items: center;
        text-align: center;
        max-width: 100%;
        padding-left: 0;
    }

    body.mode-lyrics #cover-art {
        width: 180px;
        height: 180px;
    }

    body.mode-lyrics #track-title {
        font-size: 1.6rem;
    }

    .lyric-line {
        font-size: 1.4rem;
        text-align: center;
        transform-origin: center center;
    }

    .lyric-line.active {
        font-size: 1.8rem;
    }
}
