/* ==========================================================================
   base.css — fonts, reset, typography, layout grid and utilities
   Depends on tokens.css (load tokens.css first).
   ========================================================================== */

/* ---- Fonts (self-hosted; see docs/design-system.md) ----------------------
   Variable fonts with weight and optical-size axes, subset to Latin
   (English, Spanish and other Western European languages). */
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter/Inter-Variable-latin.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/Newsreader/Newsreader-Italic-Variable-latin.woff") format("woff");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

/* ---- Reset (small, on purpose) ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, video, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---- Accessibility ---------------------------------------------------- */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -4rem;
  z-index: 10;
  padding: var(--space-2) var(--space-3);
  background: var(--highlight);
  color: var(--text);
  font-weight: var(--weight-medium);
}
.skip-link:focus { top: var(--space-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Typography roles (class or element, same result) ----------------- */
.t-display {
  font-size: var(--text-display);
  line-height: var(--lh-display);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-display);
}

h1, .t-h1 {
  font-size: var(--text-h1);
  line-height: var(--lh-h1);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-h1);
}

h2, .t-h2 {
  font-size: var(--text-h2);
  line-height: var(--lh-h2);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-h2);
}

h3, .t-h3 {
  font-size: var(--text-h3);
  line-height: var(--lh-h3);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-h3);
}

.t-body { font-size: var(--text-body); line-height: var(--lh-body); }
.t-body--measure { max-width: var(--measure); }

.t-caption {
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--text-muted);
}

.t-meta {
  font-size: var(--text-meta);
  line-height: var(--lh-meta);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-meta);
  text-transform: uppercase;
  color: var(--text-muted);
}

.t-nav {
  font-size: var(--text-nav);
  line-height: 1.2;
  font-weight: var(--weight-medium);
}

/* Editorial accent: one emphasised word in a headline, pull quotes. */
.serif-em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: var(--weight-regular);
  letter-spacing: -0.02em;
}

/* Accent as a highlighter. Always ink text on top, never accent text on paper. */
.hl {
  background: var(--highlight);
  color: var(--text);
  padding: 0 0.3em;
}

/* ---- Layout ----------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--margin);
}

/* Full-bleed band inside a container-based page (e.g. the contact block). */
.band { padding-block: var(--space-8); }
.band--inverse {
  background: var(--bg-inverse);
  color: var(--text-inverse);
}
.band--inverse .t-meta { color: var(--text-inverse-muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--gutter);
  row-gap: var(--space-6);
}

/* Items span the whole row on mobile and tablet; spans apply on desktop. */
.grid > * { grid-column: 1 / -1; min-width: 0; }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-3)); }

.section { padding-block: var(--space-8); }
.section--tight { padding-block: var(--space-6); }

@media (min-width: 48em) {   /* tablet */
  :root { --margin: 2rem; --cols: 8; }
}

@media (min-width: 68.75em) { /* desktop */
  :root { --margin: 4rem; --cols: 12; }

  .col-3  { grid-column: span 3; }
  .col-4  { grid-column: span 4; }
  .col-5  { grid-column: span 5; }
  .col-6  { grid-column: span 6; }
  .col-7  { grid-column: span 7; }
  .col-8  { grid-column: span 8; }
  .col-9  { grid-column: span 9; }
  .col-12 { grid-column: 1 / -1; }

  .offset-top { margin-top: var(--space-8); }  /* asymmetric stagger */
}
