/* tokens/tokens.css
 *
 * The structural token vocabulary every lukkes-ui primitive resolves against.
 *
 * STRUCTURAL tokens (colour roles, the type scale, the spacing scale, state
 * tokens, --ui-scale) are LAW: identical in every consuming project, never
 * overridden downstream. BRAND tokens (--accent, --accent-ink, --radius) are
 * the per-project VOICE — same grammar, different voice. A consuming project
 * overrides the brand layer in ONE small file loaded after this one (see
 * tokens/brand.example.css) and touches nothing here: every structural token
 * below that needs a brand voice already reads it through a fallback
 * (var(--accent, <neutral default>)), so setting --accent / --accent-ink /
 * --radius once is enough to retint the whole system.
 *
 * --field-bg is the token UI-FLD-001 checks a search field's background
 * against. It is deliberately not a grey: it is the SURFACE ROLE a search
 * field takes. Operator, verbatim: "no me gustan los campos de busqueda con
 * fondo gris" — this file is what makes that unrepresentable rather than
 * merely forbidden. There is no grey to choose; there is --field-bg.
 */

:root {
  /* ============================================================
   * STRUCTURAL — colour roles, light palette (the default; law)
   * ============================================================ */
  --surface: #ffffff;
  --field-bg: #ffffff;
  --ink: #16181d;
  --ink-muted: #5b6270;
  --hairline: #e2e4e9;

  /* ============================================================
   * STRUCTURAL — semantic state colours. These are LAW, not brand
   * voice: red means error and green means success in every product,
   * and a project that retinted them would be lying to its users.
   * Brand voice is --accent (below), which is a different role.
   *
   * They exist because without them every alert tone fell back to
   * --ink-muted and a "saved" alert was visually identical to a
   * "failed" one — an alert that doesn't signal is not an alert.
   * ============================================================ */
  --danger: #c0342b;
  --warning: #9a6206;
  --success: #1f7a43;
  --info: #2563eb;

  /* ============================================================
   * STRUCTURAL — the type stack. Without it every consuming project
   * falls back to the browser default (Times), which reads as an
   * unfinished draft no matter how correct the layout is. The stack
   * resolves to the platform's own UI face, so a page looks native
   * on each OS rather than imposing one font everywhere.
   * ============================================================ */
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-stack-numeric: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* ============================================================
   * STRUCTURAL — type scale. Tracking and leading are set PER SIZE,
   * never once globally: display carries negative tracking, body is 0,
   * small text and uppercase labels (e.g. table headers) carry positive
   * tracking. Sizes ride --ui-scale so the [-][+] control scales type
   * and spacing together (UI-A11Y-001) — the control itself stays fixed.
   * ============================================================ */
  --font-size-display: calc(2rem * var(--ui-scale));
  --tracking-display: -0.02em;
  --leading-display: 1.1;

  --font-size-heading: calc(1.5rem * var(--ui-scale));
  --tracking-heading: -0.01em;
  --leading-heading: 1.25;

  --font-size-body: calc(1rem * var(--ui-scale));
  --tracking-body: 0;
  --leading-body: 1.5;

  --font-size-small: calc(0.875rem * var(--ui-scale));
  --tracking-small: 0.01em;
  --leading-small: 1.4;

  --font-size-label: calc(0.75rem * var(--ui-scale));
  --tracking-label: 0.04em;
  --leading-label: 1.3;

  /* ============================================================
   * STRUCTURAL — spacing scale (also rides --ui-scale, so padding and
   * gaps grow with type instead of type outgrowing its own box)
   * ============================================================ */
  --space-1: calc(0.25rem * var(--ui-scale));
  --space-2: calc(0.5rem * var(--ui-scale));
  --space-3: calc(0.75rem * var(--ui-scale));
  --space-4: calc(1rem * var(--ui-scale));
  --space-5: calc(1.5rem * var(--ui-scale));
  --space-6: calc(2rem * var(--ui-scale));

  /* ============================================================
   * STRUCTURAL — interaction state tokens
   * ============================================================ */
  --hover-bg: rgb(0 0 0 / 4%);
  --focus-ring: var(--accent, #2563eb);
  --disabled-bg: #f0f1f3;
  --disabled-ink: #9aa1ad;

  /* ============================================================
   * STRUCTURAL — accessibility zoom. The [-][+] control multiplies
   * this; the control's own box stays in fixed px and never reads it
   * (UI-A11Y-001).
   * ============================================================ */
  --ui-scale: 1;

  /* ============================================================
   * BRAND — per-project voice, not structural law. Nothing is assigned
   * to --accent / --accent-ink / --radius here on purpose: a consuming
   * project sets these three names once (tokens/brand.example.css shows
   * the pattern) and every structural token below that carries a brand
   * voice picks it up automatically through its fallback.
   * Consumers: always go through --focus-ring / --radius-control /
   * --ink-on-accent, never var(--accent) (or --accent-ink / --radius)
   * raw with no fallback — in a project that skipped brand.example.css
   * that resolves to nothing, invisibly.
   * ============================================================ */
  --radius-control: var(--radius, 8px);
  --ink-on-accent: var(--accent-ink, #ffffff);
}

/* ============================================================
 * Dark palette by OS preference. Guarded so an explicit light choice
 * (data-theme="light") always wins over the system setting. Only
 * tokens already defined on the bare :root above are redefined here —
 * no colour's only definition lives inside this block.
 * ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #14161b;
    --field-bg: #1c1f26;
    --ink: #f4f5f7;
    --ink-muted: #9aa1ad;
    --hairline: #2a2d35;
    --hover-bg: rgb(255 255 255 / 6%);
    --disabled-bg: #23262d;
    --disabled-ink: #6b7280;
    /* Lifted state colours: the light-mode values are too dark to read
     * against a dark surface. Same meanings, adjusted for contrast. */
    --danger: #f2645a;
    --warning: #e0a030;
    --success: #4ac27c;
    --info: #6ea8fe;
  }
}

/* ============================================================
 * Explicit dark toggle wins in both directions — over the media query
 * above and over the light default — regardless of OS preference.
 * ============================================================ */
:root[data-theme="dark"] {
  --surface: #14161b;
  --field-bg: #1c1f26;
  --ink: #f4f5f7;
  --ink-muted: #9aa1ad;
  --hairline: #2a2d35;
  --hover-bg: rgb(255 255 255 / 6%);
  --disabled-bg: #23262d;
  --disabled-ink: #6b7280;
  --danger: #f2645a;
  --warning: #e0a030;
  --success: #4ac27c;
  --info: #6ea8fe;
}
