/* ==========================================================================
   Base — reset, element defaults, layout container, focus, print.
   Loaded by every page, immediately after tokens.css.
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

/* ---- Typography ---------------------------------------------------------
   Serif for headings and prose; the sans body above is the UI default. */

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--ink);
  text-wrap: balance;
}

h1 { font-size: var(--text-display); letter-spacing: -0.015em; }
h2 { font-size: var(--text-section); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p {
  margin: 0;
  text-wrap: pretty;
}

/* Figures and money read as data, not prose. */
.num,
time,
data {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- Links --------------------------------------------------------------
   Underlined by default: color alone is not a sufficient affordance. */

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--transition);
}

a:hover { color: var(--accent-hover); }

/* ---- Focus --------------------------------------------------------------
   The site previously had no focus style at all, anywhere. */

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

/* ---- Layout -------------------------------------------------------------- */

.container {
  width: min(100% - (2 * var(--space-4)), var(--max-width));
  margin-inline: auto;
}

.measure {
  max-width: var(--measure);
}

/* Skip link — visually hidden until focused. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-5)));
  transition: transform var(--transition);
}

.skip-link:focus-visible {
  transform: translateY(0);
  color: var(--on-accent);
}

/* ---- Motion -------------------------------------------------------------- */

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

/* ---- Print --------------------------------------------------------------
   Classroom use means these pages get printed. */

@media print {
  .topbar,
  .skip-link,
  .site-footer {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  /* Never let the scroll-reveal transition hide content on paper. */
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  /* Spell out destinations that won't be clickable on paper. */
  main a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }
}
