/*
  A2K design system: tokens
  Every colour, size, space, radius, shadow and timing used on an A2K surface comes from here.
  If a value you need is missing, add it here with a reason in DESIGN.md. Never type a raw value in a page.

  Layers
    1. Primitives   the raw ramps (paper, ink, green, sage, copper, signal). Pages never use these directly.
    2. Roles        what a value is for (--bg, --text, --accent ...). Pages use only these.
    3. Brand layer  a client brand file (brands/<client>.css) overrides roles, never primitives.

  Themes
    :root                     A2K light (paper). The default for everything.
    [data-theme="dark"]       Dark operate surfaces (rare; the portal at night, a TV board).
    .surface-brand            The deep green A2K page: documents, the portal sign-in, the one dark band on a landing page.
*/

:root {
  /* ---------- 1. Primitives ---------- */

  /* Paper: neutrals tinted very slightly toward A2K green. Low saturation, so a surface never reads as "green". */
  --paper-0: #fcfdfb;
  --paper-50: #f6f8f4;
  --paper-100: #ebefe8;
  --paper-150: #e2e7de;
  --paper-200: #d5dcd0;
  --paper-300: #bcc5b6;
  --paper-400: #98a392;

  /* Ink: the text ramp, same tint. */
  --ink-600: #5a665d;
  --ink-700: #435047;
  --ink-800: #2b362f;
  --ink-900: #14201a;

  /* Green: the A2K brand colour. 800 is the brand. */
  --green-100: #dce6dd;
  --green-200: #c3d3c6;
  --green-700: #2a4a39;
  --green-800: #1e382a; /* the A2K green, same as the live site, portal and documents */
  --green-900: #16291f; /* hover on green fills (the live site's deep-hover) */
  --green-950: #10201a; /* press */

  /* Sage: the "AI" in the logo. A mark colour, never body text (3.2:1 on paper). */
  --sage-500: #6f8c78;
  --sage-300: #a9bcae;

  /* Copper: money only. Totals, prices, amounts due. */
  --copper-100: #f1e4d8;
  --copper-600: #9b5a2a;
  --copper-300: #d49a6a;

  /* Signals: the portal's own values, toned to sit inside the paper palette. */
  --signal-positive: #2f6b45;
  --signal-positive-soft: #dcebdf;
  --signal-negative: #9b2c2c;
  --signal-negative-soft: #f2dada;
  --signal-warning: #8a5a12;
  --signal-warning-soft: #f3e6cc;

  /* ---------- 2. Roles (light, A2K) ---------- */

  --bg: var(--paper-100);
  --surface: var(--paper-50);
  --surface-raised: var(--paper-0);
  --surface-sunken: var(--paper-150);
  --surface-hover: rgb(20 32 26 / 0.04);
  --surface-active: rgb(20 32 26 / 0.07);

  /* Ledger rules: green-tinted hairlines, a touch firmer than grey UI (matches the site's #C6D2C0 rule on paper). */
  --line: rgb(30 56 42 / 0.13);
  --line-strong: rgb(30 56 42 / 0.24);

  --text: var(--ink-900);
  --text-2: var(--ink-700);
  --text-3: var(--ink-600);
  --text-disabled: var(--paper-400);

  --brand: var(--green-800);
  --brand-mark: var(--sage-500);

  --accent: var(--green-800);
  --accent-hover: var(--green-900);
  --accent-press: var(--green-950);
  --accent-soft: var(--green-100);
  --on-accent: var(--paper-50);

  --money: var(--copper-600);
  --money-soft: var(--copper-100);

  --positive: var(--signal-positive);
  --positive-soft: var(--signal-positive-soft);
  --negative: var(--signal-negative);
  --negative-soft: var(--signal-negative-soft);
  --warning: var(--signal-warning);
  --warning-soft: var(--signal-warning-soft);

  --focus-ring: rgb(30 56 42 / 0.32);
  --selection: var(--green-100);

  /* Charts: one lead series, the rest neutral. */
  --chart-lead: var(--green-800);
  --chart-2: var(--sage-500);
  --chart-3: var(--copper-600);
  --chart-muted: var(--paper-300);
  --chart-muted-2: var(--paper-400);
  --chart-grid: rgb(22 33 26 / 0.08);
  --chart-label: var(--ink-600);

  /* ---------- Type ---------- */

  --font-sans: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* size / line height pairs. 12px is the floor for any text. */
  --text-xs: 12px;   --leading-xs: 16px;    /* meta, counts, mono labels */
  --text-sm: 13px;   --leading-sm: 20px;    /* secondary text, captions, dense tables */
  --text-md: 14px;   --leading-md: 20px;    /* app body, nav, buttons, table rows */
  --text-base: 16px; --leading-base: 26px;  /* reading body on pages and documents */
  --text-lg: 18px;   --leading-lg: 28px;    /* lead paragraph, hero subhead */
  --text-xl: 20px;   --leading-xl: 28px;    /* card and section titles in apps */
  --text-2xl: 24px;  --leading-2xl: 32px;   /* app page title */
  --text-3xl: 32px;  --leading-3xl: 36px;   /* key figures, page title on sites */
  --text-4xl: 40px;  --leading-4xl: 44px;   /* section headline on sites */
  --text-5xl: 56px;  --leading-5xl: 60px;   /* hero headline, desktop */
  --text-6xl: 72px;  --leading-6xl: 74px;   /* rare: one hero per site */

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-strong: 600; /* rare emphasis only; never above 600 */

  --tracking-display: -0.02em; /* 40px and up */
  --tracking-hero: -0.03em;    /* 56px and up */
  --tracking-normal: 0;
  --tracking-meta: 0.01em;     /* small mono meta */

  /* ---------- Space (4px grid) ---------- */

  --space-0: 0;
  --space-px: 1px;
  --space-0-5: 2px;  /* nudges inside small controls only */
  --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;
  --space-32: 128px;

  /* ---------- Sizes ---------- */

  --control-sm: 32px;  /* nav buttons, compact toolbars */
  --control-md: 36px;  /* default buttons and inputs in apps */
  --control-lg: 44px;  /* hero buttons, every tap target on a phone */
  --row-compact: 36px;
  --row: 44px;
  --icon-sm: 16px;
  --icon-md: 18px;
  --icon-lg: 20px;
  --icon-stroke: 1.5;

  /* ---------- Layout ---------- */

  --sidebar-w: 256px;
  --header-h: 56px;
  --content-max: 1440px;
  --page-max: 1200px;   /* marketing pages */
  --prose-max: 68ch;
  --page-pad: 32px;     /* 16px under 640px wide, set in a2k.css */

  /* ---------- Radius ---------- */

  --radius-xs: 4px;   /* keycaps, tags, checkbox */
  --radius-sm: 6px;   /* small buttons, chips */
  --radius-md: 8px;   /* buttons, inputs, rows */
  --radius-lg: 12px;  /* cards */
  --radius-xl: 16px;  /* panels, dialogs */
  --radius-2xl: 20px; /* large windows, hero product view */
  --radius-pill: 999px; /* status pills and switches only */

  /* ---------- Depth (light) ---------- */

  --shadow-0: none;
  --shadow-1: 0 1px 2px rgb(22 33 26 / 0.06);
  --shadow-2: 0 1px 2px rgb(22 33 26 / 0.05), 0 8px 24px rgb(22 33 26 / 0.07);
  --shadow-3: 0 2px 4px rgb(22 33 26 / 0.06), 0 24px 48px rgb(22 33 26 / 0.14);

  /* ---------- Motion ---------- */

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 140ms;   /* hover, press, toggles */
  --dur-mid: 200ms;    /* menus, popovers, tooltips */
  --dur-slow: 360ms;   /* entrances, sheets */
  --rise: 8px;         /* enter distance */
  --press-scale: 0.98;

  /* ---------- Layers ---------- */

  --z-sticky: 10;
  --z-nav: 20;
  --z-popover: 40;
  --z-dialog: 50;
  --z-toast: 60;

  color-scheme: light;
}

