/*
 * Arrakio design tokens — the single source of truth for palette, theme variables,
 * spacing, radii, shadows, motion, and type scale.
 *
 * The SPA imports this from `globals.css`; the backend and site server embed the same
 * file for their server-rendered fallback pages. Keep this file plain CSS (custom
 * properties only) so it can be included outside the Vite/Tailwind build.
 */

/* ── PALETTE (raw brand ramps) ─────────────────────────────────────────── */
:root {
  --copper-200: #ebc4a2;
  --copper-300: #e3a578;
  --copper-400: #d98b53;
  --copper-500: #cf7b41;
  --copper-600: #b5632e;
  --copper-700: #934e22;
  --copper-800: #6f3a1a;

  --teal-300: #6fd6c7;
  --teal-400: #4fcbba;
  --teal-500: #33b9a7;
  --teal-600: #1f8e7f;
  --teal-700: #166a5f;

  --sand-300: #e6d2b0;
  --sand-400: #d8b98a;
  --sand-500: #c9a571;
  --sand-600: #a9854f;

  --clay-400: #e0685a;
  --clay-500: #d7503f;
  --clay-600: #bc3f30;
  --clay-700: #8f2c20;

  --moss-400: #5fbb86;
  --moss-500: #4fae78;
  --moss-600: #3f8f5e;
  --moss-700: #2e6b45;

  --amber-400: #e0a350;
  --amber-500: #d8a24a;
  --amber-600: #b5740c;

  --stone-950: #000000;
  --stone-925: #0c0d0f;
  --stone-900: #16171a;
  --stone-850: #202225;
  --stone-800: #2a2d31;
  --stone-700: #34383d;
  --stone-600: #43484e;
  --stone-500: #6b7077;
  --stone-450: #8c857b;
  --stone-400: #a69d91;
  --stone-300: #c9c2b6;
  --stone-250: #d6cfc2;
  --stone-200: #e0d7c7;
  --stone-150: #ebe5da;
  --stone-100: #f0ebe1;
  --stone-75: #f4efe7;
  --stone-50: #fbf8f2;
  --bone: #f2ede3;
  --ink: #26221c;
}

