/*
 * Grosik design tokens. OWNER: workstream A (Design). Rules: DESIGN.md.
 *
 * World: the transfer slip. Two inks on one sheet. "Print" (carbon violet) is the form the
 * app prints: labels, rules, boxes, chrome. "Ink" (ballpoint blue-black) is what people
 * wrote in: names, titles, amounts. Light = bond paper; dark = the carbon sheet.
 * Contrast figures for every text pair are in DESIGN.md §3 (computed by design/contrast.mjs).
 */

@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('./fonts/ahn-latin.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('./fonts/ahn-latin-ext.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;

  /* ---- Type ---------------------------------------------------------------- */
  --font-ui: 'Atkinson Hyperlegible Next', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Arabic', 'Noto Sans Hebrew', sans-serif;
  /* Figures: the same face with tabular (fixed-width) digits, so columns of money line up. */
  --font-fig: var(--font-ui);
  --font-key: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Noto Sans Mono', monospace; /* keycaps only */

  /* Strict scale: six steps, nothing in between. */
  --t-xs: 0.75rem;   /* 12  printed field labels (small caps), meta */
  --t-sm: 0.875rem;  /* 14  secondary lines, rate lines */
  --t-md: 1rem;      /* 16  body, list titles, inputs */
  --t-lg: 1.25rem;   /* 20  screen titles, sheet titles */
  --t-xl: 1.75rem;   /* 28  balance statement */
  --t-2xl: 2.5rem;   /* 40  the amount being typed */

  --lh-tight: 1.15;
  --lh-ui: 1.35;
  --lh-body: 1.5;

  --w-regular: 400;
  --w-medium: 530;
  --w-bold: 680;

  --label-tracking: 0.06em;

  /* ---- Space (4 px grid) --------------------------------------------------- */
  --s-1: 0.25rem;  /*  4 */
  --s-2: 0.5rem;   /*  8 */
  --s-3: 0.75rem;  /* 12 */
  --s-4: 1rem;     /* 16 */
  --s-5: 1.5rem;   /* 24 */
  --s-6: 2rem;     /* 32 */
  --s-7: 3rem;     /* 48 */
  --s-8: 4rem;     /* 64 */

  --tap: 2.75rem;        /* 44 px minimum touch target (WCAG 2.5.8 asks 24; we use 44) */
  --tap-lg: 3.25rem;     /* 52 px dock buttons */
  --measure: 68ch;

  /* ---- Shape --------------------------------------------------------------- */
  --r-0: 0;
  --r-1: 3px;    /* every box on the form: fields, buttons, chips */
  --r-2: 6px;    /* sheets, toasts, the dock */
  --rule: 1px;   /* one rule weight for everything printed */
  --rule-strong: 2px; /* totals rule, focus ring */

  /* ---- Motion -------------------------------------------------------------- */
  --dur-1: 120ms;  /* press, toggle */
  --dur-2: 200ms;  /* expand, colour */
  --dur-3: 320ms;  /* sheet in, stamp */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);   /* expo out */
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);

  /* ---- Layers -------------------------------------------------------------- */
  --z-dock: 20;
  --z-banner: 30;
  --z-sheet: 40;
  --z-toast: 50;

  /* ---- Colour: light, "bond paper" ----------------------------------------- */
  --paper: oklch(0.985 0.004 290);        /* page */
  --paper-sunk: oklch(0.962 0.009 290);   /* field fill, list hover */
  --paper-desk: oklch(0.945 0.012 290);   /* desktop ground behind the sheets */
  --paper-raised: oklch(1 0 0);           /* sheets, toasts (with shadow) */

  --ink: oklch(0.24 0.035 272);           /* data the people wrote: names, titles, amounts */
  --ink-2: oklch(0.44 0.03 278);          /* secondary data: dates, rate lines */

  --print: oklch(0.47 0.15 300);          /* the form's own ink: labels, codes, icons */
  --print-strong: oklch(0.40 0.17 298);   /* primary fill */
  --print-box: oklch(0.58 0.11 300);      /* control borders (≥3:1 on paper) */
  --print-rule: oklch(0.86 0.04 300);     /* decorative hairlines, dividers */
  --print-wash: oklch(0.94 0.03 300);     /* selected chip, active tab, focus field tint */
  --on-print: oklch(0.99 0.005 300);      /* text on --print-strong */

  --owe: oklch(0.49 0.17 28);             /* negative: owes */
  --owe-wash: oklch(0.95 0.03 28);
  --owed: oklch(0.46 0.11 155);           /* positive: gets back, paid stamp */
  --owed-wash: oklch(0.95 0.035 155);
  --warn: oklch(0.47 0.10 70);            /* offline, waiting, needs attention text */
  --warn-wash: oklch(0.955 0.045 85);
  --danger: oklch(0.49 0.19 25);          /* destructive buttons, sync error */
  --danger-wash: oklch(0.955 0.03 25);
  --on-danger: oklch(0.99 0.005 25);

  --focus: oklch(0.50 0.22 300);          /* focus ring */
  --scrim: oklch(0.22 0.04 290 / 0.42);
  --selection: oklch(0.86 0.08 300);

  --shadow-1: 0 1px 2px oklch(0.25 0.04 290 / 0.10), 0 1px 1px oklch(0.25 0.04 290 / 0.06);
  --shadow-2: 0 -6px 24px oklch(0.25 0.05 290 / 0.16), 0 -1px 3px oklch(0.25 0.05 290 / 0.08);
  --shadow-3: 0 10px 30px oklch(0.25 0.05 290 / 0.20), 0 2px 6px oklch(0.25 0.05 290 / 0.10);

  /* Avatar hues: 8 tints, all with --ink text ≥ 7:1 */
  --av-l: 0.88;
  --av-c: 0.06;
}

