/* Syllabeat Store — base visual system.
   Copied and adapted from the Syllabeat app (static/style.css): same tokens,
   Apex dark default with a derived light theme ([data-theme="light"]), Sora
   display / Inter text, electric-blue accent, liquid-metal pill buttons and
   the app's ProgressBar. Page-specific styles live in site.css / admin.css. */

@font-face {
    font-family: 'Sora';
    src: url('../fonts/Sora-Variable.ttf') format('truetype');
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-Variable.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;

    /* System tokens */
    --c-bg-hsl: 220 14% 8%;
    --c-bg: hsl(220 14% 8%);
    --c-surface: hsl(220 13% 12%);          /* card */
    --c-elevated: hsl(220 12% 16%);         /* raised panels: dialogs, export box, tables */
    --c-surface-alt: hsl(220 12% 16%);
    --c-track: hsl(220 12% 20%);

    --c-text: hsl(210 16% 95%);
    --c-text-2: hsl(215 12% 70%);
    --c-text-3: hsl(215 10% 58%);           /* muted-foreground */
    --c-border: hsl(220 12% 20%);
    --c-input-border: hsl(220 9% 46%);
    --c-focus: hsl(206 100% 60%);

    --c-primary: hsl(206 100% 52%);
    --c-primary-strong: hsl(206 100% 52%);
    --c-primary-text: hsl(206 100% 64%);
    --c-primary-dim: hsl(206 100% 52% / 0.12);
    --c-primary-line: hsl(206 100% 52% / 0.30);
    --c-primary-fg: #FFFFFF;

    --c-secondary: #2DD4BF;
    --c-secondary-strong: #0F766E;
    --c-secondary-text: #5EEAD4;
    --c-secondary-dim: #042F2E;
    --c-tertiary: #FBBF24;
    --c-tertiary-ink: #F59E0B;
    --c-tertiary-text: #FCD34D;
    --c-tertiary-dim: #422006;

    --c-success: hsl(152 62% 44%);
    --c-success-ink: #04180F;
    --c-success-text: hsl(152 62% 56%);
    --c-success-dim: hsl(152 62% 44% / 0.14);
    --c-success-line: hsl(152 62% 44%);
    --c-error-text: #F87171;
    --c-error-dim: hsl(0 72% 51% / 0.14);
    --c-error-btn: #DC2626;

    --glow: 0 0 0 1px hsl(206 100% 52% / 0.35), 0 0 40px -12px hsl(206 100% 52% / 0.55);

    --font-head: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-num: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
    /* Only for logs and code; numbers in the UI use --font-num with tabular figures. */
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;
    --s-7: 48px;

    --r-sm: 8px;
    --r-md: 12px;   /* rounded-xl */
    --r-lg: 16px;   /* rounded-2xl */

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.6);

    --ease: 150ms ease;
    --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);

    /* Progress bar */
    --pb-track: #1D1D1A;
    --pb-track-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
    --pb-fill: #93B0FF;
    --pb-fill-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -1px 0 rgba(0, 0, 0, 0.25);
    --pb-label: #E7E5E4;
    --pb-value: #A8A29E;
}

:root[data-theme="light"] {
    color-scheme: light;

    --c-bg-hsl: 220 20% 97%;
    --c-bg: hsl(220 20% 97%);
    --c-surface: #FFFFFF;
    --c-elevated: #FFFFFF;
    --c-surface-alt: hsl(220 18% 95%);
    --c-track: hsl(220 14% 90%);

    --c-text: hsl(222 24% 10%);
    --c-text-2: hsl(218 13% 32%);
    --c-text-3: hsl(218 11% 38%);
    --c-border: hsl(220 13% 88%);
    --c-input-border: hsl(218 10% 50%);
    --c-focus: hsl(206 100% 38%);

    --c-primary: hsl(206 100% 42%);
    --c-primary-strong: hsl(206 100% 40%);
    --c-primary-text: hsl(206 100% 33%);
    --c-primary-dim: hsl(206 100% 52% / 0.10);
    --c-primary-line: hsl(206 100% 42% / 0.30);

    --c-secondary: #14B8A6;
    --c-secondary-strong: #0F766E;
    --c-secondary-text: #115E59;
    --c-secondary-dim: #F0FDFA;
    --c-tertiary: #F59E0B;
    --c-tertiary-ink: #B45309;
    --c-tertiary-text: #92400E;
    --c-tertiary-dim: #FEF3C7;

    --c-success: hsl(152 62% 44%);
    --c-success-text: hsl(152 72% 24%);
    --c-success-dim: hsl(152 62% 44% / 0.12);
    --c-success-line: hsl(152 62% 40%);
    --c-error-text: #B91C1C;
    --c-error-dim: #FEF2F2;
    --c-error-btn: #DC2626;

    --glow: 0 0 0 1px hsl(206 100% 42% / 0.35), 0 0 36px -12px hsl(206 100% 45% / 0.45);

    --shadow-1: 0 1px 2px rgba(17, 24, 39, 0.06);
    --shadow-2: 0 8px 24px rgba(17, 24, 39, 0.10);
    --shadow-3: 0 24px 60px rgba(17, 24, 39, 0.18);

    --pb-track: rgb(231 229 228 / 0.6);
    --pb-track-shadow: inset 0 1px 2px rgba(28, 25, 23, 0.1), inset 0 0 0 1px rgba(28, 25, 23, 0.06);
    --pb-fill: #4568FF;
    --pb-fill-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(28, 25, 23, 0.2);
    --pb-label: #44403C;
    --pb-value: #57534E;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    color: var(--c-text);
    background: var(--c-bg);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-optical-sizing: auto;
}