/* ── LIGHT ─────────────────────────────────────────────────────────────── */
:root {
  --background: var(--stone-75);
  --foreground: var(--ink);
  --card: var(--stone-50);
  --card-foreground: var(--ink);
  --popover: #ffffff;
  --popover-foreground: var(--ink);

  --primary: var(--copper-600);
  --primary-foreground: #fbf3ea;
  --secondary: var(--stone-150);
  --secondary-foreground: #43392d;
  --muted: var(--stone-100);
  --muted-foreground: #867c6e;
  --accent: #ebe5da;
  --accent-foreground: var(--ink);
  --destructive: var(--clay-600);
  --destructive-foreground: #fbf3ea;

  --border: var(--stone-250);
  --input: var(--stone-250);
  --ring: var(--copper-600);

  --brand-primary: var(--copper-600);
  --brand-accent: var(--teal-600);
  --brand-sand: var(--sand-500);

  --info: var(--teal-600);
  --info-foreground: #ffffff;
  --success: var(--moss-600);
  --success-foreground: #ffffff;
  --warning: var(--amber-600);
  --warning-foreground: #ffffff;

  --primary-soft: #f6e7d8;
  --info-soft: #dff0ec;
  --success-soft: #e4f1e9;
  --warning-soft: #f6ead3;
  --destructive-soft: #f7e2dc;

  --surface-bg: var(--background);
  --surface-card: var(--card);
  --surface-raised: #ffffff;
  --surface-sunken: #ede7db;
  --surface-inset: #e7e0d2;

  --text-primary: var(--foreground);
  --text-muted: var(--muted-foreground);
  --text-faint: #a89e8e;
  --text-on-brand: #fbf3ea;

  --border-subtle: var(--stone-250);
  --border-strong: var(--stone-300);

  --status-generated: var(--muted-foreground);
  --status-generated-soft: var(--stone-100);
  --status-reviewed: var(--teal-600);
  --status-reviewed-soft: #dff0ec;
  --status-approved: var(--moss-600);
  --status-approved-soft: #e4f1e9;
  --status-deployed: var(--copper-600);
  --status-deployed-soft: #f6e7d8;

  --chart-1: var(--copper-600);
  --chart-2: var(--teal-600);
  --chart-3: var(--sand-500);
  --chart-4: var(--moss-600);
  --chart-5: var(--amber-600);

  --sidebar: var(--stone-50);
  --sidebar-foreground: var(--ink);
  --sidebar-primary: var(--copper-600);
  --sidebar-primary-foreground: #fbf3ea;
  --sidebar-accent: #ebe5da;
  --sidebar-accent-foreground: var(--ink);
  --sidebar-border: var(--stone-200);
  --sidebar-ring: var(--copper-600);

  /* Spacing / radii / motion */
  --radius: 0.625rem;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(10, 8, 6, 0.16);
  --shadow-sm: 0 1px 2px rgba(10, 8, 6, 0.18), 0 1px 1px rgba(10, 8, 6, 0.1);
  --shadow-md: 0 4px 12px rgba(10, 8, 6, 0.2), 0 2px 4px rgba(10, 8, 6, 0.12);
  --shadow-lg:
    0 12px 32px rgba(10, 8, 6, 0.28), 0 4px 10px rgba(10, 8, 6, 0.16);
  --shadow-xl: 0 24px 56px rgba(10, 8, 6, 0.36);
  /* The one scrim every modal surface draws behind itself. It is a token rather than an inline
     `color-mix` at each overlay so the two dialog primitives cannot drift apart. */
  --scrim: color-mix(in srgb, #000 58%, transparent);
  --ring-focus: 0 0 0 3px color-mix(in srgb, var(--ring) 38%, transparent);
  --ring-destructive: 0 0 0 3px
    color-mix(in srgb, var(--destructive) 32%, transparent);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 120ms;
  --duration-normal: 180ms;
  --duration-slow: 280ms;

  /* Typography tokens (both naming conventions) */
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --weight-light: 300;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.3125rem;

  --leading-none: 1;
  --leading-tight: 1.08;
  --leading-snug: 1.25;
  --leading-normal: 1.5;

  --tracking-tight: -0.02em;
  --tracking-snug: -0.01em;
  --tracking-normal: 0;
  /*
   * The overline/eyebrow tracking value. One authoritative value for the whole app: the
   * dominant hand-rolled width (0.18em) was reconciled back onto this token rather than the
   * other way around, so an eyebrow uses `--tracking-caps` and never a magic value.
   */
  --tracking-caps: 0.18em;

  /* Layout */
  --container-max: 1200px;
  --container-prose: 68ch;
  --sidebar-width: 256px;
  --header-height: 56px;
}

/* ── DARK ───────────────────────────────────────────────────────────────── */
.dark {
  --background: var(--stone-900);
  --foreground: var(--bone);
  --card: var(--stone-850);
  --card-foreground: var(--bone);
  --popover: #24272b;
  --popover-foreground: var(--bone);

  --primary: var(--copper-500);
  --primary-foreground: #1b120a;
  --secondary: var(--stone-800);
  --secondary-foreground: #e8e2d6;
  --muted: #25272b;
  --muted-foreground: var(--stone-400);
  --accent: var(--stone-800);
  --accent-foreground: var(--bone);
  --destructive: var(--clay-500);
  --destructive-foreground: #fcebe7;

  --border: var(--stone-700);
  --input: var(--stone-700);
  --ring: var(--copper-500);

  --brand-primary: var(--copper-500);
  --brand-accent: var(--teal-500);
  --brand-sand: var(--sand-400);

  --info: var(--teal-500);
  --info-foreground: #06201c;
  --success: var(--moss-500);
  --success-foreground: #07210f;
  --warning: var(--amber-400);
  --warning-foreground: #2a1c06;

  --primary-soft: #3a2a1e;
  --info-soft: #15332e;
  --success-soft: #15301f;
  --warning-soft: #32260f;
  --destructive-soft: #371b16;

  --surface-bg: var(--background);
  --surface-card: var(--card);
  --surface-raised: var(--stone-800);
  --surface-sunken: #121315;
  --surface-inset: #1b1d20;

  --text-primary: var(--foreground);
  --text-muted: var(--muted-foreground);
  --text-faint: #7e776c;
  --text-on-brand: #1b120a;

  --border-subtle: var(--stone-700);
  --border-strong: #474c52;

  --status-generated: var(--stone-400);
  --status-generated-soft: #25272b;
  --status-reviewed: var(--teal-500);
  --status-reviewed-soft: #15332e;
  --status-approved: var(--moss-500);
  --status-approved-soft: #15301f;
  --status-deployed: var(--copper-500);
  --status-deployed-soft: #3a2a1e;

  --chart-1: var(--copper-500);
  --chart-2: var(--teal-500);
  --chart-3: var(--sand-400);
  --chart-4: var(--moss-500);
  --chart-5: var(--amber-400);

  --sidebar: #1a1c1f;
  --sidebar-foreground: var(--bone);
  --sidebar-primary: var(--copper-500);
  --sidebar-primary-foreground: #1b120a;
  --sidebar-accent: #25272b;
  --sidebar-accent-foreground: var(--bone);
  --sidebar-border: #2c3035;
  --sidebar-ring: var(--copper-500);
}

/* ── AMOLED (pitch black) ───────────────────────────────────────────────── */
.dark.amoled {
  --background: var(--stone-950);
  --card: var(--stone-925);
  --popover: #0c0d0f;
  --secondary: #141518;
  --muted: #0f1012;
  --accent: #141518;

  --border: #1f2125;
  --input: #1f2125;

  --surface-bg: #000000;
  --surface-card: #0c0d0f;
  --surface-raised: #141518;
  --surface-sunken: #000000;
  --surface-inset: #0a0b0c;

  --muted-foreground: #787e87;
  --text-faint: #5e646c;
  --border-subtle: #1f2125;
  --border-strong: #2a2c30;

  --status-generated-soft: #0f1012;

  --sidebar: #000000;
  --sidebar-accent: #141518;
  --sidebar-border: #18191b;
}

/*
 * ── SPACING SCALE (declared source of truth, design D3) ─────────────────
 *
 * The curated set of spacing steps this project authors with. Numeric utilities are the
 * authoring syntax (`p-4`, `gap-3`); declaring the step here is what makes Tailwind emit
 * `var(--spacing-4)` for `p-4` instead of a computed multiple, so the scale is readable in
 * the compiled CSS. Half steps are first-class members and use the escaped dot in the key,
 * which is what makes `.p-2\.5` resolve to `var(--spacing-2\.5)`.
 *
 * The set licenses 2px, 6px and 10px and omits 14px, 18px, 28px, 36px and 40px. Declaring
 * a step does not restrict anything by itself — Tailwind still compiles an undeclared step —
 * so `bun run check:ui` reads this set and rejects values outside it.
 *
 * This is the one Tailwind construct in this file. The block is inert where the file is
 * embedded as plain CSS (the server-rendered auth pages include it verbatim): browsers drop
 * the unknown at-rule, and nothing outside the SPA build consumes a `--spacing-*` token.
 */
@theme {
  --spacing-0\.5: 0.125rem; /* 2px */
  --spacing-1: 0.25rem; /* 4px */
  --spacing-1\.5: 0.375rem; /* 6px */
  --spacing-2: 0.5rem; /* 8px */
  --spacing-2\.5: 0.625rem; /* 10px */
  --spacing-3: 0.75rem; /* 12px */
  --spacing-4: 1rem; /* 16px */
  --spacing-5: 1.25rem; /* 20px */
  --spacing-6: 1.5rem; /* 24px */
  --spacing-8: 2rem; /* 32px */
  --spacing-12: 3rem; /* 48px */
  --spacing-16: 4rem; /* 64px */
}
