:root {
  /* Palette */
  --blue:       #254EFF;
  --paper:      #F8ECDA;
  --white:      #ffffff;
  --ink:        #35302E;

  /* Semantic tokens — page bg is the warm off-white paper; the main
     content frame sits on top as a clean white card. */
  --bg:         var(--paper);
  --bg-frame:   var(--white);
  --bg-panel:   var(--white);
  --fg:         var(--ink);
  --fg-muted:   #6b6358;   /* warm grey for secondary text */
  --accent:     var(--blue);
  --rule:       #e5ddcb;   /* soft beige divider */
  --rule-strong:#35302E;   /* ink, for strong borders */

  /* Solid offset shadow (Berkeley Mono style — no blur) */
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-md: 5px 5px 0 var(--ink);
  --shadow-lg: 8px 8px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding: 2.5rem 1.5rem 4rem;
}

/* Berkeley-Mono-style outer page frame: bordered card with a solid
   offset shadow, sitting in the middle of the paper page. */
.page-frame {
  max-width: 960px;
  margin: 0 auto;
  background: var(--bg-frame);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow-lg);
  padding: 3rem 3rem 4.5rem;
}

@media (max-width: 820px) {
  body { padding: 1rem 0.75rem 3rem; }
  .page-frame { padding: 2rem 1.5rem 3rem; }
}

/* ---------- typography ---------- */

h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--fg);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 3.25rem;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  color: var(--accent);
}

/* "Edge" inherits the same Tomato Grotesk + blue colour as the rest
   of the title; the slanted italic variant gives a subtle visual pull
   without breaking the type unity. */
h1 .title-edge {
  font-family: var(--font-heading);
  font-style: italic;
  font-weight: 600;
  color: var(--accent);
}

h2 {
  font-size: 1.75rem;
  margin-top: 3.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

h3 {
  font-size: 1.15rem;
  margin-top: 2rem;
  font-weight: 600;
  letter-spacing: 0;
}

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(37, 78, 255, 0.25);
  transition: border-color 120ms ease, color 120ms ease;
}
a:hover {
  border-bottom-color: var(--accent);
}

strong, b { font-weight: 700; }

/* ---------- section dividers ---------- */

section + section {
  margin-top: 2rem;
}

/* ---------- paper card ---------- */

.card {
  background: var(--bg-panel);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.75rem;
}

/* Legacy class from prior design — map to the new card look so old
   markup still renders cleanly while we roll the redesign through. */
.pixel-frame {
  background: var(--bg-panel);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.75rem;
}

.placeholder {
  color: var(--fg-muted);
  text-align: center;
  padding: 2rem 0;
  opacity: 0.7;
  font-size: 0.9rem;
}

/* ---------- title / header ---------- */

.site-header {
  padding: 0.5rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}

.site-header .subtitle {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  line-height: 1.3;
  font-weight: 400;
  color: var(--fg-muted);
  margin: 0 0 1.75rem;
}

.site-header .authors {
  color: var(--fg);
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.site-header .authors a {
  color: var(--fg);
  border-bottom: 1px dotted var(--rule);
}
.site-header .authors a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.site-header .authors a.email-link {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 0.3em;
  padding: 0 0.1em;
  border-bottom: none;
  color: var(--fg-muted);
}
.site-header .authors a.email-link:hover {
  color: var(--accent);
  border-bottom: none;
}

.site-header .top-links {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-top: 0.5rem;
}
.site-header .top-links a { margin-right: 0.25rem; }

/* Letterhead — thin logo strip at the very top of the page frame,
   above the H1. Acts like institutional stationery. */
.letterhead {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
.letterhead img {
  height: 48px;
  width: auto;
}

/* ---------- abstract ---------- */

.abstract-box { margin: 0 0 2.5rem; }
.abstract-heading {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 0.75rem;
}
.abstract-body {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--fg);
  margin: 0;
}

/* ---------- primitive: callout ----------
   Big Tomato Grotesk statement used to emphasise a single-sentence
   thesis ("The Problem.", "The Challenge.", "Our Approach."). The
   leading label goes in a <strong> and is coloured accent blue. */

.callout {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  line-height: 1.3;
  font-weight: 400;
  color: var(--fg);
  margin: 1.75rem 0;
  letter-spacing: -0.005em;
}
.callout strong {
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.25em;
}

/* Smaller variant for when a callout needs to sit inline with body
   copy without dominating. */
.callout.callout-sm {
  font-size: 1.35rem;
}

/* Pull-quote variant — full-width, hairline rules top and bottom.
   Used as a pivot/transition from "The Problem" → "Our Approach".
   Label becomes a small uppercase kicker above the statement. */
.callout-question {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  line-height: 1.2;
  font-weight: 400;
  font-style: italic;
  color: var(--fg);
  text-align: center;
  margin: 3rem 0;
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  letter-spacing: -0.01em;
}
.callout-question strong {
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.1rem;
}

@media (max-width: 820px) {
  .callout-question { font-size: 1.75rem; padding: 2rem 1rem; }
}
@media (max-width: 640px) {
  .callout-question { font-size: 1.35rem; padding: 1.5rem 0.5rem; margin: 2.25rem 0; }
}

@media (max-width: 640px) {
  .callout { font-size: 1.3rem; }
  .callout.callout-sm { font-size: 1.1rem; }
}

/* ---------- intro section (replaces the old abstract) ---------- */

#intro { margin: 1rem 0 3rem; }
#intro p:not(.callout):not(.callout-question) {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--fg);
  margin: 1.25rem 0;
}
#intro em { font-style: italic; color: var(--fg); }

