/* Shared structure for both publications. Sites set the custom properties
   below in their own stylesheet and add identity on top. */
:root {
  --bg: #fff;
  --ink: #111;
  --muted: #555;
  --accent: #333;
  --rule: #ddd;
  --panel: #f4f4f4;
  --body-font: Georgia, serif;
  --display-font: var(--body-font);
  --mono-font: ui-monospace, monospace;
  --page: 75rem;
  --measure: 38rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.125rem/1.6 var(--body-font);
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; display: block; }
/* Images and iframes on lines of their own (src/media.ts): alone, they fill
   the text column; on consecutive lines, a gallery row at equal heights. */
.media { margin: 1.5em 0; }
.media img, .media iframe { display: block; width: 100%; height: auto; border: 0; }
.gallery { display: grid; gap: .5rem; }
.gallery-row { display: flex; gap: .5rem; align-items: flex-start; }
.gallery-row > img, .gallery-row > iframe { min-width: 0; width: auto; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 10; background: var(--bg); padding: .5rem 1rem; }

.wrap, main > section, .site-footer-inner {
  width: min(100% - 2 * var(--gutter), var(--page));
  margin-inline: auto;
}

.site-nav { display: flex; gap: clamp(1rem, 3vw, 2.5rem); align-items: center; }
.site-nav a { text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { text-decoration: underline; text-underline-offset: .3em; text-decoration-thickness: 1px; }

.button {
  display: inline-flex; align-items: center; gap: .5em;
  padding: .55em 1.1em; border-radius: 4px;
  background: var(--accent); color: var(--bg);
  text-decoration: none; font-size: 1.05rem;
}
.button:hover { filter: brightness(1.15); }

.eyebrow, .kicker {
  font: 500 .8rem/1.2 var(--mono-font);
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .75rem;
}

/* Cards */
.cards { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); padding: 0; margin: 0; }
.card a { display: block; text-decoration: none; height: 100%; }
.card-art { aspect-ratio: 16 / 10; overflow: hidden; border-radius: 3px; background: var(--panel); }
.card-art > svg { width: 100%; height: 100%; }
.card-title { font: 600 1.3rem/1.2 var(--display-font); margin: .9rem 0 .5rem; }
.card a:hover .card-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.card-dek { margin: 0 0 1rem; font-size: 1rem; line-height: 1.45; color: var(--muted); }
.card-meta { font: 500 .75rem/1 var(--mono-font); letter-spacing: .12em; text-transform: uppercase; margin: 0; color: var(--muted); }

.badge {
  display: inline-block; margin-left: .6em; padding: .25em .5em; vertical-align: .1em;
  font: 600 .65rem/1 var(--mono-font); letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 3px; color: var(--accent);
}

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 0 0 1.5rem; }
.section-head h2 { margin: 0; font: 500 2rem/1.1 var(--display-font); }
.section-head a { text-decoration: none; color: var(--accent); }
.section-head a:hover { text-decoration: underline; }

/* Article */
.article { width: min(100% - 2 * var(--gutter), var(--measure)); margin: clamp(2rem, 6vw, 4.5rem) auto 5rem; }
.article-title { font: 600 clamp(2.2rem, 5vw, 3.4rem)/1.05 var(--display-font); margin: 0 0 1rem; text-wrap: balance; }
.article-dek { font-size: 1.35rem; line-height: 1.4; color: var(--muted); margin: 0 0 1.25rem; text-wrap: pretty; }
.byline { font-size: .95rem; color: var(--muted); margin: 0 0 2.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--rule); }
.prose { hyphens: auto; text-wrap: pretty; }
.prose h2 { font: 600 1.6rem/1.2 var(--display-font); margin: 2.5em 0 .6em; }
.prose h3 { font: 600 1.25rem/1.25 var(--display-font); margin: 2em 0 .5em; }
.prose :is(h2, h3) { scroll-margin-top: 1.5rem; }
.prose a { text-decoration-thickness: 1px; text-underline-offset: .18em; color: var(--accent); }
.prose blockquote { margin: 1.5em 0; padding-left: 1.25em; border-left: 2px solid var(--rule); color: var(--muted); }
.prose code { font-family: var(--mono-font); font-size: .88em; }
.prose pre { background: var(--panel); padding: 1rem 1.25rem; overflow-x: auto; border-radius: 4px; font-size: .95rem; line-height: 1.5; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums; margin: 1.5em 0; }
.prose th, .prose td { text-align: left; padding: .45em .6em; border-bottom: 1px solid var(--rule); }
.prose .todo {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  border-left: 3px solid var(--accent); padding: .75em 1em; font-size: .95rem; border-radius: 0 4px 4px 0;
}
.prose .todo::before { content: "Author’s note · "; font-weight: 600; }

