/* =============================================================================
   dessau.dev — self-hosted fonts
   =============================================================================

   This file is NOT part of DDS.

   DDS ships no font binaries: its typography tokens name a family and fall
   through to the platform UI font, so a product carries no font weight and no
   licence obligation it did not ask for. See libs/dessau/docs/typography.md.

   This product wants the same typographic identity as Dessau itself, so it
   copies the recipe Dessau recommends a product take — the same one
   libs/dessau/reference/assets/fonts.css applies to the reference site itself.

   -----------------------------------------------------------------------------
   The recipe, as actually applied here
   -----------------------------------------------------------------------------

   1. VARIABLE fonts, as WOFF2. One file per family covers every weight.
   2. SELF-HOSTED, never a third-party CDN — same-origin, no reader IP leaked
      to a third party, no third-party connection on the critical path.
   3. `font-display: swap`. Text renders immediately in the fallback and swaps
      when the font arrives. Never `block`: invisible text is worse than
      briefly different text.
   4. The fallback stack is KEPT. The `--dds-font-*` tokens already list it and
      are not reduced to a single family here — a failed font request must
      degrade, not blank the page.
   5. SUBSET to Latin and Latin Extended-A/-B, and `unicode-range` declaring
      the same, matching the files Dessau's own reference site produced.
   6. The OFL notice travels with the files (`fonts/OFL-*.txt`). The licence
      requires it, and "we linked to it" is not the same thing.

   The files themselves are the identical WOFF2s Dessau's reference site
   serves, copied rather than re-subset — same source, same result, no reason
   to regenerate. See libs/dessau/reference/assets/fonts.css for how they were
   produced, if that is ever needed again.
   ============================================================================= */

/* The Latin coverage this project needs: Basic Latin, Latin-1 Supplement,
   Latin Extended-A and -B, general punctuation and currency symbols. Written out
   per face rather than shared, because `unicode-range` cannot be a variable. */

/* --------------------------------------------------------------- body / UI */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/Inter-Variable-latin-ext.woff2") format("woff2");
  /* The whole axis, because it is one variable file. */
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-024F, U+2000-206F, U+20A0-20BF, U+2122, U+2212;
}

/* ------------------------------------------------------------------ display */
@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/fonts/SpaceGrotesk-Variable-latin-ext.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-024F, U+2000-206F, U+20A0-20BF, U+2122, U+2212;
}

/* --------------------------------------------------------------- monospace */
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/JetBrainsMono-Variable-latin-ext.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-024F, U+2000-206F, U+20A0-20BF, U+2122, U+2212;
}

/* -----------------------------------------------------------------------------
   Metric-matched fallback
   -----------------------------------------------------------------------------

   Reduces the layout shift when the real face swaps in, by adjusting the
   fallback's metrics to match the real face's. Without it, text visibly
   reflows on font load.

   Originally applied to the body face only, on the reasoning that it
   renders first and everywhere. This site's own /DECISIONS.md 003 flagged
   the gap that reasoning left: Space Grotesk (.dds-display, the hero <h1>,
   the single largest and most prominent element on the page) got neither a
   preload nor a matched fallback. Dessau's own reference site hit the same
   gap and measured it (#124, libs/dessau DECISIONS.md #051): at 48px bold,
   a representative headline came out 7.5% wider in the system-ui fallback
   than in real Space Grotesk — enough to move a line break. Adopted here
   verbatim rather than re-derived: same files, same measured size-adjust.

   JetBrains Mono stays unmatched — it renders inline, smaller, and never as
   the first or largest thing on a page, so the original reasoning actually
   holds there.
   ----------------------------------------------------------------------------- */
@font-face {
  font-family: "Inter Fallback";
  src: local("Helvetica Neue"), local("Arial"), local("Liberation Sans");
  /* Inter runs optically smaller than Helvetica at the same size. */
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Space Grotesk Fallback";
  src: local("Helvetica Neue"), local("Arial"), local("Liberation Sans");
  size-adjust: 108%;
  ascent-override: 91%;
  descent-override: 27%;
  line-gap-override: 0%;
}

/* Slot each metric-matched fallback in directly after its real face. The
   rest of each stack stays exactly as the tokens define it. */
:root {
  --dds-font-body: Inter, "Inter Fallback", system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", sans-serif;
  --dds-font-display: "Space Grotesk", "Space Grotesk Fallback", system-ui,
    -apple-system, "Segoe UI", Roboto, sans-serif;
}