/* ---------- primitive: inline citation ----------
   Use: <a class="cite" href="...">(Author et al., 2021)</a>
   Smaller, muted-blue, no underline at rest; underlines on hover. */

a.cite {
  font-family: var(--font-body);
  font-size: 0.88em;
  color: var(--accent);
  border-bottom: none;
  white-space: nowrap;
  margin-left: 0.2em;
}
a.cite:hover { border-bottom: 1px solid var(--accent); }

/* Square figure + caption-on-the-right row. Figure is intentionally
   wider than the caption so the image reads as the lead element. */
.figure-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
  margin: 2rem 0;
  padding: 0;
}
.figure-row .figure-mount {
  aspect-ratio: 1 / 1;
  min-height: 0;          /* aspect-ratio handles sizing now */
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;              /* row provides spacing */
  padding: 1rem;
}
.figure-caption {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--fg-muted);
}
.figure-caption strong {
  color: var(--fg);
  font-weight: 600;
  margin-right: 0.35em;
}

@media (max-width: 640px) {
  .figure-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .figure-row .figure-mount {
    max-width: 280px;
    margin: 0 auto;
  }
}

/* Two figures side-by-side, each with its own caption directly below.
   Used after "Our Approach" in the intro. */
.figure-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  margin: 2.25rem 0;
}
.figure-pair figure {
  margin: 0;
  display: flex;
  flex-direction: column;
}
.figure-pair .figure-mount {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  margin: 0 0 0.75rem;
}
.figure-pair .figure-mount.svg-loaded {
  align-items: stretch;
  justify-content: stretch;
}
.figure-mount svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* fig-model-sizes interactive bits */
#fig-2b .model-name text { transition: fill 100ms ease; }
#fig-2b .model-name:hover text {
  fill: var(--accent);
  text-decoration: underline;
}
#fig-2b .model-dot { transition: fill 100ms ease; }

.model-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 320px;
  padding: 0.7rem 0.85rem;
  background: var(--bg-frame);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.model-tooltip.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.model-tooltip .model-tooltip-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.model-tooltip .model-tooltip-desc { color: var(--fg); }
.model-tooltip .model-tooltip-desc .muted { color: var(--fg-muted); font-style: italic; }
.model-tooltip .model-tooltip-links {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--rule);
  font-size: 0.85rem;
}
.model-tooltip a {
  color: var(--accent);
  border-bottom: 1px solid rgba(37, 78, 255, 0.3);
}
.model-tooltip a + a { margin-left: 0.6rem; }

/* fig-literature-clusters interactivity */
#fig-how svg .cluster-group,
#fig-how svg .cluster-label {
  transition: opacity 150ms ease;
}
#fig-how svg.has-active .cluster-group:not(.is-active),
#fig-how svg.has-active .cluster-label:not(.is-active) {
  opacity: 0.12;
}
#fig-how svg.has-active .cluster-noise { opacity: 0.08; }
#fig-how svg .cluster-group.is-active { opacity: 1; }

.cluster-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 360px;
  padding: 0.7rem 0.85rem 0.85rem;
  background: var(--bg-frame);
  border: 1px solid var(--ink);
  border-left-width: 4px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-body);
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.cluster-tooltip.is-visible { opacity: 1; pointer-events: auto; }
.cluster-tooltip-head {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.cluster-tooltip-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid var(--ink);
}
.cluster-tooltip-count {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.cluster-tooltip-kws {
  display: flex; flex-wrap: wrap; gap: 0.3rem 0.4rem;
  margin-bottom: 0.65rem;
}
.cluster-tooltip-kw {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.1rem 0.45rem;
}
.cluster-tooltip-reps-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.3rem;
}
.cluster-tooltip-reps {
  list-style: none;
  margin: 0; padding: 0;
}
.cluster-tooltip-reps li {
  margin: 0.2rem 0;
  font-size: 0.85rem;
  line-height: 1.35;
}
.cluster-tooltip-reps a {
  color: var(--accent);
  border-bottom: 1px solid rgba(37, 78, 255, 0.3);
}

/* fig-domain-network interactivity */
#fig-where svg .where-edge,
#fig-where svg .where-tech,
#fig-where svg .where-domain,
#fig-where svg .where-label,
#fig-where svg .where-leader {
  transition: opacity 140ms ease, stroke-width 140ms ease, fill 140ms ease;
}
#fig-where svg.has-active .where-edge,
#fig-where svg.has-active .where-tech,
#fig-where svg.has-active .where-label,
#fig-where svg.has-active .where-leader,
#fig-where svg.has-active .where-domain {
  opacity: 0.2;
}
#fig-where svg.has-active .where-edge.is-active,
#fig-where svg.has-active .where-tech.is-active,
#fig-where svg.has-active .where-label.is-active,
#fig-where svg.has-active .where-leader.is-active,
#fig-where svg.has-active .where-domain.is-active {
  opacity: 1;
}

