/*
 * academic.css — plain-HTML design system  ·  https://github.com/ejfox/academic.css
 * Black & white. Near-single scale. Grid-centric. System fonts. No build step.
 *
 * Spacing & sizing in rem/em so everything scales with the root font size
 * (and honours user zoom / a11y text settings). Only crisp 1px hairlines
 * and focus outlines stay in px. Almost no borders. Semantic HTML.
 */

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --gap: 1.5rem;
  --measure: 64ch;
  --page: 56.25rem;

  /* OLED black (#000) by default — pure black surface for
     deep contrast on OLED panels. Light is an opt-in escape hatch below.

     Tonal hierarchy: true white (--text-bright) is reserved for the single
     topmost element (h1 / hero). Everything else steps down the grayscale so
     information rank reads through tone, not just size. */
  --text-bright: #fff;   /* h1 / hero only — the one true white */
  --text-strong: #e6e6e6; /* h2, strong/bold */
  --text: #c4c4c4;       /* body copy — the default */
  --text-muted: #858585; /* secondary: labels, eyebrows, table heads */
  --text-faint: #767676; /* tertiary / faint — lowest tone that still clears WCAG AA (4.6:1) */
  --bg: #000;
  --bg-muted: #141414;
  --rule: #3a3a3a; /* hairline dividers — nudged up for legibility on OLED */
  --link: #d8d8d8;
  --link-visited: #858585;

  /* The one non-neutral in the system. Used only for "live" moments (text
     selection, the current-page marker), never as a surface. Override it with
     your own brand color. If you're reaching for it a third time, reconsider. */
  --accent: #e17055;
}

/* Opt-in light theme — add `.light` to <html>. Same stepped ramp, inverted. */
:root.light {
  --text-bright: #000; --text-strong: #1a1a1a; --text: #333;
  --text-muted: #666; --text-faint: #767676;
  --bg: #fff; --bg-muted: #f4f4f4; --rule: #e4e4e4;
  --link: #1a1a1a; --link-visited: #666;
  --accent: #c0492b; /* darker orange so it stays legible on white */
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; } /* 1rem = the user's default (typically 16px) */
body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}
::selection { background: var(--accent); color: #fff; }
/* Guard against horizontal scroll from full-bleed 100vw layers —
   nothing in this design scrolls sideways. */
html, body { overflow-x: hidden; }
img, svg, video { display: block; max-width: 100%; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ===== LAYOUT ===== */
.page { max-width: var(--page); margin: 0 auto; padding: 5.5rem 2.5rem 11rem; }
.measure { max-width: var(--measure); }
main { min-height: 60vh; }
section { margin: 8.5rem 0; }
section:first-child { margin-top: 0.5rem; }

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.15; text-wrap: balance; }
h1 {
  font-size: clamp(2.5rem, 4vw, 3.5rem); letter-spacing: -0.06em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 2.5rem; max-width: 20ch;
  color: var(--text-bright); /* the one true white */
}
h2 {
  font-size: 1.2rem; letter-spacing: -0.02em; text-transform: uppercase;
  margin: 7rem 0 1.5rem; color: var(--text-strong);
}
h3 {
  font-size: 1rem; margin: 2rem 0 0.5rem; font-weight: 400;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted);
}
h4 { font-size: 1rem; margin: 1.5rem 0 0.5rem; letter-spacing: 0.01em; }
h5, h6 { font-size: 1rem; margin: 1rem 0 0.25rem; font-weight: 400; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
p { margin-bottom: 1.35em; max-width: var(--measure); text-wrap: pretty; }
strong, b { font-weight: 700; color: var(--text-strong); }
em, i { font-style: italic; }
blockquote {
  padding-left: 1.25rem; margin: 1.75rem 0; color: var(--text-muted);
  font-style: italic; text-indent: -0.4em; hanging-punctuation: first;
}

a { color: var(--link); text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:visited { color: var(--link-visited); }
a:hover { background: var(--text); color: var(--bg); text-decoration: none; }

small, .small { color: var(--text-muted); }
sup, sub { font-size: 0.7em; line-height: 0; position: relative; }
sup { top: -0.5em; }

hr { border: none; border-top: 1px solid var(--rule); margin: 4rem 0; }

/* Lists (opt-in markers) */
.list { padding-left: 1.4em; margin: 0.75rem 0; }
.list li { margin-bottom: 0.5rem; }
ul.list { list-style: disc; }
ol.list { list-style: decimal; }

/* ===== TABLE — borderless; hairline under header ===== */
table { border-collapse: collapse; width: 100%; margin: 1.5rem 0; }
/* Tabular (monospaced) figures so numeric columns line up like a ledger. */
th, td { padding: 0.5rem 1rem 0.5rem 0; text-align: left; vertical-align: top; font-variant-numeric: tabular-nums; }
th {
  font-weight: 400; text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 0.85em; color: var(--text-muted); border-bottom: 1px solid var(--text);
}
td { border-bottom: 1px solid var(--rule); }

/* ===== CODE ===== */
code { font-family: var(--font-mono); background: var(--bg-muted); padding: 0.1em 0.3em; }
pre { font-family: var(--font-mono); background: var(--bg-muted); padding: 1rem; overflow-x: auto; margin: 1.75rem 0; }
pre code { background: none; padding: 0; }

/* ===== FORMS ===== */
input, select, textarea { border: 1px solid var(--text); padding: 0.75rem; background: var(--bg); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--text); outline-offset: 1px; }
label { display: block; font-weight: 700; margin-bottom: 0.375rem; }

/* ===== COMPONENTS ===== */
.btn {
  display: inline-block; font-family: var(--font-sans); font-weight: 700;
  background: var(--text-strong); border: none; padding: 0.75rem 1.25rem;
  cursor: pointer; text-decoration: none;
  text-transform: uppercase; letter-spacing: -0.02em;
}
/* Pin the fill contrast across every link state — otherwise :visited (#555)
   wins on specificity and turns visited buttons into low-contrast grey. */
.btn, .btn:link, .btn:visited { color: var(--bg); }
.btn:hover, .btn:focus { background: var(--text-strong); color: var(--bg); opacity: 0.75; }
.btn.big { padding: 0.875rem 1.75rem; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }
.eyebrow {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--text-muted); margin-bottom: 0.5rem; font-size: 0.85em;
}
.lead { font-size: 1.15rem; line-height: 1.65; max-width: var(--measure); }
.card { padding: 0; }
.tag { display: inline-block; font-family: var(--font-mono); color: var(--text-muted); margin: 0 0.75rem 0.375rem 0; text-decoration: none; }
.tag::before { content: "#"; opacity: 0.5; }
.tag:hover { color: var(--text); }

