/* Maynard Focus — base layer: fonts, type scale, spacing, grid, prose.
   Colours live in tokens.css (generated). Components in components.css.
   See docs/DESIGN.md for the reasoning behind every value here. */

/* ---------- Fonts (self-hosted, SIL OFL, Latin subset) ---------- */
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-var.woff2") format("woff2-variations"),
       url("../fonts/newsreader-var.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-italic-var.woff2") format("woff2-variations"),
       url("../fonts/newsreader-italic-var.woff2") format("woff2");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/instrument-sans-var.woff2") format("woff2-variations"),
       url("../fonts/instrument-sans-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Fluid type scale: min at 375px viewport, max at 1280px. */
  --step--2: clamp(0.75rem, 0.7371rem + 0.0553vw, 0.7813rem);    /* 12 → 12.5 */
  --step--1: clamp(0.8438rem, 0.8179rem + 0.1105vw, 0.9063rem);  /* 13.5 → 14.5 */
  --step-0:  clamp(1.0625rem, 1.0107rem + 0.221vw, 1.1875rem);   /* 17 → 19 body */
  --step-1:  clamp(1.2188rem, 1.1541rem + 0.2762vw, 1.375rem);   /* 19.5 → 22 */
  --step-2:  clamp(1.375rem, 1.2455rem + 0.5525vw, 1.6875rem);   /* 22 → 27 */
  --step-3:  clamp(1.625rem, 1.392rem + 0.9945vw, 2.1875rem);    /* 26 → 35 */
  --step-4:  clamp(2rem, 1.5856rem + 1.768vw, 3rem);             /* 32 → 48 */
  --step-5:  clamp(2.5rem, 1.8785rem + 2.6519vw, 4rem);          /* 40 → 64 */
  --step-mast: clamp(2.25rem, 0.9033rem + 5.7459vw, 5.5rem);     /* 36 → 88 */

  /* 4px spacing scale */
  --s-1: 0.25rem;  /*  4 */
  --s-2: 0.5rem;   /*  8 */
  --s-3: 0.75rem;  /* 12 */
  --s-4: 1rem;     /* 16 */
  --s-5: 1.25rem;  /* 20 */
  --s-6: 1.5rem;   /* 24 */
  --s-8: 2rem;     /* 32 */
  --s-10: 2.5rem;  /* 40 */
  --s-12: 3rem;    /* 48 */
  --s-16: 4rem;    /* 64 */
  --s-20: 5rem;    /* 80 */
  --s-24: 6rem;    /* 96 */

  --gutter: clamp(1rem, 0.4822rem + 2.2099vw, 2.25rem);  /* 16 → 36 page margin */
  --col-gap: var(--s-6);
  --measure: 38rem;          /* ~68 characters of body Newsreader */
  --page-max: 80rem;         /* 1280 */
  --radius: 2px;
  --hair: 1px;

  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- Reset (minimal) ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: first allow-end last;
}
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ol, ul { margin: 0; }
ol[role="list"], ul[role="list"], .list-bare { list-style: none; padding: 0; }
img, svg, video { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Page ---------- */
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.55;
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.005em;
  text-wrap-style: balance;
}
h1 { font-size: var(--step-5); font-weight: 500; letter-spacing: -0.015em; line-height: 1.04; }
h2 { font-size: var(--step-3); font-weight: 500; letter-spacing: -0.01em; }
h3 { font-size: var(--step-1); }
h4 { font-size: var(--step-0); }

/* text-wrap-style, not the text-wrap shorthand, so white-space: nowrap still wins where set */
p, li { text-wrap-style: pretty; }

a {
  color: var(--brick);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--brick) 45%, transparent);
  transition: text-decoration-color 120ms var(--ease);
}
a:hover { text-decoration-color: currentColor; }
:focus-visible {
  outline: 2px solid var(--brick);
  outline-offset: 3px;
  border-radius: var(--radius);
}

strong, b { font-weight: 650; }
em, i { font-style: italic; }
small { font-size: var(--step--1); }
abbr[title] { text-decoration: none; border-bottom: 1px dotted var(--rule-strong); }

hr {
  border: 0;
  border-top: var(--hair) solid var(--rule);
  margin-block: var(--s-8);
}

::selection { background: var(--brick-wash); color: var(--ink); }

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: var(--s-2) var(--s-3);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: var(--step--1);
  z-index: 30; /* above the sticky header */
}
.skip-link:focus { top: var(--s-2); }

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

/* ---------- Type utilities ---------- */
.sans { font-family: var(--sans); }
.tnum { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--ink-muted); }

/* Kicker: tracked caps in the sans (neither font has true small caps). */
.kicker {
  font-family: var(--sans);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brick);
  line-height: 1.3;
}

/* Dek: the standfirst under a headline. */
.dek {
  font-size: var(--step-1);
  line-height: 1.4;
  color: var(--ink-muted);
  font-weight: 400;
  max-width: 34em;
}

.meta {
  font-family: var(--sans);
  font-size: var(--step--1);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.45;
}

time { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- Prose ---------- */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--s-4); }
.prose > h2, .prose > h3 { margin-top: var(--s-10); }
.prose > h2 + *, .prose > h3 + * { margin-top: var(--s-3); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: var(--s-2); }
.prose li::marker { color: var(--ink-muted); }
.prose blockquote {
  font-style: italic;
  padding-left: var(--s-5);
  border-left: var(--hair) solid var(--rule-strong);
}

/* Citation markers: [1] style superscripts linking to the sources list. */
.cite {
  font-family: var(--sans);
  font-size: 0.62em;
  font-weight: 600;
  vertical-align: 0.55em;
  line-height: 0;
  margin-left: 0.08em;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.cite:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Single column with generous rhythm on small screens; a real 12-column grid
   from 960px. Spans vary by section — no identical card grids. */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-8) var(--col-gap);
}
@media (min-width: 60em) {
  .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .span-3  { grid-column: span 3; }
  .span-4  { grid-column: span 4; }
  .span-5  { grid-column: span 5; }
  .span-6  { grid-column: span 6; }
  .span-7  { grid-column: span 7; }
  .span-8  { grid-column: span 8; }
  .span-9  { grid-column: span 9; }
  .span-12 { grid-column: 1 / -1; }
  .start-2 { grid-column-start: 2; }
  .start-3 { grid-column-start: 3; }
  .start-9 { grid-column-start: 9; }
  .start-10 { grid-column-start: 10; }
  /* A vertical column rule between spans, like a broadsheet gutter. */
  .col-rule { border-left: var(--hair) solid var(--rule); padding-left: var(--col-gap); }
}

.stack > * + * { margin-top: var(--stack, var(--s-4)); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); align-items: center; }

.section { padding-block: var(--s-12); }
.section + .section { border-top: var(--hair) solid var(--rule); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
