/*
 * @aisquare/ui · FOUNDATIONS — primitive design-token tier (WS-15 token set)
 *
 * This file is the OPT-IN mirror of `foundationTokensPlugin` in
 * `tailwind.preset.ts` (the same distribution pattern `onyx-hex.css` uses for
 * `glassMaterialPlugin`). Preset consumers get every variable below injected
 * automatically via `addBase`; import this file only if you consume the tokens
 * WITHOUT the Tailwind preset:
 *
 *   @import "@aisquare/ui/tokens/foundations.css";
 *
 * Tier model (core primitives → semantic intent):
 *   - PRIMITIVES (this file): absolute values — color ramps, spacing, radius,
 *     motion, grid. They do NOT flip under `.dark`; the semantic tokens in
 *     `tokens.template.css` (`--primary`, `--success`, …) are the mode-aware
 *     layer and keep flipping exactly as before.
 *   - The one exception is the elevation ladder (`--elevation-1..4`), which is
 *     mode-aware by nature (dark-on-dark shadows need more weight to read) and
 *     therefore carries a `.dark` block, same as `--shadow-pop`.
 *
 * Ramp anchors (brand contract):
 *   - `--navy-900`  = `213 80% 13%` — brand navy #071E3C, the exact light-mode
 *     `--primary` / `--foreground` triplet.
 *   - `--accent-500` = `213 100% 56%` — brand blue #1F84FF, the exact
 *     `--accent` triplet (both modes).
 *   - The neutral (`--slate-*`) and status ramps (`--red/green/amber/sky-*`)
 *     are the Tailwind v3 palettes verbatim (as HSL triplets). Their 500
 *     steps sit within 1 RGB point per channel of the existing
 *     `--destructive` / `--success` / `--warning` / `--info` light values
 *     (the semantics keep rounded triplets; the ramps carry Tailwind's
 *     decimals) — visually identical, but NOT literally equal: never
 *     substitute a ramp step for a semantic token. Both invariants (this
 *     mirror matching the TS source, ramps staying Tailwind-verbatim) are
 *     pinned by `src/lib/foundation-tokens.test.ts`.
 *
 * All colors are HSL triplets (no commas) so `bg-navy-900/20` opacity syntax
 * works through the preset, same convention as `tokens.template.css`.
 * Per-studio overrides in the consumer's own `:root { ... }` win cascade-wise.
 */

