/*
 * fonts.css - the ONE font-face declaration for the whole Construct portfolio.
 *
 * SOURCE OF TRUTH. This file lives at packages/brand/fonts/fonts.css and is
 * mirrored byte-for-byte into every sites/<slug>/public/fonts.css by
 * `scripts/sync-fonts.sh`. `packages/template/src/lib/fonts.test.ts` fails if
 * any copy drifts, so there is exactly one place to change a font decision.
 *
 * WHY A SELF-HOSTED FONT AT ALL (the case is not aesthetic).
 * Before this the portfolio ran `system-ui, -apple-system, "Segoe UI", Roboto,
 * Helvetica, Arial, sans-serif`. Three consequences, all measured:
 *
 *   1. `Roboto` in that stack is an LVL reflex-reject family (typography.md).
 *      It shipped in all 38 tokens.css files.
 *   2. Every spatial guarantee in this design system was only true on ONE
 *      platform. x-height, cap-height and digit advance differ between SF,
 *      Segoe UI and Roboto, so a 48px tap target, a 45-to-75ch line length and
 *      a card height measured in headless Chromium on macOS were claims about
 *      macOS, not about the site. A self-hosted face makes a measurement
 *      portable, which is the whole reason this pass exists.
 *   3. Digit alignment was per-platform luck. MEASURED in this subset: every
 *      digit advances 572/1000 em and `$` matches at 572, so figures are
 *      tabular by construction. On a portfolio of 38 calculators that is a
 *      functional property, not a nicety.
 *
 * WHY NOTO SANS. It is the owner-ratified brand type: the Big Rig Math mark
 * (owner-selected 2026-07-29, "going with #1") specifies "Type: Noto Sans" and
 * sets the wordmark in Noto Sans Condensed Black. Adopting it here needs no
 * logo re-render, because a wordmark is allowed a width variant the running UI
 * does not use. It also carries the widest glyph repertoire of the three
 * candidates considered, which matters directly: 16 name-generator sites plus
 * the calculators put diacritics, currency and math signs into shipped copy.
 *
 * THE FILE. `noto-sans-lattice.woff2`, 39,248 bytes, one variable axis
 * `wght 350..700`, 510 glyphs. Derived from the OFL release of
 * Noto Sans (see BUILD.md for the exact reproducible command and the source
 * SHA-256). OFL.txt ships beside it because OFL 1.1 requires the licence to
 * travel with the font.
 *
 * WEIGHT RANGE. 350 is the low bound because LVL typography sets body weight
 * to 350 on a dark canvas (the whole trucker family is dark) and 400 on light.
 * 700 is the top because headings top out there. Widening to 350..800 measured
 * 46,128 bytes for a weight nothing uses: 7KB of nothing.
 *
 * NO THIRD-PARTY CDN, deliberately. A Google Fonts or jsDelivr <link> is a
 * third-party request on a YMYL page that also has to satisfy a consent banner,
 * and since browsers partitioned the HTTP cache (Chrome 86, 2020) a shared CDN
 * origin buys zero cross-site cache reuse while costing a DNS lookup and a TLS
 * handshake on the critical path. Same-origin and preloaded beats it outright.
 */

@font-face {
  font-family: "Noto Sans Lattice";
  font-style: normal;
  /* The whole 350..700 axis in one file. `font-weight: 350 700` is what tells
     the browser this face covers the range, so a `font-weight: 600` heading
     interpolates instead of being synthetically emboldened. */
  font-weight: 350 700;
  font-display: swap;
  src: url("/fonts/noto-sans-lattice.woff2") format("woff2-variations");
}

/*
 * METRIC-MATCHED FALLBACK (the CLS guarantee).
 *
 * `font-display: swap` means the first paint uses a fallback face and the real
 * face swaps in when it arrives. Without matched metrics that swap reflows
 * every line box on the page, which is a Cumulative Layout Shift on the exact
 * frame the reader starts reading.
 *
 * So the fallback is not left to chance: this face is a metric OVERRIDE over
 * the platform's Arial-class grotesque, scaled so its x-height and its line
 * box match Noto Sans exactly. Numbers derived from measured font tables, not
 * estimated:
 *
 *   Noto Sans Lattice : upem 1000, xHeight 536, ascent 1069, descent 293, gap 0
 *   Arial             : upem 2048, xHeight 1062              (measured locally)
 *
 *   size-adjust      = (536/1000) / (1062/2048)      = 103.364%
 *   ascent-override  = (1069/1000) / 1.033639        = 103.421%
 *   descent-override = ( 293/1000) / 1.033639        =  28.346%
 *   line-gap-override= 0
 *
 * (The overrides divide by size-adjust because size-adjust scales the
 * overridden metrics too.)
 *
 * `local()` targets the one metrically-close grotesque that exists on every
 * target platform: Helvetica Neue on macOS and iOS, Arial on Windows,
 * Liberation Sans on Linux. Helvetica's x-height ratio differs from Arial's by
 * 0.85%, which is sub-pixel at 17px. If none resolve, the stack falls through
 * to `system-ui` unadjusted, which is still legible: this is insurance, not a
 * dependency.
 */
@font-face {
  font-family: "Noto Sans Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Liberation Sans");
  size-adjust: 103.364%;
  ascent-override: 103.421%;
  descent-override: 28.346%;
  line-gap-override: 0%;
}
