/**
 * BozonMusic Premium Stylesheet v4.0
 * Uses #app-wrapper for layout — body stays simple.
 * Desktop: sidebar + main side by side (flex row on wrapper)
 * Mobile:  sidebar off-canvas drawer, main = full width
 */

/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    --bg-dark: #050505;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #a0a0b0;
    --accent-primary: #ff007f;
    --accent-secondary: #00f2fe;
    --neon-shadow: 0 0 10px rgba(255, 0, 127, .5), 0 0 20px rgba(255, 0, 127, .3);
    --neon-shadow-cyan: 0 0 10px rgba(0, 242, 254, .5), 0 0 20px rgba(0, 242, 254, .3);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --t: all 0.3s ease;
    --sidebar-w: 280px;
    --topbar-h: 68px;
}

/* =============================================
   RESET
   ============================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
    /* Ensures fixed children are measured against the viewport, not extending it */
    overflow-y: auto;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* =============================================
   BACKGROUND ORBS
   ============================================= */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
    animation: orb-float 20s infinite alternate;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 0, 127, .4) 0%, transparent 70%);
    top: -200px;
    left: -200px;
}

.orb-2 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(0, 242, 254, .3) 0%, transparent 70%);
    bottom: -300px;
    right: -200px;
    animation-delay: -10s;
}

@keyframes orb-float {
    to {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* On mobile, orbs must NOT exceed the screen width or they trigger zoom-out */
@media (max-width: 768px) {
    .orb-1 {
        width: 300px;
        height: 300px;
        top: -100px;
        left: -100px;
    }

    .orb-2 {
        width: 300px;
        height: 300px;
        bottom: -120px;
        right: -100px;
    }
}

/* =============================================
   TYPOGRAPHY UTILITIES
   ============================================= */
.gradient-text {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.neon-text {
    color: var(--accent-secondary);
    text-shadow: 0 0 10px rgba(0, 242, 254, .5);
}

.highlight {
    color: var(--accent-primary);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}

/* =============================================
   APP WRAPPER  — the actual layout container
   ============================================= */
#app-wrapper {
    display: block;
    /* sidebar is now an overlay on all viewports */
    min-height: 100vh;
    width: 100%;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    background: rgba(5, 5, 5, .96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--glass-border);
    z-index: 1000;
    transform: translateX(-110%);
    transition: transform .38s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 4px 0 40px rgba(0, 0, 0, .6);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.sidebar .logo {
    font-size: 1.8rem;
    font-weight: 800;
    font-family: 'Playfair Display', serif;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.sidebar .logo i {
    font-size: 2rem;
}

/* Close button — visible on all viewports since sidebar is always a drawer */
.close-btn {
    display: flex;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    transition: var(--t);
}

.close-btn:hover {
    color: var(--accent-primary);
    background: rgba(255, 0, 127, .1);
    transform: rotate(90deg);
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    margin-bottom: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--t);
}

.nav-links a:hover,
.nav-links li.active a {
    color: var(--text-main);
}

.nav-links a:hover i,
.nav-links li.active a i {
    color: var(--accent-primary);
    text-shadow: var(--neon-shadow);
}

.nav-footer a {
    text-decoration: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .5rem;
    transition: var(--t);
    font-size: .95rem;
}

.nav-footer a:hover {
    color: var(--accent-secondary);
}

/* Sidebar overlay - Fixed for Mobile Clicks */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 999;
    opacity: 0;
    transition: opacity .3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
    width: 100%;
    min-width: 0;
    /* critical: stop flex children from overflowing */
    padding: 2rem 3rem;
    padding-bottom: 130px;
}

/* =============================================
   TOP NAV
   ============================================= */
.top-nav {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 3rem;
}

.menu-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--t);
}

.menu-toggle:hover {
    color: var(--accent-secondary);
    box-shadow: var(--neon-shadow-cyan);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .75rem 1.4rem;
    border-radius: 50px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    flex: 1;
    max-width: 480px;
    backdrop-filter: blur(10px);
}

.search-bar i {
    color: var(--text-muted);
    font-size: .9rem;
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    width: 100%;
    font-size: .95rem;
    font-family: inherit;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

/* =============================================
   HERO SECTION
   ============================================= */
.hero-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-bottom: 4rem;
}

