/*
 * Typeface token. ONE variable (--font-app) holds the font of the whole product when a font is chosen in
 * /font-choice.js. With the default choice ("current") nothing here applies and the original styling is untouched.
 *
 * To add a font: add one html[data-font="name"] line below and one entry in /font-choice.js.
 */
:root {
  --font-app: "Circe", "Inter", system-ui, sans-serif; /* the baseline, shown for reference */
}

/* Fallback faces sized like the web font, so text does not jump when the real font arrives (no layout shift). */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107.4%;
  ascent-override: 90.2%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Atkinson Fallback";
  src: local("Arial");
  size-adjust: 103%;
  ascent-override: 94%;
  descent-override: 24%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Source Sans Fallback";
  src: local("Arial");
  size-adjust: 94%;
  ascent-override: 100%;
  descent-override: 28%;
  line-gap-override: 0%;
}

html[data-font="inter"]      { --font-app: "Inter", "Inter Fallback", system-ui, sans-serif; }
html[data-font="atkinson"]   { --font-app: "Atkinson Hyperlegible Next", "Atkinson Fallback", system-ui, sans-serif; }
html[data-font="sourcesans"] { --font-app: "Source Sans 3", "Source Sans Fallback", system-ui, sans-serif; }

/* A chosen font replaces every text font, including the many fonts set inline in components. Code stays monospace. */
html[data-font] body,
html[data-font] :where(*):not(code, pre, kbd, samp, .font-mono, svg, svg *) {
  font-family: var(--font-app) !important;
}

/* The old per-weight font names ("Circe:Bold", "Inter:Medium") carried the weight in the NAME. When the font is
   replaced, restore that weight. An explicit inline font-weight still wins because these are not !important. */
html[data-font] [style*="Light'"], html[data-font] [style*=":Light"] { font-weight: 300; }
html[data-font] [style*=":Medium"], html[data-font] [class*="Inter:Medium"], html[data-font] [class*="Circe:Medium"] { font-weight: 500; }
html[data-font] [style*=":Semi Bold"], html[data-font] [class*="Semi_Bold"] { font-weight: 600; }
html[data-font] [style*=":Bold"], html[data-font] [class*=":Bold"] { font-weight: 700; }
html[data-font] [style*=":Extra Bold"] { font-weight: 800; }
