/* ============================================================
   LocalMusic — Modern Styles
   Design: Mobile-first, dark/light theme, Spotify-inspired
   ============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    color-scheme: dark;
    --background:   #0d0d0d;
    --surface:      #161616;
    --surface-2:    #1e1e1e;
    --surface-3:    #272727;
    --foreground:   #f5f5f5;
    --muted:        #737373;
    --muted-2:      #525252;
    --border:       #2a2a2a;
    --border-hover: #404040;
    --accent:       #1db954;
    --accent-hover: #1ed760;
    --accent-glow:  rgba(29, 185, 84, 0.25);
    --navbar-bg:    rgba(13, 13, 13, 0.92);
    --player-bg:    rgba(18, 18, 18, 0.98);
    --grid-line:    rgba(255,255,255,0.028);
    --shadow-md:    0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:    0 12px 40px rgba(0,0,0,0.6);
    --radius-sm:    8px;
    --radius-md:    12px;
    --radius-lg:    16px;
    --radius-pill:  100px;
}

:root[data-theme="light"] {
    color-scheme: light;
    --background:   #fafafa;
    --surface:      #ffffff;
    --surface-2:    #f2f2f2;
    --surface-3:    #e8e8e8;
    --foreground:   #0a0a0a;
    --muted:        #737373;
    --muted-2:      #a3a3a3;
    --border:       #e5e5e5;
    --border-hover: #c8c8c8;
    --accent:       #1db954;
    --accent-hover: #18a349;
    --accent-glow:  rgba(29, 185, 84, 0.18);
    --navbar-bg:    rgba(250, 250, 250, 0.92);
    --player-bg:    rgba(255, 255, 255, 0.98);
    --grid-line:    rgba(0,0,0,0.04);
    --shadow-md:    0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg:    0 12px 40px rgba(0,0,0,0.12);
}

/* ── Base ─────────────────────────────────────────────────── */

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* ── Navbar ───────────────────────────────────────────────── */

.navbar {
    position: fixed;
    top: 0;
    inset-inline: 0;
    z-index: 200;
    background: var(--navbar-bg);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border-bottom: 1px solid var(--border);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 62px;
}

.logo {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.4px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--foreground);
    text-decoration: none;
}

.logo i {
    font-size: 26px;
    color: var(--accent);
    background: none !important;
    -webkit-text-fill-color: var(--accent) !important;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 28px;
}

.nav-links a {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: color .18s;
    letter-spacing: .01em;
}

.nav-links a:hover {
    color: var(--foreground);
}

.nav-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--foreground);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s, transform .15s;
    font-size: 17px;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--surface-3);
    transform: scale(1.06);
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--foreground);
    cursor: pointer;
    padding: 6px;
    font-size: 24px;
    line-height: 1;
}

/* Mobile nav drawer */
.mobile-nav {
    display: none;
    position: fixed;
    top: 62px;
    inset-inline: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    z-index: 199;
    box-shadow: var(--shadow-md);
}

.mobile-nav.active {
    display: block;
}

.mobile-nav a {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: color .15s, background .15s;
}

.mobile-nav a:hover,
.mobile-nav a:active {
    color: var(--foreground);
    background: var(--surface-2);
}

/* ── App layout ───────────────────────────────────────────── */

.app-layout {
    display: flex;
    margin-top: 62px;
    padding-bottom: 100px;
}

.main-content {
    flex: 1;
    min-height: calc(100vh - 162px);
    width: 100%;
    overflow-x: hidden;
}

/* ── Hero ─────────────────────────────────────────────────── */

.hero {
    padding: 64px 0 44px;
    position: relative;
    overflow: hidden;
}

.hero-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center top, black 20%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center top, black 20%, transparent 75%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    text-align: center;
    max-width: 660px;
    margin: 0 auto;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 22px;
    color: var(--muted);
    letter-spacing: .02em;
}

.badge-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulse 2.2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .55; transform: scale(.85); }
}

.hero h1 {
    font-size: clamp(30px, 5vw, 54px);
    font-weight: 900;
    letter-spacing: -1.5px;
    line-height: 1.08;
    margin-bottom: 14px;
    color: var(--foreground);
}

.hero p {
    font-size: 15px;
    color: var(--muted);
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.65;
}

/* ── Music Library ────────────────────────────────────────── */

