/* GreaseGiant Dashboard: the tokens. Contract: crm/CONTRACTS.md §8.
 *
 * Every colour, size and space a screen uses is one of these. Nothing else is allowed in a screen.
 *
 * Brand (brand guide v2): Grease Yellow #F5B81C is the ONE accent (the main action, the item you
 * are on, a win). Ink #161814 and Paper #F1EAD8 make every surface and every word. Red #E84A2C is
 * danger and overdue only. Moss #3A4B2E is success. Amber Deep #A8761F is "waiting".
 * Yellow is used sparingly so that it means something.
 *
 * Light and dark: the person's computer decides, unless they chose one (data-theme on <html>,
 * remembered). data-theme also works on any box inside a page (the gallery shows both at once).
 * The two dark blocks below must stay identical; app/test/run_tokens.js fails if they differ, and
 * checks every text/background pair for WCAG AA contrast in both themes.
 */

/* ---------- colours: light ---------- */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #F9F6EE;
  --surface: #FFFEFA;
  --surface-2: #F3EEE1;
  --line: #E4DDCC;
  --line-strong: #8A8576;
  --text: #161814;
  --text-2: #54574D;
  --accent: #F5B81C;
  --accent-hover: #E5A90E;
  --accent-soft: #FCEFC6;
  --on-accent: #161814;
  --link: #74500E;
  --danger: #E84A2C;
  --danger-hover: #F35E41;
  --danger-soft: #FBE3DC;
  --danger-text: #A82C14;
  --on-danger: #161814;
  --good: #3A4B2E;
  --good-soft: #E3EADB;
  --good-text: #3A4B2E;
  --on-good: #F1EAD8;
  --wait-soft: #F4E7C9;
  --wait-text: #6E4C0D;
  --focus: #161814;
  --overlay: rgba(22, 24, 20, 0.45);
  --shadow: 0 8px 24px rgba(22, 24, 20, 0.14);
  --logo-body: #161814;
  --logo-hoop: #F1EAD8;
  --logo-lid: #A8761F;
  --logo-word-1: #8A5F14;
  --logo-word-2: #161814;
  --map-filter: none;
}

/* ---------- colours: dark (the person chose it) ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161814;
  --surface: #1F221D;
  --surface-2: #282B25;
  --line: #363930;
  --line-strong: #84877A;
  --text: #F1EAD8;
  --text-2: #B9B4A3;
  --accent: #F5B81C;
  --accent-hover: #FFC93A;
  --accent-soft: #3E3312;
  --on-accent: #161814;
  --link: #F5B81C;
  --danger: #E84A2C;
  --danger-hover: #F35E41;
  --danger-soft: #45211A;
  --danger-text: #FF9A83;
  --on-danger: #161814;
  --good: #3A4B2E;
  --good-soft: #27321F;
  --good-text: #AECB9E;
  --on-good: #F1EAD8;
  --wait-soft: #3A2E14;
  --wait-text: #E6BA66;
  --focus: #F1EAD8;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  --logo-body: #F1EAD8;
  --logo-hoop: #161814;
  --logo-lid: #A8761F;
  --logo-word-1: #F5B81C;
  --logo-word-2: #F1EAD8;
  --map-filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
}

/* ---------- colours: dark (their computer is set to dark and they chose nothing) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #161814;
    --surface: #1F221D;
    --surface-2: #282B25;
    --line: #363930;
    --line-strong: #84877A;
    --text: #F1EAD8;
    --text-2: #B9B4A3;
    --accent: #F5B81C;
    --accent-hover: #FFC93A;
    --accent-soft: #3E3312;
    --on-accent: #161814;
    --link: #F5B81C;
    --danger: #E84A2C;
    --danger-hover: #F35E41;
    --danger-soft: #45211A;
    --danger-text: #FF9A83;
    --on-danger: #161814;
    --good: #3A4B2E;
    --good-soft: #27321F;
    --good-text: #AECB9E;
    --on-good: #F1EAD8;
    --wait-soft: #3A2E14;
    --wait-text: #E6BA66;
    --focus: #F1EAD8;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --logo-body: #F1EAD8;
    --logo-hoop: #161814;
    --logo-lid: #A8761F;
    --logo-word-1: #F5B81C;
    --logo-word-2: #F1EAD8;
    --map-filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
  }
}

/* ---------- everything that is not a colour ---------- */
:root {
  /* Space: a 4-pixel scale. */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Type: three sizes for dense screens, three larger ones for simple screens. System fonts only. */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --dense-1: 12px;
  --dense-2: 14px;
  --dense-3: 20px;
  --simple-1: 16px;
  --simple-2: 20px;
  --simple-3: 30px;
  --w-normal: 400;
  --w-strong: 600;
  --lh: 1.45;
  --lh-tight: 1.2;

  /* One radius, one shadow (the shadow's colour is with the colours above). */
  --radius: 8px;

  /* Movement: short and calm; switched off for people who ask their computer for less motion. */
  --fast: 120ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* The frame. */
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --page-max: 1320px;
  --focus-w: 2px;
}

/* ---------- density: what an element reads. A screen never sets these; the shell does. ---------- */
:root, [data-density="dense"] {
  --text-s: var(--dense-1);
  --text-m: var(--dense-2);
  --text-l: var(--dense-3);
  --control-h: 32px;
  --row-h: 36px;
  --pad-x: var(--s-3);
  --gap: var(--s-3);
  --panel-pad: var(--s-4);
  --target: 24px;
}
[data-density="simple"] {
  --text-s: var(--simple-1);
  --text-m: var(--simple-2);
  --text-l: var(--simple-3);
  --control-h: 52px;
  --row-h: 60px;
  --pad-x: var(--s-5);
  --gap: var(--s-5);
  --panel-pad: var(--s-6);
  --target: 44px;
}

@media (prefers-reduced-motion: reduce) {
  :root { --fast: 0ms; }
}
