/*
 * Spring Agents — shared design system
 *
 * Linked from every template. Provides tokens (colors, fonts, radii,
 * spacing), component base classes (.btn, .card, .tag, .eyebrow,
 * .form-field), and a11y defaults (focus ring, skip link, reduced motion).
 *
 * Think of it as the "config file" every page reads before applying its
 * page-specific styles.
 */

/*
 * Fonts are self-hosted so the app works under a strict CSP that blocks
 * external origins. No runtime network dependency, no render-blocking
 * @import round-trip. ~85KB total for latin + latin-ext.
 */

/* Geist — variable font, one file serves weights 400–800 */
@font-face {
    font-family: 'Geist';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/static/fonts/geist-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Geist';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/static/fonts/geist-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* JetBrains Mono — weights 400 and 500 */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('/static/fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('/static/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* Brand palette — keep in sync with style.css */
    --navy:        #0a0f1e;
    --navy-mid:    #111827;
    --navy-light:  #1e2a3a;
    --navy-surface:#141c2e;
    --navy-border: #1f3050;
    --blue:        #3b82f6;
    --blue-light:  #60a5fa;
    --yellow:      #fbbf24;
    --yellow-warm: #f5b93f;
    --yellow-dim:  #f59e0b;

    /* Text */
    --text:      #e8edf5;
    --text-dim:  #8a97ab;
    --text-mute: #5a6a80;
    --white:     #ffffff;

    /* Status */
    --green: #22c55e;
    --red:   #ef4444;
    --amber: #f59e0b;

    /* Fonts */
    --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Radii */
    --radius-sm:   6px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-pill: 100px;

    /* Shadows (tinted to navy, not pure black) */
    --shadow-sm: 0 2px 8px rgba(3, 7, 18, 0.4);
    --shadow-md: 0 8px 24px rgba(3, 7, 18, 0.35);
    --shadow-lg: 0 16px 48px rgba(3, 7, 18, 0.45);
    --glow-yellow: 0 0 0 1px rgba(251, 191, 36, 0.2), 0 8px 28px rgba(251, 191, 36, 0.2);
    --glow-blue:   0 0 0 1px rgba(96, 165, 250, 0.2), 0 8px 28px rgba(96, 165, 250, 0.15);
}

html {
    scroll-behavior: smooth;
}

/* Baseline typography — pages can override, but this is the default. */
body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    color: var(--text);
}

/* Keyboard-visible focus ring — applied to every interactive element. */
:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Screen reader only — used by skip links and visually-hidden labels. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Keyboard-only skip link — appears when focused. */
.skip-link {
    position: absolute;
    top: -48px;
    left: 12px;
    background: var(--yellow);
    color: var(--navy);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    z-index: 1000;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 12px;
}

/* ==========================================================================
   Component: .btn
   Base button. Add .btn-primary / .btn-ghost / .btn-danger for variants.
   Works as both <button> and <a>.
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.1px;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.15s ease, background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    will-change: transform;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
    color: var(--navy);
    background: var(--yellow);
    border-color: var(--yellow);
    box-shadow: 0 4px 18px rgba(251, 191, 36, 0.22);
}
.btn-primary:hover:not(:disabled) {
    background: #ffd255;
    border-color: #ffd255;
    box-shadow: 0 6px 26px rgba(251, 191, 36, 0.38);
    transform: translateY(-1px);
}

.btn-ghost {
    color: var(--text);
    background: transparent;
    border-color: var(--navy-border);
}
.btn-ghost:hover:not(:disabled) {
    border-color: var(--blue-light);
    color: var(--blue-light);
    background: rgba(96, 165, 250, 0.04);
}

.btn-danger {
    color: var(--white);
    background: var(--red);
    border-color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }

.btn-small { padding: 8px 14px; font-size: 13px; }
.btn-large { padding: 14px 26px; font-size: 15px; }

/* ==========================================================================
   Component: .card
   Surface container. Use for groupings, panels, dashboards widgets.
   ========================================================================== */

.card {
    background: var(--navy-mid);
    border: 1px solid var(--navy-border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--navy-border);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.2px;
}

/* ==========================================================================
   Component: .tag
   Compact status/label pill. For statuses, counts, categories.
   ========================================================================== */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: rgba(30, 42, 58, 0.6);
    border: 1px solid var(--navy-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    font-family: var(--font-mono);
}
.tag-yellow { color: var(--yellow-warm); background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.25); }
.tag-blue   { color: var(--blue-light);  background: rgba(96, 165, 250, 0.08); border-color: rgba(96, 165, 250, 0.25); }
.tag-green  { color: var(--green);       background: rgba(34, 197, 94, 0.08);  border-color: rgba(34, 197, 94, 0.25); }
.tag-red    { color: var(--red);         background: rgba(239, 68, 68, 0.08);  border-color: rgba(239, 68, 68, 0.25); }

/* Status dot — animated heartbeat */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(251, 191, 36, 0.06);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    color: var(--yellow-warm);
    font-family: var(--font-mono);
}
.status-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 0 8px var(--yellow);
    animation: statusBlink 1.8s ease-in-out infinite;
}
.status-pill.green .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-pill.green       { color: var(--green); border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.06); }

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* ==========================================================================
   Component: .eyebrow
   Small pre-heading label, lowercase mono yellow. Sits above a title.
   ========================================================================== */

.eyebrow {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--yellow-warm);
    margin-bottom: 10px;
    letter-spacing: 0;
}

/* ==========================================================================
   Component: .form-field
   Label + input + helper. Used across signup, onboarding, customer-edit.
   ========================================================================== */

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0;
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 11px 14px;
    background: var(--navy-surface);
    border: 1px solid var(--navy-border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
}

.form-field input:hover,
.form-field textarea:hover,
.form-field select:hover {
    border-color: rgba(96, 165, 250, 0.3);
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    border-color: var(--blue-light);
    background: var(--navy-mid);
}

.form-field input::placeholder,
.form-field textarea::placeholder {
    color: var(--text-mute);
}

.form-field .helper {
    font-size: 12px;
    color: var(--text-mute);
}
.form-field .helper.error { color: var(--red); }

/* ==========================================================================
   Utilities
   ========================================================================== */

.text-mute    { color: var(--text-mute); }
.text-dim     { color: var(--text-dim); }
.text-yellow  { color: var(--yellow-warm); }
.text-blue    { color: var(--blue-light); }
.mono         { font-family: var(--font-mono); }
.tabular      { font-variant-numeric: tabular-nums; }
.balance      { text-wrap: balance; }
.pretty       { text-wrap: pretty; }

/* ==========================================================================
   Reduced motion — respect user preference system-wide
   ========================================================================== */

@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;
    }
}