/* Figures may break out of the text measure */
.prose figure { margin: 2.25em 0; }
.prose figure.wide { width: min(100vw - 2 * var(--gutter), var(--page)); margin-inline: calc(50% - min(50vw - var(--gutter), var(--page) / 2)); }
.prose figcaption { font-size: .9rem; line-height: 1.45; color: var(--muted); margin-top: .75rem; }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: .25em 0; }
/* Numbered display equations: $$ … $$ (1) */
.prose section.eqno { display: flex; align-items: center; gap: 1rem; }
.prose section.eqno > eqn { flex: 1; min-width: 0; }
.prose section.eqno > span { flex: none; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Footnotes */
.footnotes-sep { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0 1rem; width: 6rem; }
.footnotes { font-size: .92rem; line-height: 1.5; color: var(--muted); }
.footnote-ref a, .footnote-backref { text-decoration: none; }

/* Archive */
.archive { width: min(100% - 2 * var(--gutter), 52rem) !important; margin: clamp(2rem, 6vw, 4rem) auto 5rem; }
.archive-title { font: 600 clamp(2.2rem, 5vw, 3rem)/1.1 var(--display-font); margin: 0 0 2rem; }
.archive-year h2 { font: 500 1.1rem/1 var(--mono-font); color: var(--muted); border-bottom: 1px solid var(--rule); padding-bottom: .5rem; }
.archive-list { list-style: none; padding: 0; margin: 0 0 2.5rem; }
.archive-list li { display: grid; grid-template-columns: 8rem 1fr; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.archive-list time { font: 500 .8rem/1.9 var(--mono-font); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.archive-list a { font: 600 1.25rem/1.25 var(--display-font); text-decoration: none; }
.archive-list a:hover { text-decoration: underline; }
.archive-list p { margin: .25rem 0 0; color: var(--muted); font-size: 1rem; }
@media (max-width: 34rem) { .archive-list li { grid-template-columns: 1fr; gap: .25rem; } }

/* Interactive modules */
[data-module] { margin: 2rem 0; }
.module-controls { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; font-size: .95rem; margin-top: .75rem; }
.module-controls label { display: inline-flex; gap: .5rem; align-items: center; }
.module-controls input[type="range"] { accent-color: var(--accent); }
.module-readout { font: 400 .85rem/1.4 var(--mono-font); color: var(--muted); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Admin bar: shown only to signed-in editors */
.adminbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .35rem var(--gutter); background: #1d1d1f; color: #e8e8ea;
  font: 13px/1.4 system-ui, -apple-system, sans-serif;
}
.adminbar b { color: #fff; }
.adminbar-edit {
  color: #fff; text-decoration: none; font-weight: 600;
  padding: .2rem .75rem; border-radius: 4px; background: #1f883d;
}
.adminbar-edit:hover { filter: brightness(1.1); }
.adminbar-actions { display: flex; gap: .5rem; align-items: center; }
.adminbar-new {
  color: #e8e8ea; text-decoration: none; padding: .2rem .75rem; border-radius: 4px;
  border: 1px solid #5a5a60;
}
.adminbar-new:hover { color: #fff; border-color: #8a8a90; }
.version-banner {
  padding: .5rem var(--gutter); background: #fff8c5; color: #3b2f00;
  font: 13px/1.5 system-ui, -apple-system, sans-serif; border-bottom: 1px solid #d4a72c66;
}
.version-banner a { color: inherit; }
.prose .math-nobr { white-space: nowrap; }
