:root {
  --bench: #e9e4ef;
  --paper: #fbfafc;
  --ink: #1a1920;
  --muted: #625f69;
  --line: #c9c2d0;
  --pine: #1f5a46;
  --plum: #634373;
  --cobalt: #3e4d96;
  --a: #006b5e;
  --c: #5b3a8d;
  --g: #8a5500;
  --u: #a52e48;
  --shadow: 0 26px 70px rgb(33 22 45 / 12%);
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bench);
  color: var(--ink);
  font-family: "Atkinson Next", system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.55;
}

a { color: inherit; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 0.14em; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link:focus {
  position: fixed !important;
  z-index: 100;
  top: 1rem;
  left: 1rem;
  width: auto !important;
  height: auto !important;
  clip: auto !important;
  margin: 0 !important;
  padding: 0.65rem 0.9rem !important;
  background: var(--ink);
  color: white;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 74px;
  border-bottom: 1px solid rgb(26 25 32 / 25%);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand { font-weight: 700; text-decoration: none; }
.lang-switch { display: flex; align-items: center; gap: 0.35rem; }
.lang-switch a { padding: 0.45rem; text-decoration: none; }
.lang-switch [aria-current="page"] { background: var(--ink); color: white; }

.hero { padding: 5rem 0 3.5rem; }
.kicker, .section-label, .machine-label {
  margin: 0 0 1.15rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  max-width: 1120px;
  margin-bottom: 2rem;
  font-family: "Anybody", system-ui, sans-serif;
  font-weight: 760;
  font-variation-settings: "wdth" 115;
  line-height: 0.94;
  letter-spacing: -0.055em;
}

.hero-number {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(2.25rem, 6.2vw, 5.7rem);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 1;
}

.hero-suffix {
  display: block;
  max-width: 900px;
  margin-top: 0.35rem;
  font-size: clamp(3.35rem, 7.6vw, 7.35rem);
}

.lead {
  max-width: 830px;
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.42;
}

.machine-section { padding: 1rem 0 5rem; }
.machine {
  position: relative;
  overflow: hidden;
  padding: clamp(1.1rem, 3vw, 2.4rem);
  border: 2px solid var(--ink);
  border-radius: 34px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.machine::before,
.machine::after {
  position: absolute;
  z-index: 0;
  content: "";
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}

.machine::before {
  top: -120px;
  right: -90px;
  width: 340px;
  height: 250px;
  background: rgb(99 67 115 / 13%);
}

.machine::after {
  bottom: -130px;
  left: -90px;
  width: 310px;
  height: 250px;
  background: rgb(31 90 70 / 12%);
}

.machine > * { position: relative; z-index: 1; }
.machine-head {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1.2fr);
  gap: 2rem;
  align-items: end;
  padding-bottom: 1.8rem;
  border-bottom: 2px solid var(--ink);
}

h2 {
  font-family: "Anybody", system-ui, sans-serif;
  font-size: clamp(2.35rem, 5vw, 4.6rem);
  font-weight: 720;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.machine-head h2 { margin-bottom: 0; }
.machine-head p { max-width: 590px; margin-bottom: 0.2rem; }

.protein-rail {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.6rem 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: var(--pine);
  color: white;
}

.protein-rail strong { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem; text-transform: uppercase; }
.protein-rail span:last-child { text-align: right; }
.rna-label { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }

.station-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0.75rem 0 1.5rem;
}

.station {
  position: relative;
  min-width: 0;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(255 255 255 / 72%);
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.station.is-changed {
  border-color: var(--cobalt);
  box-shadow: inset 0 0 0 2px var(--cobalt);
  transform: translateY(-2px);
}

.station-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem;
  align-items: center;
  min-height: 42px;
  margin-bottom: 0.45rem;
}

.aa-token {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--pine);
  color: white;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
}

.station-meta { min-width: 0; color: var(--muted); font-size: 0.66rem; line-height: 1.15; }
.station-meta b { display: block; color: var(--ink); font-family: "IBM Plex Mono", monospace; font-weight: 400; }
.change-flag { color: var(--cobalt); font-weight: 700; }

.codon-button {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 100%;
  min-height: 48px;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  cursor: pointer;
}

.codon-button:hover { transform: translateY(-1px); }
.base {
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: 5px;
  color: white;
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(0.72rem, 1.1vw, 0.92rem);
  line-height: 1;
}
.base-A { background: var(--a); }
.base-C { background: var(--c); }
.base-G { background: var(--g); }
.base-U { background: var(--u); }

.machine-controls {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.75rem;
  align-items: center;
}

.primary-button, .secondary-button {
  min-height: 48px;
  padding: 0.7rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}
.primary-button { background: var(--ink); color: white; }
.secondary-button { background: transparent; color: var(--ink); }
.primary-button:hover { background: var(--plum); }
.secondary-button:hover { background: var(--bench); }
.primary-button:disabled { cursor: wait; opacity: 0.55; }

.variant-readout { justify-self: end; margin: 0; font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; text-align: right; }
.change-status { margin: 1rem 0 0; color: var(--pine); font-weight: 650; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  margin: 1rem 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
}
.legend-title { color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-item .base { width: 24px; height: 24px; }
.combinatorial-note { max-width: 760px; margin: 1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.98rem; }

.noscript-proof { margin-top: 1.25rem; padding: 1rem; border: 2px dashed var(--plum); border-radius: 14px; }
.noscript-proof code { display: block; overflow-wrap: anywhere; font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; }

.explanation { padding: 5rem 0; }
.prose { width: min(780px, 100%); }
.prose p { margin-bottom: 1.35rem; }
.formula-panel {
  margin: 2rem 0;
  padding: clamp(1.2rem, 3vw, 2rem);
  border-radius: 24px;
  background: var(--ink);
  color: white;
}
.factor-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; }
.factor {
  min-height: 120px;
  padding: 1rem;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 14px;
}
.factor strong { display: block; margin-bottom: 0.35rem; font-family: "IBM Plex Mono", monospace; font-size: clamp(1.65rem, 4vw, 3rem); }
.equation { margin: 1.5rem 0 0; font-family: "IBM Plex Mono", monospace; font-size: clamp(1.05rem, 2.7vw, 2rem); overflow-wrap: anywhere; }
.time-scale { margin-bottom: 0; color: #e9e4ef; }

.caveat-section { padding: 5rem 0; background: var(--paper); }
.caveat-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: clamp(2rem, 6vw, 6rem); align-items: start; }
.ribosome-mark { position: sticky; top: 2rem; min-height: 330px; }
.ribosome-shape { position: absolute; border: 3px solid var(--ink); background: var(--bench); }
.ribosome-shape.one { top: 20px; left: 5%; width: 80%; height: 180px; border-radius: 53% 47% 58% 42% / 48% 62% 38% 52%; }
.ribosome-shape.two { top: 150px; right: 0; width: 67%; height: 150px; border-radius: 58% 42% 44% 56% / 42% 49% 51% 58%; background: #d8d3ea; }
.ribosome-slot { position: absolute; z-index: 2; top: 145px; left: 0; width: 100%; height: 30px; border: 3px solid var(--ink); background: repeating-linear-gradient(90deg, var(--u) 0 28px, var(--c) 28px 56px, var(--a) 56px 84px, var(--g) 84px 112px); }
.ribosome-label { position: absolute; z-index: 3; right: 0; bottom: 0; max-width: 210px; font-family: "IBM Plex Mono", monospace; font-size: 0.76rem; text-align: right; }

.methods { padding: 5rem 0 7rem; }
.sources-list { padding-left: 1.2rem; }
.sources-list li { margin-bottom: 0.9rem; padding-left: 0.35rem; }
.source-date { color: var(--muted); font-size: 0.95rem; }
.takeaway { margin: 4rem 0 0; padding-top: 2rem; border-top: 2px solid var(--ink); font-family: "Anybody", system-ui, sans-serif; font-size: clamp(2.4rem, 6vw, 5rem); font-weight: 720; line-height: 1; letter-spacing: -0.045em; }

footer {
  border-top: 1px solid rgb(26 25 32 / 25%);
  padding: 2rem 0 4rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.to-top.is-enhanced {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  display: flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 8px 24px rgb(26 25 32 / 15%);
  opacity: 0;
  pointer-events: none;
  text-indent: -999px;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  text-decoration: none;
}
.to-top.is-enhanced::after {
  content: "↑";
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.1rem;
  text-indent: 0;
}
.to-top.is-enhanced.is-visible { transform: translateY(0); opacity: 1; pointer-events: auto; }

@media (max-width: 900px) {
  .station-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .machine-head, .caveat-grid { grid-template-columns: 1fr; }
  .ribosome-mark { position: relative; width: min(520px, 100%); }
}

@media (max-width: 560px) {
  body { font-size: 1.02rem; }
  .shell { width: min(100% - 28px, 1180px); }
  .hero { padding-top: 3.4rem; }
  .hero-number { font-size: clamp(1.85rem, 9.1vw, 2.5rem); letter-spacing: -0.08em; }
  .hero-suffix { font-size: clamp(3rem, 15vw, 4.4rem); }
  .machine { border-radius: 22px; }
  .machine-head { gap: 1rem; }
  .protein-rail, .rna-label { align-items: flex-start; flex-direction: column; }
  .protein-rail span:last-child { text-align: left; }
  .station-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .station { padding: 0.48rem; }
  .base { font-size: 0.9rem; }
  .machine-controls { grid-template-columns: 1fr; }
  .primary-button, .secondary-button { width: 100%; }
  .variant-readout { justify-self: start; text-align: left; overflow-wrap: anywhere; }
  .factor-row { grid-template-columns: 1fr; }
  .factor { min-height: 0; }
  .ribosome-mark { min-height: 260px; }
  .ribosome-shape.one { height: 145px; }
  .ribosome-shape.two { top: 125px; height: 115px; }
  .ribosome-slot { top: 120px; }
  .ribosome-label { bottom: -1rem; }
  .footer-row { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .station.is-changed { transform: none; }
}

@media print {
  .machine-controls, .to-top { display: none !important; }
  body { background: white; }
  .machine { box-shadow: none; }
}