/* ---------- Dark operate theme ---------- */
[data-theme="dark"] {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-raised: #1c1c1f;
  --surface-sunken: #060607;
  --surface-hover: rgb(236 240 234 / 0.04);
  --surface-active: rgb(236 240 234 / 0.08);

  --line: rgb(255 255 255 / 0.08);
  --line-strong: rgb(255 255 255 / 0.14);

  --text: #f2f2f3;
  --text-2: #a8a8ad;
  --text-3: #8a8a90;
  --text-disabled: #5b665e;

  --brand: #ecf0ea;
  --brand-mark: var(--sage-300);

  --accent: #ecf0ea;          /* off-white primary button, dark text */
  --accent-hover: #ffffff;
  --accent-press: #d5dcd0;
  --accent-soft: rgb(236 240 234 / 0.08);
  --on-accent: var(--green-900);

  --money: var(--copper-300);
  --money-soft: rgb(212 154 106 / 0.14);

  --positive: #6fbf8b;
  --positive-soft: rgb(111 191 139 / 0.14);
  --negative: #e0806f;
  --negative-soft: rgb(224 128 111 / 0.14);
  --warning: #d9ad5b;
  --warning-soft: rgb(217 173 91 / 0.14);

  --focus-ring: rgb(236 240 234 / 0.36);
  --selection: rgb(169 188 174 / 0.3);

  --chart-lead: #ecf0ea;
  --chart-2: var(--sage-300);
  --chart-3: var(--copper-300);
  --chart-muted: #34443a;
  --chart-muted-2: #4a5b50;
  --chart-grid: rgb(236 240 234 / 0.07);
  --chart-label: #8c988f;

  --shadow-1: none;
  --shadow-2: 0 0 0 1px rgb(236 240 234 / 0.06), 0 12px 32px rgb(0 0 0 / 0.4);
  --shadow-3: 0 0 0 1px rgb(236 240 234 / 0.08), 0 24px 64px rgb(0 0 0 / 0.5);

  color-scheme: dark;
}

