/* ViaForte design tokens — shared across every product consuming
   @viaforte/da. Palette: deep teal on cool neutrals. Three theme states
   (light / dark / unset-follows-OS) via the data-theme attribute — never
   collapse this to two, see the dark block's own note below. */

:root {
  --bg: #f6f8f8;
  --surface: #ffffff;
  --surface-alt: #fafbfb;
  --border: #e3e8e8;
  --border-strong: #cfd8d8;
  --ink: #16221f;
  --ink-dim: #66756f;
  --ink-faint: #8c9a94;
  --accent: #12554e;
  --accent-hover: #0d423d;
  --accent-bright: #2a8f83;
  --accent-dim: #e8f1ef;
  --danger: #b3261e;
  --danger-dim: #fdecea;
  --ok: #166a3c;
  --ok-dim: #e7f4ec;
  --warn: #9a5a00;
  --warn-dim: #fdf3e3;
  --deep: #0b1a18;
  --deep-alt: #112724;
  --deep-ink: #eaf2f0;
  --deep-dim: #9db3ae;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-sm: 0 1px 2px rgba(16, 32, 28, .05);
  --shadow-md: 0 2px 10px rgba(16, 32, 28, .08);
  --shadow-lg: 0 18px 48px rgba(11, 26, 24, .14);
  /* --sans exists because --mono needs an opposite. A cell set in --mono
     that wants one glyph back in the UI face cannot say so by unsetting
     font-family — font-family INHERITS, so `unset` there means `inherit`,
     which hands back the very mono it was escaping. Naming the stack is the
     only way to say "not mono". */
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --sidebar: 236px;

  --warn-ink: #7a4700;
  --danger-ink: #8f1e18;
  --accent-ink: var(--accent-hover);
  --pill-bg: #eef2f2;
  --flag-bg: #fdfaf3;
  --disabled-bg: #f2f4f4;
  --locked-ink: #b3bfbb;
  /* Navy shell palette (DA 1.5.0; used only under AppShell theme="navy", fixed in every user theme) */
  --nav-bg: #0d2540;
  --nav-hover: #17375c;
  --nav-border: #2c4a6e;
  --nav-ink: #f2f6fb;
  --nav-ink-dim: #c5d2e2;
  --nav-ink-faint: #9db3cc;
  --nav-active: #1b6b4a;
  --nav-active-ink: #ffffff;
  --nav-focus: #8fd0ff;
  --no-ink: #c9d1cf;
  --danger-border: #f0d6d4;
  --header-bg: rgba(255, 255, 255, .93);
}

/* A stored dark/light preference that can't also mean "match system"
   silently overrides the OS forever after one click — so
   :root:not([data-theme="light"]) under prefers-color-scheme handles
   "unset", and :root[data-theme="dark"] handles an explicit choice,
   independently. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d0d;
    --surface: #141616;
    --surface-alt: #1b1d1d;
    --border: #26292a;
    --border-strong: #383d3d;
    --ink: #e9ecec;
    --ink-dim: #9ba2a2;
    --ink-faint: #6e7575;
    --accent: #2fa295;
    --accent-hover: #42b9ab;
    --accent-bright: #55cdbd;
    --accent-dim: #142624;
    --danger: #ef8a82;
    --danger-dim: #2f1e1c;
    --ok: #66c08d;
    --ok-dim: #15281d;
    --warn: #dda253;
    --warn-dim: #2b2314;
    --deep: #090a0a;
    --deep-alt: #141616;
    --deep-ink: #e9ecec;
    --deep-dim: #9ba2a2;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
    --warn-ink: #e8b878;
    --danger-ink: #f2a79f;
    --accent-ink: #6fd0c2;
    --pill-bg: #222626;
    --flag-bg: #251f13;
    --disabled-bg: #1b1d1d;
    --locked-ink: #5a6160;
    --no-ink: #414646;
    --danger-border: #432826;
    --header-bg: rgba(20, 22, 22, .93);
  }
}

:root[data-theme="dark"] {
  --bg: #0c0d0d;
  --surface: #141616;
  --surface-alt: #1b1d1d;
  --border: #26292a;
  --border-strong: #383d3d;
  --ink: #e9ecec;
  --ink-dim: #9ba2a2;
  --ink-faint: #6e7575;
  --accent: #2fa295;
  --accent-hover: #42b9ab;
  --accent-bright: #55cdbd;
  --accent-dim: #142624;
  --danger: #ef8a82;
  --danger-dim: #2f1e1c;
  --ok: #66c08d;
  --ok-dim: #15281d;
  --warn: #dda253;
  --warn-dim: #2b2314;
  --deep: #090a0a;
  --deep-alt: #141616;
  --deep-ink: #e9ecec;
  --deep-dim: #9ba2a2;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 2px 10px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
  --warn-ink: #e8b878;
  --danger-ink: #f2a79f;
  --accent-ink: #6fd0c2;
  --pill-bg: #222626;
  --flag-bg: #251f13;
  --disabled-bg: #1b1d1d;
  --locked-ink: #5a6160;
  --no-ink: #414646;
  --danger-border: #432826;
  --header-bg: rgba(20, 22, 22, .93);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: calc(14px * var(--a11y-scale, 1));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.018em; line-height: 1.2; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img, svg { max-width: 100%; }

/* The OS/browser default scrollbar is always light-chrome, which reads as a
   stray white bar against a dark sidebar/panel — style it from the same
   tokens so it tracks the active theme instead of the OS's own. */
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid var(--surface); background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: padding-box; }
code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--accent-dim);
  color: var(--accent-hover);
  padding: .12em .4em;
  border-radius: 4px;
}

