/* RegRadar design tokens.
   Two layers: palette primitives (--stone-*, --brand-*, --green-*, --amber-*,
   --red-*, --night-*) hold every hex in the system; semantic tokens (--color-*,
   --text-*, --space-*, --radius-*) are what components reference. Components
   must never reference a primitive or a raw hex.
   :root holds the light theme; the [data-theme="dark"] block at the foot
   overrides the semantic colours, and nothing else. These were one `light-dark`
   call per line, which read better but made the whole palette depend on a
   feature from 2024: a browser that does not know the function drops the
   declaration, so every semantic colour goes unset and the page loses its
   theme rather than just its dark mode. Overriding the custom property needs
   nothing newer than `var`, and an older browser simply stays light. */

:root {
  /* Light unless the visitor asks for dark. Following prefers-color-scheme
     meant a new window opened dark on a machine set to dark, which reads as
     the toggle flipping itself. Only [data-theme="dark"] turns it over. */
  color-scheme: light;

  --white: #ffffff;
  --stone-0: #ffffff;
  --stone-25: #fafafa;
  --stone-50: #f7f7f8;
  --stone-100: #eeeef0;
  --stone-200: #e0e0e3;
  --stone-300: #c3c3c9;
  --stone-400: #8b8b93;
  --stone-500: #6e6e77;
  --stone-600: #57575f;
  --stone-700: #414148;
  --stone-800: #2a2a30;
  --stone-900: #18181c;

  --night-950: #0b0b0d;
  --night-900: #121215;
  --night-800: #1a1a1e;
  --night-700: #232328;
  --night-600: #303036;
  --night-500: #45454d;
  --night-400: #74747e;

  /* The brand is red on a white page. --brand-950 is the one near-black in the
     system that keeps the brick hue: it is the full-bleed band colour, and it
     stays the same in both themes so a band reads as a band, not as the page. */
  --brand-50: #fff0f0;
  --brand-100: #ffdada;
  --brand-200: #ffb3b3;
  --brand-300: #ff8080;
  --brand-400: #ff4040;
  --brand-500: #ff0000;
  --brand-600: #e00000;
  --brand-700: #b80000;
  --brand-800: #8f0000;
  --brand-900: #5c0000;
  --brand-950: #330000;

  /* Green is the second brand colour as well as the "good" tone. One green,
     used for both — see the note in ARCHITECTURE.md ui:. */
  --green-50: #eefaf1;
  --green-100: #d3f2dd;
  --green-200: #a5e4bd;
  --green-300: #6bcf95;
  --green-400: #35b070;
  --green-500: #1f8f56;
  --green-600: #167345;
  --green-700: #125c38;
  --green-800: #0e472c;
  --green-900: #08301d;

  --amber-50: #fbf2e3;
  --amber-100: #f6e4c4;
  --amber-200: #ebc98c;
  --amber-300: #dcab55;
  --amber-500: #9e6e18;
  --amber-600: #7e5712;
  --amber-800: #4b330b;
  --amber-900: #332208;

  /* Cooler and more saturated than the brand brick on purpose: with a red
     brand, a warm danger red is indistinguishable from a primary button. */
  --red-50: #fdeef1;
  --red-100: #fad7de;
  --red-200: #f2aab8;
  --red-300: #e5788d;
  --red-500: #c21f45;
  --red-600: #a21739;
  --red-800: #641024;
  --red-900: #450b19;

  /* Jost, as on Diranx. One typeface — headings separate from body by weight
     and size, not by family. Mono is system-only, for document references. */
  --font-sans: "Jost", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Diranx runs a 15px body at 1.7, with small uppercase labels. */
  --text-2xs: 0.5625rem;
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-md: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.625rem;
  --text-3xl: clamp(1.625rem, 1.25rem + 1.6vw, 2.125rem);
  --text-display: clamp(1.875rem, 1.35rem + 2.7vw, 3rem);

  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-normal: 1.7;
  --leading-relaxed: 1.8;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.01em;
  --tracking-normal: 0;
  --tracking-wide: 0.06em;

  --space-1: 0.25rem;
  --space-2: 0.375rem;
  --space-3: 0.625rem;
  --space-4: 0.875rem;
  --space-5: 1.125rem;
  --space-6: 1.5rem;
  --space-7: 2.25rem;
  --space-8: 3rem;
  --space-9: 4.5rem;
  /* Section rhythm scales with the viewport so a phone never gets desktop padding. */
  --space-section: clamp(2rem, 1.3rem + 2.4vw, 3.25rem);
  /* The signed-in page's vertical rhythm, as two numbers rather than a margin
     per component: --gap-stack between any two blocks on a page, --gap-heading
     from a section heading to its body. Overview, Obligations, Updates and
     Admin each shipped their own distance from the heading to the first card
     (18 / 41 / 68 / 48 px measured) because each owned its own margin. */
  --gap-stack: var(--space-6);
  --gap-heading: var(--space-3);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-pill: 999px;

  --border-thin: 1.5px;
  --border-thick: 2px;
  /* The coloured edge down one side of a note, a quote or a flagged card.
     One width for all three, so a flag reads as a flag wherever it appears. */
  --border-flag: 3px;
  --border: var(--border-thin) solid var(--color-border);
  --border-strong: var(--border-thin) solid var(--color-border-strong);

  --ring-width: 2px;
  --ring-offset: 2px;

  --control-height: 2.5rem;
  --control-height-sm: 2rem;

  --measure: 66ch;
  --width-page: 1080px;
  --width-narrow: 720px;
  /* The signed-in shell is wider than a reading page: it carries a sidebar
     beside the content, and the footer and the auth header line up with it. */
  --width-app: 1240px;
  --width-sidebar: 220px;
  --width-drawer: 16.5rem;

  --scrollbar-size: 0.75rem;

  --duration-fast: 120ms;
  --duration-base: 200ms;
  --ease: cubic-bezier(0.2, 0, 0.2, 1);

  --color-bg: var(--stone-25);
  --color-surface: var(--white);
  --color-surface-raised: var(--white);
  --color-surface-sunken: var(--stone-50);
  --color-hover-surface: var(--stone-50);

  --color-text: var(--stone-900);
  --color-text-muted: var(--stone-600);
  --color-text-subtle: var(--stone-500);

  --color-border: var(--stone-200);
  --color-border-strong: var(--stone-400);
  --color-border-accent: var(--brand-600);

  --color-accent: var(--brand-500);
  --color-accent-hover: var(--brand-600);
  --color-accent-active: var(--brand-700);
  --color-accent-contrast: var(--white);
  --color-accent-soft: var(--brand-50);
  --color-accent-soft-text: var(--brand-700);

  --color-link: var(--brand-700);
  --color-link-hover: var(--brand-800);
  --color-link-visited: var(--brand-800);

  --color-good: var(--green-600);
  --color-good-soft: var(--green-50);
  --color-good-border: var(--green-200);

  --color-warn: var(--amber-600);
  --color-warn-soft: var(--amber-50);
  --color-warn-border: var(--amber-200);

  --color-critical: var(--red-600);
  --color-critical-soft: var(--red-50);
  --color-critical-border: var(--red-200);

  /* Neutral, and deliberately not derived from the accent: with a red brand,
     an informational note tinted from it is indistinguishable from an error.
     "Assessment started" was rendering pink. */
  --color-info: var(--stone-700);
  --color-info-soft: var(--stone-50);
  --color-info-border: var(--stone-200);

  --color-table-head: var(--stone-900);
  --color-table-head-text: var(--white);

  --color-field-bg: var(--white);
  --color-field-border: var(--stone-400);
  --color-field-border-hover: var(--stone-500);
  --color-field-placeholder: var(--stone-500);
  --color-disabled-bg: var(--stone-100);
  --color-disabled-text: var(--stone-400);

  --color-focus-ring: var(--brand-500);
  --color-selection-bg: var(--brand-100);
  --color-selection-text: var(--brand-900);
  --color-caret: var(--color-accent);
  --color-tap-highlight: color-mix(in srgb, var(--color-accent) 18%, transparent);

  /* The second accent. Red carries the calls to action; green carries the
     band, the marks and the one filled card, so the page reads as both. */
  --color-accent-2: var(--green-600);
  --color-accent-2-hover: var(--green-700);
  --color-accent-2-contrast: var(--white);
  --color-accent-2-soft: var(--green-50);
  --color-accent-2-soft-text: var(--green-700);

  /* The one full-bleed band. Green in both themes — a band is a band. */
  --color-band: var(--green-600);
  --color-band-text: var(--white);
  --color-band-accent: var(--green-200);

  --color-scrollbar-thumb: var(--stone-300);
  --color-scrollbar-thumb-hover: var(--stone-400);
  --color-scrollbar-track: var(--stone-50);
  --color-overlay: color-mix(in srgb, var(--stone-900) 45%, transparent);

  /* Icons are masks (they take their colour from background-color), except the
     checkmark, which is painted on the accent fill and so matches
     --color-accent-contrast by construction in both themes. */
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23000' d='M1.4 3.6 6 8.2l4.6-4.6 1.1 1.1L6 10.4.3 4.7z'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='m3 8.5 3.3 3.3L13 4.8'/%3E%3C/svg%3E");
  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E");
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M21 13.2A9 9 0 1 1 10.8 3a7 7 0 0 0 10.2 10.2z'/%3E%3C/svg%3E");
  --icon-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 3C6.9 3 3 6.4 3 10.6c0 2.3 1.2 4.4 3.1 5.8v3.3l3.1-1.7c.9.2 1.8.3 2.8.3 5.1 0 9-3.4 9-7.7S17.1 3 12 3z'/%3E%3C/svg%3E");
  --icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M8.7 2.3 14.4 8l-5.7 5.7-1.1-1.1L11.2 8.8H1.6V7.2h9.6L7.6 3.4z'/%3E%3C/svg%3E");

  /* Diranx separates surfaces with shadow, not outline. Two steps: resting
     and lifted. Borders stay for the things that really are dividers. */
  --shadow-color: color-mix(in srgb, var(--stone-900) 8%, transparent);
  --shadow-sm: 0 1px 3px var(--shadow-color);
  --shadow-md: 0 2px 16px var(--shadow-color);
  --shadow-lg: 0 8px 30px var(--shadow-color);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --color-bg: var(--night-900);
  --color-surface: var(--night-800);
  --color-surface-raised: var(--night-700);
  --color-surface-sunken: var(--night-950);
  --color-hover-surface: var(--night-700);
  --color-text: var(--stone-50);
  --color-text-muted: var(--stone-300);
  --color-text-subtle: var(--stone-400);
  --color-border: var(--night-600);
  --color-border-strong: var(--night-400);
  --color-border-accent: var(--brand-300);
  --color-accent-soft: var(--brand-900);
  --color-accent-soft-text: var(--brand-200);
  --color-link: var(--brand-300);
  --color-link-hover: var(--brand-200);
  --color-link-visited: var(--brand-200);
  --color-good: var(--green-300);
  --color-good-soft: var(--green-900);
  --color-good-border: var(--green-800);
  --color-warn: var(--amber-300);
  --color-warn-soft: var(--amber-900);
  --color-warn-border: var(--amber-800);
  --color-critical: var(--red-300);
  --color-critical-soft: var(--red-900);
  --color-critical-border: var(--red-800);
  --color-info: var(--stone-200);
  --color-info-soft: var(--night-700);
  --color-info-border: var(--night-500);
  --color-table-head: var(--night-700);
  --color-table-head-text: var(--stone-50);
  --color-field-bg: var(--night-950);
  --color-field-border: var(--night-400);
  --color-field-border-hover: var(--stone-400);
  --color-field-placeholder: var(--stone-400);
  --color-disabled-bg: var(--night-800);
  --color-disabled-text: var(--stone-500);
  --color-focus-ring: var(--brand-300);
  --color-selection-bg: var(--brand-800);
  --color-selection-text: var(--stone-0);
  --color-accent-2: var(--green-500);
  --color-accent-2-hover: var(--green-400);
  --color-accent-2-soft: var(--green-900);
  --color-accent-2-soft-text: var(--green-200);
  --color-band: var(--green-800);
  --color-scrollbar-thumb: var(--night-600);
  --color-scrollbar-thumb-hover: var(--night-500);
  --color-scrollbar-track: var(--night-950);
  --color-overlay: color-mix(in srgb, var(--night-950) 68%, transparent);
  --shadow-color: color-mix(in srgb, var(--night-950) 70%, transparent);
}
