/* =====================================================================
 * CattleBase design tokens (the restyle foundation).
 *
 * Copied verbatim from design/ui-guide.html (its token blocks), which takes
 * its values from design/DESIGN.md, the source of truth. Do not retype or
 * tweak a value here: change DESIGN.md and the guide first, then copy again.
 *
 * Loaded by index.html BEFORE app.css. app.css keeps its older token names
 * (--ink, --green, --line ...) as aliases of these, so the whole app picks up
 * the new palette, fonts and radii without every rule being rewritten at once.
 * The aliases are retired screen by screen as each restyle slice lands.
 *
 * Holds design values only: no per-tenant data and nothing user-specific.
 *
 * Dark theme (features/dark-mode.md): both of the guide's dark blocks are
 * live, copied verbatim. With no data-theme on <html> the OS setting rules
 * (@media prefers-color-scheme); data-theme="light" or "dark" is the user's
 * forced choice. js/theme-boot.js sets the attribute before first paint and
 * app.js changes it from the Light / Dark / Auto menu. Values that stay the
 * same in both themes (ear tags, sticky notes, the toast, --frame, the first
 * two chart series, --logo-ground) are not repeated in the dark blocks on
 * purpose. Plum (--chart-3) has a lighter dark step.
 * ===================================================================== */

/* ---------- tokens: light ----------
   .theme-light (the one app addition to the guide's blocks, dark mode): a subtree that is paper and
   stays light whatever the theme, e.g. the report sheet. The dark blocks below target :root only, so
   an element carrying .theme-light re-declares the light values and its children inherit those. */
