/* System fonts, one accent, dark mode via media query. The tokens and the
   site chrome match seenix, nixpkgs-multiverse and trynix, so the sites
   read as one family. */
:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6a6a6a;
  --line: #e0e0e0;
  --accent: #4f6bed;
  --code-bg: #f4f4f4;
  --error: #c94f4f;
  --ok: #2f8a4f;
  --tint-a: #eef1fd;
  --tint-b: #f7f7f5;
  --hot: #ffd866;
  --hot-line: #d9822b;
  --era-hex: #b8641f;
  --era-m2: #2f8a5f;
  --era-mes: #8250c4;
  --era-tcc: #2a74b8;
  --era-gcc: #c0465f;
  --era-cxx: #4f5fd0;
  --syn-hex: #1a1a1a;
  --syn-comment: #7a7a7a;
  --syn-mnemonic: #2a6aa8;
  --syn-ref: #a8552a;
  --syn-label: #7a46b8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --fg: #e6e6e6;
    --muted: #9a9a9a;
    --line: #33363d;
    --accent: #8fa3ff;
    --code-bg: #22252c;
    --error: #e07070;
    --ok: #6cc28a;
    --tint-a: #1f2433;
    --tint-b: #1c1e23;
    --hot: #6b5a1e;
    --hot-line: #f0a24a;
    --era-hex: #e0904a;
    --era-m2: #5cc08c;
    --era-mes: #b18cf0;
    --era-tcc: #62a8ec;
    --era-gcc: #ec7590;
    --era-cxx: #8f9cff;
    --syn-hex: #e6e6e6;
    --syn-comment: #8a8a8a;
    --syn-mnemonic: #7fb4ea;
    --syn-ref: #e8a070;
    --syn-label: #c0a0f0;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0 auto;
  padding: 1rem;
  max-width: 72rem;
  background: var(--bg);
  color: var(--fg);
  font:
    15px/1.5 system-ui,
    sans-serif;
}
h1 {
  font-size: 1.3rem;
  margin: 0.2rem 0;
}
h1 a {
  color: inherit;
  text-decoration: none;
}

/* The site header: the title on the left, the destinations on the right.
   Wraps to two lines on a narrow phone rather than shrinking. */
header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.3rem 1rem;
  margin: 0.2rem 0 0.6rem;
}
nav.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
  font-size: 14px;
}
nav.site a {
  color: var(--accent);
  text-decoration: none;
}
nav.site a:hover {
  text-decoration: underline;
}
h2 {
  font-size: 1.1rem;
  margin: 2rem 0 0.4rem;
}
h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.3rem;
}
a {
  color: var(--accent);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.lede {
  font-weight: 600;
}
/* Prose is short and set small, so the seed and the tower carry the
   page. */
.intro,
.roots,
.credits {
  max-width: 44rem;
  font-size: 14px;
}

/* What the climb leads to, under the tower. */
.after-climb {
  margin-top: 0.8rem;
}

/* The owner's note at the top, signed in small type. */
.note {
  max-width: 44rem;
  margin: 0.8rem 0 1rem;
  padding: 0 0 0 0.9rem;
  border-left: 3px solid var(--era-hex);
}
.note blockquote {
  margin: 0;
  font-size: 15px;
  font-style: italic;
}
.note figcaption {
  margin-top: 0.2rem;
  font-size: 12px;
  color: var(--muted);
}
code {
  font:
    13px/1.5 ui-monospace,
    monospace;
  background: var(--code-bg);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  overflow-wrap: anywhere;
}

/* The seed: a 16-column grid of bytes beside the hex0 source. The grid's
   column is as wide as the grid; the text under it wraps to fit, and the
   source takes the rest. */
.seed-layout {
  display: grid;
  grid-template-columns: min-content minmax(0, 1fr);
  grid-template-areas:
    "bytes source"
    "info source";
  gap: 1rem;
  align-items: start;
}
.seed-bytes {
  grid-area: bytes;
}
.seed-source {
  grid-area: source;
}
.byte-info {
  grid-area: info;
}

/* On a narrow screen the byte description goes under the source pane,
   so its height, which changes from byte to byte, never moves the pane
   under the pointer. */
@media (max-width: 52rem) {
  .seed-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "bytes"
      "source"
      "info";
  }
}
.seed-grid {
  display: grid;
  grid-template-columns: repeat(16, 2rem);
  gap: 2px;
  font:
    13px/1 ui-monospace,
    monospace;
}
@media (max-width: 40rem) {
  .seed-grid {
    grid-template-columns: repeat(16, minmax(0, 1fr));
    font-size: 11px;
  }
}
.seed-grid button {
  padding: 0.45rem 0;
  border: 1px solid transparent;
  border-radius: 3px;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
}
.seed-grid button.tint-a {
  background: var(--tint-a);
}
.seed-grid button.tint-b {
  background: var(--tint-b);
}
.seed-grid button.same-line {
  background: var(--hot);
}
.seed-grid button.active {
  border-color: var(--accent);
}
.check.ok {
  color: var(--ok);
}
.check.bad {
  color: var(--error);
}
.byte-info {
  min-height: 7.5rem;
  max-width: 36rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.byte-info dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.8rem;
  margin: 0;
}
.byte-info dt {
  color: var(--muted);
}
.byte-info dd {
  margin: 0;
  overflow-wrap: anywhere;
}
/* The source wraps rather than scrolling sideways. Each line hangs its
   continuation rows --hang columns in from the end of the line-number
   gutter (seed-view.js picks the column), so numbers and hex stay in
   their columns. */
