:root {
  /* Backgrounds */
  --bg:        #ffffff;
  --bg-warm:   #faf8f4;
  --bg-subtle: #f3f0eb;

  /* Text */
  --ink:       #333333;
  --ink-soft:  #5a5959;
  --ink-muted: #909090;

  /* Borders */
  --line:        rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.16);

  /* Shadow — very light for academic feel */
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);

  /* Brand */
  --orange:      #e07428;
  --orange-deep: #c05618;
  --orange-dim:  rgba(224, 116, 40, 0.12);
  --blue:        #4a88c8;
  --blue-deep:   #2a68a8;
  --blue-dim:    rgba(74, 136, 200, 0.10);
  --teal:        #2a9090;

  /* Shape — more rectilinear for academic feel */
  --radius-xl: 6px;
  --radius-lg: 5px;
  --radius-md: 4px;
  --radius-sm: 3px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Newsreader", Georgia, serif;
  line-height: 1.68;
}

/* ---- Publication container ---- */
.publication {
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: 0 24px 96px;
}

/* ---- Reveal animations ---- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise-in 0.6s ease forwards;
}

.reveal:nth-of-type(2) { animation-delay: 0.05s; }
.reveal:nth-of-type(3) { animation-delay: 0.10s; }
.reveal:nth-of-type(4) { animation-delay: 0.15s; }
.reveal:nth-of-type(5) { animation-delay: 0.20s; }
.reveal:nth-of-type(6) { animation-delay: 0.25s; }
.reveal:nth-of-type(7) { animation-delay: 0.30s; }
.reveal:nth-of-type(8) { animation-delay: 0.35s; }

@keyframes rise-in {
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Layout: narrow text column, wider for asides ---- */
/* Distill-style: prose is ~640px, with right gutter for margin notes */

.hero {
  max-width: 960px;
  margin: 0 auto;
  padding: 56px 0 48px;
  border-bottom: 1px solid var(--line);
}

.section {
  max-width: 648px;
  margin: 48px auto 0;
}

/* Sections with margin notes get a wider container */
.section-with-aside {
  max-width: 960px;
  display: grid;
  grid-template-columns: 640px minmax(0, 1fr);
  gap: 0 56px;
  align-items: start;
}

/* Annotation-strip sections need more width for the 4-up grid */
.section:has(.annotation-strip) {
  max-width: 960px;
}

