/* ============================================================================
   tokens.css — every colour, size, font and speed in the platform.
   Brief 7. Nothing anywhere else may invent one.

   TWO THEMES.
     Obsidian (default)  near-black background, graphite panels, ivory text
     Ivory                the light mode, chosen with the toggle and remembered

   ONE ACCENT. Champagne gold, and it is rationed on purpose: the single most
   important ACTION on a page, and the single most important NUMBER on a page.
   Nothing else. A page with three gold things has no important thing.

   The muted status colours are deliberately dull. A dashboard where the
   "failed" red shouts is a dashboard you stop reading.
   ========================================================================= */

:root {
  /* ---------------------------------------------------------- Obsidian ---- */

  /* Surfaces, darkest to lightest. */
  --bg:            #0a0b0d;   /* the page itself — obsidian */
  --bg-sunken:     #07080a;   /* behind a panel: table headers, wells */
  --panel:         #111317;   /* graphite: every panel, card and table */
  --panel-2:       #171a1f;   /* a panel raised on a panel, hover rows */
  --panel-3:       #1e2228;   /* inputs, chips, the third level */
  --overlay:       rgba(5, 6, 7, 0.72);   /* behind a drawer or a modal */

  /* Hairlines. 1px, and never more than one shade apart. */
  --line:          rgba(255, 255, 255, 0.07);
  --line-strong:   rgba(255, 255, 255, 0.13);
  --line-focus:    rgba(201, 169, 110, 0.55);

  /* Text. */
  --text:          #f2efe9;   /* ivory */
  --text-2:        #9aa0a8;   /* muted grey — labels, secondary */
  --text-3:        #6a7077;   /* the faintest readable thing on the page */
  --text-on-gold:  #14120d;

  /* THE accent. One colour, rationed. */
  --gold:          #c9a96e;   /* champagne */
  --gold-bright:   #dcc08c;   /* hover only */
  --gold-dim:      rgba(201, 169, 110, 0.14);   /* a wash behind gold text */
  --gold-line:     rgba(201, 169, 110, 0.32);

  /* Status. Muted, one per row, never bright. */
  --emerald:       #6fae8e;
  --emerald-dim:   rgba(111, 174, 142, 0.13);
  --amber:         #c9a15e;
  --amber-dim:     rgba(201, 161, 94, 0.13);
  --rose:          #c07b7b;
  --rose-dim:      rgba(192, 123, 123, 0.13);
  --slate:         #7b8794;   /* "nothing / unknown / not researched" */
  --slate-dim:     rgba(123, 135, 148, 0.12);
  --violet:        #9a8bb5;   /* hot lead only */
  --violet-dim:    rgba(154, 139, 181, 0.13);

  /* ------------------------------------------------------- Typography ---- */
  --font-serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-sans:  "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont,
                "Noto Sans Arabic", "Segoe UI Arabic", Arial, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  /* An 8px grid, expressed as type sizes that sit on it. */
  --t-display: 40px;   /* one number per page, serif */
  --t-title:   27px;   /* page title, serif */
  --t-h2:      19px;   /* panel title */
  --t-h3:      15px;
  --t-body:    14px;
  --t-small:   13px;
  --t-label:   11px;   /* uppercase, tracked */
  --t-micro:   10px;

  /* ------------------------------------------------------------ Space ---- */
  --s1: 4px;  --s2: 8px;   --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px;  --s7: 48px; --s8: 64px;

  /* ------------------------------------------------------ Geometry ------- */
  --r-sm:  8px;
  --r:     10px;
  --r-lg:  14px;
  --r-pill: 999px;

  --sidebar-w: 248px;
  --topbar-h:  64px;
  --panel-w:   min(560px, 100vw);   /* the right-hand detail panel */
  --content-max: 1560px;

  /* ------------------------------------------------------ Elevation ------ */
  --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-pop:   0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-drawer: -24px 0 64px rgba(0, 0, 0, 0.5);

  /* --------------------------------------------------------- Motion ------ */
  /* Calm. 150–200ms, one easing, no bounce anywhere. */
  --ease:   cubic-bezier(0.32, 0.72, 0.28, 1);
  --fast:   150ms;
  --normal: 200ms;
  --slow:   280ms;   /* the drawer sliding the full width of the panel */

  color-scheme: dark;
}

/* ============================================================== Ivory ====
   The light mode. Same structure, same one accent, warmer paper.
   It is applied by [data-theme="ivory"] on <html>, set before first paint by
   core/theme.js, so there is never a flash of the wrong theme.
   ======================================================================= */

:root[data-theme="ivory"] {
  --bg:            #f7f5f0;
  --bg-sunken:     #efece5;
  --panel:         #fffefb;
  --panel-2:       #f7f5f0;
  --panel-3:       #efece5;
  --overlay:       rgba(30, 27, 22, 0.28);

  --line:          rgba(26, 22, 16, 0.10);
  --line-strong:   rgba(26, 22, 16, 0.18);
  --line-focus:    rgba(140, 110, 56, 0.55);

  --text:          #1a1710;
  --text-2:        #63605a;
  --text-3:        #8d8a84;
  --text-on-gold:  #ffffff;

  /* Champagne has to go darker on paper or it is unreadable — it is the same
     hue, taken down until it passes contrast on --panel. */
  --gold:          #8c6e38;
  --gold-bright:   #6f5629;
  --gold-dim:      rgba(140, 110, 56, 0.10);
  --gold-line:     rgba(140, 110, 56, 0.28);

  --emerald:       #3f7a5c;
  --emerald-dim:   rgba(63, 122, 92, 0.10);
  --amber:         #8a6520;
  --amber-dim:     rgba(138, 101, 32, 0.10);
  --rose:          #9b4747;
  --rose-dim:      rgba(155, 71, 71, 0.10);
  --slate:         #5c6670;
  --slate-dim:     rgba(92, 102, 112, 0.09);
  --violet:        #6a5a8a;
  --violet-dim:    rgba(106, 90, 138, 0.10);

  --shadow-panel:  0 1px 2px rgba(26, 22, 16, 0.06);
  --shadow-pop:    0 16px 48px rgba(26, 22, 16, 0.14), 0 2px 8px rgba(26, 22, 16, 0.06);
  --shadow-drawer: -24px 0 64px rgba(26, 22, 16, 0.13);

  color-scheme: light;
}

/* Somebody who has never touched the toggle and whose computer is set to light
   mode gets Ivory. theme.js writes data-theme the moment it chooses one, so
   this only ever applies for the first paint of a first visit. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f7f5f0; --bg-sunken: #efece5; --panel: #fffefb;
    --panel-2: #f7f5f0; --panel-3: #efece5;
    --overlay: rgba(30, 27, 22, 0.28);
    --line: rgba(26, 22, 16, 0.10); --line-strong: rgba(26, 22, 16, 0.18);
    --text: #1a1710; --text-2: #63605a; --text-3: #8d8a84;
    --text-on-gold: #ffffff;
    --gold: #8c6e38; --gold-bright: #6f5629;
    --gold-dim: rgba(140, 110, 56, 0.10); --gold-line: rgba(140, 110, 56, 0.28);
    --emerald: #3f7a5c; --emerald-dim: rgba(63, 122, 92, 0.10);
    --amber: #8a6520;  --amber-dim: rgba(138, 101, 32, 0.10);
    --rose: #9b4747;   --rose-dim: rgba(155, 71, 71, 0.10);
    --slate: #5c6670;  --slate-dim: rgba(92, 102, 112, 0.09);
    --violet: #6a5a8a; --violet-dim: rgba(106, 90, 138, 0.10);
    color-scheme: light;
  }
}