.hero-title {
    font-size: 4.2rem;
    line-height: 1.1;
    letter-spacing: -2px;
    margin-bottom: 1.2rem;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 380px;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: .9rem 1.8rem;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-family: inherit;
    transition: var(--t);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(45deg, var(--accent-primary), #ff4d94);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: var(--neon-shadow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
}

.btn-secondary:hover {
    background: var(--glass-bg);
}

/* =============================================
   VINYL
   ============================================= */
.hero-visual {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    /* Clip the rotating vinyl so it NEVER bleeds beyond this box */
    overflow: hidden;
    contain: paint;
}

.vinyl-record {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: repeating-radial-gradient(#111, #111 5px, #222 6px, #222 10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 20px rgba(255, 0, 127, .2) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spin 6s linear infinite;
    transform-origin: center center;
    /* explicit center so rotation stays inside */
    flex-shrink: 0;
    will-change: transform;
    /* promote to own layer — avoids layout recalc */
}

.vinyl-center {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    position: relative;
}

.vinyl-center::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px;
    height: 14px;
    background: var(--bg-dark);
    border-radius: 50%;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =============================================
   TRACKS GRID
   ============================================= */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.view-all {
    color: var(--accent-secondary);
    text-decoration: none;
    font-weight: 600;
}

.view-all:hover {
    text-shadow: var(--neon-shadow-cyan);
}

.tracks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.track-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: var(--t);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.track-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .4);
    border-color: rgba(255, 255, 255, .2);
}

.track-card .cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    object-fit: cover;
    margin-bottom: .8rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
    display: block;
}

.play-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, .65);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .8rem;
    opacity: 0;
    transition: var(--t);
    backdrop-filter: blur(4px);
}

.track-card:hover .play-overlay {
    opacity: 1;
}

.card-btn {
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #fff;
    padding: .65rem 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .4rem;
    width: 82%;
    justify-content: center;
    transition: var(--t);
    text-decoration: none;
}

.card-btn.play-btn:hover {
    background: var(--accent-primary);
    box-shadow: var(--neon-shadow);
}

.card-btn.dl-btn:hover {
    background: var(--accent-secondary);
    color: #000;
    box-shadow: var(--neon-shadow-cyan);
}

.track-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    color: var(--text-muted);
    font-size: .85rem;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 3rem auto;
    grid-column: 1 / -1;
}

/* =============================================
   GLOBAL PLAYER
   ============================================= */
.global-player {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 90px;
    z-index: 200;
    border-top: 1px solid var(--glass-border);
    background: rgba(8, 8, 12, .92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    transform: translateY(100%);
    transition: transform .4s cubic-bezier(.175, .885, .32, 1.275);
}

.global-player.active {
    transform: translateY(0);
}

.global-player.hidden {
    display: none;
}

.now-playing {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 28%;
    min-width: 0;
}

.player-cover {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(0, 0, 0, .5);
}

.track-info {
    min-width: 0;
}

.track-info h4 {
    font-size: .95rem;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-info p {
    color: var(--text-muted);
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    padding: 0 1rem;
}

.main-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.ctrl-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--t);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}

.ctrl-btn:hover {
    color: var(--text-main);
}

.play-pause-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--text-main);
    color: var(--bg-dark);
    font-size: 1.1rem;
    padding-left: 2px;
}

.play-pause-btn:hover {
    background: var(--accent-secondary);
    box-shadow: var(--neon-shadow-cyan);
    color: #000;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: .8rem;
    width: 100%;
    max-width: 500px;
}

.progress-container span {
    font-size: .75rem;
    color: var(--text-muted);
    min-width: 32px;
}

.progress-bar-wrapper {
    flex: 1;
    height: 5px;
    background: var(--glass-border);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    width: 0%;
}

.progress-knob {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    width: 11px;
    height: 11px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity .2s;
    box-shadow: 0 0 8px rgba(255, 255, 255, .5);
}

.progress-bar-wrapper:hover .progress-knob {
    opacity: 1;
}

.extra-controls {
    width: 20%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}

.volume-slider {
    width: 90px;
    height: 5px;
    background: var(--glass-border);
    border-radius: 3px;
    cursor: pointer;
}

.volume-fill {
    height: 100%;
    background: #fff;
    border-radius: 3px;
    width: 80%;
}