/* ---------- accessibility modes (CT-DA-02.7) ----------
   The preference kit (vf_a11y) sets attributes on <html>; the server can
   render the same attributes with no script (RULE-SEC-10), so everything
   below is plain CSS keyed on them. An attribute is present only when the
   setting is not its default. */

/* Text size: data-text-scale="90|110|120|130" scales every size built on
   --a11y-scale. 100 is the absence of the attribute. Components write their
   fixed px sizes as calc(Npx * var(--a11y-scale, 1)). */
:root { --a11y-scale: 1; }
:root[data-text-scale="90"] { --a11y-scale: .9; }
:root[data-text-scale="110"] { --a11y-scale: 1.1; }
:root[data-text-scale="120"] { --a11y-scale: 1.2; }
:root[data-text-scale="130"] { --a11y-scale: 1.3; }

:root[data-underline-links="true"] a:not(.vf-btn),
:root[data-underline-links="true"] .vf-linkbtn { text-decoration: underline !important; text-underline-offset: .18em; }

:root[data-reduce-motion="true"] *,
:root[data-reduce-motion="true"] *::before,
:root[data-reduce-motion="true"] *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }

/* High contrast: ink on surface at 21:1 and every border dark enough to see
   (the contrast test in src/accessibility.test.ts measures these values).
   Dark high contrast follows the theme exactly as the normal palette does:
   explicit dark, or the OS when no light choice was made. */
:root[data-high-contrast="true"] {
  --bg: #ffffff; --surface: #ffffff; --surface-alt: #f4f4f4;
  --border: #454545; --border-strong: #111111;
  --ink: #000000; --ink-dim: #222222; --ink-faint: #333333;
  --accent: #004d40; --accent-hover: #00332b; --accent-bright: #00a895; --accent-dim: #e0f2ef;
  --header-bg: rgba(255, 255, 255, .98);
}
@media (prefers-color-scheme: dark) {
  :root[data-high-contrast="true"]:not([data-theme="light"]) {
    --bg: #000000; --surface: #000000; --surface-alt: #111111;
    --border: #aaaaaa; --border-strong: #ffffff;
    --ink: #ffffff; --ink-dim: #eeeeee; --ink-faint: #dddddd;
    --accent: #4fe0cc; --accent-hover: #7ff5e5; --accent-dim: #082d28;
    --header-bg: rgba(0, 0, 0, .98);
  }
}
:root[data-high-contrast="true"][data-theme="dark"] {
  --bg: #000000; --surface: #000000; --surface-alt: #111111;
  --border: #aaaaaa; --border-strong: #ffffff;
  --ink: #ffffff; --ink-dim: #eeeeee; --ink-faint: #dddddd;
  --accent: #4fe0cc; --accent-hover: #7ff5e5; --accent-dim: #082d28;
  --header-bg: rgba(0, 0, 0, .98);
}

/* Focus ring (all themes). tabindex="-1" targets are focused by script only. */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
summary:focus-visible, [tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 3px solid var(--accent-bright);
  outline-offset: 3px;
}
/* High contrast: --accent-bright is only about 3:1 on white, so the ring is
   ink with a surface-coloured halo that stays visible on dark panels too. */
:root[data-high-contrast="true"] a:focus-visible,
:root[data-high-contrast="true"] button:focus-visible,
:root[data-high-contrast="true"] summary:focus-visible,
:root[data-high-contrast="true"] [tabindex]:not([tabindex="-1"]):focus-visible {
  outline-color: var(--ink);
  box-shadow: 0 0 0 3px var(--surface);
}
:root[data-high-contrast="true"] input:focus-visible,
:root[data-high-contrast="true"] textarea:focus-visible,
:root[data-high-contrast="true"] select:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}
main[tabindex="-1"]:focus { outline: none; }