/* ---- Labels ---- */
.eyebrow,
.figure-label {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.note-label,
.metric-label,
.mini-stat-grid span,
.depth-chip span,
.depth-controls .note-label {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.step-index {
  margin: 0 0 4px;
  color: var(--ink-muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

/* ---- Headings ---- */
h1, h2, h3 {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

h1 {
  max-width: 640px;
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.06;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.standfirst {
  max-width: 620px;
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-size: 1.22rem;
  line-height: 1.62;
  font-style: italic;
}

/* ---- Hero grid (text + margin note) ---- */
.hero-grid {
  display: grid;
  grid-template-columns: 640px minmax(0, 1fr);
  gap: 0 56px;
  align-items: start;
  margin-top: 32px;
}

/* ---- Prose ---- */
.prose {
  max-width: 640px;
}

.prose h2 {
  margin-bottom: 16px;
  font-size: 1.72rem;
  line-height: 1.14;
  letter-spacing: -0.02em;
}

.prose p {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 1.06rem;
}

.prose em {
  color: var(--ink);
  font-style: italic;
}

/* ---- Margin notes ---- */
.margin-note {
  position: sticky;
  top: 24px;
  padding-top: 4px;
}

/* Distill-style side note: small, light gray text with left rule */
.hero-note,
.section-with-aside .margin-note {
  padding: 0 0 0 16px;
  border-left: 2px solid var(--line-strong);
}

.note-copy {
  margin: 0;
  color: var(--ink-muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.88rem;
  line-height: 1.72;
}

.equation {
  margin: 0 0 10px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.72;
}

/* ---- Annotation strip ---- */
.annotation-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.annotation-strip-wide {
  margin-top: 16px;
}

.annotation-card {
  padding: 16px 20px 16px 0;
  border-top: 1px solid var(--line-strong);
}

.annotation-card:not(:last-child) {
  padding-right: 20px;
  margin-right: 0;
}

.annotation-card h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  font-size: 0.96rem;
  font-weight: 800;
}

.annotation-card p {
  margin: 0;
  color: var(--ink-soft);
  font-family: "Manrope", sans-serif;
  font-size: 0.92rem;
  line-height: 1.68;
}

/* ---- Figure blocks — break out wider than text column ---- */
.figure-block {
  width: 100%;
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}

.figure-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
}

.figure-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 28px;
  margin-bottom: 20px;
}

.figure-copy {
  max-width: 52rem;
}

.figure-copy h2 {
  font-size: 1.72rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.figure-intro,
.inspector-copy {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-family: "Manrope", sans-serif;
  font-size: 0.94rem;
  line-height: 1.68;
}

.figure-story {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) 340px;
  gap: 38px;
  align-items: start;
}

.figure-stage {
  position: sticky;
  top: 18px;
}

/* ---- Graph frames — light academic background ---- */
.graph-frame {
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.graph-frame-primary,
.graph-frame-light {
  background:
    radial-gradient(circle at 20% 16%, rgba(74, 136, 200, 0.06), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(224, 116, 40, 0.06), transparent 24%),
    var(--bg-warm);
}

.graph-frame svg {
  display: block;
  width: 100%;
}

/* ---- Figure legend ---- */
.figure-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  margin-top: 12px;
  color: var(--ink-muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.86rem;
}

.figure-legend span {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.figure-legend code {
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.legend-low  { background: var(--blue); }
.legend-high { background: var(--orange); }

.legend-line {
  width: 24px;
  height: 0;
  display: inline-block;
  border-top: 2px solid rgba(0, 0, 0, 0.30);
}

/* ---- Graph SVG sizes ---- */
#message-graph { height: 720px; }
#depth-graph   { height: 620px; }

/* ---- Metrics bar ---- */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric-card,
.inspector-card,
.depth-chip {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.metric-card {
  min-height: 96px;
  padding: 14px 14px 12px;
  border-top: 2px solid var(--line);
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.36rem;
}

/* Highlighted "Updated state" metric */
.metric-card-strong {
  border-top-color: var(--orange);
  background: rgba(224, 116, 40, 0.04);
}

/* ---- Inspector grid ---- */
.inspector-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.inspector-card {
  padding: 16px;
  border-top: 2px solid var(--line);
}

/* Equation card gets a blue top accent */
.equation-card {
  border-top-color: var(--blue);
  background: rgba(74, 136, 200, 0.04);
}

.inspector-card h3 {
  margin: 4px 0 8px;
  font-family: "Manrope", sans-serif;
  font-size: 0.96rem;
  font-weight: 800;
}

.equation-large {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.96rem;
  line-height: 1.82;
}

/* ---- Value / message rows ---- */
.value-stack,
.message-list { display: grid; gap: 8px; }

.value-row,
.message-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: "Manrope", sans-serif;
  font-size: 0.88rem;
}

.value-row:first-child,
.message-row:first-child { padding-top: 0; border-top: 0; }

.value-row strong,
.message-row strong {
  flex-shrink: 0;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
}

.message-row small {
  display: block;
  color: var(--ink-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  line-height: 1.5;
}

/* ---- Figure narrative (scrolly steps) ---- */
.figure-narrative { display: grid; gap: 0; padding-top: 10px; }

.figure-step {
  min-height: 34vh;
  padding: 20px 16px 20px 18px;
  border-left: 2px solid var(--line);
  opacity: 0.44;
  cursor: pointer;
  transition: opacity 200ms ease, border-color 200ms ease, background 200ms ease;
  display: grid;
  align-content: center;
  gap: 8px;
}

.figure-step.is-active {
  opacity: 1;
  border-left-color: var(--orange);
}

.figure-step.is-active .step-index {
  color: var(--orange);
}

.figure-step:focus-visible {
  outline: none;
  border-left-color: var(--teal);
}

.figure-step h3 {
  font-family: "Manrope", sans-serif;
  font-size: 1.02rem;
  font-weight: 800;
}

.figure-step p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-family: "Manrope", sans-serif;
  font-size: 0.92rem;
  line-height: 1.68;
}

/* ---- Segmented controls ---- */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

button { font: inherit; cursor: pointer; }

.segmented button {
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink-soft);
  font-family: "Manrope", sans-serif;
  font-size: 0.88rem;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.segmented button:hover {
  background: var(--bg-subtle);
  border-color: rgba(0, 0, 0, 0.24);
  color: var(--ink);
}

.segmented button.is-active {
  border-color: var(--orange);
  background: rgba(224, 116, 40, 0.08);
  color: var(--orange-deep);
  font-weight: 600;
}

.scene-picker { justify-content: flex-end; }

/* ---- Depth figure ---- */
.depth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 300px;
  gap: 22px;
  align-items: start;
}

.depth-main { min-width: 0; }
.depth-controls { margin-top: 14px; }
.depth-picker  { margin-top: 8px; }

.depth-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.depth-chip {
  padding: 12px 12px 10px;
  border-top: 2px solid transparent;
}

.depth-chip strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.02rem;
}

.depth-chip small {
  display: block;
  margin-top: 5px;
  color: var(--ink-muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.78rem;
  line-height: 1.5;
}

.depth-chip.is-active {
  border-top-color: var(--orange);
  background: rgba(224, 116, 40, 0.06);
}

.depth-rail { display: grid; gap: 10px; }

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.mini-stat-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.08rem;
}

.section-closing { padding-bottom: 10px; }

/* ---- SVG graph element styles ---- */
.graph-edge {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 160ms ease, stroke 160ms ease, stroke-width 160ms ease;
}

.edge-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  fill: var(--ink);
  paint-order: stroke;
  stroke: rgba(250, 248, 244, 0.94);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.graph-node { cursor: pointer; }

.graph-node circle,
.graph-node text {
  transition: transform 160ms ease, opacity 160ms ease;
}

.graph-node:hover circle { transform: scale(1.02); }

.graph-node.is-selected .node-shell {
  stroke: rgba(23, 23, 19, 0.88) !important;
  stroke-width: 3.5;
}

.graph-node.is-focus .node-shell {
  stroke: var(--orange) !important;
}

.graph-node:focus-visible { outline: none; }

.graph-node:focus-visible .node-shell {
  stroke: var(--teal) !important;
  stroke-width: 3.5;
}

.node-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
  dominant-baseline: middle;
  text-anchor: middle;
}

.node-caption {
  font-family: "Manrope", sans-serif;
  font-size: 11px;
  fill: var(--ink-muted);
  text-anchor: middle;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hop-halo-1,
.hop-halo-2 { fill: none; stroke-width: 2; }

.hop-halo-1 { stroke: rgba(42, 144, 144, 0.42); }
.hop-halo-2 { stroke: rgba(74, 136, 200, 0.40); stroke-dasharray: 5 5; }

.graph-note {
  font-family: "Manrope", sans-serif;
  font-size: 12px;
  fill: var(--ink-muted);
}

.contributors-empty {
  margin: 0;
  color: var(--ink-soft);
  font-family: "Manrope", sans-serif;
  font-size: 0.9rem;
  line-height: 1.68;
}

/* ---- Responsive ---- */
@media (max-width: 1280px) {
  .figure-story,
  .depth-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .figure-stage,
  .margin-note {
    position: static;
  }

  .scene-picker { justify-content: flex-start; }
}

@media (max-width: 1024px) {
  .hero-grid,
  .section-with-aside {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px 0;
    max-width: 648px;
  }

  .hero-note,
  .section-with-aside .margin-note {
    padding: 16px;
    border-left: none;
    border-top: 1px solid var(--line-strong);
    background: var(--bg-warm);
    border-radius: var(--radius-sm);
  }
}

@media (max-width: 960px) {
  .annotation-strip,
  .annotation-strip-wide,
  .metrics-bar,
  .depth-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inspector-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .publication {
    padding: 0 16px 72px;
  }

  .hero {
    padding: 32px 0 36px;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .standfirst { font-size: 1.1rem; }
  .prose p    { font-size: 1rem; }

  .annotation-strip,
  .annotation-strip-wide,
  .metrics-bar,
  .depth-track,
  .mini-stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #message-graph { height: 540px; }
  #depth-graph   { height: 480px; }

  .figure-step {
    min-height: auto;
    padding-left: 14px;
  }
}