#downloadBtn {
    color: var(--accent-primary);
}

#downloadBtn:hover {
    color: #ff4d94;
    text-shadow: var(--neon-shadow);
}

/* =================================================================
   MOBILE — ≤ 768px
   ================================================================= */
@media (max-width: 768px) {

    #app-wrapper {
        display: block;
        width: 100%;
        overflow-x: hidden;
    }

    /* ── SIDEBAR: mobile adjustments (base styles already handle drawer behavior) ── */
    .sidebar {
        width: min(290px, 84vw);
        padding: 1.5rem;
    }

    /* ── MAIN CONTENT ── */
    .main-content {
        width: 100%;
        display: block;
        padding: 0;
        padding-top: calc(var(--topbar-h) + 1rem);
        padding-left: 1rem;
        padding-right: 1rem;
        padding-bottom: 140px;
    }

    /* ── FIXED TOP BAR ── */
    .top-nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--topbar-h);
        width: 100%;
        padding: 0 1rem;
        gap: .8rem;
        margin-bottom: 0;
        background: rgba(5, 5, 5, .96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--glass-border);
        z-index: 900;
    }

    .search-bar {
        flex: 1;
        padding: .55rem 1rem;
        min-width: 0;
        /* Allows text box to shrink gracefully */
    }

    .search-bar input {
        min-width: 0;
        width: 100%;
    }

    /* ── HERO ── */
    .hero-section {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1.5rem;
        margin-top: 1rem;
        margin-bottom: 2rem;
    }

    .hero-visual {
        order: -1;
        justify-content: center;
        width: 100%;
    }

    .vinyl-record {
        width: 180px;
        height: 180px;
    }

    .vinyl-center {
        width: 60px;
        height: 60px;
    }

    .hero-title {
        font-size: clamp(2rem, 8vw, 2.5rem);
        letter-spacing: -1px;
        margin-bottom: .8rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        max-width: 100%;
        margin-bottom: 1.2rem;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
        gap: .7rem;
    }

    .hero-buttons .btn {
        width: 100%;
        justify-content: center;
        padding: .9rem 1rem;
    }

    /* ── TRACKS ── */
    .section-header h2 {
        font-size: 1.3rem;
    }

    .tracks-grid {
        /* Fluid grid avoids crushing columns on very small phones */
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .track-card {
        padding: .8rem;
    }

    .track-title {
        font-size: .9rem;
    }

    .track-artist {
        font-size: .8rem;
    }

    .card-btn {
        font-size: .8rem;
        padding: .5rem .6rem;
        width: 100%;
    }

    /* ── GLOBAL PLAYER: Spotify-Style Mini Player ── */
    .global-player {
        display: grid;
        grid-template-columns: 48px 1fr auto;
        grid-template-areas:
            "progress progress progress"
            "cover info controls";
        gap: 0.5rem 0.8rem;
        align-items: center;
        padding: 0.6rem 1rem 1rem;
        height: auto;
        border-radius: 16px 16px 0 0;
    }

    .now-playing {
        display: contents;
    }

    .player-cover {
        grid-area: cover;
        width: 48px;
        height: 48px;
    }

    .track-info {
        grid-area: info;
        min-width: 0;
    }

    .track-info h4 {
        font-size: .95rem;
        margin-bottom: 2px;
    }

    .track-info p {
        font-size: .8rem;
    }

    .player-controls {
        display: contents;
    }

    .progress-container {
        grid-area: progress;
        width: 100%;
        max-width: 100%;
        gap: 0.5rem;
    }

    .progress-container span {
        font-size: .7rem;
        min-width: 30px;
    }

    .main-controls {
        grid-area: controls;
        gap: 0.6rem;
    }

    .play-pause-btn {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    #prevBtn,
    #nextBtn {
        min-width: 32px;
        min-height: 32px;
        font-size: 1rem;
    }

    .extra-controls {
        display: none;
    }

    /* Hide volume/download on mobile */
}

/* ── Very small phones ≤ 400px ── */
@media (max-width: 400px) {
    .sidebar {
        width: 100%;
    }

    .vinyl-record {
        width: 140px;
        height: 140px;
    }

    .vinyl-center {
        width: 50px;
        height: 50px;
    }

    .section-header h2 {
        font-size: 1.1rem;
    }
}