/*
 * Explainer page. Builds on style.css for tokens, typography, sections and footer.
 *
 * Every scene reads correctly on its first frame; motion only adds emphasis. Scenes
 * loop on their own clocks and pause while offscreen. Under prefers-reduced-motion
 * nothing moves.
 */
.explainer-hero {
  padding-block: 64px 48px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}

/* Running prose keeps a book-like line length; figures still take the whole column. */
:root {
  --measure: 76ch;
}

.section-intro,
.explainer-hero .hero-lead,
.explainer-hero .hero-claim {
  max-width: var(--measure);
}

.hero-byline {
  display: flex;
  flex-wrap: wrap;
  row-gap: 4px;
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.hero-byline span:first-child {
  color: var(--text);
  font-weight: 650;
}

.hero-byline span + span::before {
  margin-inline: 10px;
  color: var(--text-faint);
  content: "·";
}

.explainer-hero h1 {
  max-width: var(--prose);
  margin-top: 12px;
  font-size: clamp(2.4rem, 5vw, 3.8rem);
}

.explainer-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.explainer-toc a {
  padding: 6px 12px;
  color: var(--primary);
  background: rgb(255 255 255 / 0.74);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
}

.explainer-toc a:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.prose-block {
  max-width: var(--prose);
  margin-top: 52px;
}

.prose-block h4 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.prose-block h3,
.setting-title {
  margin: 0 0 10px;
  font-size: 1.4rem;
}

.prose-block p,
.setting-copy {
  max-width: var(--measure);
  margin: 0;
  color: var(--text-muted);
}

/* Most setting blurbs are one paragraph, so the base rule zeroes the margin.
   Where a blurb runs to several, they still need to read as paragraphs. */
.setting-copy + .setting-copy {
  margin-top: 0.9em;
}

/* A declaration the reader needs before the figure, and therefore cannot live
   inside it: every other code block on this page belongs to a figure panel. */
.prose-code {
  max-width: var(--prose);
  margin: 14px 0 0;
  padding: 14px 18px;
  overflow-x: auto;
  background: var(--surface-muted);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.prose-block p + .prose-code {
  margin-top: 16px;
}

/* The names a following formula is written in. One column of terms, so their
   definitions line up and the formula can then be read straight through. */
.prose-terms {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  max-width: var(--measure);
  margin: 14px 0 0;
}

.prose-terms dt {
  color: var(--text);
  font: 0.78rem var(--mono);
}

.prose-terms dd {
  margin: 0;
  color: var(--text-muted);
}

@media (width <= 600px) {
  .prose-terms {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .prose-terms dd {
    margin-bottom: 8px;
  }
}

/* Paragraphs carry no margin of their own, so two in a row would touch. */
.prose-block p + p {
  margin-top: 14px;
}

/* Two readings of one thing, side by side: the notation and what it denotes. */
.side-by-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  max-width: var(--prose);
  margin: 18px 0 0;
}

.side-by-side .prose-code {
  height: 100%;
  margin: 0;
}

/* One equation per card, as the equations figure sets them: the reader is meant
   to recognize this as the same system, so it is not a second notation. */
.eq-system {
  height: 100%;
  padding: 14px 18px;
  background: var(--surface-muted);
  border-radius: var(--radius);
}

.eq-system p {
  margin: 0 0 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  border-radius: 8px;
  font: 0.82rem / 1.6 var(--mono);
}

.eq-system p:last-child {
  margin-bottom: 0;
}

.eq-system b {
  color: var(--accent);
  font-weight: 700;
}

.eq-rel {
  margin: 0 4px;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .side-by-side {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------------------- */
/* Query-answer trees: one equation system, drawn                             */
/* -------------------------------------------------------------------------- */

.qat-frame {
  position: relative;
  height: 100%;
  padding: 12px 14px;
  background: var(--surface-muted);
  border-radius: var(--radius);
}

/* The band names the system once and each tree's unknown above its own box, so
   a tree is read as the right-hand side of the equation for that name. */
/* A fixed first track, not `auto`: the two grids size their tracks
   independently, so an `auto` column set by the word "eqs" in one and by an
   empty cell in the other would leave every name off-centre over its box. */
.qat,
.qat-row {
  display: grid;
  grid-template-columns: 52px repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* On a phone six trees in six columns leave about 50px each, which is narrower
   than a single node label. Scroll the frame instead of shrinking the trees: both
   grids sit inside it, so the band stays aligned over its own row. */
@media (max-width: 720px) {
  .qat-frame {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .qat-frame .qat,
  .qat-frame .qat-row {
    min-width: max-content;
    grid-template-columns: 52px repeat(4, minmax(150px, 1fr));
  }

  .qat-frame .qat-2 {
    grid-template-columns: 52px repeat(2, minmax(150px, 1fr));
  }

  .qat-frame .qat-5 {
    grid-template-columns: 52px repeat(5, minmax(150px, 1fr));
  }

  .qat-frame .qat-6 {
    grid-template-columns: 52px repeat(6, minmax(150px, 1fr));
  }
}

/* A system with a different number of unknowns than the counting loop's four. */
.qat-2 {
  grid-template-columns: 52px repeat(2, minmax(0, 1fr));
}

.qat-5 {
  grid-template-columns: 52px repeat(5, minmax(0, 1fr));
}

.qat-6 {
  grid-template-columns: 52px repeat(6, minmax(0, 1fr));
}

/* A second procedure's row, under the first. */
.qat-frame .qat + .qat-row + .qat {
  margin-top: 16px;
}

.qat {
  align-items: center;
  padding-block: 5px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.qat-system,
.qat-name {
  text-align: center;
  font: 700 0.78rem var(--mono);
}

.qat-system {
  padding-left: 10px;
  color: var(--text-muted);
  font-style: italic;
  text-align: left;
}

.qat-row {
  margin-top: 8px;
}

/* Keeps the trees' columns under the band's: the band's first cell is the
   system's name, which no tree sits under. */
.qat-row::before {
  content: "";
}

.qat-box {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.qat-svg {
  width: 100%;
  height: auto;
}

.qat-node rect {
  fill: var(--surface-muted);
  stroke: var(--border-strong);
}

.qat-answer rect {
  stroke: var(--accent);
}

.qat-label {
  fill: var(--text);
  font: 0.5rem var(--mono);
}

.qat-kind {
  fill: var(--accent);
  font-weight: 700;
}

.qat-edge {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.qat-note {
  max-width: var(--measure);
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.qat-edge-label {
  fill: var(--text-muted);
  font: italic 0.5rem var(--mono);
}

/* -------------------------------------------------------------------------- */
/* Pipeline: what goes into a stage and what comes out                        */
/* -------------------------------------------------------------------------- */

.pipe {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  max-width: var(--prose);
  margin: 18px 0 0;
}

/* Content-sized, not stretched: the second pipeline is the first with a stage
   in front, and that only reads if the shared stages keep the same size. */
.pipe-stage {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  min-width: 128px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.pipe-stage code,
.pipe-stage strong {
  font-size: 0.86rem;
}

.pipe-stage small {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

/* The solver is the one stage that is not a value being carried along. */
.pipe-engine {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* The stage the second pipeline adds in front of the first. */
.pipe-added {
  border-style: dashed;
  border-color: var(--accent);
}

.pipe-arrow {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
}

.pipe-arrow i {
  font-size: 0.9rem;
}

.pipe-arrow small {
  font: 600 0.66rem / 1 var(--mono);
}

@media (max-width: 720px) {
  .pipe {
    flex-direction: column;
  }

  .pipe-arrow {
    flex-direction: row;
    gap: 6px;
  }

  .pipe-arrow i {
    rotate: 90deg;
  }
}

.setting-title {
  margin-top: 56px;
}

/* -------------------------------------------------------------------------- */
/* Scene frame and shared SVG vocabulary                                      */
/* -------------------------------------------------------------------------- */

.scene {
  margin: 28px 0 0;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* Capped so labels drawn at 12-15px stay near that size on a wide screen. */
.scene svg {
  display: block;
  width: 100%;
  max-width: 1000px;
  height: auto;
  margin-inline: auto;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* A captured figure, such as the solve replay's animation, keeps its own size at most. */
.scene > img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

/* Below the prose column the labels would shrink past reading size, so the figure
   keeps a floor and the frame scrolls, as the timeline axis already does. */
@media (max-width: 720px) {
  .scene {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .scene > svg {
    min-width: 640px;
  }
}

.scene figcaption {
  max-width: var(--prose);
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.scene.is-offscreen *,
.scene.is-offscreen *::before,
.scene.is-offscreen *::after {
  animation-play-state: paused !important;
}

.scene text {
  fill: var(--text);
  font-size: 13px;
}

.scene .code-label {
  font-family: var(--mono);
}

.axis-label {
  fill: var(--text-muted) !important;
  font-size: 12px !important;
}

.axis {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.arrow-head {
  fill: var(--text-muted);
}

/* -------------------------------------------------------------------------- */
/* Testing versus abstraction                                                 */
/* -------------------------------------------------------------------------- */

@keyframes dash-flow {
  to {
    stroke-dashoffset: -12;
  }
}

/* -------------------------------------------------------------------------- */
/* Loop stepper: script sets data-step, CSS draws it                          */
/* -------------------------------------------------------------------------- */

@keyframes caption-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.loop-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.loop-play {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.loop-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.loop-chips button {
  padding: 4px 11px;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 600 0.8rem var(--mono);
  cursor: pointer;
  transition:
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease;
}

.loop-chips button:hover {
  border-color: var(--border-strong);
}

.loop-chips button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.loop-chips button.done[aria-pressed="true"] {
  background: var(--success);
  border-color: var(--success);
}

/* -------------------------------------------------------------------------- */
/* Trust boundary (9s)                                                        */
/* -------------------------------------------------------------------------- */

.shield {
  fill: var(--success);
}

.shield-check {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* -------------------------------------------------------------------------- */
/* Theorem explorer                                                           */
/* -------------------------------------------------------------------------- */

@keyframes flow-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.claim-card li strong {
  color: var(--text);
}

/* -------------------------------------------------------------------------- */
/* Domains                                                                    */
/* -------------------------------------------------------------------------- */

.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 196px), 1fr));
  gap: 16px;
  margin-top: 18px;
}

.domain-card {
  padding: 16px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.domain-card svg {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  margin: 0 auto 8px;
  font-family: var(--mono);
}

.domain-card h4 {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 1rem;
}

.domain-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.domain-card .axis {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.domain-card .axis-label {
  fill: var(--text-muted);
  font-size: 11px;
}

.lattice-edges line {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.lattice-nodes circle {
  fill: var(--surface-muted);
  stroke: var(--primary);
  stroke-width: 1.5;
}

.lattice-nodes text {
  fill: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
}

.domain-grid .sign-zero circle,
.domain-grid .parity-even circle {
  animation: lattice-lit 6s ease infinite backwards;
}

.domain-grid .sign-pos circle,
.domain-grid .parity-odd circle {
  animation: lattice-lit 6s ease infinite backwards;
  animation-delay: 1s;
}

.domain-grid .sign-join circle,
.domain-grid .parity-top circle {
  animation: lattice-join 6s ease infinite backwards;
  animation-delay: 2s;
}

@keyframes lattice-lit {
  0% {
    fill: var(--surface-muted);
  }
  8%,
  60% {
    fill: var(--primary-soft);
    stroke-width: 3;
  }
  75%,
  100% {
    fill: var(--surface-muted);
  }
}

@keyframes lattice-join {
  0% {
    fill: var(--surface-muted);
  }
  8%,
  45% {
    fill: var(--accent-soft);
    stroke: var(--accent);
    stroke-width: 3;
  }
  60%,
  100% {
    fill: var(--surface-muted);
  }
}

.ivl-bar {
  fill: rgb(23 75 87 / 0.2);
  stroke: var(--primary);
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: ivl-breathe 6s ease-in-out infinite;
}

@keyframes ivl-breathe {
  0%,
  100% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(1.35);
  }
}

.ivl-label {
  fill: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.cong-ticks circle {
  fill: var(--border-strong);
}

.cong-ticks .hit {
  fill: var(--accent);
  animation: cong-hit 3s ease-in-out infinite;
}

@keyframes cong-hit {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.product-rows rect {
  fill: var(--surface-muted);
  stroke: var(--border);
}

.product-rows text {
  fill: var(--text-muted);
  font-size: 11px;
}

.product-rows .val {
  fill: var(--primary);
  font-weight: 700;
}

/* -------------------------------------------------------------------------- */
/* Solver disciplines (9s: three 3s steps)                                    */
/* -------------------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
}

/* -------------------------------------------------------------------------- */
/* Which discipline to pick                                                   */
/* -------------------------------------------------------------------------- */

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 14px;
  margin-top: 20px;
}

.guide-card {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.guide-card.try {
  border-top-color: var(--success);
}

.guide-card.caution {
  border-top-color: var(--caution);
}

.guide-card.stuck {
  border-top-color: var(--danger);
}

.guide-card h4 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--text);
  font-size: 0.98rem;
}

.guide-card h4 i {
  color: var(--primary);
}

.guide-card.try h4 i {
  color: var(--success);
}

.guide-card.caution h4 i {
  color: var(--caution);
}

.guide-card.stuck h4 i {
  color: var(--danger);
}

.guide-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.guide-sources {
  max-width: var(--prose);
  margin-top: 16px;
}

.guide-sources summary {
  color: var(--primary);
  font-weight: 650;
  cursor: pointer;
}

.guide-sources li {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.guide-sources cite {
  display: block;
  color: var(--text-faint);
  font-size: 0.82rem;
}

/* -------------------------------------------------------------------------- */
/* Further reading                                                            */
/* -------------------------------------------------------------------------- */

.reading-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 36px 48px;
  margin-top: 36px;
}

/* Groups in one grid row share a height; a closing rule at the bottom of each makes the
   columns end on one line however long their entries run. */
.reading-group {
  display: flex;
  flex-direction: column;
}

.reading-group .reading-list {
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.reading-group h3 {
  margin: 0 0 12px;
  font-size: 1.3rem;
}

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

.reading-list li {
  padding-block: 12px;
  border-top: 1px solid var(--border);
}

.reading-list a {
  color: var(--primary);
  font-weight: 650;
  text-decoration: none;
}

.reading-list a:hover {
  text-decoration: underline;
}

.reading-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 0.82rem;
}

.reading-why {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* -------------------------------------------------------------------------- */
/* Reading a result                                                           */
/* -------------------------------------------------------------------------- */

.mock-editor {
  margin: 0;
  padding: 12px 0;
  overflow-x: auto;
  color: var(--editor-text);
  background: var(--surface-dark);
  border: 1px solid var(--editor-border);
  border-radius: 10px;
  font: 0.82rem / 1.85 var(--mono);
}

.ml {
  display: inline-block;
  min-width: 100%;
  padding: 0 16px;
  box-shadow: inset 3px 0 0 var(--verdict-color, transparent);
  background: var(--verdict-tint, transparent);
}

.ml.proved {
  --verdict-color: #6fcf97;
  --verdict-tint: rgb(111 207 151 / 0.1);
}

.ml.unknown {
  --verdict-color: #f0c674;
  --verdict-tint: rgb(240 198 116 / 0.1);
}

.ml.warning {
  --verdict-color: #d7a0ff;
  --verdict-tint: rgb(215 160 255 / 0.1);
}

.ml.refuted {
  --verdict-color: #ff8a73;
  --verdict-tint: rgb(255 138 115 / 0.13);
}

.ml.dead {
  --verdict-color: #7c9096;
  --verdict-tint: rgb(124 144 150 / 0.08);
}

.ml .dim {
  opacity: 0.42;
}

.mb {
  margin-left: 1.5em;
  padding: 0 0.5em;
  color: var(--verdict-color);
  background: rgb(0 0 0 / 0.22);
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 600;
}

.mh {
  margin-left: 1.4em;
  color: #8fb3ba;
  font-size: 0.8em;
  font-style: italic;
}

.legend {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
}

.legend > div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

.legend dt {
  justify-self: start;
  padding: 1px 8px;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-radius: 999px;
  font: 700 0.72rem var(--mono);
  white-space: nowrap;
}

.legend dd {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.lg.proved {
  color: var(--success);
  background: var(--success-soft);
}

.lg.refuted {
  color: var(--danger);
  background: var(--danger-soft);
}

.lg.unknown {
  color: var(--caution);
  background: #f7efe2;
}

.lg.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.lg.dead {
  color: var(--text-faint);
  background: transparent;
  border: 1px dashed var(--text-faint);
}

.lg.hint {
  font-style: italic;
  font-weight: 600;
}

.gn {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1;
}

.gn.proved {
  fill: var(--success-soft);
  stroke: var(--success);
  stroke-width: 2;
}

.gn.refuted {
  fill: var(--danger-soft);
  stroke: var(--danger);
  stroke-width: 2;
}

.gn.unknown {
  fill: #fbf1dc;
  stroke: var(--caution);
  stroke-width: 2;
}

.gn.dead {
  fill: var(--surface-muted);
  stroke: var(--text-faint);
  stroke-dasharray: 5 3;
}

.gn.seed {
  fill: var(--warning-soft);
  stroke: var(--warning);
  stroke-width: 2;
}

.gn.global {
  fill: var(--surface);
  stroke: var(--global-link);
  stroke-width: 2;
}

.gn.entry {
  fill: var(--primary-soft);
  stroke: var(--primary);
  stroke-width: 1.5;
}

.gn.entry-inner {
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.5;
}

.ge {
  stroke-dasharray: 7 5;
  stroke-width: 1.4;
}

.ge.step {
  stroke: #7c9096;
}

.ge.call {
  stroke: var(--primary);
  stroke-width: 2.2;
}

.ge.resume {
  stroke: #3f7fb4;
  stroke-width: 1.2;
}

.ge.cont {
  stroke: #9aa9ae;
}

.ga.step {
  fill: #7c9096;
}

.ga.call {
  fill: var(--primary);
}

.ga.resume {
  fill: #3f7fb4;
}

.ga.cont {
  fill: #9aa9ae;
}

.g-cluster {
  fill: var(--surface);
  stroke: var(--border-strong);
}

@media (max-width: 640px) {
  .legend > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
}

.explainer-cta {
  margin: 40px 0 0;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: #ffffff;
  background: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 750;
  text-decoration: none;
}

.cta-button:hover {
  background: var(--primary-hover);
}

@media (max-width: 820px) {
  .scene {
    padding: 14px;
  }
}

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

/* -------------------------------------------------------------------------- */
/* Links into the playground                                                  */
/* -------------------------------------------------------------------------- */

.try-link {
  margin-left: 4px;
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
}

/* Keeping the arrow with the last word is worth one line, not an overflowing one. */
@media (max-width: 640px) {
  .try-link {
    white-space: normal;
  }
}

/* -------------------------------------------------------------------------- */
/* What an abstract value stands for                                          */
/* -------------------------------------------------------------------------- */

.call-modes button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
}

.call-modes button:is([aria-selected="true"], [aria-pressed="true"]) {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.gamma-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 20px;
  margin: 6px 0 0;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  list-style: none;
}

.gamma-legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.swatch.in {
  background: var(--primary);
}

/* -------------------------------------------------------------------------- */
/* Inside the top-down solver                                                 */
/* -------------------------------------------------------------------------- */

.td-node circle {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 2;
  transition:
    fill 250ms ease,
    stroke 250ms ease,
    stroke-width 250ms ease;
}

.td-node-id {
  fill: var(--primary) !important;
  font-size: 13px !important;
  font-weight: 700;
  text-anchor: middle;
}

.td-node-val {
  fill: var(--text) !important;
  font-size: 12px !important;
  font-weight: 700;
}

.td-node.is-current circle {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 3.5;
}

.td-end circle {
  fill: lightyellow;
  stroke: orange;
  stroke-width: 2;
}

.td-panel-title {
  margin: 0 0 8px;
  color: var(--text-muted);
  font: 700 0.72rem var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.td-caption {
  min-height: 3.2em;
  margin: 16px 0 0;
  color: var(--text);
  font-size: 1rem;
}

/* -------------------------------------------------------------------------- */
/* The price of precision                                                     */
/* -------------------------------------------------------------------------- */

.cost-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: 18px;
}

.cost-grid .scene {
  margin-top: 20px;
}

/* -------------------------------------------------------------------------- */
/* Limits                                                                     */
/* -------------------------------------------------------------------------- */

/* The playground's hero already opens the page; the analyzer follows closely. */
.explainer-hero + .page-shell > .analyzer-section {
  padding-top: 32px;
}

/* -------------------------------------------------------------------------- */
/* Theorem explanations and formalization links                               */
/* -------------------------------------------------------------------------- */

.isa-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 700;
}

/* -------------------------------------------------------------------------- */
/* Reading progress                                                           */
/* -------------------------------------------------------------------------- */

.doc-toc {
  display: none;
}

@media (min-width: 1200px) {
  .doc-layout {
    display: grid;
    grid-template-columns: 145px minmax(0, 1fr);
    column-gap: 32px;
    align-items: start;
  }

  /* Inset so the marker dots and their ring stay inside the scroll box: overflow-y
     forces overflow-x to scroll too, and anything poking out would add a scrollbar. */
  /* A column the height of the window, so the build link can sit at its bottom. */
  .doc-toc {
    position: sticky;
    top: calc(env(safe-area-inset-top, 0px) + 84px);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 110px);
    margin-top: 64px;
    padding-left: 8px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* The hero chips duplicate the sidebar where it shows. */
  .explainer-toc {
    display: none;
  }
}

/* A little more room once the prose does not have to give any up for it. */
@media (min-width: 1400px) {
  .doc-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: 20px;
  }
}

/* Wide enough for the longest entry to sit on one line: 268px of text plus the
   timeline's inset. Only where the prose gives up nothing for it. */
@media (min-width: 1750px) {
  .doc-layout {
    grid-template-columns: 300px minmax(0, 1fr);
    column-gap: 40px;
  }
}

.doc-toc-title {
  margin: 0 0 10px;
  color: var(--text-muted);
  font: 700 0.62rem var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.doc-toc-body {
  position: relative;
  padding-left: 18px;
}

.doc-toc-track {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 3px;
  width: 3px;
  background: var(--border);
  border-radius: 3px;
}

.doc-toc-fill {
  width: 100%;
  height: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: height 120ms linear;
}

.doc-toc ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-toc-part {
  position: relative;
  margin: 10px 0 1px -24px;
  padding: 2px 0 2px 24px;
  background: var(--bg);
  color: var(--accent);
  font: 700 0.6rem var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.doc-toc-part:first-child {
  margin-top: 0;
}

.doc-toc a {
  position: relative;
  display: block;
  padding: 3px 0;
  color: var(--text-faint);
  font-size: 0.73rem;
  line-height: 1.32;
  text-decoration: none;
  overflow-wrap: break-word;
  transition: color 150ms ease;
}

.doc-toc a::before {
  content: "";
  position: absolute;
  top: 7px;
  /* Centred on the 3px track: the body's 18px padding minus 20px puts the
     13px marker (9px plus two 2px borders) at the track's own centre. */
  left: -20px;
  width: 9px;
  height: 9px;
  background: var(--bg);
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  transition:
    background 150ms ease,
    border-color 150ms ease;
}

.doc-toc a:hover {
  color: var(--primary);
}

.doc-toc a.is-read {
  color: var(--text-muted);
}

.doc-toc a.is-read::before {
  background: var(--accent);
  border-color: var(--accent);
}

/* Color, not weight: a bolder current item would rewrap its line while scrolling. */
.doc-toc a.is-current {
  color: var(--primary);
}

.doc-toc a.is-current::before {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.doc-toc-percent {
  margin: 12px 0 0 18px;
  color: var(--text-faint);
  font: 600 0.7rem var(--mono);
}

/* Which commit the site was built from: a footnote in the footer, not a nav entry. */
.doc-toc-build a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  text-decoration: none;
}

.doc-toc-build a:hover {
  color: var(--primary);
}

.doc-toc-build code {
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  font-size: 0.92em;
}

/* -------------------------------------------------------------------------- */
/* From a graph to equations to values                                        */
/* -------------------------------------------------------------------------- */

.blackbox {
  margin-top: 20px;
}

.blackbox > summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.blackbox > summary:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

.blackbox > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.blackbox > summary::-webkit-details-marker {
  display: none;
}

/* The pill alone reads as a link to somewhere else. The chevron, and the word
   that flips with it, are what say the panel opens in place. */
.blackbox-chevron {
  margin-left: 2px;
  font-size: 0.78em;
  transition: transform 150ms ease;
}

.blackbox[open] > summary .blackbox-chevron {
  transform: rotate(180deg);
}

.blackbox > summary .blackbox-label::before {
  content: "Open ";
}

.blackbox[open] > summary .blackbox-label::before {
  content: "Close ";
}

.blackbox[open] > summary {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.loop-chips button code {
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
}

/* -------------------------------------------------------------------------- */
/* Hero                                                                       */
/* -------------------------------------------------------------------------- */

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

/* -------------------------------------------------------------------------- */
/* Hero: what the proofs connect                                              */
/* -------------------------------------------------------------------------- */

.hero-spine {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 0;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}

.hero-spine li {
  display: flex;
  align-items: center;
}

.hero-spine li + li::before {
  content: "→";
  margin: 0 10px;
  color: var(--accent);
  font-weight: 700;
}

.hero-spine a {
  display: grid;
  padding: 6px 12px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  line-height: 1.3;
}

.hero-spine a:hover {
  border-color: var(--border-strong);
}

.hero-spine b {
  font-size: 0.9rem;
}

.hero-spine span {
  color: var(--text-muted);
  font: 0.72rem var(--mono);
}

.hero-claim {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* -------------------------------------------------------------------------- */
/* Shared: verdict pills and stacks                                           */
/* -------------------------------------------------------------------------- */

.verdict {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font: 700 0.72rem var(--mono);
}

.verdict.proved {
  color: var(--success);
  background: var(--success-soft);
}

.verdict.unknown {
  color: var(--caution);
  background: #f7efe2;
}

/* -------------------------------------------------------------------------- */
/* The life of a call                                                         */
/* -------------------------------------------------------------------------- */

.call-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* -------------------------------------------------------------------------- */
/* The proof chain                                                            */
/* -------------------------------------------------------------------------- */

.swatch.band {
  width: 22px;
  border-radius: 7px;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1.2px var(--primary);
}

/* -------------------------------------------------------------------------- */
/* Comparison tables                                                          */
/* -------------------------------------------------------------------------- */

/* Every table that puts settings against outcomes reads as a grid, so the cells
   being compared sit centred under their heading and only the label column,
   which the eye runs down, stays left. */
:is(.guide-table, .solver-table, .spiral-table, .obs-table) :is(th, td) {
  text-align: center;
  vertical-align: middle;
}

:is(.guide-table, .solver-table, .spiral-table, .obs-table) :is(tbody th, thead th:first-child) {
  text-align: left;
}
