/*
 * Literata, self-hosted.
 *
 * ═══════════════════════════════════════════════════════════════════════════
 * WHY THIS FILE EXISTS
 * ═══════════════════════════════════════════════════════════════════════════
 *
 * index.html carried this, for months, as a shipping TODO:
 *
 *     TODO(app-store): self-host this before submission. A remote font means
 *     the native app renders in a fallback face whenever the device is
 *     offline, which is a visible regression Apple reviewers do hit.
 *
 * That was the known cost. Two more were found by looking:
 *
 * 1. EVERY SCREENSHOT THIS REPO HAS EVER TAKEN WAS IN THE WRONG FACE.
 *    `scripts/audit-a11y.mts` cuts third-party origins so its perf numbers are
 *    the app's own, and it prints the list it cut — fonts.googleapis.com is on
 *    it. So the harness renders Literata's `serif` fallback, and so does every
 *    App Store screenshot, every welcome slice, and every contrast measurement
 *    taken through it. The type on those images is not the type that ships.
 *    Self-hosting is what makes the instrument show the product.
 *
 * 2. A WALLET'S FRONT DOOR ANNOUNCED EVERY VISITOR TO A THIRD PARTY.
 *    Two preconnects and a render-blocking stylesheet meant loading /welcome
 *    told fonts.googleapis.com and fonts.gstatic.com that a browser at that IP
 *    had arrived, before the reader chose anything. Nothing else on the page
 *    does that; it is the only third party in the critical path.
 *
 * ─── WHAT IS AND IS NOT BUNDLED ───────────────────────────────────────────
 *
 * Two files, 153KB total, both variable across the 400–700 weight range this
 * app uses — one variable file per subset serves both weights, which is why
 * each rule below declares `font-weight: 400 700` rather than being duplicated.
 *
 * `latin-ext` is NOT optional here. Hawaiian orthography needs U+0100–017F for
 * the kahakō (ā, ē, ī, ō, ū) — "Kāneʻohe" is on the welcome page — and dropping
 * that subset would render the macrons as fallback-face glyphs mid-word. The
 * ʻokina (U+02BB) is in the `latin` range.
 *
 * ITALICS ARE DELIBERATELY ABSENT. Google serves them as two more files, 156KB,
 * and the entire app contains three italic spans. The browser synthesises an
 * oblique for those; paying 156KB on every first load of a wallet for three
 * words of emphasis is not a trade worth making.
 *
 * ─── REGENERATING ─────────────────────────────────────────────────────────
 *
 * Google revs the `v40` path when it reissues the family, at which point these
 * files stop matching upstream (they keep working — they are ours now). To
 * refresh: request the css2 URL with a modern browser User-Agent (a plain curl
 * gets TTF, not WOFF2), keep the `latin` and `latin-ext` normal blocks, and
 * download each `src` URL into this directory.
 */

/* latin */
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/literata-latin.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;
}

/* latin-ext */
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/literata-latin-ext.woff2) format('woff2');
  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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/*
 * ═══════════════════════════════════════════════════════════════════════════
 * A FALLBACK WITH LITERATA'S METRICS, SO THE SWAP MOVES NOTHING
 * ═══════════════════════════════════════════════════════════════════════════
 *
 * `font-display: swap` renders the fallback first and replaces it when the
 * webfont arrives. If the two have different metrics, that replacement
 * RELAYS OUT THE PAGE — and Literata is not close to the default serif.
 * Measured in a browser at 100px, same string:
 *
 *     Literata   width 2656.2   ascent 118%   descent 31%
 *     serif      width 2378.2   ascent  89%   descent 22%
 *
 * 11.7% wider, and a line box half again as tall. The boundary sweep caught
 * the consequence on /welcome: 0.134 cumulative layout shift against a 0.02
 * budget, in two jumps of 57px and 68px, as the two subsets arrived. Content
 * moving under someone while they read it is the front door of the product.
 *
 * The subsets are also loaded LAZILY by design — a browser fetches
 * `latin-ext` only once a character in its range is painted, and this app
 * spells Hawaiian with macrons (ʻōlelo noʻeau, KOKUA), so that file arrives
 * when a section scrolls into view rather than at load. Preloading it would
 * cost every visitor 70KB to fix one of the two jumps.
 *
 * This fixes both, and any future one, for nothing: the fallback is aliased
 * to a local serif and then adjusted to Literata's own metrics, so the swap
 * is invisible whenever it happens.
 *
 * ─── WHERE THE NUMBERS COME FROM ──────────────────────────────────────────
 *
 * `size-adjust: 111.69%` is 2656.2 / 2378.2 — the width ratio measured above.
 *
 * The ascent and descent overrides are expressed against the em AFTER
 * size-adjust, so Literata's 118% and 31% are divided by 1.1169:
 *
 *     ascent-override   118 / 1.1169 = 105.65%
 *     descent-override   31 / 1.1169 =  27.76%
 *
 * `line-gap-override: 0%` because Literata declares none, and inheriting the
 * fallback's would re-open the same gap in the line box.
 *
 * If none of the `local()` names resolve, this @font-face simply fails and
 * the stack falls through to plain `serif` — exactly today's behaviour, so
 * the worst case is no worse.
 */
@font-face {
  font-family: 'Literata Fallback';
  src: local('Times New Roman'), local('Times'), local('Georgia'), local('serif');
  size-adjust: 111.69%;
  ascent-override: 105.65%;
  descent-override: 27.76%;
  line-gap-override: 0%;
}
