/* The two faces the design system names, served from here and from nowhere else.
   `I27`. Until 2026-08-09 they were fetched from `fonts.googleapis.com` on every load,
   which sent the signing person's IP address — and the fact that they use GROMA — to a
   processor outside the EU that the DPA does not list (SECURITY.md invariant 17). The
   files are OFL; the licences travel with them in `web/fonts/`.

   `size-adjust` is deliberately absent: the fallbacks in the stacks below are system
   faces, and tuning a metric override against whatever the operating system happens to
   provide is a number nobody can verify.

   `font-display: swap` — the queue must be readable before a font arrives. A signing
   surface that is blank while a face downloads is worse than one in the wrong typeface. */

@font-face {
  font-family: "Archivo";
  /* Variable on `wght` only. The full font carries `wdth` 62–125 as well and costs 156 KB
     subset instead of 56; the design system reserves the condensed for kickers, and no
     screen draws one. When one does, this file is replaced with the two-axis build — a
     decision worth making with the screen in front of you, not by paying 100 KB on every
     load of the signing queue for a width nobody uses. */
  src: url("../fonts/archivo-latin.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/*
 * GROMA product tokens — delivery scaffold (Q5 / B1 / B2).
 * Normative rules: docs/design/design-system.md
 * Exact artifact hex for residual tokens: see web/HANDOFF.md
 * Namespace for components: .g-*
 */

:root {
  color-scheme: light;
  /* Surfaces */
  --carta: #f8f9f7;
  --foglio: #ffffff;
  --fondo-app: #eff1eb;
  --foglio-2: #f3f5f0;
  --chrome: #20282b;

  /* Brand & semantic */
  --verde: #2c5741;
  --timbro: #9e2b25;
  --arancio: #c2510a;
  --success: #217a48;
  --warning: #8a5a06;
  --destructive: #c0303a;
  --on-action: #f3f5f0;
  /* Darker than --arancio for text on carta (DS: arancio alone is 4.4:1 on carta) */
  --arancio-txt: #9a4208;

  /* Status badges — ten closed tokens (ADR-0014 + design system) */
  --st-fatto: var(--success);
  --st-corso: var(--arancio-txt);
  --st-programmata: #5a6560;
  --st-verifica: var(--warning);
  --st-eccezione: var(--timbro);
  --st-firma: var(--timbro);
  --st-approvato: var(--verde);
  /* B1: revision loop — never a terminal refusal */
  --st-revisione: var(--arancio-txt);
  /* B2: terminal refusal → Core posts kind:abandon */
  --st-rifiutato: var(--destructive);
  /* Was #6b7280 = 4.40:1 on --foglio-2, the only one of the ten under AA 4.5:1 — and it is
     the badge a person reads when a connector is off. Darkened within the same family; the
     ratios of all ten are now computed by a gate instead of asserted in a comment. */
  --st-sospeso: #5f6772;

  /* Typography stacks (faces loaded by the shell) */
  --sans: "Archivo", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  /* Type scale (design-system.md) */
  --fs-31: 1.9375rem;
  --fs-25: 1.5625rem;
  --fs-20: 1.25rem;
  --fs-17: 1.0625rem;
  --fs-15: 0.9375rem;
  --fs-13: 0.8125rem;
  /* `--fs-12` was 0.75rem = 12.0px — below the floor the DS sets at 12,5px, on real text:
     queue meta, the ageing warning, field hints, `.g-hash`, `&lt;dt&gt;`, the Esci button. The gate
     that exists for this read only `--fs-10` and so never saw it. The two bottom names are
     historical and now share the floor: meta stays smaller than dense text, and nothing goes
     under 12,5px. */
  --fs-12: 0.78125rem;
  /* Named fs-10 historically; floor is 12.5px (DS criterion 6). Never 10px. */
  --fs-10: 0.78125rem;

  /* Space base 4px */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4rem;

  /* Layout (design-system + ADR-0021) */
  --w-sidebar: 232px;
  --h-topbar: 56px;
  /* Page padding: fluid via media queries in shell.css (s5 → s4 → s3) */
  --pad-page-x: var(--s5);
  --pad-page-y: var(--s5);
  --pad-page-bottom: var(--s7);
  --content-max: 56rem;
  /* Touch: WCAG 2.5.5 / Apple HIG-ish 44px; design system mobile buttons */
  --touch-min: 2.75rem;
  --bordo: #d8ddd6;
  /* ≥3:1 on --foglio / --carta (WCAG 1.4.11). Decorative --bordo stays lighter. */
  --bordo-input: #6e786e;
  --ink: #20282b;
  /* ≥7:1 on --carta (AAA 1.4.6). Was #5c6560 ≈5:1 — AA only. Hue unchanged. */
  --ink-muted: #3a4240;
  --r-card: 0.5rem;
  --r-control: 0.35rem;
  /* One restrained elevation for cards; hierarchy comes from spacing and rules. */
  --shadow-card: 0 1px 2px rgba(32, 40, 43, 0.08);

  /* Motion — restrained; prefer-reduced-motion kills these in ui.css */
  --motion-fast: 120ms;
  --motion-med: 1.2s;
  --ease-standard: ease;

  /*
   * Breakpoints (media queries cannot use custom props portably — keep in sync):
   *   ≥1024px  desktop: sidebar 232px
   *   ≤1023px  tablet: one compact chrome row + drawer
   *   ≤859px   dense page pad (design-system: 16px under 860px)
   *   ≤640px   phone; product target 375px (S13 / A-17)
   *
   * Più uno guidato dal contenuto e non dal dispositivo, che per questo non sta nella scala:
   *   ≤1180px  `shell.css` nasconde `.g-topbar__roles` — i chip di ruolo chiedono ~280px e
   *            sotto quella misura mandano «Esci» a capo. È scritto qui perché un breakpoint
   *            che nessun documento nomina si legge come una svista, e questo non lo è.
   */
}

html[data-theme="scuro"] {
  color-scheme: dark;
  --carta: #171d1b;
  --foglio: #1d2522;
  --fondo-app: #111715;
  --foglio-2: #26302c;
  --verde: #7cc99f;
  --timbro: #ff8a82;
  --arancio: #ff9a4c;
  --success: #6fd49a;
  --warning: #f4c15d;
  --destructive: #ff8a92;
  --on-action: #15201b;
  --arancio-txt: #ffad66;
  --st-fatto: #6fd49a;
  --st-corso: #ffad66;
  --st-programmata: #b9c2bd;
  --st-verifica: #f4c15d;
  --st-eccezione: #ff8a82;
  --st-firma: #ff8a82;
  --st-approvato: #8bd6a9;
  --st-revisione: #ffad66;
  --st-rifiutato: #ff8a92;
  --st-sospeso: #c1c7d0;
  --bordo: #46524c;
  --bordo-input: #8d9a93;
  --ink: #f3f5f0;
  --ink-muted: #c4cec8;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.42);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="sistema"] {
    color-scheme: dark;
    --carta: #171d1b;
    --foglio: #1d2522;
    --fondo-app: #111715;
    --foglio-2: #26302c;
    --verde: #7cc99f;
    --timbro: #ff8a82;
    --arancio: #ff9a4c;
    --success: #6fd49a;
    --warning: #f4c15d;
    --destructive: #ff8a92;
    --on-action: #15201b;
    --arancio-txt: #ffad66;
    --st-fatto: #6fd49a;
    --st-corso: #ffad66;
    --st-programmata: #b9c2bd;
    --st-verifica: #f4c15d;
    --st-eccezione: #ff8a82;
    --st-firma: #ff8a82;
    --st-approvato: #8bd6a9;
    --st-revisione: #ffad66;
    --st-rifiutato: #ff8a92;
    --st-sospeso: #c1c7d0;
    --bordo: #46524c;
    --bordo-input: #8d9a93;
    --ink: #f3f5f0;
    --ink-muted: #c4cec8;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.42);
  }
}
