/* tokens.css — Design token system for the Surf Suite
   Canonical source of truth for colors, typography, spacing, radii, shadows.
   Load BEFORE any other stylesheet so tokens are available everywhere.

   Light-first (matches app.css conventions).
   Dark mode via [data-theme="dark"].
*/

/* Inter — the body/UI face (type canon W-C, 2026-07-29: Surf Display Black
   for headings, Inter for everything else — matches the Android client's
   bundled OTFs). 400/500/600 vendored full-charset woff2 (converted from the
   same Inter cuts Android ships); 700 keeps the original latin subset.
   All vendored so the binary stays self-contained; falls back to the system
   sans stack. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/inter-700-latin.woff2') format('woff2');
}

:root {
    /* ── Colors — primary / accent ── */
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-primary-light: #eff6ff;

    /* ── Colors — semantic ── */
    --color-success: #22c55e;
    --color-success-light: #f0fdf4;
    --color-warning: #f59e0b;
    --color-warning-light: #fffbeb;
    --color-danger: #ef4444;
    --color-danger-light: #fef2f2;
    --color-purple: #8b5cf6;
    --color-purple-light: #f5f3ff;

    /* ── Colors — surfaces ── */
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-alt: #ffffff;
    --color-hover-bg: #f1f5f9;

    /* ── Colors — text ── */
    --color-text: #0f172a;
    --color-text-secondary: #334155;
    --color-text-muted: #5b6b7d;

    /* ── Colors — borders ── */
    --color-border: #e2e8f0;
    --color-border-hover: #cbd5e1;

    /* ── Colors — code ── */
    --color-code-bg: #f1f5f9;
    --color-pre-bg: #0f172a;
    --color-pre-text: #e2e8f0;

    /* ── Typography ── */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-brand: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;

    /* ── Font sizes — primitive scale ──
       Use the semantic tokens below in new code; primitives kept for
       backwards compat. */
    --font-size-xs: 0.75rem;       /* 12px */
    --font-size-sm: 0.875rem;      /* 14px */
    --font-size-base: 1rem;        /* 16px */
    --font-size-lg: 1.125rem;      /* 18px */
    --font-size-xl: 1.25rem;       /* 20px */
    --font-size-2xl: 1.5rem;       /* 24px */

    /* ── Font sizes — semantic scale (canonical) ──
       Reference these in new code. Each token names a role, not a size,
       so the scale can retune without sweeping component files. */
    --font-size-micro:    0.6875rem;  /* 11px — count badge, microlabel, sublabel */
    --font-size-caption:  0.75rem;    /* 12px — caption, status micro, footnote */
    --font-size-ui:       0.8125rem;  /* 13px — drawer row, dropdown row, table cell, dense UI */
    --font-size-body-sm:  0.875rem;   /* 14px — button, input, mobile drawer row */
    --font-size-body:     0.9375rem;  /* 15px — body default */
    --font-size-body-lg:  1rem;       /* 16px — long-form prose */
    --font-size-h3:       1.125rem;   /* 18px — subsection title */
    --font-size-h2:       1.25rem;    /* 20px — section title */
    --font-size-h1:       1.5rem;     /* 24px — page header */
    --font-size-display:  2rem;       /* 32px — hero / display */

    /* ── Line heights ── */
    --line-height-tight:    1.1;    /* display, hero */
    --line-height-snug:     1.25;   /* headlines, buttons (single line) */
    --line-height-normal:   1.5;    /* body, inputs, code blocks */
    --line-height-relaxed:  1.65;   /* long-form prose, comments */

    /* ── Font weights ── */
    --font-weight-regular:    400;  /* body copy */
    --font-weight-medium:     500;  /* drawer rows, nav links, ghost button labels */
    --font-weight-semibold:   600;  /* titles, primary buttons, active states */
    --font-weight-bold:       700;  /* H1/H2, brand text, table headers, status labels */
    --font-weight-extrabold:  800;  /* hero headlines only */

    /* ── Letter spacing / tracking ── */
    --tracking-tight:   -0.02em;    /* display, h1, h2 — pulls letters together */
    --tracking-normal:  0;          /* body, UI default */
    --tracking-wide:    0.05em;     /* uppercase labels (status header, section header) */
    --tracking-micro:   0.04em;     /* small caps tag text (.surf-tile-tag) */

    /* ── Spacing ── */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;

    /* ══ Border radii — THE canonical radius scale ══════════════════════
       The old "sharp 90° corners everywhere, never rounded" rule is RETIRED
       for web (Brady, 2026-07-24). This block is the single source of truth
       for corner rounding across Surfspace web.

       Rules of use:
         • Consume these tokens. Never hardcode a px radius in component CSS.
         • Never introduce a second radius scale or a parallel *-radius-*
           namespace. If a surface needs a value that is not here, the scale
           gets retuned here — not forked.
         • --surf-radius-md is the DEFAULT for ordinary chrome. Reach for
           xs/sm only when a control is genuinely tight, xl only for large
           floating surfaces.

       Slot guide (restrained, shadcn-style neutral baseline):
         none  0      full-bleed edges, topbar, drawer edges, table cells
         xs    2px    badges, tags, count pills that must stay crisp
         sm    4px    inputs, selects, small/icon buttons, code chips
         md    6px    DEFAULT — buttons, menu rows, chips, tiles, toolbars
         lg    8px    cards, panels, dropdowns, popovers, media thumbs
         xl    12px   modals, bottom sheets, large floating panels
         full  9999px true pills and pill-shaped controls (search, toggles) */
    --surf-radius-none: 0;
    --surf-radius-xs:   2px;
    --surf-radius-sm:   4px;
    --surf-radius-md:   6px;
    --surf-radius-lg:   8px;
    --surf-radius-xl:   12px;
    --surf-radius-full: 9999px;

    /* Legacy compat aliases — pre-existing consumers keep working and now
       inherit the scale above. Do NOT reference these in new code; they are
       kept only so the ~30 existing var(--radius*) call sites retune with
       the scale instead of freezing at the old sharp values. */
    --radius-sm: var(--surf-radius-sm);
    --radius-md: var(--surf-radius-md);
    --radius-lg: var(--surf-radius-lg);
    --radius:    var(--surf-radius-md);

    /* Legacy SHELL alias names. These used to be declared in surf-shell.css,
       which meant every sheet that consumes them (surf.css, mako-chat.css,
       surf-wavesite.css, surf-apps.css) rendered SQUARE on any page that
       links those sheets without surf-shell.css — e.g. the code_public/*
       pages, which extend base.html. Declared here so one definition point
       covers every surface. Same rule as above: do NOT reference these in
       new code, and never give one a literal value. */
    --surf-radius-sharp:       var(--surf-radius-md);
    --surf-radius-square:      var(--surf-radius-none);
    --surf-radius-pill:        var(--surf-radius-full);
    --surf-radius-legacy-soft: var(--surf-radius-lg);
    /* Genuine circular shapes (avatars, dots) — not part of the scale. */
    --surf-radius-circle:      50%;

    /* ── Shadows ── */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);

    /* ── Transitions ── */
    --transition-fast: 150ms ease;
}

/* ── Dark theme ── */
[data-theme="dark"] {
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-primary-light: #172554;

    --color-success-light: #052e16;
    --color-warning-light: #451a03;
    --color-danger-light: #450a0a;
    --color-purple-light: #2e1065;

    --color-bg: #0a0a0f;
    --color-surface: #111118;
    --color-surface-alt: #111118;
    --color-hover-bg: #16161f;

    --color-text: #e5e5ef;
    --color-text-secondary: #cbd5e1;
    --color-text-muted: #8b8ba0;

    --color-border: #1e1e2a;
    --color-border-hover: #2a2a3a;

    --color-code-bg: #16161f;
    --color-pre-bg: #0a0a0f;
    --color-pre-text: #e2e8f0;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
}