/* ---- Colour: dark, "the carbon sheet" -------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: oklch(0.195 0.022 288);
    --paper-sunk: oklch(0.235 0.028 288);
    --paper-desk: oklch(0.165 0.02 288);
    --paper-raised: oklch(0.255 0.03 288);
    --ink: oklch(0.95 0.01 290);
    --ink-2: oklch(0.78 0.02 290);
    --print: oklch(0.79 0.10 300);
    --print-strong: oklch(0.80 0.11 300);
    --print-box: oklch(0.60 0.09 300);
    --print-rule: oklch(0.34 0.04 295);
    --print-wash: oklch(0.31 0.06 298);
    --on-print: oklch(0.19 0.03 290);
    --owe: oklch(0.76 0.13 30);
    --owe-wash: oklch(0.28 0.05 28);
    --owed: oklch(0.79 0.12 155);
    --owed-wash: oklch(0.27 0.045 155);
    --warn: oklch(0.82 0.11 80);
    --warn-wash: oklch(0.28 0.045 80);
    --danger: oklch(0.74 0.15 25);
    --danger-wash: oklch(0.28 0.055 25);
    --on-danger: oklch(0.18 0.03 25);
    --focus: oklch(0.82 0.13 300);
    --scrim: oklch(0.08 0.02 290 / 0.6);
    --selection: oklch(0.42 0.10 300);
    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.35);
    --shadow-2: 0 -6px 24px oklch(0 0 0 / 0.45), 0 -1px 3px oklch(0 0 0 / 0.3);
    --shadow-3: 0 10px 30px oklch(0 0 0 / 0.5), 0 2px 6px oklch(0 0 0 / 0.3);
    --av-l: 0.40;
    --av-c: 0.07;
  }
}
:root[data-theme='dark'] {
  --paper: oklch(0.195 0.022 288);
  --paper-sunk: oklch(0.235 0.028 288);
  --paper-desk: oklch(0.165 0.02 288);
  --paper-raised: oklch(0.255 0.03 288);
  --ink: oklch(0.95 0.01 290);
  --ink-2: oklch(0.78 0.02 290);
  --print: oklch(0.79 0.10 300);
  --print-strong: oklch(0.80 0.11 300);
  --print-box: oklch(0.60 0.09 300);
  --print-rule: oklch(0.34 0.04 295);
  --print-wash: oklch(0.31 0.06 298);
  --on-print: oklch(0.19 0.03 290);
  --owe: oklch(0.76 0.13 30);
  --owe-wash: oklch(0.28 0.05 28);
  --owed: oklch(0.79 0.12 155);
  --owed-wash: oklch(0.27 0.045 155);
  --warn: oklch(0.82 0.11 80);
  --warn-wash: oklch(0.28 0.045 80);
  --danger: oklch(0.74 0.15 25);
  --danger-wash: oklch(0.28 0.055 25);
  --on-danger: oklch(0.18 0.03 25);
  --focus: oklch(0.82 0.13 300);
  --scrim: oklch(0.08 0.02 290 / 0.6);
  --selection: oklch(0.42 0.10 300);
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.35);
  --shadow-2: 0 -6px 24px oklch(0 0 0 / 0.45), 0 -1px 3px oklch(0 0 0 / 0.3);
  --shadow-3: 0 10px 30px oklch(0 0 0 / 0.5), 0 2px 6px oklch(0 0 0 / 0.3);
  --av-l: 0.40;
  --av-c: 0.07;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-1: 0ms;
    --dur-2: 0ms;
    --dur-3: 0ms;
  }
}
