/* ============================================================================
   Layout: the reading column, the section grammar, the chrome.
   ========================================================================= */

/* ── Progress rail ────────────────────────────────────────────────────── */
.rail {
  position: fixed; inset: 0 auto 0 0; width: 3px; z-index: 40;
  background: color-mix(in srgb, var(--hairline) 60%, transparent);
  pointer-events: none;
}
.rail__fill {
  position: absolute; inset: 0 0 auto 0; height: 0;
  background: linear-gradient(180deg, var(--key), var(--space) 55%, var(--human));
  box-shadow: 0 0 18px color-mix(in srgb, var(--space) 55%, transparent);
  transform-origin: top;
}

/* ── Section nav ──────────────────────────────────────────────────────── */
.dots {
  position: fixed; right: clamp(0.75rem, 2vw, 1.75rem); top: 50%; z-index: 40;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 0.75rem;
  list-style: none; margin: 0; padding: 0;
}
.dots button {
  appearance: none; border: 0; padding: 0; cursor: pointer;
  width: 9px; height: 9px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink-faint) 70%, transparent);
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
  position: relative;
}
.dots button::after {
  content: attr(data-label);
  position: absolute; right: 1.4rem; top: 50%; transform: translateY(-50%) translateX(6px);
  font: 600 0.6875rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-dim); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.dots button:hover::after, .dots button:focus-visible::after {
  opacity: 1; transform: translateY(-50%) translateX(0);
}
.dots button[aria-current="true"] {
  background: var(--space); transform: scale(1.45);
  box-shadow: 0 0 12px color-mix(in srgb, var(--space) 70%, transparent);
}
@media (max-width: 900px) { .dots { display: none; } }

/* ── Sections ─────────────────────────────────────────────────────────── */
.section {
  position: relative;
  padding: var(--section-gap) var(--gutter);
  border-top: 1px solid transparent;
}
.section + .section::before {
  content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 1px;
  background: linear-gradient(90deg,
    transparent, color-mix(in srgb, var(--hairline-lit) 90%, transparent) 30%,
    color-mix(in srgb, var(--hairline-lit) 90%, transparent) 70%, transparent);
}

/* A centred reading column that lets specific children break out wider.
   The 1fr gutters absorb whatever is left over at any viewport width. */
.wrap {
  display: grid;
  grid-template-columns:
    [full-start] minmax(0, 1fr)
    [text-start] min(var(--measure), 100%) [text-end]
    minmax(0, 1fr) [full-end];
}
.wrap > * { grid-column: text; }
.wrap > .instrument,
.wrap > .breakout {
  grid-column: full;
  width: min(var(--wide), 100%);
  justify-self: center;
}

.kicker {
  font: 600 0.75rem/1 var(--sans);
  letter-spacing: 0.19em; text-transform: uppercase;
  color: var(--space); margin: 0 0 1.1rem;
  display: flex; align-items: center; gap: 0.7rem;
}
.kicker::before {
  content: ""; width: 1.6rem; height: 1px;
  background: currentColor; opacity: 0.7; flex: none;
}

.section h2 {
  font-size: clamp(2rem, 1.3rem + 3.1vw, 3.4rem);
  margin-bottom: 1.6rem;
}
.section h3 {
  font-size: clamp(1.15rem, 1rem + 0.8vw, 1.45rem);
  margin: 2.6rem 0 0.9rem;
  letter-spacing: -0.015em;
}

.lede {
  font-size: 1.18em; line-height: 1.6; color: var(--ink);
  margin-bottom: 1.6em;
}

/* ── Pull quote ───────────────────────────────────────────────────────── */
.pull {
  margin: 3rem auto; max-width: 30rem;
  font-family: var(--sans); font-weight: 600;
  font-size: clamp(1.3rem, 1.05rem + 1.2vw, 1.95rem);
  line-height: 1.24; letter-spacing: -0.025em;
  color: var(--ink); text-wrap: balance;
  padding-left: 1.4rem;
  border-left: 2px solid var(--space);
}
.pull--center {
  border: 0; padding: 0; text-align: center;
  max-width: 34rem;
}

