/* Design tokens. Every colour pair used for text is listed in docs/design.md.
   No colour outside this list is allowed. */

:root {
  color-scheme: dark;

  --bg: #000000;
  --surface: #1B1D21;
  --panel: #0C0D10;
  --accent: #66FF99;
  --accent-strong: #22E070;
  --text: #E8E8E8;
  --text-muted: #9CA0A4;
  --border: #2A2D31;
  --border-strong: #3A3E43;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.25rem;
  --text-lg: 1.5rem;
  --text-xl: 2rem;
  --text-2xl: 3rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --radius-sm: 4px;
  --radius-md: 8px;

  --measure: 70ch;
  --width: 1120px;
  --section-gutter: calc(9rem + var(--space-5));
  --head-h: 64px;
  --motion: 150ms;
}

/* Reset */

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  overflow-x: clip;
}

/* The header is sticky, so an anchor jump must stop below it. */

html {
  scroll-padding-top: calc(var(--head-h) + var(--space-4));
}

::selection {
  background: var(--accent-strong);
  color: var(--bg);
}

/* Focus. A visible ring on every keyboard focus, never removed without one. */

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

/* Links */

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: color var(--motion) ease, text-decoration-color var(--motion) ease;
}

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

a:active {
  color: var(--accent-strong);
  text-decoration-color: var(--accent-strong);
}

/* Shell */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0 var(--space-5);
  min-height: var(--head-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4) var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  width: 10px;
  height: 10px;
  background: var(--accent);
  flex: none;
}

.brand-name {
  font-size: var(--text-md);
}

.nav-tools {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.nav-links {
  display: flex;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 10px;
  height: 1px;
  background: var(--accent);
  transition: right var(--motion) ease;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after {
  right: 0;
}

.nav-links a[aria-current="page"] {
  color: var(--accent);
}

.page {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0 var(--space-5) var(--space-9);
}

.site-footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: var(--width);
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

.footer-inner p {
  margin: 0;
}

.footer-note {
  font-size: var(--text-sm);
}

.footer-top {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-decoration: none;
}

/* Search palette. The panel is a native popover, so opening, Escape, and the
   click outside come from HTML attributes. The rows are actions: pages from the
   navbar first, then post titles from the embedded index. */

.palette-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-2) 0 var(--space-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  transition: color var(--motion) ease, border-color var(--motion) ease;
}

.palette-key {
  padding: 2px var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  transition: color var(--motion) ease, border-color var(--motion) ease;
}

.palette-trigger:hover,
.site-header:has(.palette:popover-open) .palette-trigger {
  color: var(--text);
  border-color: var(--accent-strong);
}

.palette-trigger:hover .palette-key,
.site-header:has(.palette:popover-open) .palette-key {
  border-color: var(--accent-strong);
}

.palette {
  position: fixed;
  inset: 0;
  margin: auto;
  display: flex;
  flex-direction: column;
  width: min(36rem, calc(100vw - 2 * var(--space-5)));
  height: fit-content;
  max-height: 76vh;
  overflow: hidden;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.6);
}

/* A popover is hidden by the browser until it opens. Author display above
   would otherwise keep the panel on screen, so restore the hidden state. */
.palette:not(:popover-open) {
  display: none;
}

.palette::backdrop {
  background: rgb(0 0 0 / 0.72);
}

.palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4) 0;
}

.palette-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-muted);
}

.palette-close {
  min-height: 28px;
  padding: 0 var(--space-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  transition: color var(--motion) ease, border-color var(--motion) ease;
}

.palette-close:hover {
  color: var(--text);
  border-color: var(--accent-strong);
}

.palette-form {
  margin-top: var(--space-2);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--motion) ease;
}

.palette-form:focus-within {
  border-bottom-color: var(--accent-strong);
}

.palette-input {
  width: 100%;
  min-height: 46px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
}

.palette-input::placeholder {
  color: var(--text-muted);
}

.palette-input:focus-visible {
  outline: none;
}

.palette-results {
  flex: 1 1 auto;
  overflow: auto;
  padding: var(--space-2) 0 var(--space-3);
}

.palette-results:empty {
  display: none;
}

