/*
 * Face declarations and the family stack. Nothing else.
 *
 * DESIGN_SPEC §§2.2, 2.5, 2.8 and ADR-005 decision 1 own every value here. This file exists
 * separately from globals.css because `tokens.test.ts` asserts that file holds `:root` and
 * nothing else — no @font-face, no @import. That is the correct division: globals.css is
 * where a value comes from, this is where a face comes from.
 *
 * NO HEX LITERAL, per ADR-004 §8 rule 6, which greps `.css` under src/render/. Logical
 * properties only, per CLAUDE.md §11. Neither constraint has anything to declare here, and
 * both are stated so the next editor of this file inherits them.
 *
 * THE BINARIES ARE NOT SERVED YET. `loadStylesheets` in src/server/main.ts picks this sheet
 * up from the directory listing, so it is served the moment it exists; nothing serves
 * /fonts/. Every `src:` below therefore 404s until a binary route is wired. That is
 * expected and is not worked around here — no base64, no alternative path.
 *
 * SUBSETS: `latin` and `arabic`. English and Arabic are the priority (2026-08-26 scope
 * change; the 2026-08-24 English-only cut no longer holds at the font layer). latin-ext,
 * Nastaliq and Bengali are NOT placed; src/render/fonts/MANIFEST.json enumerates them with
 * measured sizes and the reasons.
 */

/* --------------------------------------------------------------------------------------
 * IBM Plex Sans Arabic — the whole Latin-script product surface.
 *
 * DESIGN_SPEC §2.5: ONE family, TWO weights, 400 and 600. No 300, no 500, no 700, and
 * never a synthesised third. Adding a weight here means adding a --weight-* token, and
 * tokens.test.ts asserts there are exactly two.
 *
 * The `latin` files carry the harmonised Latin that DESIGN_SPEC §2.2 reason 1 rests on and
 * §2.9 required someone to confirm. Confirmed 2026-08-26 by reading the cmap out of these
 * exact files: 225 codepoints, full ASCII and Latin-1. ADR-005 decision 2 stands.
 * ------------------------------------------------------------------------------------ */

@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 400;
  /*
   * DESIGN_SPEC §2.8, and NOT `swap`. The Arabic fallback metrics differ enough that a swap
   * reflows the question block after paint, and on a fixed kiosk a person may already be
   * reaching for an option when it moves. `optional` accepts a fallback first paint on a
   * cold cache in exchange for never moving the target.
   */
  font-display: optional;
  src: url('/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2') format('woff2');
  /*
   * The subset, declared rather than implied, so a character outside it degrades to the
   * fallback stack instead of silently coming from a file that does not contain it. Range
   * copied from the source package's own unicode.json for the `latin` subset.
   */
  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: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: optional;
  src: url('/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2') format('woff2');
  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;
}

/* --------------------------------------------------------------------------------------
 * IBM Plex Sans Arabic — the Arabic script.
 *
 * Same family, same two weights, same file set as the Latin above: DESIGN_SPEC §2.2 chose
 * ONE family for `ar` and `en` and this is what that means in files. Placed 2026-08-26 when
 * Arabic moved from deferred to priority alongside English.
 *
 * THIS FILE CARRIES NO LETTERFORMS OUTSIDE ARABIC. Below U+0300 it holds exactly four
 * codepoints — .notdef, CR, space, nbsp — read out of its own cmap. So an Arabic surface
 * loads FOUR files, not two: every Arabic screen also carries latn digits and ASCII
 * identifiers (§13.2), and those come from the latin files above. That is a fact about the
 * preload budget in §2.8, which says "the two weights of the active locale's face" and is
 * counting for a Latin locale.
 *
 * Arabic is the reference locale for layout (CLAUDE.md §6), and it is the locale §2.8's
 * argument for `font-display: optional` was actually written about: the Arabic fallback
 * metrics differ enough from Plex Arabic that a swap reflows the question block after
 * paint. So `optional` is kept here without qualification — it is more motivated on these
 * two faces than on the Latin ones, not less.
 *
 * §2.7's per-script metric multipliers (size ×1.06, line-height ×1.10) are NOT here. They
 * are two custom properties set on the <html> element per locale, which is render-layer
 * work and belongs with the locale routing, not with the face declarations.
 * ------------------------------------------------------------------------------------ */

@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: optional;
  src: url('/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2') format('woff2');
  /* Range copied from the source package's own unicode.json for the `arabic` subset. */
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC,
    U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F,
    U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42,
    U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59,
    U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72,
    U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3,
    U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: optional;
  src: url('/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC,
    U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F,
    U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42,
    U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59,
    U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72,
    U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3,
    U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

/* --------------------------------------------------------------------------------------
 * IBM Plex Mono — DESIGN_SPEC §2.5's one exception, enumerated so it stays checkable.
 *
 * 400 ONLY. Four uses, all on the clinician surface, all identifiers a reviewer compares
 * character by character: rule ids, cartridge ids, version strings, the encounter short-id.
 * Mono never carries prose, never appears on the patient surface, never appears in a
 * heading. A fifth use is a defect, and a 600 here would be the first step toward one.
 *
 * Latin only in every locale: §2.7 does not multiply --type-report-mono because §13.2
 * renders ASCII identifiers in every locale. There is no second subset of this face to add.
 * ------------------------------------------------------------------------------------ */

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: optional;
  src: url('/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
  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;
}

/* --------------------------------------------------------------------------------------
 * The stacks.
 *
 * ADR-005 decision 1 states the sans stack verbatim and calls it unchanged; it is
 * reproduced here character for character rather than paraphrased. "Noto Sans Arabic" sits
 * second because DESIGN_SPEC §2.3 keeps it as the fallback precisely for its metric
 * proximity to Plex Arabic — that is what a fallback is for.
 *
 * These two properties are declared here rather than in globals.css only because that file
 * is sealed by tokens.test.ts and by this session's file scope. If the token sheet is ever
 * the right home for them, they move as a pair and this comment goes with them.
 * ------------------------------------------------------------------------------------ */

:root {
  --font-sans: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

/*
 * The lowest-specificity rule that can exist, so every surface sheet overrides it by simply
 * existing. Without it the faces above are inert and the product renders in the browser's
 * default serif, which is the state this file was written to end.
 */
html {
  font-family: var(--font-sans);
}