.where-detail {
  margin-top: 1rem;
}
.where-detail-head {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 0.55rem;
}
.where-detail-list {
  margin: 0;
  padding-left: 1.2rem;
}
.where-detail-list li {
  margin: 0.35rem 0;
  color: var(--fg);
  font-size: 0.92rem;
  line-height: 1.45;
}
.where-detail-year {
  color: var(--fg-muted);
  font-style: italic;
}

.figure-pair figcaption {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--fg-muted);
}
.figure-pair figcaption strong {
  color: var(--fg);
  font-weight: 600;
  margin-right: 0.35em;
}

@media (max-width: 640px) {
  .figure-pair {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* ---------- pipeline hero ---------- */

#pipeline-hero { margin: 2.5rem 0 3rem; }

/* Pipeline figure: borderless mount. An animated wireframe mesh
   canvas sits behind the stack (see pipeline-mesh.js). */
#pipeline-figure {
  position: relative;
  min-height: 260px;
  padding: 1.25rem 0;
}
.pipeline-mesh-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

.pipeline-stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  width: 100%;
}

/* ---- requirement bands (above + below the strip) ---- */

.pipeline-band-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.pipeline-band-top    { order: 0; }
.pipeline-band-bottom { order: 2; }

.pipeline-band {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-align: center;
}

.pipeline-reqs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}
.pipeline-req {
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  min-width: 5.5rem;
  text-align: center;
  transition: color 120ms ease, background 120ms ease;
}
.pipeline-req:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.pipeline-req.is-active {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- pipeline strip: one continuous horizontal bar ---- */

.pipeline-strip {
  order: 1;
  display: flex;
  width: 100%;
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  background: var(--bg-panel);
}
.pipeline-segment {
  flex: 1 1 0;
  min-width: 0;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--fg);
  background: transparent;
  border: 0;
  padding: 1.1rem 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: color 120ms ease, background 120ms ease;
}
.pipeline-segment + .pipeline-segment {
  border-left: 1px solid var(--ink);
}
.pipeline-segment:hover {
  color: var(--accent);
  background: var(--bg);
}
.pipeline-segment.is-active {
  color: var(--paper);
  background: var(--accent);
}

@media (max-width: 640px) {
  .pipeline-segment { font-size: 0.78rem; padding: 0.85rem 0.4rem; }
  .pipeline-req { font-size: 0.8rem; min-width: 0; padding: 0.25rem 0.7rem; }
}

#pipeline-detail h3 { margin-top: 0; }
#pipeline-detail .refs {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  color: var(--fg-muted);
}
#pipeline-detail .refs ol { padding-left: 1.5rem; margin: 0.5rem 0 0; }
#pipeline-detail .refs li { margin: 0.25rem 0; }

sup.ref-marker a {
  color: var(--accent);
  border: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* ---------- analysis ---------- */

/* ---------- tabs (analysis) ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2rem;
}
.tab {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1rem;
  color: var(--fg-muted);
  background: transparent;
  border: 0;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms ease, border-color 120ms ease;
}
.tab:hover { color: var(--fg); }
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.chart-mount {
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.placeholder-text { color: var(--fg-muted); }

/* Figure on the left + caption on the right inside each analysis tab. */
.analysis-figure {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  margin: 1.5rem 0 0;
  padding: 0;
}
.analysis-figure .figure-mount {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  margin: 0;
}
.analysis-figure figcaption {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--fg-muted);
  padding-top: 0.25rem;
}
.analysis-figure figcaption strong {
  color: var(--fg);
  font-weight: 600;
  margin-right: 0.35em;
}

@media (max-width: 820px) {
  .analysis-figure { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 640px) {
  .tab { padding: 0.75rem 0.9rem; font-size: 0.9rem; }
}

/* ---------- recommendations ---------- */

.recs-list {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--fg);
}
.recs-list li { margin: 0.6rem 0; }

/* ---------- citation ---------- */

.bibtex {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  line-height: 1.5;
  padding-right: 5.5rem;   /* room for the copy button */
}

.bibtex-wrap { position: relative; }

.copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--fg);
  background: var(--bg-panel);
  border: 1px solid var(--ink);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 80ms ease, box-shadow 80ms ease,
              color 120ms ease, background 120ms ease;
}
.copy-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--accent);
}
.copy-btn.is-copied {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--ink);
}
.copy-btn.is-copied:hover {
  color: var(--paper);
}

/* ---------- discussion ---------- */

.giscus { width: 100%; }
.giscus-frame {
  width: 100%;
  border: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1rem; }
  .site-header .subtitle { font-size: 1.2rem; }
  .pipeline-stage { min-width: 7rem; font-size: 0.9rem; }
}