.music-library {
    padding: 40px 0 60px;
}

.section-header {
    margin-bottom: 28px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.section-header h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.5px;
    line-height: 1.15;
}

.section-header p {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

/* ── Track Grid ───────────────────────────────────────────── */

.track-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 20px;
}

/* ── Track Card (desktop grid) ────────────────────────────── */

.track-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    cursor: pointer;
    position: relative;
    transition: background .22s, border-color .22s, transform .25s cubic-bezier(.25,.46,.45,.94), box-shadow .25s;
    outline: none;
}

.track-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.track-card:hover {
    background: var(--surface-2);
    border-color: var(--border-hover);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.track-card:hover .play-btn-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* Cover */
.track-cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    color: rgba(255,255,255,.8);
    background: linear-gradient(135deg, #5c6bc0, #9c27b0);
}

.track-card:nth-child(6n+1) .track-cover { background: linear-gradient(135deg, #1db954, #0e7c34); }
.track-card:nth-child(6n+2) .track-cover { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.track-card:nth-child(6n+3) .track-cover { background: linear-gradient(135deg, #f43f5e, #f97316); }
.track-card:nth-child(6n+4) .track-cover { background: linear-gradient(135deg, #06b6d4, #0ea5e9); }
.track-card:nth-child(6n+5) .track-cover { background: linear-gradient(135deg, #a855f7, #ec4899); }
.track-card:nth-child(6n+0) .track-cover { background: linear-gradient(135deg, #eab308, #f97316); }

/* Play overlay button */
.play-btn-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 46px;
    height: 46px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .22s, transform .22s, box-shadow .22s;
    box-shadow: 0 6px 18px var(--accent-glow);
    color: #000;
    font-size: 22px;
    z-index: 2;
}

.play-btn-overlay:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.track-info { min-width: 0; flex: 1; }

.track-name {
    font-weight: 700;
    font-size: 14.5px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--foreground);
}

.track-artist {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Now-Playing card highlight ───────────────────────────── */

html[data-theme="dark"] .track-card.now-playing {
    border: 1.5px solid #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15), var(--shadow-md) !important;
    background: rgba(59,130,246,.1) !important;
}

html[data-theme="dark"] .track-card.now-playing .track-name { color: #93c5fd !important; }
html[data-theme="dark"] .track-card.now-playing .track-artist { color: #60a5fa !important; }
html[data-theme="dark"] .equalizer span { background: #3b82f6 !important; }

html[data-theme="light"] .track-card.now-playing {
    border: 1.5px solid #1d4ed8 !important;
    box-shadow: 0 0 0 3px rgba(29,78,216,.12), var(--shadow-md) !important;
    background: rgba(29,78,216,.06) !important;
}

html[data-theme="light"] .track-card.now-playing .track-name  { color: #1d4ed8 !important; }
html[data-theme="light"] .track-card.now-playing .track-artist { color: #3b82f6 !important; }
html[data-theme="light"] .equalizer span { background: #1d4ed8 !important; }

/* ── Equalizer ────────────────────────────────────────────── */

.equalizer {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: none;
    gap: 3px;
    height: 20px;
    align-items: flex-end;
    z-index: 3;
}

.track-card.now-playing .equalizer { display: flex; }

.equalizer span {
    width: 3px;
    border-radius: 2px;
    animation: equalize .65s ease-in-out infinite;
}

.equalizer span:nth-child(1) { animation-delay: 0s; }
.equalizer span:nth-child(2) { animation-delay: .2s; }
.equalizer span:nth-child(3) { animation-delay: .4s; }

@keyframes equalize {
    0%, 100% { height: 4px; }
    50%       { height: 20px; }
}

.track-card.now-playing.paused .equalizer span {
    animation-play-state: paused;
    height: 4px;
}

/* ── Empty State ──────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--muted);
}

.empty-icon {
    font-size: 72px;
    margin-bottom: 20px;
    opacity: .25;
}

.empty-state h2 {
    font-size: 26px;
    margin-bottom: 10px;
    color: var(--foreground);
    font-weight: 800;
}

.empty-state code {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 13px;
}

.empty-state .hint {
    margin-top: 8px;
    font-size: 13px;
}

/* ── Player Bar ───────────────────────────────────────────── */

.player-bar {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    height: 88px;
    background: var(--player-bg);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 300;
}

/* Track info (left) */
.player-track-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.player-track-cover {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #1db954, #0e7c34);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: rgba(255,255,255,.9);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.playing .player-track-cover {
    animation: spin 22s linear infinite;
    border-radius: 50%;
}

.player-track-details {
    min-width: 0;
    flex: 1;
}

.player-track-details h4 {
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--foreground);
}

.player-track-details p {
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls (center) */
.player-controls-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.player-buttons {
    display: flex;
    align-items: center;
    gap: 14px;
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    transition: color .16s, transform .14s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.control-btn:hover {
    color: var(--foreground);
    transform: scale(1.1);
}

.control-btn:disabled {
    opacity: .3;
    cursor: not-allowed;
    pointer-events: none;
}

.play-pause-btn {
    width: 38px;
    height: 38px;
    background: var(--foreground);
    border-radius: 50%;
    color: var(--background);
    font-size: 18px;
    padding: 0;
    transition: transform .15s, background .15s;
}

.play-pause-btn:hover {
    transform: scale(1.07);
    background: var(--foreground);
    color: var(--background);
}

/* Progress bar */
.progress-bar-container {
    width: 100%;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.time {
    font-size: 10.5px;
    color: var(--muted);
    min-width: 34px;
    text-align: center;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.progress-bar,
.volume-bar {
    flex: 1;
    height: 4px;
    background: var(--surface-3);
    border-radius: 99px;
    cursor: pointer;
    position: relative;
    overflow: visible;
    transition: height .15s;
}

.progress-bar:hover,
.volume-bar:hover {
    height: 6px;
}

.progress-bar:hover .progress-fill::after,
.volume-bar:hover .volume-fill::after {
    opacity: 1;
}

.progress-fill,
.volume-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    position: relative;
    transition: width .1s linear;
    width: 0%;
}

.progress-fill::after,
.volume-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(50%, -50%);
    width: 11px;
    height: 11px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity .15s;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

/* Volume (right) */
.player-volume {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.volume-bar {
    width: 90px;
    flex: none;
}

.volume-fill { width: 100%; }

/* ── Responsive: 1024px ───────────────────────────────────── */

@media (max-width: 1024px) {
    .track-grid {
        grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
        gap: 16px;
    }

    .container { padding: 0 20px; }

    .player-track-info { display: none; }

    .player-bar {
        grid-template-columns: 0 1fr auto;
    }
}

/* ── Responsive: 768px ────────────────────────────────────── */

@media (max-width: 768px) {
    .play-btn-overlay {
        display: none;
    }

    .nav-links { display: none; }
    .mobile-menu-btn { display: flex; }

    .track-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Row layout on mobile */
    .track-card {
        padding: 12px 14px;
        display: flex;
        align-items: center;
        gap: 14px;
        border-radius: var(--radius-md);
    }

    .track-card:hover {
        transform: none;
        box-shadow: none;
    }

    .track-card:active {
        transform: scale(.98);
        background: var(--surface-2);
    }

    .track-cover {
        width: 56px;
        height: 56px;
        aspect-ratio: 1;
        font-size: 28px;
        margin-bottom: 0;
        flex-shrink: 0;
        border-radius: var(--radius-sm);
    }

    .track-info { flex: 1; min-width: 0; }

    .track-name  { font-size: 14px; }
    .track-artist { font-size: 12px; }

    /* Always-visible play button on mobile */
    .play-btn-overlay {
        position: relative;
        bottom: auto;
        right: auto;
        opacity: 1;
        transform: none;
        width: 40px;
        height: 40px;
        font-size: 20px;
        margin-left: auto;
        flex-shrink: 0;
        background: var(--surface-3);
        color: var(--foreground);
        box-shadow: none;
    }

    .track-card:hover .play-btn-overlay {
        transform: none;
        background: var(--accent);
        color: #000;
    }

    .track-card.now-playing .play-btn-overlay { display: none; }

    /* Hero shrink */
    .hero { padding: 46px 0 30px; }

    .music-library { padding: 30px 0 48px; }

    .section-header { margin-bottom: 20px; }

    /* ── Mobile player bar ── */
    .player-bar {
        height: 76px;
        padding: 0 16px;
        /* Zostawiamy miejsce na pasek postępu przyklejony do dołu */
        padding-bottom: 4px;
        grid-template-columns: 1fr auto;
        gap: 0;
        /* position: relative potrzebne do absolute dzieci */
        position: fixed;
    }

    .player-track-info {
        display: flex !important;
    }

    .player-controls-center {
        flex-direction: row;
        gap: 0;
    }

    /* ── Pasek postępu na dole na całą szerokość ── */
    .progress-bar-container {
        display: flex;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        padding: 0;
        gap: 0;
        height: 3px;
        /* Lekko pogrubiony przy dotknięciu */
        touch-action: none;
    }

    .progress-bar-container .time {
        display: none;
    }

    .progress-bar-container .progress-bar {
        flex: 1;
        height: 3px;
        border-radius: 0;
        overflow: hidden;
        transition: height .15s;
    }

    .progress-bar-container .progress-bar:active {
        height: 5px;
    }

    /* Bez kulistego handlera — za mało miejsca */
    .progress-bar-container .progress-fill::after {
        display: none;
    }

    .progress-bar-container .progress-fill {
        border-radius: 0;
    }

    .player-buttons { gap: 10px; }

    .player-volume { display: none; }

    .control-btn { font-size: 22px; padding: 8px; }

    .play-pause-btn {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .app-layout { padding-bottom: 84px; }
}

/* ── Responsive: 480px ────────────────────────────────────── */

@media (max-width: 480px) {
    .container { padding: 0 14px; }

    .hero { padding: 36px 0 22px; }
    .hero h1 {
        font-size: 27px;
        letter-spacing: -.8px;
        margin-bottom: 10px;
    }
    .hero p { font-size: 13.5px; }

    .badge {
        font-size: 11.5px;
        padding: 4px 12px;
        margin-bottom: 18px;
    }

    .section-header h2 { font-size: 20px; }
    .section-header p  { font-size: 12px; }

    .track-card { padding: 11px 12px; gap: 12px; }

    .track-cover { width: 52px; height: 52px; font-size: 26px; }

    .track-name   { font-size: 13.5px; }
    .track-artist { font-size: 11.5px; }

    /* Smaller navbar */
    .navbar-inner { height: 56px; }
    .app-layout   { margin-top: 56px; }

    .logo { font-size: 16px; }
    .logo i { font-size: 22px; }

    .theme-toggle { width: 36px; height: 36px; font-size: 15px; }

    /* Player */
    .player-bar {
        height: 72px;
        padding: 0 12px;
    }

    .player-track-cover { width: 44px; height: 44px; font-size: 20px; }

    .player-track-details h4 { font-size: 12.5px; }
    .player-track-details p  { font-size: 10.5px; }

    .play-pause-btn { width: 38px; height: 38px; font-size: 18px; }
    .control-btn    { font-size: 20px; padding: 6px; }
}

/* ── 360px ────────────────────────────────────────────────── */

@media (max-width: 360px) {
    .container { padding: 0 10px; }
    .track-card { padding: 10px; gap: 10px; }
    .track-cover { width: 46px; height: 46px; font-size: 22px; }
    .track-name { font-size: 13px; }
    .player-bar { padding: 0 10px; }
    .player-track-details h4 { font-size: 12px; }
}

/* ── Touch devices ────────────────────────────────────────── */

@media (hover: none) and (pointer: coarse) {
    .control-btn:hover      { transform: none; color: var(--muted); }
    .control-btn:active     { transform: scale(.9); color: var(--foreground); }
    .play-pause-btn:hover   { transform: none; }
    .play-pause-btn:active  { transform: scale(.92); }
    .track-card:hover       { transform: none; border-color: var(--border); background: var(--surface); }
    .track-card:active      { transform: scale(.97); background: var(--surface-2); }
    .theme-toggle:hover     { transform: none; }
    .theme-toggle:active    { transform: scale(.92); }
}

/* ── Landscape phones ─────────────────────────────────────── */

@media (max-height: 500px) and (orientation: landscape) {
    .hero { padding: 18px 0 12px; }
    .hero h1 { font-size: 22px; margin-bottom: 6px; }
    .hero p { font-size: 12.5px; }
    .badge { margin-bottom: 10px; }
    .music-library { padding: 16px 0 24px; }
    .section-header { margin-bottom: 12px; }
}