/* ─── Design tokens ─────────────────────────────────────────────── */

:root {
    /* Surfaces (zinc scale, darkest → lightest) */
    --bg-0: #09090b;
    --bg-1: #0e0e10;
    --bg-2: #18181b;
    --bg-3: #27272a;
    --bg-4: #3f3f46;

    /* Text */
    --fg-0: #fafafa;
    --fg-1: #e4e4e7;
    --fg-2: #a1a1aa;
    --fg-3: #71717a;
    --fg-4: #52525b;

    /* Borders */
    --border-1: rgba(255, 255, 255, 0.06);
    --border-2: rgba(255, 255, 255, 0.10);
    --border-3: rgba(255, 255, 255, 0.16);

    /* Accent — dynamically overridden by theme.js from album art OR
       by user via color-manager. */
    --accent: #818cf8;
    --accent-hi: #a5b4fc;
    --accent-glow: rgba(129, 140, 248, 0.35);
    --accent-soft: rgba(129, 140, 248, 0.12);

    /* Per-element customizable colors. Default to neutral tokens.
       color-manager.js overrides any of these via inline style on :root. */
    --color-bg: var(--bg-0);
    --color-title: var(--fg-0);
    --color-artist: var(--fg-2);
    --color-lyrics: #ffb3d1;
    --color-vinyl-tint: transparent;

    /* Semantic */
    --success: #34d399;
    --danger: #f87171;
    --warn: #fbbf24;

    /* Radii */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-xl: 24px;
    --r-pill: 999px;

    /* Spacing scale (4-pt) */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;
    --s-10: 40px;
    --s-12: 48px;
    --s-16: 64px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 32px var(--accent-glow);

    /* Motion */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ease-in-out: cubic-bezier(0.6, 0, 0.4, 1);
    --dur-fast: 120ms;
    --dur: 200ms;
    --dur-slow: 320ms;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    /* Player text (title/artist/lyrics) — font-manager.js overrides via inline
       style on :root when the user picks a non-default font. */
    --font-player: var(--font-sans);
}

/* ─── Reset ─────────────────────────────────────────────────────── */

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

/* The HTML `hidden` attribute must always win over component CSS like
   `.modal-overlay { display: grid }` or `.export-progress { display: flex }`. */
[hidden] {
    display: none !important;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-feature-settings: "ss01", "cv01", "cv03";
    color: var(--fg-1);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    line-height: 1.5;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

input, textarea {
    font: inherit;
    color: inherit;
    background: transparent;
}

input:focus, textarea:focus, button:focus-visible {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* ─── Form primitives ───────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.field-label {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.field-label .req {
    color: var(--accent);
}

.field-hint {
    margin-left: 4px;
    color: var(--fg-4);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.text-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--fg-0);
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    transition: border-color var(--dur), background var(--dur);
}

.text-input::placeholder {
    color: var(--fg-3);
}

.text-input:hover {
    border-color: var(--border-2);
}

.text-input:focus {
    border-color: var(--accent);
    background: var(--bg-1);
}

/* ─── File drop zone ────────────────────────────────────────────── */

.drop-zone {
    position: relative;
    padding: var(--s-4);
    background: var(--bg-2);
    border: 1px dashed var(--border-2);
    border-radius: var(--r-md);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--dur), background var(--dur);
}

.drop-zone:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-zone .dz-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--fg-1);
    margin-bottom: 2px;
    /* Truncate long file names to a single line; full name shown via title= */
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drop-zone .dz-hint {
    font-size: 11px;
    color: var(--fg-3);
}

.drop-zone[data-loaded="true"] {
    border-style: solid;
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.08);
}

.drop-zone-clear {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: var(--fg-1);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: background var(--dur);
    z-index: 1;
}

.drop-zone[data-loaded="true"] .drop-zone-clear {
    display: inline-flex;
}

.drop-zone-clear:hover {
    background: var(--danger);
}

/* ─── Buttons ───────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--r-md);
    background: var(--bg-3);
    color: var(--fg-0);
    border: 1px solid var(--border-1);
    transition: background var(--dur), border-color var(--dur), transform var(--dur);
}

.btn:hover:not(:disabled) {
    background: var(--bg-4);
    border-color: var(--border-2);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-0);
    border-color: transparent;
    font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hi);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    background: var(--bg-3);
    color: var(--fg-3);
    box-shadow: none;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--fg-2);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-2);
    color: var(--fg-0);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--r-pill);
}

/* ─── Icons (Lucide subset, hydrated by js/icons.js) ────────────── */

[data-icon] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

[data-icon] svg {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* Inside circular controls, scale icon to fit the button regardless of the
   intrinsic svg width/height set by icons.js. */
.control-btn [data-icon] {
    width: 50%;
    height: 50%;
}
.vinyl-play-pause-btn [data-icon] {
    width: 45%;
    height: 45%;
}
.control-btn [data-icon] svg {
    width: 100%;
    height: 100%;
}

/* ─── Hide scrollbars (visual choice) ───────────────────────────── */

::-webkit-scrollbar {
    width: 0;
    height: 0;
}

html {
    scrollbar-width: none;
}

/* ─── Motion sensitivity ────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