.palette-group {
  margin: var(--space-3) 0 var(--space-1);
  padding: 0 var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.palette-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.palette-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 40px;
  padding: var(--space-1) var(--space-4);
  border-left: 2px solid transparent;
  color: var(--text);
  text-decoration: none;
  transition: background-color var(--motion) ease, border-color var(--motion) ease;
}

.palette-row:hover,
.palette-row[data-active="true"] {
  background: var(--border);
  border-left-color: var(--accent);
}

.palette-row:hover,
.palette-row:hover .palette-row-title,
.palette-row:focus-visible {
  color: var(--text);
}

.palette-row[data-active="true"] .palette-row-title {
  color: var(--accent);
}

.palette-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.palette-row-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--text-sm);
}

.palette-row-desc {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.palette-row-meta {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.palette-status {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.palette-status:empty {
  display: none;
}

.palette-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.palette-foot span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.palette-foot kbd {
  padding: 1px var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text);
}

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

.search-summary {
  margin-bottom: var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Type scale */

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-lg);
  font-weight: 700;
}

h3 {
  font-size: var(--text-base);
  font-weight: 600;
}

p {
  margin: 0;
}

/* The one recurring gesture: small mono text carries dates, years, and labels */

.meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
}

.muted {
  color: var(--text-muted);
}

/* Hero on the home page. It shares the section grid: a numbered index in the
   left column, then the role, the name, and a short mono ledger of facts. */

.hero {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
  padding: var(--space-9) 0 var(--space-8);
}

.hero-index {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.hero-role {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent);
}

.hero-title {
  margin-top: var(--space-3);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.hero-title::after {
  content: "";
  display: inline-block;
  width: 0.16em;
  height: 0.16em;
  margin-left: 0.14em;
  vertical-align: baseline;
  background: var(--accent);
}

.hero-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(160px, 18vw, 220px);
  grid-template-rows: auto auto;
  column-gap: var(--space-7);
  align-items: start;
}

.hero-intro {
  grid-column: 1;
  grid-row: 1;
}

/* The portrait sits beside the name, not above it, so the name stays the
   largest thing in the hero. Hover moves only the photo inside its frame. */

.hero-photo {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: start;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--motion) ease;
}

.hero-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  transition: transform 260ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.hero-photo:hover {
  border-color: var(--accent);
}

.hero-meta {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5) var(--space-7);
  align-items: start;
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.hero-facts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  max-width: 52ch;
}

.hero-fact {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: var(--space-3);
  align-items: baseline;
}

.hero-fact dt {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.hero-fact dd {
  margin: 0;
  font-size: var(--text-base);
}

.hero-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding-left: var(--space-4);
  border-left: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.hero-links a {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  color: var(--text);
}

.hero-links a span {
  font-size: var(--text-xs);
  color: var(--accent);
}

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

/* Page head on every other page. Same shape as the hero, smaller. */

.page-head {
  padding: var(--space-9) 0 var(--space-8);
  max-width: var(--measure);
}

.page-kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
}

.page-title {
  margin-top: var(--space-3);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.page-lede {
  margin-top: var(--space-4);
  max-width: 58ch;
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-muted);
}

.page-action {
  margin-top: var(--space-5);
}

/* Sections. One hairline opens each block, and a numbered mono label marks it.
   Everything after the head starts in the same column as the heading, so text
   never hangs back to the left of its own title. */

.section {
  padding: var(--space-7) 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--head-h) + var(--space-5));
}

.section-head {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
  margin-bottom: var(--space-6);
}

@media (min-width: 761px) {
  .section > *:not(.section-head) {
    margin-left: var(--section-gutter);
  }
}

.section-index {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-top: var(--space-1);
}

.section-index__rule {
  display: block;
  width: 24px;
  height: 1px;
  background: var(--border-strong);
}

.section-body h2 {
  font-size: var(--text-xl);
  letter-spacing: -0.035em;
  scroll-margin-top: calc(var(--head-h) + var(--space-5));
}