/* ---------- The deep green A2K page ---------- */
.surface-brand {
  --bg: var(--green-800);
  --surface: rgb(246 248 244 / 0.06);
  --surface-raised: rgb(246 248 244 / 0.1);
  --surface-sunken: var(--green-900);
  --surface-hover: rgb(246 248 244 / 0.06);
  --surface-active: rgb(246 248 244 / 0.1);

  --line: rgb(246 248 244 / 0.14);
  --line-strong: rgb(246 248 244 / 0.24);

  --text: var(--paper-50);
  --text-2: rgb(246 248 244 / 0.78);
  --text-3: rgb(246 248 244 / 0.66);

  --brand: var(--paper-50);
  --brand-mark: var(--sage-300);

  --accent: var(--paper-50);
  --accent-hover: #ffffff;
  --accent-press: var(--paper-150);
  --accent-soft: rgb(246 248 244 / 0.1);
  --on-accent: var(--green-800);

  /* Signals and money re-toned for the green page (the light ones fail contrast here). */
  --money: #f2c9a7;            /* the document kit's money colour */
  --money-soft: rgb(242 201 167 / 0.14);
  --positive: #8fd0a4;
  --positive-soft: rgb(143 208 164 / 0.14);
  --negative: #f2b8a8;         /* the proposal lock screen's error colour */
  --negative-soft: rgb(242 184 168 / 0.14);
  --warning: #e9c77d;
  --warning-soft: rgb(233 199 125 / 0.14);
  --chart-lead: var(--paper-50);
  --chart-2: var(--sage-300);
  --chart-3: #f2c9a7;
  --chart-muted: rgb(246 248 244 / 0.22);
  --chart-muted-2: rgb(246 248 244 / 0.36);
  --chart-grid: rgb(246 248 244 / 0.1);
  --chart-label: rgb(246 248 244 / 0.66);
  --shadow-1: none;
  --shadow-2: 0 0 0 1px rgb(246 248 244 / 0.08), 0 12px 32px rgb(0 0 0 / 0.28);
  --shadow-3: 0 0 0 1px rgb(246 248 244 / 0.1), 0 24px 64px rgb(0 0 0 / 0.36);
  --focus-ring: rgb(246 248 244 / 0.4);

  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
}

/* ---------- Automatic dark (added by build/build.py from the block above) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface-raised: #1c1c1f;
    --surface-sunken: #060607;
    --surface-hover: rgb(236 240 234 / 0.04);
    --surface-active: rgb(236 240 234 / 0.08);

    --line: rgb(255 255 255 / 0.08);
    --line-strong: rgb(255 255 255 / 0.14);

    --text: #f2f2f3;
    --text-2: #a8a8ad;
    --text-3: #8a8a90;
    --text-disabled: #5b665e;

    --brand: #ecf0ea;
    --brand-mark: var(--sage-300);

    --accent: #ecf0ea;          /* off-white primary button, dark text */
    --accent-hover: #ffffff;
    --accent-press: #d5dcd0;
    --accent-soft: rgb(236 240 234 / 0.08);
    --on-accent: var(--green-900);

    --money: var(--copper-300);
    --money-soft: rgb(212 154 106 / 0.14);

    --positive: #6fbf8b;
    --positive-soft: rgb(111 191 139 / 0.14);
    --negative: #e0806f;
    --negative-soft: rgb(224 128 111 / 0.14);
    --warning: #d9ad5b;
    --warning-soft: rgb(217 173 91 / 0.14);

    --focus-ring: rgb(236 240 234 / 0.36);
    --selection: rgb(169 188 174 / 0.3);

    --chart-lead: #ecf0ea;
    --chart-2: var(--sage-300);
    --chart-3: var(--copper-300);
    --chart-muted: #34443a;
    --chart-muted-2: #4a5b50;
    --chart-grid: rgb(236 240 234 / 0.07);
    --chart-label: #8c988f;

    --shadow-1: none;
    --shadow-2: 0 0 0 1px rgb(236 240 234 / 0.06), 0 12px 32px rgb(0 0 0 / 0.4);
    --shadow-3: 0 0 0 1px rgb(236 240 234 / 0.08), 0 24px 64px rgb(0 0 0 / 0.5);

    color-scheme: dark;
  }
}
