/* ============ BASE — reset, typography, a11y ============ */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-med), color var(--t-med);
  overflow-x: clip;
}

main { flex: 1; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 550;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p { margin: 0 0 var(--space-3); max-width: var(--measure); }

a { color: var(--bathy); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--vermilion); }

img { max-width: 100%; height: auto; display: block; }

code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

::selection { background: var(--vermilion-wash); color: var(--vermilion-deep); }
:root[data-theme="dark"] ::selection { color: var(--vermilion); }

/* ---- A11y ---- */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--vermilion); color: #fff;
  padding: var(--space-2) var(--space-3); z-index: 999;
  font-family: var(--font-mono); font-size: var(--text-sm);
}
.skip-link:focus { left: 0; }

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

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

/* ---- Marginalia utilities (the atlas voice) ---- */
.marginalia {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.kicker {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--vermilion);
  margin-bottom: var(--space-2);
}

/* Scale-bar rule: a horizontal rule drawn like a map scale bar */
.scalebar {
  border: 0;
  height: 5px;
  margin: var(--space-5) 0;
  background:
    repeating-linear-gradient(90deg,
      var(--ink) 0 24px, transparent 24px 25px,
      var(--line-strong) 25px 49px, transparent 49px 50px) left center / 200px 3px no-repeat,
    linear-gradient(var(--line), var(--line)) left bottom / 100% 1px no-repeat;
}

/* Graticule tick rule under section headings */
.tick-rule {
  border: 0;
  height: 9px;
  margin: 0 0 var(--space-4);
  background:
    repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 48px) left top / 100% 5px no-repeat,
    linear-gradient(var(--line), var(--line)) left top / 100% 1px no-repeat;
}
