/* ==========================================================================
   fsd/theme.css — the colour tokens of the documentation, light and dark
   ==========================================================================

   DashMind: the neutrals below are the prototype's (assets/app.css, direction "Sinal": black,
   greys; the ultramarine blue is kept for the keyboard focus only), so the documentation
   looks like the system it documents.

   Linked by fsd/index.html, DataModelErd.html and docs/developer-guide.html, BEFORE the page's own
   <style>. A page does not write colours of its own: it says `var(--card)`,
   `var(--muted)`, `var(--warn-bg)` … and this file decides what that is in the
   theme being shown (the header, dark in both themes, is the one exception).
   fsd/theme.js sets <html data-theme="light|dark">.

   WHAT STAYS WHERE
   - The brand tokens (--blue --cyan --green --lime --yellow --orange --magenta
     --purple) stay in each page's :root: they are the client's colours. So do a
     project's own light NEUTRALS (--ink --muted --line --bg), if it changed them:
     declared there, after this file, they win in the light theme; the dark block
     below is more specific and still wins in the dark one.
   - The LIGHT values below are the ones the pages always had, so a project that
     never touches the switch looks as before. The only differences: five near-white
     panel tints (each within 5/255 of --soft) now share it, the tooltip and the
     card-hover shadows are the shared --shadow-m / --shadow-s, and the focus ring of
     the header's back link is white (the header is dark in both themes).
   - The DARK values were chosen for READABILITY before looks. Rules of thumb,
     measured (the developer guide, section 9, recomputes them live):
       · every text, even the smallest label . 7 : 1 or better (WCAG AAA)
       · borders of an input or a button ..... 3 : 1 or better (--line-ui)
       · the keyboard focus ring ............. 3 : 1 or better (--focus)
     The page is a dark GREY, not black, and the text is an off-white, not #fff:
     pure white on pure black is the harshest pairing for a reader who is
     sensitive to light. Nothing here flashes, fades or animates.
   - Colours that come from DATA (a profile's colour, a status colour, a system's
     colour in fsd-data.js) cannot be tokens: fsd/theme.js `tone()` re-derives
     them for the dark theme with the same hue and a guaranteed contrast.

   A new colour in a page is a new token here, in BOTH blocks — never a hex
   literal in the page, or the dark theme breaks on that one element.
   ========================================================================== */

