/*
 * Self-hosted webfaces. Spec 06 §6.
 *
 * Latin subset only (U+0000–00FF and the usual punctuation), pulled from
 * Google's own woff2 files and served from this origin. No CDN: a third-party
 * font host is a third-party connection on an ad landing page, it is a second
 * DNS lookup and TLS handshake before first paint, and the CSP would have to
 * be widened to allow it.
 *
 * 137KB across five files, cached for a year by .htaccess. Every face carries
 * font-display: swap, so text paints immediately in the fallback and the
 * webface swaps in when it lands — the LCP element is never waiting on a font.
 *
 * The fallbacks in tokens.css are chosen to be metrically close, which is what
 * keeps the swap from moving the page:
 *   Fraunces     → Iowan Old Style, Georgia
 *   Karla        → system-ui
 *   IBM Plex Mono → ui-monospace, SF Mono, Menlo
 */

/* Variable, 300–600, with the optical-size axis. One file for every heading
   weight on the site. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('/assets/fonts/fraunces-var-latin.woff2') format('woff2-variations');
  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: 'Karla';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/assets/fonts/karla-var-latin.woff2') format('woff2-variations');
  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;
}

/* Plex Mono is static, so one file per weight. Only the three the stylesheets
   actually ask for. */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/plexmono-400-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;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/plexmono-500-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;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/plexmono-600-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;
}

/*
 * Light text on a dark ground optically thins. Spec 06 §6 asks for a slightly
 * heavier body weight in dark mode; with variable fonts that is a real weight
 * rather than a smoothing hint, so the shape stays correct at every size.
 */
:root { --body-weight: 420; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --body-weight: 400; }
}
:root[data-theme="light"] { --body-weight: 400; }
:root[data-theme="dark"]  { --body-weight: 420; }