/* ── Figures & instruments ────────────────────────────────────────────── */
.instrument {
  margin: 3.5rem auto;
  background: linear-gradient(180deg, var(--raised), var(--deep));
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 70px -30px rgba(0, 0, 0, 0.9),
              inset 0 1px 0 color-mix(in srgb, var(--ink) 6%, transparent);
}
.instrument__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--raised-2) 60%, transparent);
}
.instrument__title {
  font: 600 0.75rem/1.3 var(--sans);
  letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-soft);
  margin: 0;
}
.instrument__note {
  font: 400 0.75rem/1.4 var(--sans); color: var(--ink-dim); margin: 0;
}
.instrument__body { padding: clamp(1rem, 3vw, 1.75rem); }
.instrument__foot {
  padding: 0.85rem 1.25rem; border-top: 1px solid var(--hairline);
  font: 400 0.8125rem/1.5 var(--sans); color: var(--ink-dim);
  background: color-mix(in srgb, var(--void) 40%, transparent);
}

.controls {
  display: grid; gap: 1rem 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  margin-bottom: 1.4rem;
}
.control { display: flex; flex-direction: column; gap: 0.4rem; }
.control__row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem;
  font: 600 0.6875rem/1.4 var(--sans); letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-dim);
}
.control__row label { cursor: pointer; }
.control output {
  color: var(--space); font-family: var(--mono); letter-spacing: 0;
  text-transform: none; text-align: right; white-space: nowrap;
}
.control output sup { font-size: 0.72em; }

input[type="range"] {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--key-deep), var(--space-deep));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6.5px;
  border-radius: 50%; background: var(--ink);
  border: 2px solid var(--void);
  box-shadow: 0 0 0 1px var(--space), 0 0 14px color-mix(in srgb, var(--space) 60%, transparent);
}
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--key-deep), var(--space-deep));
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--ink);
  border: 2px solid var(--void); box-shadow: 0 0 0 1px var(--space);
}

input[type="text"], select {
  font-family: var(--mono); font-size: 0.9rem;
  background: var(--void); color: var(--ink);
  border: 1px solid var(--hairline-lit); border-radius: 7px;
  padding: 0.6rem 0.7rem; width: 100%;
}
input[type="text"]:focus, select:focus { border-color: var(--space); outline: none; }

.btn {
  appearance: none; cursor: pointer;
  font: 600 0.75rem/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink); background: var(--raised-2);
  border: 1px solid var(--hairline-lit); border-radius: 7px;
  padding: 0.65rem 1rem;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease),
              background 0.2s var(--ease);
}
.btn:hover { border-color: var(--space); color: var(--space); }

.readout {
  font-family: var(--mono); font-size: clamp(1.5rem, 1rem + 2.4vw, 2.6rem);
  color: var(--ink); letter-spacing: -0.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.readout--space { color: var(--space); }
.readout--human { color: var(--human); }
.readout--broken { color: var(--broken); }
.readout__label {
  display: block; font: 600 0.6875rem/1 var(--sans);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 0.5rem;
}

.grid-2 {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.note {
  font-family: var(--sans); font-size: 0.875rem; line-height: 1.6;
  color: var(--ink-dim);
}

/* ── Footnotes / colophon ─────────────────────────────────────────────── */
.colophon { font-family: var(--sans); font-size: 0.9375rem; }
.colophon h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); }
.colophon ul { padding-left: 1.15rem; }
.colophon li { margin-bottom: 0.55rem; }

/* ── Reveal-on-scroll ─────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ── No-JavaScript notice ─────────────────────────────────────────────── */
.noscript {
  margin: 0; padding: 0.9rem var(--gutter);
  font: 500 0.875rem/1.6 var(--sans);
  color: var(--human);
  background: color-mix(in srgb, var(--human) 10%, var(--void));
  border-bottom: 1px solid color-mix(in srgb, var(--human) 30%, transparent);
  text-align: center;
}

/* ── Narrow viewports ─────────────────────────────────────────────────── */
@media (max-width: 620px) {
  :root { --section-gap: clamp(3.5rem, 10vh, 5.5rem); }
  .instrument { border-radius: 10px; }
  .instrument__head { padding: 0.85rem 1rem; }
  .instrument__foot { padding: 0.75rem 1rem; font-size: 0.75rem; }
  .pull { margin: 2.25rem auto; padding-left: 1rem; }
  .hero__quote, .hero__attrib { padding-left: 1rem; }
  .jumps .btn { font-size: 0.625rem; padding: 0.45rem 0.6rem; }
}

/* The bit grid is 32 cells wide; below this it stops being readable as bits
   and starts being a smear, so halve the columns instead of the cell size. */
@media (max-width: 420px) {
  .bitgrid { grid-template-columns: repeat(16, 1fr); }
}