h1, h2, h3, h4 {
    font-family: var(--font-head);
    color: var(--c-text);
    line-height: 1.2;
    text-wrap: balance;
}
h1 { font-size: 18px; font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
h4 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

p { color: var(--c-text-2); }
ol, ul { list-style: none; }
[tabindex="-1"]:focus { outline: none; }

:focus-visible {
    outline: 2px solid var(--c-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute;
    left: var(--s-4);
    top: -100px;
    z-index: 5000;
    padding: var(--s-3) var(--s-4);
    background: var(--c-surface);
    color: var(--c-primary-text);
    font-weight: 700;
    border: 2px solid var(--c-focus);
    border-radius: var(--r-md);
    text-decoration: none;
}
.skip-link:focus { top: var(--s-4); }

.hidden { display: none !important; }
.mono, .num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.help { font-size: 13px; color: var(--c-text-2); margin-top: var(--s-2); }
.field-error { font-size: 13px; color: var(--c-error-text); margin-top: var(--s-2); font-weight: 600; }

/* ─── Buttons: liquid-metal pill family ───
   Every button is a black pill with a 2px metallic rim. Solid buttons (all
   but ghost) get a live liquid-metal rim from static/liquid-metal.js
   (.lm-live) while on screen and enabled; without WebGL or with reduced
   motion they keep the static rim painted as a border-box gradient.
   Hierarchy: primary > secondary > ghost. */
:root {
    --lm-body: linear-gradient(180deg, #202020 0%, #000000 100%);
    --lm-ink: #FAFAF9;
    --lm-ink-2: #E7E5E4;
    --lm-rim: linear-gradient(135deg, #FAFAF9 0%, #78716C 22%, #F5F5F4 44%, #57534E 66%, #D6D3D1 84%, #A8A29E 100%);
    --lm-rim-quiet: linear-gradient(135deg, #A8A29E 0%, #44403C 30%, #A8A29E 55%, #292524 78%, #78716C 100%);
    --lm-rim-danger: linear-gradient(135deg, #FCA5A5 0%, #7F1D1D 30%, #F87171 55%, #450A0A 78%, #DC2626 100%);
    --lm-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 36px 14px 0 rgba(0, 0, 0, 0.02), 0 20px 12px 0 rgba(0, 0, 0, 0.08), 0 9px 9px 0 rgba(0, 0, 0, 0.12), 0 2px 5px 0 rgba(0, 0, 0, 0.15);
    --lm-shadow-hover: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 12px 6px 0 rgba(0, 0, 0, 0.05), 0 8px 5px 0 rgba(0, 0, 0, 0.1), 0 4px 4px 0 rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --lm-shadow-pressed: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --lm-shadow-quiet: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 2px 5px 0 rgba(0, 0, 0, 0.12);
    --lm-press-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn {
    position: relative;
    isolation: isolate;
    overflow: visible;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 44px;
    padding: 0 var(--s-5);
    font: 500 14px/1 var(--font-body);
    color: var(--lm-ink-2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    background: var(--lm-body) padding-box, var(--lm-rim-quiet) border-box;
    border: 2px solid transparent;
    border-radius: 999px;
    box-shadow: var(--lm-shadow-quiet);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    touch-action: manipulation;
    transition:
        transform 0.8s var(--lm-press-spring),
        box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        color var(--ease),
        filter var(--ease),
        opacity var(--ease);
}
.btn:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 3px; border-radius: 999px; }
.btn:hover:not(:disabled) { color: var(--lm-ink); box-shadow: var(--lm-shadow-hover); }
.btn.is-pressed:not(:disabled),
.btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
    box-shadow: var(--lm-shadow-pressed), inset 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
.btn:disabled { cursor: not-allowed; opacity: 0.45; filter: saturate(0); box-shadow: none; }
.btn[aria-busy="true"] { cursor: progress; }

.btn-primary {
    color: var(--lm-ink);
    background: var(--lm-body) padding-box, var(--lm-rim) border-box;
    box-shadow: var(--lm-shadow);
}
/* Live shader rim: the button itself goes transparent, the shader layer fills
   the full pill (including the 2px border ring) and ::before paints the black
   body on top of it, so only the 2px rim of the shader stays visible. */
.lm.lm-live,
.lm.lm-live:hover { background: transparent; }
.lm.lm-live::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--lm-body);
    pointer-events: none;
}
.lm.lm-live.is-pressed:not(:disabled)::before {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
.lm-shader {
    position: absolute;
    inset: -2px;
    z-index: -2;
    border-radius: 999px;
    overflow: hidden;
    pointer-events: none;
}
.lm-shader:empty { display: none; }
/* Secondary buttons sit a step below primary; danger tints the metal red. */
.lm-live:not(.btn-primary) > .lm-shader { opacity: 0.8; }
.btn-danger.lm-live > .lm-shader canvas,
.card-remove-btn.lm-live:hover > .lm-shader canvas { filter: sepia(1) saturate(5) hue-rotate(-35deg); }
.lm-shader canvas {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    border-radius: 999px;
}

.btn-accent,
.btn-secondary { background: var(--lm-body) padding-box, var(--lm-rim-quiet) border-box; }

.btn-ghost {
    color: var(--c-text-2);
    text-shadow: none;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}
.btn-ghost:hover:not(:disabled) {
    color: var(--c-text);
    background: var(--c-track) padding-box, var(--lm-rim-quiet) border-box;
    box-shadow: none;
}
.btn-ghost.is-pressed:not(:disabled),
.btn-ghost:active:not(:disabled) { box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2); }

.btn-danger {
    color: #FECACA;
    background: var(--lm-body) padding-box, var(--lm-rim-danger) border-box;
}
.btn-danger:hover:not(:disabled) { color: #FFFFFF; }

.btn-lg { min-height: 48px; padding: 0 var(--s-6); font-size: 15px; }
.btn-sm { min-height: 44px; padding: 0 var(--s-4); font-size: 13px; }
.btn-block { width: 100%; }

/* Click ripple (static/liquid-metal.js). Uses currentColor so it reads on
   both the black pills and the transparent ghost buttons. */
.lm-ripples {
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
}
.lm-ripple {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, currentColor 45%, transparent) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0.6;
    animation: lm-ripple 0.6s ease-out forwards;
}
@keyframes lm-ripple {
    to { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

.button-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.button-stack { display: flex; flex-direction: column; gap: var(--s-2); }
.disk-usage-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; justify-content: space-between; margin-top: calc(var(--s-2) * -1); }
.library-search-row { display: flex; flex-direction: column; gap: var(--s-1); margin-top: var(--s-2); }
.library-search-row label { font-size: 13px; font-weight: 600; color: var(--c-text-2); }

/* ─── Forms ─── */
.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.field + .field { margin-top: var(--s-4); }
.field label, .label-like {
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text);
}
.field-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 200px; }

.input, .select, .textarea {
    width: 100%;
    min-height: 44px;
    padding: var(--s-2) var(--s-3);
    font: 400 16px/1.4 var(--font-body);
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-input-border);
    border-radius: var(--r-md);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-3); opacity: 1; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
    outline: 2px solid var(--c-focus);
    outline-offset: 0;
    border-color: var(--c-focus);
}
.input[aria-invalid="true"] { border-color: var(--c-error-text); box-shadow: 0 0 0 1px var(--c-error-text); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--c-bg); color: var(--c-text-3); }

.select {
    appearance: none;
    padding-right: var(--s-6);
    background-image: url('../img/chevron.svg');
    background-repeat: no-repeat;
    background-position: right var(--s-3) center;
}
.textarea { min-height: 220px; resize: vertical; line-height: 1.7; padding: var(--s-3); }

.check {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: 44px;
    font-size: 15px;
    color: var(--c-text);
    cursor: pointer;
}
.check input {
    width: 20px; height: 20px;
    accent-color: var(--c-primary-strong);
    cursor: pointer;
}

/* ─── Progress ───
   Spring easings sampled from the original component's springs:
   fill = stiffness 210 / damping 34 / mass 0.9 (settles in ~0.9s, no overshoot),
   crossfade = stiffness 260 / damping 34 / mass 0.8 (~0.73s). */
:root {
    --pb-ease-fill: 0.896s linear(0, 0.107, 0.283, 0.449, 0.583, 0.687, 0.764, 0.824, 0.868, 0.901, 0.926, 0.945, 0.958, 0.969, 0.977, 0.983, 0.987, 0.99, 0.993, 0.995, 0.996, 0.997, 0.998, 0.998, 1);
    --pb-ease-fade: 0.73s linear(0, 0.102, 0.279, 0.444, 0.582, 0.688, 0.769, 0.829, 0.874, 0.906, 0.931, 0.949, 0.962, 0.972, 0.979, 0.985, 0.989, 0.992, 0.994, 0.995, 0.997, 0.998, 0.998, 0.999, 1);
}
.progress-block { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-4); }
.progress-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
    font-size: 13px;
    font-weight: 500;
    color: var(--pb-label);
}
.progress-head > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-value {
    display: grid;
    flex-shrink: 0;
    justify-items: end;
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
    color: var(--pb-value);
}
.progress-value > * { grid-area: 1 / 1; white-space: nowrap; transition: opacity var(--pb-ease-fade); }
.progress-percent { font-variant-numeric: tabular-nums; }
.progress-pending { opacity: 0; }
:is(.progress-block, .export-progress):has(.progressbar.indeterminate) .progress-pending { opacity: 1; }
:is(.progress-block, .export-progress):has(.progressbar.indeterminate) .progress-percent { opacity: 0; }