@layer base {
  :root {
    /* ------------------------------------------------------------------ *
     * Color ramps — 50 (lightest) → 950 (darkest)
     * ------------------------------------------------------------------ */

    /* Navy — brand ink. Hue 213, anchored at 900 = #071E3C (--primary light). */
    --navy-50: 213 45% 96%;
    --navy-100: 213 42% 91%;
    --navy-200: 213 38% 83%;
    --navy-300: 213 34% 71%;
    --navy-400: 214 28% 56%;
    --navy-500: 214 30% 42%;
    --navy-600: 214 40% 32%;
    --navy-700: 213 55% 24%;
    --navy-800: 213 68% 18%;
    --navy-900: 213 80% 13%; /* #071E3C — brand navy, = --primary (light) */
    --navy-950: 214 85% 8%;  /* sits beside the dark --background (213 80% 6%) */

    /* Accent blue — brand action color. Anchored at 500 = #1F84FF (--accent). */
    --accent-50: 213 100% 97%;
    --accent-100: 213 100% 93%;
    --accent-200: 213 100% 87%;
    --accent-300: 213 100% 78%;
    --accent-400: 213 100% 67%;
    --accent-500: 213 100% 56%; /* #1F84FF — brand blue, = --accent (both modes) */
    --accent-600: 213 90% 48%;
    --accent-700: 213 85% 40%;
    --accent-800: 213 80% 32%;
    --accent-900: 213 78% 24%;
    --accent-950: 213 80% 16%;

    /* Neutral (slate) — Tailwind v3 slate verbatim. 200 ≈ --border/--input,
       500 ≈ --muted-foreground: within 1 RGB point of the semantics. */
    --slate-50: 210 40% 98%;
    --slate-100: 210 40% 96.1%;
    --slate-200: 214 31.8% 91.4%; /* ≈ --border / --input (light) */
    --slate-300: 213 26.8% 83.9%;
    --slate-400: 215 20.2% 65.1%;
    --slate-500: 215 16.3% 46.9%; /* ≈ --muted-foreground (light) */
    --slate-600: 215 19.3% 34.5%;
    --slate-700: 215 25% 26.7%;
    --slate-800: 217 32.6% 17.5%;
    --slate-900: 222 47.4% 11.2%;
    --slate-950: 229 84% 4.9%;

    /* Error (red) — Tailwind v3 red verbatim. 500 ≈ --destructive (light). */
    --red-50: 0 85.7% 97.3%;
    --red-100: 0 93.3% 94.1%;
    --red-200: 0 96.3% 89.4%;
    --red-300: 0 93.5% 81.8%;
    --red-400: 0 90.6% 70.8%;
    --red-500: 0 84.2% 60.2%; /* ≈ --destructive (light) */
    --red-600: 0 72.2% 50.6%;
    --red-700: 0 73.7% 41.8%;
    --red-800: 0 70% 35.3%;
    --red-900: 0 62.8% 30.6%;
    --red-950: 0 74.7% 15.5%;

    /* Success (green) — Tailwind v3 green verbatim. 500 ≈ --success (light). */
    --green-50: 138 76.5% 96.7%;
    --green-100: 141 84.2% 92.5%;
    --green-200: 141 78.9% 85.1%;
    --green-300: 142 76.6% 73.1%;
    --green-400: 142 69.2% 58%;
    --green-500: 142 70.6% 45.3%; /* ≈ --success (light) */
    --green-600: 142 76.2% 36.3%;
    --green-700: 142 71.8% 29.2%;
    --green-800: 143 64.2% 24.1%;
    --green-900: 144 61.2% 20.2%;
    --green-950: 145 80.4% 10%;

    /* Warning (amber) — Tailwind v3 amber verbatim. 500 ≈ --warning /
       --premium (light). */
    --amber-50: 48 100% 96.1%;
    --amber-100: 48 96.5% 88.8%;
    --amber-200: 48 96.6% 76.7%;
    --amber-300: 46 96.7% 64.5%;
    --amber-400: 43 96.4% 56.3%;
    --amber-500: 38 92.1% 50.2%; /* ≈ --warning / --premium (light) */
    --amber-600: 32 94.6% 43.7%;
    --amber-700: 26 90.5% 37.1%;
    --amber-800: 23 82.5% 31.4%;
    --amber-900: 22 77.8% 26.5%;
    --amber-950: 21 91.7% 14.1%;

    /* Info (sky) — Tailwind v3 sky verbatim. 500 ≈ --info (light); distinct
       from the accent-blue ramp on purpose (info ≠ action). */
    --sky-50: 204 100% 97.1%;
    --sky-100: 204 93.8% 93.7%;
    --sky-200: 201 94.4% 86.1%;
    --sky-300: 199 95.5% 73.9%;
    --sky-400: 198 93.2% 59.6%;
    --sky-500: 199 88.7% 48.4%; /* ≈ --info (light) */
    --sky-600: 200 98% 39.4%;
    --sky-700: 201 96.3% 32.2%;
    --sky-800: 201 90% 27.5%;
    --sky-900: 202 80.3% 23.9%;
    --sky-950: 204 80.2% 15.9%;

    /* ------------------------------------------------------------------ *
     * Spacing — the 4px grid, named after the Tailwind keys they mirror
     * (`p-4` ↔ `--space-4` = 16px). Tailwind's numeric scale REMAINS the
     * spacing system; these vars are the interop/documentation tier for
     * non-Tailwind consumers and the Foundations docs.
     * ------------------------------------------------------------------ */
    --space-0: 0px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;
    --space-24: 96px;

    /* ------------------------------------------------------------------ *
     * Radius primitives — the raw scale. The SEMANTIC knob stays
     * `--radius` (12px, tokens.template.css): `rounded-sm…2xl` all derive
     * from it and are what components use. Primitives are for docs and
     * one-off absolute corners.
     * ------------------------------------------------------------------ */
    --radius-0: 0px;
    --radius-1: 4px;
    --radius-2: 8px;
    --radius-3: 12px; /* = --radius default → rounded-lg */
    --radius-4: 16px;
    --radius-5: 20px;
    --radius-6: 24px;
    --radius-full: 9999px;

    /* ------------------------------------------------------------------ *
     * Motion — durations + easings. Durations name the steps the preset's
     * `duration-120/180/240/320/480` utilities already use; easings name
     * the preset's `ease-smooth-out/snappy/anticipate` curves plus the
     * card-in / Brain-contract curve (`out-soft`), previously anonymous.
     * ------------------------------------------------------------------ */
    --motion-duration-fast: 120ms;     /* micro feedback: hover tint, press */
    --motion-duration-base: 180ms;     /* default UI transition */
    --motion-duration-moderate: 240ms; /* overlays, accordions */
    --motion-duration-slow: 320ms;     /* card entrances, layout shifts */
    --motion-duration-slower: 480ms;   /* stage/hero reveals */
    --motion-ease-smooth-out: cubic-bezier(0.16, 1, 0.3, 1);
    --motion-ease-snappy: cubic-bezier(0.4, 0, 0.2, 1);
    --motion-ease-anticipate: cubic-bezier(0.7, -0.2, 0.4, 1.3);
    --motion-ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1); /* card-in easing */

    /* ------------------------------------------------------------------ *
     * Grid & layout — 12-column contract. Breakpoints stay Tailwind
     * defaults (sm 640 / md 768 / lg 1024 / xl 1280 / 2xl 1536), documented
     * in the Foundations docs rather than tokenized.
     * ------------------------------------------------------------------ */
    --grid-columns: 12;
    --grid-gutter: 24px;   /* = gap-6, the dominant grid gap in components */
    --grid-margin: 32px;   /* page gutter, = p-8 (AppShell padding) */
    --content-max: 1280px; /* = max-w-7xl / the xl breakpoint container */
  }

  /* -------------------------------------------------------------------- *
   * Elevation ladder — named neutral rungs, navy-tinted rgba(10,37,64,…).
   * Consumed via `shadow-elevation-1..4`. elevation-2 matches the weight of
   * a raised card/dropdown, elevation-3 a panel/drawer, elevation-4 ≡
   * --shadow-pop. Mode-aware like --shadow-pop: dark flips to pure black at
   * higher opacity.
   * -------------------------------------------------------------------- */
  :root {
    --elevation-1: 0 1px 3px rgba(10, 37, 64, 0.1);
    --elevation-2: 0 2px 4px rgba(10, 37, 64, 0.1), 0 10px 22px rgba(10, 37, 64, 0.13);
    --elevation-3: 0 2px 6px rgba(10, 37, 64, 0.08), 0 18px 40px rgba(10, 37, 64, 0.17);
    --elevation-4: 0 30px 60px rgba(10, 37, 64, 0.18); /* ≡ --shadow-pop (light) */
  }

  .dark {
    /* Pure-black rungs at the same weights as :root's light values, plus
       --shadow-pop — FLAGGED for design sign-off (--dropFloat precedent). */
    --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --elevation-2: 0 1px 1px rgba(0, 0, 0, 0.3), 0 7px 16px rgba(0, 0, 0, 0.32);
    --elevation-3: 0 1px 1px rgba(0, 0, 0, 0.4), 0 16px 34px rgba(0, 0, 0, 0.4);
    --elevation-4: 0 30px 60px rgba(0, 0, 0, 0.55); /* ≡ --shadow-pop (dark) */
  }
}