.section-note {
  margin-top: var(--space-2);
  max-width: 54ch;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.section-more {
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.section-prose {
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  color: var(--text);
}

/* Projects. A title column beside a small ledger of facts. */

.project-list {
  border-top: 1px solid var(--border);
}

.project {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: var(--space-5) var(--space-7);
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border);
}

.project-title {
  font-size: var(--text-md);
  font-weight: 600;
}

.project-title a {
  text-decoration: none;
}

.project-title a:hover {
  text-decoration: underline;
}

.project-summary {
  margin-top: var(--space-2);
  max-width: 56ch;
  color: var(--text-muted);
}

.project-links {
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.ledger {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.ledger--block {
  max-width: var(--measure);
  margin-bottom: var(--space-5);
}

.ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.ledger dt {
  color: var(--text-muted);
}

.ledger dd {
  margin: 0;
  color: var(--text);
  text-align: right;
  overflow-wrap: anywhere;
}

/* Entry lists used by post listings. Rows share one rule per item. */

.entries {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.entries > li {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border);
  transition: border-color var(--motion) ease;
}

.entries > li:hover {
  border-bottom-color: var(--accent-strong);
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.entry-title {
  font-size: var(--text-md);
  font-weight: 600;
}

.entry-title a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}

.entry-title a:hover {
  text-decoration: underline;
}

.entry-body {
  margin-top: var(--space-2);
  color: var(--text-muted);
  max-width: var(--measure);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Definition rows used by About */

.facts {
  margin: 0;
  max-width: var(--measure);
  border-top: 1px solid var(--border);
}

.facts > div {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.facts dt {
  flex: 0 0 12rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.facts dd {
  flex: 1 1 16rem;
  margin: 0;
}

.section-list {
  margin: 0;
  max-width: var(--measure);
  padding: 0;
  list-style: none;
}

.section-list > li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.section-list li:last-child {
  border-bottom: none;
}

/* Numbered variant, used by the principles list on the about page. The counter
   repeats the two digit index the section headings already use. */

.section-list--numbered {
  counter-reset: principle;
}

.section-list--numbered > li {
  display: flex;
  gap: var(--space-4);
  counter-increment: principle;
}

.section-list--numbered > li::before {
  content: counter(principle, decimal-leading-zero);
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Contact. The address is the page: it takes the size a heading would, and the
   supporting notes sit underneath in mono. One card, one primary action. */

.contact-card {
  max-width: var(--measure);
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.contact-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.contact-email {
  display: inline-block;
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.contact-email:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.contact-note {
  margin-top: var(--space-3);
  max-width: 54ch;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.contact-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--motion) ease, background var(--motion) ease;
}

.contact-button:hover,
.contact-button:active {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--bg);
  text-decoration: none;
}

.contact-hint {
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.contact-availability {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.contact-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-strong);
}

/* The three step guide reuses the ledger rhythm with numbers in the gutter. */

.contact-guide {
  counter-reset: step;
  max-width: var(--measure);
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-guide > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.contact-guide > li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
}

@media (min-width: 761px) {
  .contact-email {
    font-size: var(--text-xl);
  }
}

/* Empty states. Honest text, no illustration. */

.empty {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  max-width: var(--measure);
}

/* Prose, used for Markdown posts */

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

.prose > * + * {
  margin-top: var(--space-5);
}

.prose h2 {
  font-size: var(--text-lg);
  margin-top: var(--space-7);
}

.prose h3 {
  font-size: var(--text-md);
  margin-top: var(--space-6);
}

.prose ul,
.prose ol {
  padding-left: var(--space-5);
}

.prose li + li {
  margin-top: var(--space-2);
}

.prose blockquote {
  margin: 0;
  padding-left: var(--space-5);
  border-left: 2px solid var(--border);
  color: var(--text-muted);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.prose :not(pre) > code {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.prose pre code {
  font-size: var(--text-sm);
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.prose th,
.prose td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

/* Post header and footer */

.post-header {
  max-width: var(--measure);
  padding: var(--space-9) 0 var(--space-7);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.post-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.post-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

/* Outline beside a post. Below the two column breakpoint it sits above the
   body, where it still works as a jump list. */

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "outline" "prose";
  gap: var(--space-6);
}

.post-outline {
  grid-area: outline;
  min-width: 0;
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}

.post-outline__title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
}

.post-outline__list {
  display: flex;
  flex-direction: column;
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.post-outline__item a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0 0 var(--space-3);
  border-left: 1px solid var(--border);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--text-muted);
  text-decoration: none;
}

.post-outline__item--h3 a {
  padding-left: var(--space-5);
  font-size: var(--text-xs);
}

.post-outline__item a:hover {
  color: var(--text);
}

.post-outline__item a[aria-current="true"] {
  color: var(--text);
  border-left-color: var(--accent);
}

.prose {
  grid-area: prose;
  min-width: 0;
}

/* The sticky header covers an anchor target unless the heading keeps its
   distance from the top of the viewport. */
.prose :is(h2, h3) {
  scroll-margin-top: calc(var(--head-h) + var(--space-4));
}

@media (min-width: 1041px) {
  .post-layout {
    grid-template-columns: minmax(0, 1fr) 240px;
    grid-template-areas: "prose outline";
    gap: var(--space-8);
    align-items: start;
  }

  /* Centred in the viewport while the post scrolls past it. The transform
     cancels the element's own height, so its middle, not its top, is the
     point that sticks at the halfway line. */
  .post-outline {
    position: sticky;
    top: 50vh;
    transform: translateY(-50%);
    padding-bottom: 0;
    border-bottom: 0;
  }

  .post-outline__title {
    font-size: var(--text-sm);
  }

  .post-outline__list {
    margin-top: var(--space-4);
  }

  .post-outline__item a {
    min-height: 0;
    padding: var(--space-2) 0 var(--space-2) var(--space-4);
    font-size: var(--text-base);
  }

  .post-outline__item--h3 a {
    padding-left: var(--space-6);
    font-size: var(--text-sm);
  }
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: var(--space-7);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Pointer affordance in one place, so no control is left without it */

a[href],
button,
summary,
select,
label[for] {
  cursor: pointer;
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: calc(var(--head-h) + var(--space-7));
  }

  .nav {
    flex-wrap: wrap;
    padding-block: var(--space-2);
  }

  .nav-tools {
    display: contents;
  }

  .nav-links {
    gap: var(--space-3);
    order: 2;
    flex-basis: 100%;
  }

  .palette-trigger {
    order: 1;
    padding: 0 var(--space-2);
  }

  .palette-key {
    display: none;
  }

  .section-head {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .hero {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .project {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .hero,
  .page-head,
  .post-header {
    padding-top: var(--space-7);
  }

  .facts dt {
    flex: 0 0 100%;
  }

  /* The palette is used by thumb too, so its rows and close control get a
     full tap target even though the desktop panel stays compact. */
  .palette-row {
    min-height: 44px;
  }

  .palette-close {
    min-height: 44px;
    min-width: 44px;
  }

  .hero-links a,
  .section-more a,
  .project-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
}

/* Below 480px the hero gets its own stacking: name full width, portrait beside
   the facts, jump list on its own row. */
@media (max-width: 480px) {
  .hero-body {
    grid-template-columns: minmax(0, 1fr) clamp(88px, 26vw, 112px);
    column-gap: var(--space-4);
  }

  .hero-intro {
    grid-column: 1 / -1;
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--border);
  }

  .hero-meta {
    display: contents;
  }

  .hero-facts {
    grid-column: 1;
    grid-row: 2;
    margin-top: var(--space-4);
  }

  .hero-fact {
    grid-template-columns: 3.5rem minmax(0, 1fr);
  }

  .hero-photo {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    margin-top: var(--space-4);
  }

  .hero-links {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: var(--space-5);
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    padding-left: 0;
    border-left: 0;
  }
}

/* Motion. The page header and the section rule enter once; links, the focus
   ring, and the portrait hover confirm a state. Nothing loops. Reduced motion
   turns all of it off. */
@media (prefers-reduced-motion: no-preference) {
  .hero,
  .page-head,
  .post-header {
    animation: enter 380ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
  }

  .section-index__rule {
    transform-origin: left center;
    animation: draw 320ms cubic-bezier(0.2, 0.7, 0.3, 1) 120ms both;
  }

  .hero-photo:hover img {
    transform: scale(1.04);
  }

  html {
    scroll-behavior: smooth;
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes draw {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

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