/* Design tokens. Usage: docs/design/art-direction.md */
:root {
  color-scheme: light;

  /* --- Colour: surfaces --- */
  --bg: #f3f6fb;            /* page */
  --card: #ffffff;          /* raised surface: widget, cards, details */
  --surface-tint: #eaf1fd;  /* quiet band behind a section, icon tiles */
  --surface-sunk: #f6f8fc;
  --seg-hover: color-mix(in srgb, var(--card) 50%, var(--surface-sunk)); /* segment hover */
  --text: #101828;
  --muted: #475467;
  --muted-quiet: #5b6678;
  --border: #d0d7e2;        /* hairlines, card edges */
  --field: #6b778a;         /* input borders, 3:1 against card */
  --border-strong: var(--field); --rule-total: var(--text); /* .is-total rule */
  --app-placeholder: #dde3ec; /* mock app icons/bars */

  /* --- Colour: brand --- */
  --accent: #0b5fd3;        /* links, primary button, selected toggle, key numbers */
  --accent-hover: #0a52b6;
  --accent-text: #ffffff;   /* text on --accent */
  --accent-soft: #e6effd;
  --accent-bd: #a9c6f3;     /* border of tinted accent surfaces */
  --accent-ink: #0a4fae;    /* accent text sitting on --accent-soft (AA) */
  --placeholder-hint: #456fae;
  --hint-bg: #f2f7ff;
  --hint-bd: #a9c6f3;
  --ot: #b54708;            /* secondary accent: overtime figures and the OT marker only */
  --ot-soft: #fef3e7;

  /* --- Colour: status --- */
  --ok: #067647; --ok-bg: #e7f6ee; --ok-bd: #75c79c;
  --ok-soft: var(--ok-bg); --ok-ink: #05603a; /* status chip text on --ok-soft */
  --text-subtle: #637085; /* placeholders */
  --figure-idle: var(--text-subtle); /* idle/zero result figure */
  --warn-soft: var(--warn-bg); --warn-ink: #7a5200; /* .chip.warn: 6.3:1 */
  --info-bg: #eef4ff; --info-bd: #8fb3ee;            /* neutral notes (example banner) */
  --warn-bg: #fff4d6; --warn-bd: #9a6700;
  --err-bg: #ffe9e7; --err-bd: #b42318;
  --invalid-bd: #b42318;
  --invalid-ring: 0 0 0 3px rgba(180,35,24,.22); /* focus ring of an invalid field */

  /* --- Colour: lines --- */
  --connector: #8fb3ee;
  --paper-rule: inset 0 var(--rule-w) 0 var(--accent);
  --perf-ring: var(--accent-bd);   /* ring of each punched notch / dot */
  --perf-fill: var(--card);        /* inside of a notch: the surface the card sits on */
  /* Print only */
  --print-paper: #ffffff; --print-ink: #000000; --print-muted: #555555; /* 7.5:1 */
  --print-rule: #999999; --print-head-bg: #f2f2f2;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475467' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

  --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 9.5 17 19 7'/%3E%3C/svg%3E");
  --mask-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11.28 4.82Q12 2.18 12.72 4.82L20.28 18.68Q21 20 19.5 20H4.5Q3 20 3.72 18.68ZM12 9.5V14M12 17h0'/%3E%3C/svg%3E");
  --fade-x: linear-gradient(to right, transparent 0, #000 var(--fade-w), #000 calc(100% - var(--fade-w)), transparent 100%);

  /* --- Depth, glow, gradients --- */
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 12px -2px rgba(16,24,40,.06);
  --shadow-lg: 0 2px 4px rgba(16,24,40,.04), 0 16px 40px -8px rgba(16,40,90,.14);
  --shadow-bar: 0 -6px 20px rgba(16,24,40,.10);
  --page-glow: radial-gradient(1100px 420px at 50% -160px, rgba(11,95,211,.13), rgba(11,95,211,0) 70%);
  --grad-total: linear-gradient(160deg, #eef4ff 0%, #e2ecfc 100%);
  --ring: 0 0 0 3px rgba(11,95,211,.28);

  /* --- Type --- */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px;      /* micro labels, day dates, +1 day tag */
  --fs-sm: 13px;      /* field labels, column heads, row decimal */
  --fs-body-sm: 14px; /* summary lines, small UI copy */
  --fs-md: 15px;      /* lead, card text */
  --fs-body: 16px;    /* body, inputs */
  --fs-lg: 18px;      /* card titles (h3), estimated gross */
  --fs-total-2: 22px; /* mobile bar value (and other compact secondary figures) */
  --fs-total-dec: 24px;
  --fs-h2: 28px;      /* section title */
  --fs-h1: 32px;      /* page title */
  --fs-total: 40px;   /* the weekly total */
  --lh-tight: 1.1; --lh-snug: 1.3; --lh-body: 1.55;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700; --fw-heavy: 750;
  --tracking-tight: -0.02em; --tracking-caps: 0.06em;

  /* --- Space (4px grid) --- */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 48px;
  --space-section: 72px;

  /* --- Radius --- */
  --radius-xs: 6px;    /* tags, badges */
  --radius-sm: 8px;    /* inputs, buttons, toggles, rows */
  --radius-md: 12px;   /* cards, total card, details */
  --radius-lg: 16px;   /* widget shell, feature cards */
  --radius-pill: 999px;

  /* --- Size --- */
  --tap: 44px;          /* minimum tap target */
  --control-h: calc(var(--tap) + 2 * var(--field-w)); --seg-pad: var(--field-w); /* tool-widget controls: 47 outer, 44 inside */
  --maxw: 1180px;       /* content width */
  --mbar-h: 64px;       /* mobile sticky total bar height (without safe-area inset) */
  --icon-sm: 16px; --icon-md: 20px; --icon-lg: 24px;
  --icon-em: 1em; --icon-em-lg: 1.25em;
  --icon-tile: 40px;
  --icon-caption: var(--icon-md);
  --icon-stroke: 1.75;
  --icon-mark: 28px;    /* app mark next to the H1 */
  --time-input-min: 3.6em;
  --select-pad: 32px;   /* right padding of .select: room for the 16px chevron */
  --check-size: 22px; --check-size-lg: 24px; /* drawn checkbox box (.t-check, .steps-check); the label is the 44px target */
  --switch-w: 44px; --switch-h: 26px; --switch-knob: 20px; /* .t-switch */
  --knob: #ffffff;      /* switch knob, light in both themes */
  --fade-w: 16px;       /* edge fade of horizontal scrollers */
  --head-row: 44px;     /* one site-header row */
  --chart-col: 14em; --compare-max: 44em; /* .t-cols column min width, .t-compare max width */
  --peek-h: 56px;
  --peek-live: calc(var(--peek-h) + var(--safe-b)); --peek-clear: calc(var(--peek-live) + var(--space-3));
  --group-gap: 20px;    /* result card: figures to their explanation */
  --gap-block: var(--space-7);  /* control row (preset chips) -> next card */
  --footer-gap: var(--space-8); /* last block -> footer on short pages */
  --check-gap: var(--space-3);  /* drawn checkbox <-> its label (8-12) */
  --illo-gap: var(--space-4);   /* min gap illustration <-> text */
  --link-pad: 6px;      /* .link side padding; -1x = optical offset */
  --illo-stub-w: 96px; --illo-stub-h: 72px; --illo-stub-w-sm: 64px; --illo-stub-h-sm: 48px;
  --illo-w: 280px; --illo-h: 120px; --illo-404-w: 160px; --illo-404-h: 120px; --illo-404-h-sm: 72px; /* .illo sizes */
  --border-w: 1px; --field-w: 1.5px;
  --tok-pad-y: 0.2em; --tok-pad-x: 0.4em;
  --rule-w: 3px;        /* accent rule on the total card; double rule under its caption */
  --perf-pitch: 14px; --perf-r: 4px; --perf-h: 6px; /* punched-edge notches on the total card */
  --perf-strip-h: 8px;
  /* Safe-area insets (notch, home indicator). */
  --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);

  /* --- Motion --- */
  --dur-fast: 120ms; --dur: 180ms; --dur-slow: 260ms;
  --ease: cubic-bezier(.2,.7,.2,1);
  --z-bar: 10;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b111b; --card: #151c2a; --surface-tint: #121a29; --surface-sunk: #111827;
    --text: #f1f4f9; --muted: #b4bfd0; --border: #2c3648; --field: #8793a8;
    --muted-quiet: #8a96aa;
    --hint-bg: #14223a; --hint-bd: #2f4f80;
    --accent: #6aa6ff; --accent-hover: #8dbbff; --accent-text: #08121f;
    --accent-soft: #16243c; --accent-bd: #2f4f80; --accent-ink: #9cc3ff;
    --placeholder-hint: #7f9fcf;
    --ot: #fdb022; --ot-soft: #33240b;
    --app-placeholder: #273246;
    --ok: #4ade80; --ok-bg: #0f2a1c; --ok-bd: #2f7d52; --ok-ink: #7ee2a8; --text-subtle: #8793a8; --warn-ink: #f5c451; --knob: #e6ecf5;
    --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2308121f' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 9.5 17 19 7'/%3E%3C/svg%3E");
    --info-bg: #13203a; --info-bd: #4a78c2;
    --warn-bg: #3a2e0c; --warn-bd: #e0a928;
    --err-bg: #3d1713; --err-bd: #ff8a80;
    --invalid-bd: #ff8a80; --invalid-ring: 0 0 0 3px rgba(255,138,128,.32);
    --connector: #3b609a;
    --perf-ring: #4a78c2;
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4bfd0' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    --shadow-sm: 0 0 0 0 transparent;
    --shadow: 0 0 0 1px rgba(255,255,255,.02), 0 6px 16px -4px rgba(0,0,0,.45);
    --shadow-lg: 0 0 0 1px rgba(255,255,255,.03), 0 18px 44px -10px rgba(0,0,0,.6);
    --shadow-bar: 0 -6px 20px rgba(0,0,0,.45);
    --page-glow: radial-gradient(1100px 420px at 50% -160px, rgba(106,166,255,.14), rgba(106,166,255,0) 70%);
    --grad-total: linear-gradient(160deg, #182a47 0%, #131f35 100%);
    --ring: 0 0 0 3px rgba(106,166,255,.35);
  }
}

@media (max-width: 760px) {
  :root {
    --fs-h1: 26px; --fs-h2: 24px; --fs-total: 34px; --fs-total-dec: 20px;
    --space-section: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; }
}