.progressbar {
    width: 100%;
    padding: 2px;
    border-radius: 4px;
    background: var(--pb-track);
    box-shadow: var(--pb-track-shadow);
}
.progressbar-track {
    position: relative;
    height: 8px;
    overflow: hidden;
    border-radius: 2px;
}
.progressbar-fill {
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background: var(--pb-fill);
    box-shadow: var(--pb-fill-shadow);
    transform-origin: left center;
    transform: scaleX(var(--pb-value, 0));
    transition: transform var(--pb-ease-fill);
}
.progressbar.indeterminate .progressbar-fill { transform: scaleX(0); }
.progressbar.indeterminate .progressbar-track::after {
    content: "";
    position: absolute;
    inset-block: 0;
    left: 0;
    width: 40%;
    border-radius: 2px;
    background: var(--pb-fill);
    box-shadow: var(--pb-fill-shadow);
    animation:
        pb-slide 1.25s ease-in-out infinite,
        pb-appear 0.18s ease-out;
}
@keyframes pb-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(250%); }
}
@keyframes pb-appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

.status-text { font-size: 13px; color: var(--c-text-2); }

/* ─── Inline alerts, password fields, small dialogs ─── */
.inline-alert {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
    margin-top: var(--s-3);
    padding: var(--s-3) var(--s-4);
    font-size: 14px;
    color: var(--c-error-text);
    background: var(--c-error-dim);
    border: 1px solid var(--c-error-text);
    border-left-width: 4px;
    border-radius: var(--r-md);
}
.inline-alert p { color: inherit; flex: 1 1 240px; }
p.inline-alert { display: block; }
p.inline-alert.hidden, .inline-alert.hidden { display: none !important; }

.password-wrap { display: flex; gap: var(--s-2); align-items: stretch; }
.password-wrap .input { flex: 1; min-width: 0; }
.password-toggle { flex-shrink: 0; min-width: 88px; border: 1px solid var(--c-border); }

.dialog-sm { max-width: 460px; }
.dialog-title { font-size: 20px; }
.dialog-actions { justify-content: flex-end; margin-top: var(--s-5); }

code {
    font: 500 0.92em/1 var(--font-mono);
    padding: 2px 6px;
    color: var(--c-text);
    background: var(--c-track);
    border-radius: var(--r-sm);
}


@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .progressbar.indeterminate .progressbar-track::after { content: none; }
    .lm-ripples { display: none; }
}
