/* Design tokens — the only file that may contain raw colours, radii and font names.
   Everything else uses var(--…). Lint: node scripts/check-tokens.mjs
   Direction: docs/design-direction.md */
:root {
  /* colour */
  --c-bg: #f4f4f2;
  --c-card: #ffffff;
  --c-paper: #f8f8f6;
  --c-line: #e4e4e0;
  --c-text: #25272a;
  --c-soft: #62666b;
  --c-muted: #92969b;
  --c-sage: #587a67;
  --c-sage-strong: #2f4a3c;
  --c-sage-wash: #e4eee4;
  --c-cell: #efefec;
  --c-well: #e6e6e2;
  --c-cell-ink: #2c2e31;
  --c-scrim: rgba(30, 32, 35, 0.38);
  --c-handle: #c9cbc6;
  --c-blue: #2f63d6;


  /* Fit-check palette from the reviewed design. */
  --fit-bg: #f5f2ed;
  --fit-card: #fffefb;
  --fit-line: #e0dbd2;
  --fit-text: #2a2520;
  --fit-soft: #6f655b;
  --fit-muted: #8a8178;
  --fit-accent: #4a6b5a;
  --fit-accent-dark: #2d5a3f;
  --fit-accent-wash: #e8f0ec;
  --fs-fit-count: 28px;
  --w-fit-compare-label: 64px;

  /* External sign-in button colours. */
  --c-google-ink: #3c4043;
  --c-google-line: #dadce0;
  --c-google-pressed: #f7f8f8;

  /* state colours */
  --c-danger: #b3402f;
  --c-danger-strong: #8e2f22;
  --c-danger-line: #e8c9c4;
  --c-danger-wash: #f9ecea;
  --c-warn: #a97c22;
  --c-warn-strong: #8a6417;
  --c-warn-line: #c99a3f;
  --c-blue-strong: #1d4ed8;
  --c-sage-mid: #7a9e8a;
  --c-shadow-s: rgba(0, 0, 0, 0.14);
  --c-shadow-m: rgba(0, 0, 0, 0.2);
  --c-press: rgba(0, 0, 0, 0.08);
  --c-glass: rgba(255, 255, 255, 0.5);
  --c-swatch-line: rgba(0, 0, 0, 0.2);

  /* chart (the knitting chart's own palette) */
  --ch-def-bg: #f8f9fb;
  --ch-def-border: #bcc9d8;
  --ch-def-symbol: #3d5170;
  --ch-active-bg: var(--c-sage-wash);
  --ch-active-border: var(--c-sage);
  --ch-active-symbol: var(--c-sage-strong);
  --ch-empty-bg: #dde1e7;
  /* Distinct from --ch-blue on purpose — that's the mid-row drag marker's colour (see
     .mid-row-line/.mid-row-handle), and a combined-chart's source-panel divider (.cc-seg-end)
     needs to read as a different kind of line at a glance. */
  --ch-purple: #8b5cf6;

  /* shape */
  --r-card: 12px;
  --r-control: 10px;
  --r-small: 8px;
  --r-sheet: 16px;
  --r-round: 50%;
  --r-pill: 999px;
  --r-cell: 4px;
  --r-progress: 3px;
  --r-checkbox: 5px;
  --r-swatch: 2px;

  /* space (multiples of 4) */
  --s-1: 4px;
  --s-2: 8px;
  --s-2h: 6px;
  --s-3: 12px;
  --s-3h: 14px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;

  /* type */
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-ui: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --fs-instruction: 21px;
  --fs-title: 16px;
  --fs-heading: 18px;
  --fs-body: 14px;
  --fs-meta: 13px;
  --fs-lead: 15px;
  --fs-small: 12px;
  --fs-caps: 11px;
  --fs-micro: 10px;
  /* Sizes retained for existing library, sheet and large action treatments. */
  --fs-tiny: 8px;
  --fs-tiny-plus: 9px;
  --fs-meta-half: 13.5px;
  --fs-brand: 1.05rem;
  --fs-sheet-title: 1.2rem;
  --fs-page-title: 1.25rem;
  --fs-phase-title: 1.35rem;
  --fs-icon-large: 20px;
  --fs-stepper-large: 26px;
  --fs-fab: 30px;
  --fs-fab-large: 48px;
  --ls-caps: .12em;
  --ls-label: .1em;
  --ls-small: .08em;
  --ls-tag: .04em;
  --ls-hint: .02em;
  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* sizes */
  --h-bar: 56px;
  --h-btn: 54px;
  --h-icon: 36px;
  --h-chart-min: 205px;
  --h-cell: 24px;
  --h-cell-mini: 18px;
  --h-dock: 86px;
  --h-tap: 44px;
  --h-status-dot: 12px;
  --w-handle: 40px;
  --h-handle: 5px;
  --w-kv-label: 96px;
  --w-mrow-input: 88px;
  --w-mrow-unit: 20px;
  --h-step: 48px;
  --w-step-input: 72px;
  --w-column: 640px;
  --w-navbtn: 52px;
  --h-check: 22px;
  --h-seg-icon: 16px;
  --h-badge-icon: 12px;
  --w-rownum: 58px;
  /* fit screen (js/core/fitScreen.js): the fits-band bar and the number fields */
  --h-fit-bar: 10px;
  --h-fit-dot: 14px;
  --h-fit-tick: 18px;
  --w-fit-num: 88px;
  --fs-input: 16px;   /* 16px or iOS zooms the page on focus */
  /* fit diagram (js/core/fitDiagram.js): the box, its outline and dimension strokes
     (SVG units, drawn non-scaling so they are screen px), and the result tags */
  --w-fit-diagram: 480px;     /* width cap; .fit-diagram also caps width so its height stays near 40vh */
  --w-fit-diagram-min: 254px; /* tags clear each other from here up (fitShapes.js); wins over the 40vh cap */
  --h-fit-diagram-max: 40vh;  /* rough: tolerates a toolbar's worth of vh mis-report */
  --sw-fit-outline: 1.25;
  --sw-fit-detail: 1;
  --sw-fit-dim: 1.5;
  --sw-fit-dim-sel: 3;
  --da-fit-unknown: 3 3;
  --c-fit-outline: var(--c-muted);
  --c-fit-fill: var(--c-card);
  --c-fit-detail: var(--c-line);
  --fs-fit-tag-s: var(--fs-micro);   /* phone-width size; scaled up with the box below where cqi works */
  --fs-fit-tag-v: var(--fs-caps);
  --h-fit-tag-hit: var(--h-tap); /* tap target, one-handed on a phone */
  --w-fit-tag-max: 34%;       /* of the box; the short label truncates first */
  /* fit result cards: a strip under the diagram, full-bleed past the page gutter */
  --w-fit-bleed: 0.75rem;     /* the fit screen's side gutter: .content's padding there (ui.css), and the top bar's */
  --w-fit-card: 360px;
  --w-fit-peek: 64px;         /* room for the next card and a smaller previous-card preview */
  --w-fit-peek-prev: 32px;    /* reveal the previous card after scrolling */
  --h-fit-sec: 20px;          /* the strip's band for section labels */

  /* restored with the components in css/components.css */
  --accent-pressed: var(--c-sage-strong);
  --ch-blue-pressed: #1d4ed8;
  --danger: #a4553f;
  --danger-bg: #f7ece8;
  --danger-border: #e4c7bd;
  --danger-pressed: #8e4634;
  --danger-text: #8e4634;
  --on-accent: var(--c-card);
  --radius-pill: 999px;
  --radius-xs: 6px;
  --shadow-fab: 0 4px 14px rgba(0, 0, 0, .22);
  --text-pressed: #444;
  /* legacy bridge: the app's older variables follow the tokens, which restyles the
     screens that still use them without touching their selectors or layout */
  --bg: var(--c-bg);
  --card: var(--c-card);
  --border: var(--c-line);
  --text: var(--c-text);
  --muted: var(--c-muted);
  --accent: var(--c-sage);
  --accent-light: var(--c-sage-wash);
  --done-bg: var(--c-sage-wash);
  --done-text: var(--c-sage-strong);
  --ch-blue: var(--c-blue);
  --accent-mid: var(--c-sage-mid);
  --checkbox-done: var(--c-muted);
  --phase-band-bg: var(--c-line);
  --radius: var(--r-card);
  --radius-sm: var(--r-small);
}

/* Fit diagram tags scale with their box (container units). Only where cqi is supported:
   inside a custom property an unsupported unit would make font-size invalid at computed
   time and fall back to the inherited 16px, not to an earlier declaration. */
@supports (width: 1cqi) {
  :root {
    --fs-fit-tag-s: clamp(var(--fs-micro), 2.6cqi, var(--fs-small));
    --fs-fit-tag-v: clamp(var(--fs-caps), 2.9cqi, var(--fs-meta));
  }
}