.seed-source {
  --gutter: 5;
  position: relative;
  margin: 0;
  max-height: 34rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.5rem 0;
  background: var(--code-bg);
  border-radius: 4px;
  font:
    12px/1.45 ui-monospace,
    monospace;
}
.seed-source .line {
  display: block;
  padding: 0 0.6rem 0 calc(0.6rem + (var(--gutter) + var(--hang, 0)) * 1ch);
  text-indent: calc((var(--gutter) + var(--hang, 0)) * -1ch);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.seed-source .seg.whole {
  display: inline-block;
  text-indent: 0;
}
.seed-source .probe {
  position: absolute;
  visibility: hidden;
  white-space: pre;
}
.seed-source .line.code {
  cursor: pointer;
}
.seed-source .line.hot {
  background: var(--hot);
}
.seed-source .num {
  display: inline-block;
  width: calc(var(--gutter) * 1ch);
  text-indent: 0;
  color: var(--muted);
  user-select: none;
}

/* The provenance line carries a base64 hash with no break in it. */
.provenance {
  overflow-wrap: anywhere;
}

/* The two-roots aside and the joke citation share a boxed style. */
.roots,
.citation {
  margin: 1.5rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.roots p {
  margin: 0.4rem 0;
}

/* The climb: the gauges stay pinned while the picture scrolls past. */
.gauges {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.6rem;
  padding: 0.6rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.gauge {
  display: flex;
  flex-direction: column;
}

/* Which stage the gauges count through, over them on its own line. */
.gauge-through {
  flex-basis: 100%;
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.gauge-through strong {
  color: var(--fg);
}
.gauge-label {
  font-size: 12px;
  color: var(--muted);
}
.gauge-value {
  font:
    600 1.15rem/1.2 ui-monospace,
    monospace;
}
/* The picture beside the card for the stage in view. On a phone the card
   becomes a sheet pinned to the bottom of the screen. */
.climb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 24rem);
  gap: 1.2rem;
  align-items: start;
  margin-top: 0.8rem;
}
.tower-wrap {
  margin: 0;
  min-width: 0;
}
.stage-card {
  font-size: 13.5px;
  position: sticky;
  top: 6rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 0.8rem 1rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
@media (max-width: 52rem) {
  .climb-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Room under the climb so its end can scroll clear of the sheet. */
  #climb {
    padding-bottom: min(40vh, 21rem);
  }
  .stage-card {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 4;
    max-height: min(38vh, 20rem);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -4px 16px rgb(0 0 0 / 0.15);
  }
  .stage-card.in-view {
    display: block;
  }
  .tower .title {
    font-size: 12px;
  }

  /* Compact gauges: four small values in four equal columns. */
  .gauges {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.2rem 0.5rem;
    padding: 0.4rem 0;
  }
  .gauge-label {
    font-size: 10px;
  }
  .gauge-value {
    font-size: 0.9rem;
  }
}
.stage-card h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  margin: 0;
  font-size: 1.05rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.stage-card .stage-number {
  font:
    12px ui-monospace,
    monospace;
  color: var(--muted);
}
.stage-card p {
  margin: 0.4rem 0;
}
.card-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.badge {
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
}
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.05rem 0.9rem;
  margin: 0.4rem 0;
  font-size: 13px;
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
details.also summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}
details.also p {
  font-size: 13px;
}
.citation .kicker {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* The tower sits on a dark panel in both themes, so the era colours and
   the textures carry. The panel has its own tokens: the dark theme's era
   colours, a light foreground and a muted grey. */
.tower-wrap {
  --panel-bg: #121419;
  --panel-fg: #e8e8ea;
  --panel-muted: #8d94a0;
  --panel-line: #2c3039;
  --panel-accent: #8fa3ff;
  --era-hex: #e0904a;
  --era-m2: #5cc08c;
  --era-mes: #b18cf0;
  --era-tcc: #62a8ec;
  --era-gcc: #ec7590;
  --era-cxx: #8f9cff;
  padding: 0.7rem 0.6rem 0.4rem;
  background: var(--panel-bg);
  border-radius: 8px;
}
.legend {
  margin: 0 0 0.5rem;
  font-size: 12px;
  color: var(--panel-muted);
}
.tower {
  display: block;
  max-width: 100%;
  overflow: visible;
  font-family: system-ui, sans-serif;
}
.tower .era-bg {
  opacity: 0.09;
}
.tower .era-label {
  font-size: 11px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--panel-bg);
  stroke-width: 4px;
}
.tower .gridline {
  stroke: var(--panel-line);
  stroke-dasharray: 2 4;
}
.tower .grid-label {
  font-size: 10px;
  fill: var(--panel-muted);
  text-anchor: middle;
}
.tower .hit {
  fill: transparent;
  cursor: pointer;
}
.tower .row:focus {
  outline: none;
}
.tower .row:focus-visible .hit {
  fill: rgb(255 255 255 / 0.05);
}
.tower .connector {
  stroke: var(--panel-line);
  stroke-width: 1;
}
.tower .seed-frame {
  fill-opacity: 0.2;
}
.tower .outline {
  fill: none;
  stroke: none;
}
.tower .source {
  fill: var(--panel-muted);
  opacity: 0.6;
}
.tower .title {
  font-size: 13px;
  font-weight: 600;
  fill: var(--panel-fg);
}
.tower .size,
.tower .milestone {
  font-size: 11px;
  fill: var(--panel-muted);
}
.tower .milestone {
  font-style: italic;
}
.tower .arc {
  fill: none;
  stroke: var(--panel-muted);
  stroke-width: 1;
  opacity: 0.4;
}

/* Highlighting stays light: the stage shown is outlined, its builder
   outlined dashed, and the arc between them tinted. A pinned stage gets
   a marker at its left edge and an accent title. */
.tower .row.focus .outline,
.tower .row.focus .seed-frame {
  stroke: var(--panel-fg);
  stroke-width: 1.5;
}
.tower .row.builder .outline,
.tower .row.builder .seed-frame {
  stroke: var(--panel-fg);
  stroke-width: 1;
  stroke-dasharray: 3 2;
}
.tower .arc.focus {
  stroke: var(--panel-accent);
  opacity: 1;
  stroke-width: 1.5;
}
.tower .pin-mark {
  fill: transparent;
}
.tower .row.pinned .pin-mark {
  fill: var(--panel-accent);
}
.tower .row.pinned .title {
  fill: var(--panel-accent);
}

.era-hex .bar,
.era-hex .slice,
.era-hex .byte,
.era-hex .seed-frame,
.era-hex.era-bg,
.era-text-hex {
  fill: var(--era-hex);
}
.era-m2 .bar,
.era-m2 .slice,
.era-m2 .byte,
.era-m2 .seed-frame,
.era-m2.era-bg,
.era-text-m2 {
  fill: var(--era-m2);
}
.era-mes .bar,
.era-mes .slice,
.era-mes .byte,
.era-mes .seed-frame,
.era-mes.era-bg,
.era-text-mes {
  fill: var(--era-mes);
}
.era-tcc .bar,
.era-tcc .slice,
.era-tcc .byte,
.era-tcc .seed-frame,
.era-tcc.era-bg,
.era-text-tcc {
  fill: var(--era-tcc);
}
.era-gcc .bar,
.era-gcc .slice,
.era-gcc .byte,
.era-gcc .seed-frame,
.era-gcc.era-bg,
.era-text-gcc {
  fill: var(--era-gcc);
}
.era-cxx .bar,
.era-cxx .slice,
.era-cxx .byte,
.era-cxx .seed-frame,
.era-cxx.era-bg,
.era-text-cxx {
  fill: var(--era-cxx);
}

@media (prefers-reduced-motion: no-preference) {
  .tower .arc,
  .tower .outline,
  .tower .pin-mark {
    transition:
      opacity 0.15s,
      stroke 0.15s,
      fill 0.15s;
  }
}

/* Syntax colours for the hex0 listing: bytes in the text colour, the
   mnemonic after ';' in blue, label references in orange, label
   definitions in purple, comments grey. */
.tok-hex {
  color: var(--syn-hex);
}
.tok-mnemonic {
  color: var(--syn-mnemonic);
}
.tok-ref {
  color: var(--syn-ref);
}
.tok-label {
  color: var(--syn-label);
  font-weight: 600;
}
.tok-comment {
  color: var(--syn-comment);
}

.credits li {
  margin: 0.3rem 0;
}
/* The footer, as on nixpkgs-higher-lower: centred, small and muted. */
footer {
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
  font-size: 13px;
  text-align: center;
}
footer p {
  margin: 0.3rem 0;
}

/* A store path is a single token; keep it on one line and shrink it to
   fit a phone. */
#store code {
  font-size: min(12px, 2.6vw);
  white-space: nowrap;
  background: none;
  padding: 0;
}