:root {
  color-scheme: light;

  /* ---- surfaces ---- */
  --bg: #fafaf9;            /* the page, the list pane */
  --card: #fff;             /* cards, the detail pane, the toolbar, fields */
  --raised: #fff;           /* a control sitting ON a --sunk track (active tab) */
  --sunk: #ededea;          /* tracks, label chips, an empty bar */
  --soft: #f6f6f4;          /* a quiet panel inside a card */
  --tint: #f2f2f0;          /* link pills, the scope line */
  --tint2: #ededea;         /* small tags */
  --tint3: #ebebe8;         /* rule numbers */
  --tint-hover: #e8e8e5;
  --tint2-hover: #e0e0dc;
  --track: #e5e5e2;         /* the empty part of a progress bar */
  --gauge-track: #e5e5e2;   /* the empty part of the ring */
  --bar-track: #f2f2ef;     /* the empty part of a stacked bar */

  /* ---- lines ---- */
  --line: #e5e5e2;
  --line-tint: #dadad6;
  --line-tint2: #e5e5e2;
  --line-tint3: #dadad6;
  --line-strong: #d4d4d0;
  --line-ui: var(--line);   /* the border of a field or a button */
  --hair: #efefec;          /* separators inside a card */
  --hair2: #f5f5f3;

  /* ---- text ---- */
  --ink: #0a0a0a;
  --ink-strong: #000;     /* the one paragraph meant to be read first */
  --text1: #1a1a1a;
  --text2: #2e2e2b;
  --text3: #45453f;
  --muted: #55554f;
  --faint: #6e6e68;         /* the quietest label */
  --zero: #d4d4d0;          /* a 0 in the coverage matrix */
  --tint-ink: #2e2e2b;      /* text on --tint2 */
  --on-fill: #fff;          /* text on any filled chip, button or band */

  /* ---- accent ---- */
  --blue-ink: var(--blue);  /* the accent as TEXT or as a border */
  --blue-mark: var(--blue); /* the accent as a bar/line on a --track */
  --green-mark: var(--green);
  --amber: #b7791f;         /* "changed" chip */
  --av-bg: #ededea;         /* the avatar */
  --av-ink: #0a0a0a;
  --focus: #2b3bc4;         /* keyboard focus ring */
  --ring: rgba(77, 99, 255, .35);   /* the halo of a focused field */

  /* ---- states ---- */
  --warn-bg: #fffbeb; --warn-bg2: #fef3c7; --warn-bg3: #fffdf5;
  --warn-line: #fde68a; --warn-ink: #78350f; --warn-ink2: #92400e;
  --err-bg: #fef2f2; --err-line: #fecaca; --err-ink: #7f1d1d;
  --danger: #b91c1c;        /* red as text */
  --danger-fill: #b91c1c;   /* red as a filled chip */
  --ok-bg: #f0fdf4; --ok-bg2: #f4fdf7; --ok-line: #bbf7d0; --ok-ink: #065f46;

  /* ---- chrome that is dark in both themes ---- */
  --top-bg: #0a0a0a;        /* the header */
  --inv-bg: #1c1c1c;        /* toast, tooltip, header select */
  --inv-ink: #fff;
  --inv-sub: #adada9;
  --code-bg: #141414;
  --code-ink: #e5e5e2;
  --scrim: rgba(15, 23, 42, .44);
  --scrim-zoom: rgba(15, 23, 42, .78);
  --shadow-s: 0 4px 14px rgba(15, 23, 42, .10);
  --shadow-m: 0 12px 34px rgba(15, 23, 42, .34);
  --shadow-l: 0 24px 60px rgba(15, 23, 42, .32);
  --shot-filter: none;      /* screenshots are light pictures: see dark */
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #141414;
  --card: #1c1c1c;
  --raised: #2c2c2c;
  --sunk: #262626;
  --soft: #202020;
  --tint: #242424;
  --tint2: #2a2a2a;
  --tint3: #2c2c2c;
  --tint-hover: #2e2e2e;
  --tint2-hover: #333333;
  --track: #333333;
  --gauge-track: #2c2c2c;
  --bar-track: #262626;

  --line: #2c2c2c;
  --line-tint: #3a3a3a;
  --line-tint2: #333333;
  --line-tint3: #3a3a3a;
  --line-strong: #3a3a3a;
  --line-ui: #6e6e6a;
  --hair: #262626;
  --hair2: #232323;

  --ink: #f5f5f3;
  --ink-strong: #fafaf9;
  --text1: #ededeb;
  --text2: #dadad6;
  --text3: #c4c4c0;
  --muted: #adada9;
  --faint: #a8a8a4;
  --zero: #8a8a86;
  --tint-ink: #dadad6;
  --on-fill: #f5f5f3;

  /* The brand FILLS are re-tuned here so white text keeps ≥ 7 : 1 on them; a
     project with another brand colour adjusts these three values. */
  --blue: #333333;
  --green: #1f5c41;
  --blue-ink: #f5f5f3;
  --blue-mark: #d6d6d2;
  --green-mark: #4cc38a;
  --amber: #704a0c;
  --av-bg: #2c2c2c;
  --av-ink: #f5f5f3;
  --focus: #8c9aff;
  --ring: rgba(140, 154, 255, .5);
  --magenta-pin: #a8135a;   /* white digits on it: ≥ 7 : 1 */

  --warn-bg: #2b2414; --warn-bg2: #352b12; --warn-bg3: #241f12;
  --warn-line: #6b5520; --warn-ink: #f3d38c; --warn-ink2: #f3d38c;
  --err-bg: #2d1a1c; --err-line: #7a3a3f; --err-ink: #ffb4b4;
  --danger: #ff9c9c;
  --danger-fill: #a31b1b;
  --ok-bg: #14281d; --ok-bg2: #16291f; --ok-line: #2f6b4f; --ok-ink: #8fe0b2;

  --top-bg: #0a0a0a;
  --inv-bg: #262626;
  --inv-ink: #f5f5f3;
  --inv-sub: #adada9;
  --code-bg: #0e0e0e;
  --code-ink: #e5e5e2;
  --scrim: rgba(0, 0, 0, .62);
  --scrim-zoom: rgba(0, 0, 0, .82);
  --shadow-s: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-m: 0 12px 34px rgba(0, 0, 0, .55);
  --shadow-l: 0 24px 60px rgba(0, 0, 0, .6);
  /* A screenshot is a picture of a LIGHT screen; at full brightness it is the
     brightest thing on a dark page. 12 % less takes the edge off without
     changing what it shows. The zoomed view keeps the true brightness. */
  --shot-filter: brightness(.88);
}

/* Someone who asked their system for more contrast gets it in both themes. */
@media (prefers-contrast: more) {
  :root { --line-ui: #6b6457; --faint: #5f6b7d; --muted: #4f493e; }
  :root[data-theme="dark"] {
    --line: #4b5463; --line-ui: #aab3c2; --faint: #b9c1ce; --muted: #c9d0dc;
    --zero: #b9c1ce;
  }
}

/* Nothing on the pages needs to move; whoever asked for less motion gets none. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- the light / dark switch ----------
   One button, the same in every header. Its home is the dark header bar (dark in
   both themes), so its colours are fixed rather than tokens. role="switch" +
   aria-checked tell a screen reader the state; the knob's POSITION tells
   everybody else, so the state never depends on colour alone. */
.theme-toggle {
  flex: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: 600 11.5px/1 Inter, system-ui, sans-serif; color: #fff; white-space: nowrap;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 999px; padding: 6px 8px 6px 11px; transition: background .15s, border-color .15s;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .17); border-color: rgba(255, 255, 255, .5); }
.theme-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.theme-toggle svg { width: 15px; height: 15px; flex: none; }
.theme-toggle .tt-track {
  position: relative; width: 32px; height: 18px; border-radius: 999px; flex: none;
  background: rgba(255, 255, 255, .42);
}
.theme-toggle .tt-track i {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.theme-toggle[aria-checked="true"] .tt-track { background: #f5f5f3; }
.theme-toggle[aria-checked="true"] .tt-track i { transform: translateX(14px); background: #12151a; }
@media (max-width: 900px) { .theme-toggle .tt-label { display: none; } .theme-toggle { padding-left: 9px; } }
/* A page with no header bar (the developer guide) floats it in the corner on a
   solid dark chip, so it reads on a light page and on a dark one. */
.theme-toggle.float {
  position: fixed; top: 14px; right: 18px; z-index: 50; background: var(--top-bg);
  border-color: rgba(255, 255, 255, .5); box-shadow: var(--shadow-m); padding: 8px 10px 8px 13px;
}
