/* ==========================================================================
   Base — font, reset, typography primitives
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/InterVariable.woff2") format("woff2");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
  /* Thinnest standard scrollbar on every scroll area (not inherited, hence *) */
  scrollbar-width: thin;
}

html {
  /* Paint the canvas itself in the theme color (not just <body>), so nothing
     white can show through while a page transition fades its snapshots */
  background: var(--bg-main);
  /* Reserve the scrollbar's space even while scrolling is locked (open menu),
     so the page doesn't widen and shift sideways. No effect with overlay
     scrollbars (macOS default, phones). */
  scrollbar-gutter: stable;
  /* Theme-colored scrollbars (scrollbar-color is inherited by every scroll area) */
  scrollbar-color: var(--scrollbar-thumb) transparent;
  /* No mobile "font inflation": a deliberately sized layout shouldn't jump on rotation */
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  /* Never fake bold (Inter Variable has every weight). Italic synthesis stays
     allowed until an Inter italic file is added. */
  font-synthesis: style;
}

body {
  min-height: 100vh;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-feature-settings: var(--font-features);
  font-size: var(--text-md);
  line-height: var(--text-md-lh);
  letter-spacing: var(--text-md-tracking);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Keep the fallback font's apparent size close to Inter's while it loads */
  font-size-adjust: from-font;
  /* Use the font's own kerning, ligatures and optical sizes (Inter has an opsz axis) */
  font-kerning: normal;
  font-variant-ligatures: common-ligatures contextual;
  font-optical-sizing: auto;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul,
ol {
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* After a tap or click, no ring even where a script moved focus (main.js) */
:root[data-input="pointer"] :focus-visible {
  outline: none;
}

/* Typography refinements ---------------------------------------------------
   From "Taming Typography with a Modern CSS Reset" (CSS-Tricks). Only the parts
   that don't alter the Figma metrics: no fluid type, no text-box trimming. */

/* Wrapping: balanced headings, no stranded last word in running text */
:is(h1, h2, h3, h4, h5, h6), blockquote, figcaption {
  text-wrap: balance;
}

p, li, dd {
  text-wrap: pretty;
}

/* A hyphenated heading reads as an error; a broken code word can change meaning */
:is(h1, h2, h3, h4, h5, h6), pre, code, var, samp, kbd {
  -webkit-hyphens: manual;
  hyphens: manual;
}

/* Let quotes and punctuation hang outside the text edge (Safari) */
p, blockquote {
  hanging-punctuation: first allow-end last;
}

/* Underlines (for any link that shows one): the font's own thickness,
   room for descenders, and broken where descenders cross */
a {
  text-decoration-thickness: from-font;
  text-underline-offset: 0.15em;
  text-decoration-skip-ink: auto;
}

/* Figures that line up in columns */
table, .tabular {
  font-variant-numeric: tabular-nums lining-nums;
}

/* Locale-correct quotation marks for <q>; zero specificity so a class can override */
:where(:lang(en)) > * {
  quotes: "\201C" "\201D" "\2018" "\2019";
}

:where(:lang(en-GB)) > * {
  quotes: "\2018" "\2019" "\201C" "\201D";
}

q::before { content: open-quote; }
q::after { content: close-quote; }

/* Real superscript/subscript glyphs (Inter has them for numerals) instead of
   shrunken, shifted text that disturbs the line height */
@supports (font-variant-position: super) {
  sup, .sup {
    vertical-align: baseline;
    font-size: 100%;
    line-height: inherit;
    font-variant-position: super;
  }

  sub, .sub {
    vertical-align: baseline;
    font-size: 100%;
    line-height: inherit;
    font-variant-position: sub;
  }
}

/* Typography primitives ---------------------------------------------------- */

.text-md-400 { font-weight: 400; }
.text-md-500 { font-weight: 500; }
.text-md-600 { font-weight: 600; }

.caption {
  font-size: var(--caption);
  line-height: var(--caption-lh);
  letter-spacing: var(--caption-tracking);
  font-weight: 600;
  text-transform: uppercase;
}

.prose p + p {
  margin-top: var(--space-4);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