:root,.theme-light{
  /* brand and frame */
  --accent:#9FBF3F; --accent-hover:#8EAD33; --accent-active:#7D9A2B; --on-accent:#1E211C;
  --accent-strong:#4F6B1C; --accent-strong-hover:#3F5C10;
  --accent-tint:#EEF4DD; --accent-selected:#E6EFC9;
  --frame:#2A2D27; --frame-hover:#363A32; --frame-text:#E4E6DC; --frame-muted:#A3A896;
  /* neutrals */
  --dark:#1E211C; --text-1:#1E211C; --text-2:#3A3E33; --text-3:#5E6650;
  --bg:#F3F4EF; --surface:#FFFFFF; --surface-2:#F8F9F5;
  --border:#E2E4DA; --border-strong:#8E9480;
  /* semantic */
  --success:#0F5E4E; --success-hover:#0B4C3F; --success-active:#083A30; --success-tint:#D6EFE9;
  --warning:#7A3B00; --warning-hover:#632F00; --warning-active:#4D2400; --warning-tint:#FBE3CF;
  --error:#8A2A1C;   --error-hover:#73221A;   --error-active:#5C1B14;   --error-tint:#F6DEDA;
  --error-fill:#A8321F; --error-fill-hover:#8F2A1A; --error-fill-active:#75221A;
  --info:#234A73;    --info-hover:#1C3C5E;    --info-active:#152E48;    --info-tint:#DDE7F2;
  /* ear tags: physical objects, identical in both themes */
  --tag-yellow:#F2C94C; --tag-yellow-edge:#C99A1E; --tag-yellow-text:#3D2F00;
  --tag-blue:#2F6DB5;   --tag-blue-edge:#1F4F87;   --tag-blue-text:#FFFFFF;
  --tag-red:#C2362B;    --tag-red-edge:#8E2219;    --tag-red-text:#FFFFFF;
  --tag-green:#2E7D32;  --tag-green-edge:#1F5C23;  --tag-green-text:#FFFFFF;
  --tag-orange:#E8892E; --tag-orange-edge:#B5661A; --tag-orange-text:#1E211C;
  --tag-white:#FFFFFF;  --tag-white-edge:#8E9480;  --tag-white-text:#1E211C;
  --tag-print:#111111; --print-rule:#D9DBD2;
  /* sticky-note papers: objects, so the same in both themes; text on them is always ink */
  --note-sage:#EAF1DA; --note-sage-edge:#C9D7A8; --note-sage-label:#4F6B1C;
  --note-clay:#F4E4DA; --note-clay-edge:#E0C4B2; --note-clay-label:#7A3B00;
  --note-sky:#E2EAF2;  --note-sky-edge:#BFCFDF;  --note-sky-label:#234A73;
  --note-tape:rgb(142 148 128 / 0.35); --note-ink:#1E211C; --note-ink-2:#3A3E33; --note-ink-3:#5E6650; /* print sheet ink and hairline, same in both themes */
  --logo-ground:#FFFFFF; /* the logo always sits on white, in both themes */
  --on-strong:#FFFFFF;   /* text and ticks on --accent-strong fills (flips in dark) */
  --on-danger:#FFFFFF;   /* text on --error-fill (both themes) */
  /* chart series: fixed order, never cycled; no lime and no status colours (a bar is never a warning).
     --chart-1 and --chart-2 keep their values in dark (3.3 and 4.3:1 on the dark surface, over 3:1);
     plum gets a lighter dark step (#C46A9E, 4.4:1) in the dark blocks below. */
  --chart-1:#2B78B0; --chart-2:#B7791F; --chart-3:#A3477A;
  /* the second series is always hatched, so expected vs actual still reads in greyscale print */
  --chart-hatch:repeating-linear-gradient(135deg, rgb(255 255 255 / 0.5) 0 2px, transparent 2px 6px);
  /* toast: always an ink chip, in both themes, so its icons keep their contrast */
  --toast-bg:#1E211C; --toast-text:#EEF0E8; --toast-ok:#9FBF3F; --toast-bad:#F2A59A; --toast-info:#9DC1EA;
  /* form aliases */
  --label-color:var(--text-2); --label-color-focused:var(--accent-strong);
  --label-color-error:var(--error); --label-color-disabled:var(--text-3);
  --input-bg:var(--surface); --input-bg-disabled:var(--surface-2);
  --input-border:var(--border-strong); --input-border-hover:var(--text-3);
  --input-border-focused:var(--accent-strong); --input-border-error:var(--error);
  --placeholder-color:var(--text-3); --helper-color:var(--text-3); --helper-color-error:var(--error);
  /* interaction */
  --focus-ring:0 0 0 2px var(--surface), 0 0 0 4px var(--accent-strong);
  --focus-ring-input:0 0 0 1.5px var(--accent-strong); /* fields already have an edge: thicken it, no white gap */
  --selected-ring:inset 0 0 0 1px var(--accent-strong); /* 1px: owner review, 1.5px read heavy */
  --disabled-opacity:0.45; --hover-tint:var(--accent-tint); --touch-min:44px;
  /* type */
  --font-display:'Barlow Condensed','Arial Narrow','Roboto Condensed',sans-serif; /* one weight in use: 600 */
  --font-body:'Atkinson Hyperlegible Next','Segoe UI',Roboto,Arial,sans-serif;
  --font-mono:ui-monospace,'Cascadia Mono',Consolas,monospace;
  --text-display:clamp(2.25rem, 1.8rem + 2.25vw, 3.5rem);
  /* headings sized for a busy app screen (owner review 2026-10-29): the title leads, sections just lead the body */
  --text-h1:clamp(1.625rem, 1.5rem + 0.5vw, 1.875rem);
  --text-h2:1.25rem;
  --text-h3:1.0625rem;
  /* big numbers are data, not headings: they keep the earlier, larger sizes */
  --text-figure:clamp(1.75rem, 1.5rem + 1.25vw, 2.5rem);
  --text-figure-sm:clamp(1.375rem, 1.25rem + 0.6vw, 1.75rem);
  --text-overline:clamp(0.875rem, 0.85rem + 0.1vw, 0.9375rem);
  --text-body-lg:clamp(1.0625rem, 1.04rem + 0.1vw, 1.125rem);
  --text-body:1rem;
  --text-small:clamp(0.875rem, 0.86rem + 0.05vw, 0.9375rem);
  --text-caption:clamp(0.8125rem, 0.8rem + 0.05vw, 0.875rem);
  /* space, size, layout */
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:20px; --space-6:24px;
  --space-8:32px; --space-10:40px; --space-12:48px; --space-16:64px; --space-20:80px; --space-24:96px;
  --h-control:44px; --h-control-dense:36px;
  --max-prose:65ch; --max-content:720px; --max-wide:1440px; --sidebar-w:240px; --topbar-h:56px;
  --icon-xs:14px; --icon-sm:16px; --icon-md:20px; --icon-lg:24px; --icon-xl:32px;
  /* shape and depth */
  --radius-sm:3px; --radius-md:6px; --radius-lg:10px; --radius-full:999px;
  --radius-tag:4px 10px 10px 4px; --radius-tag-portrait:28px 28px 14px 14px;
  --shadow-sm:0 1px 2px rgb(30 33 28 / 0.10);
  --shadow-md:0 4px 12px rgb(30 33 28 / 0.12), 0 1px 3px rgb(30 33 28 / 0.08);
  --shadow-lg:0 16px 40px rgb(30 33 28 / 0.18), 0 4px 10px rgb(30 33 28 / 0.10);
  /* motion */
  --duration-fast:100ms; --duration-base:150ms; --duration-slow:250ms;
  --ease-out:cubic-bezier(0.2, 0, 0, 1); --ease-in-out:cubic-bezier(0.4, 0, 0.2, 1);
  /* layers */
  --z-base:1; --z-dropdown:100; --z-sticky:200; --z-topbar:300; --z-drawer:400;
  --z-modal-backdrop:500; --z-modal:600; --z-toast:700; --z-tooltip:800;
  color-scheme:light;
}