/* ===== GRID ===== */
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.grid-2 { display: grid; gap: 4rem; grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; gap: 4rem; grid-template-columns: repeat(3, 1fr); }
.grid-4 { display: grid; gap: 3rem; grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: var(--gap); align-items: baseline; flex-wrap: wrap; }
.between { display: flex; gap: var(--gap); align-items: center; justify-content: space-between; }
.stack > * + * { margin-top: 0.75rem; }
@media (max-width: 43.75rem) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 2rem; }
}

/* ===== SITE CHROME ===== */
.site-header .page { padding-top: 1.5rem; padding-bottom: 1.5rem; }
/* Even 2rem (32px) gaps — one flex row instead of per-link margins. */
.site-header nav { display: flex; align-items: baseline; gap: 2rem; }
.site-header nav a { text-decoration: none; }
.site-header nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.brand { font-family: var(--font-mono); font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; text-decoration: none; color: var(--text); }
.site-footer { margin-top: 8rem; }
.site-footer .page { padding-top: 3rem; padding-bottom: 4.5rem; }

/* ===== MOBILE ===== */
/* The generous desktop padding/rhythm is too much on a phone; tighten the
   frame, shrink the display type, and let the header wrap. */
@media (max-width: 43.75rem) {
  .page { padding: 3.25rem 1.25rem 6rem; }
  section { margin: 5rem 0; }
  section:first-child { margin-top: 0; }

  h1 { font-size: 2.25rem; letter-spacing: -0.05em; margin-bottom: 1.75rem; }
  h2 { font-size: 1.1rem; margin: 4.5rem 0 1.25rem; }

  /* Header: let the wordmark + nav wrap onto two lines rather than crush. */
  .site-header .page { padding-top: 1.1rem; padding-bottom: 1.1rem; }
  .site-header .between { flex-wrap: wrap; gap: 0.5rem 1rem; }

  /* Tables: tighter cells + wrap-friendly so 3-column tables fit a phone. */
  th, td { padding: 0.5rem 0.75rem 0.5rem 0; font-size: 0.9375rem; }

  .lead { font-size: 1.08rem; }
  .grid-2, .grid-3, .grid-4 { gap: 2.5rem; }

  .site-footer { margin-top: 5rem; }
  .site-footer .page { padding-top: 2.5rem; padding-bottom: 3rem; }
}

/* Extra squeeze for very small phones. */
@media (max-width: 26.25rem) {
  .page { padding-left: 1rem; padding-right: 1rem; }
  h1 { font-size: 1.9rem; }
}

/* ===== PROSE (markdown content) ===== */
/* Body copy needs its own rhythm — the global h2/h3 margins (7rem/2rem) are
   tuned for top-level page sections and read as gaping holes inside an article.
   Here headings sit close to the text they introduce. */
.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 1.5rem; margin: 0 0 1rem; color: var(--text-strong); }
.prose h2 { font-size: 1.2rem; margin: 2.5rem 0 0.75rem; }
.prose h3 { font-size: 1rem; margin: 2rem 0 0.5rem; }
.prose p { margin-bottom: 1.25em; }
.prose ul { list-style: disc; padding-left: 1.4em; margin: 1rem 0; }
.prose ol { list-style: decimal; padding-left: 1.4em; margin: 1rem 0; }
.prose li { margin-bottom: 0.375rem; }
.prose img { margin: 2rem 0; }
/* Two images side by side, collapsing to a stack on phones. */
.prose .image-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 2rem 0; }
.prose .image-pair img { margin: 0; }
@media (max-width: 43.75rem) { .prose .image-pair { grid-template-columns: 1fr; } }
.prose a { text-decoration: underline; }

/* ===== PRINT ===== */
@media print {
  .site-header nav, .btn { display: none; }
  a { color: #000; }
}