/* ---------- tokens: dark (OS preference unless forced light) ----------
   Applies when the device is in dark mode and the user left the theme on Auto (no data-theme)
   or forced Dark. :not([data-theme="light"]) is what lets a forced Light beat the OS. */
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --accent-strong:#B7D46A; --accent-strong-hover:#C9E082; --accent-tint:#2C3520; --accent-selected:#334019; --on-strong:#1E211C;
    --text-1:#EEF0E8; --text-2:#D2D5C8; --text-3:#A3A896;
    --bg:#1A1C18; --surface:#22251F; --surface-2:#2C3029; --border:#3A3E35; --border-strong:#737966;
    --success:#7FD3BE; --success-tint:#123A32; --warning:#F2B27A; --warning-tint:#3D2512;
    --error:#F2A59A; --error-tint:#3E1C17; --info:#9DC1EA; --info-tint:#1B2C40;
    --shadow-sm:0 1px 2px rgb(0 0 0 / 0.4); --shadow-md:0 4px 12px rgb(0 0 0 / 0.5); --shadow-lg:0 16px 40px rgb(0 0 0 / 0.6);
    --chart-3:#C46A9E;
    color-scheme:dark;
  }
}
/* ---------- tokens: dark (forced by the toggle) ----------
   The user picked Dark in the theme menu (data-theme="dark", set by theme-boot.js / app.js). */
:root[data-theme="dark"]{
  --accent-strong:#B7D46A; --accent-strong-hover:#C9E082; --accent-tint:#2C3520; --accent-selected:#334019; --on-strong:#1E211C;
  --text-1:#EEF0E8; --text-2:#D2D5C8; --text-3:#A3A896;
  --bg:#1A1C18; --surface:#22251F; --surface-2:#2C3029; --border:#3A3E35; --border-strong:#737966;
  --success:#7FD3BE; --success-tint:#123A32; --warning:#F2B27A; --warning-tint:#3D2512;
  --error:#F2A59A; --error-tint:#3E1C17; --info:#9DC1EA; --info-tint:#1B2C40;
  --shadow-sm:0 1px 2px rgb(0 0 0 / 0.4); --shadow-md:0 4px 12px rgb(0 0 0 / 0.5); --shadow-lg:0 16px 40px rgb(0 0 0 / 0.6);
  --chart-3:#C46A9E;
  color-scheme:dark;
}

/* reduced motion: one switch, no component code changes */
@media (prefers-reduced-motion: reduce){
  :root{ --duration-fast:0ms; --duration-base:0ms; --duration-slow:0ms; }
}
