:root {
  --bg: #fbfaf7;
  --card: #ffffff;
  --ink: #1d232b;
  --ink-2: #414b58;
  --muted: #687484;
  --line: #e6e3dc;
  --blue: #1c6fb8;
  --blue-fill: #d9e8f6;
  --blue-soft: #8fb9df;
  --amber: #e08a1e;
  --amber-fill: #fdf0dc;
  --red: #d2402c;
  --purple: #8b3fb0;
  --teal: #12917b;
  --dot: #28313c;
  --gray: #8a94a3;
  --good: #1f7a55;
  --code-bg: #1d232b;
  --code-ink: #e8eaed;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1b1e24;
    --ink: #eceef1;
    --ink-2: #c3c9d2;
    --muted: #929ba8;
    --line: #2d313a;
    --blue: #4a9be0;
    --blue-fill: #1e3246;
    --blue-soft: #3f6f9c;
    --amber: #dd8f33;
    --amber-fill: #3a2c17;
    --red: #ee6a55;
    --purple: #b97fda;
    --teal: #3dbba2;
    --dot: #d9dee5;
    --gray: #7d8795;
    --good: #5cc79a;
    --code-bg: #0e1013;
    --code-ink: #e8eaed;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
sup, sub { line-height: 0; font-size: 0.72em; }

.col { width: min(100% - 40px, 720px); margin-inline: auto; }

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(20px, calc((100vw - 1180px) / 2));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans); font-size: 16px;
}
.topbar .brand { font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .links { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; flex: none; max-width: 100%; }
.topbar .links::-webkit-scrollbar { display: none; }
.topbar .links a { color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.topbar .links a:hover { color: var(--blue); }

/* ── hero ── */
.hero { padding: 72px 0 8px; }
h1 {
  font-size: clamp(33px, 4.8vw, 48px); line-height: 1.1; font-weight: 500;
  letter-spacing: -0.02em; margin: 0 0 22px; text-wrap: balance;
}
.lede { font-size: clamp(22px, 2.6vw, 27px); line-height: 1.35; color: var(--ink-2); margin: 0 0 30px; text-wrap: balance; }
.lede em { color: var(--ink); }
.authors { font-family: var(--sans); font-size: 17px; line-height: 1.65; margin: 0 0 10px; color: var(--ink); }
.affils { font-family: var(--sans); font-size: 16px; line-height: 1.6; color: var(--muted); margin: 0 0 6px; }
.affils.notes { margin-bottom: 30px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--sans); font-size: 17px; font-weight: 500;
  padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn svg { width: 20px; height: 20px; }

.marquee { margin-top: 56px; display: grid; gap: 6px; overflow: hidden; }
.strip {
  --cell: clamp(110px, 12vw, 160px);
  height: var(--cell);
  background-image: url("assets/samples_mosaic.jpg");
  background-size: calc(var(--cell) * 6) calc(var(--cell) * 6);
  background-repeat: repeat-x;
  background-position: 0 calc(var(--row) * var(--cell) * -1);
  animation: slide 70s linear infinite;
}
.strip.rev { animation-direction: reverse; }
@keyframes slide { to { background-position-x: calc(var(--cell) * -6); } }
.marquee-note { font-family: var(--sans); font-size: 16px; color: var(--muted); margin-top: 14px; }

/* ── article ── */
section { padding: 64px 0 8px; }
h2 { font-size: clamp(29px, 3.8vw, 38px); line-height: 1.18; font-weight: 500; letter-spacing: -0.015em; margin: 0 0 20px; text-wrap: balance; }
h3 { font-size: 25px; line-height: 1.25; font-weight: 600; margin: 44px 0 12px; }
p { margin: 0 0 20px; }
.aside { font-family: var(--sans); font-size: 16px; color: var(--muted); }

/* ── the equation: each factor is a button that opens a small animation of what it measures ── */
.eqwrap { margin: 34px 0 26px; text-align: center; }
.eqline { position: relative; }
.eq { font-size: clamp(24px, 3.6vw, 32px); line-height: 1.6; margin: 0; white-space: nowrap; }
.eq-lhs { font-style: italic; }
.term {
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
  padding: 0 12px 2px; margin: 0 4px; border-radius: 12px; border: 2px solid var(--blue); background: var(--card);
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.term.t-dec { color: var(--blue); background: var(--blue-fill); }
.term.t-gen { border: 2px dashed var(--dot); }
.term:hover, .term.on { transform: translateY(-2px); box-shadow: 0 5px 16px rgba(0,0,0,.16); }
.term:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.eqwrap:not(.seen) .term { animation: nudge 2.6s ease-in-out infinite; }
.eqwrap:not(.seen) .term.t-gen { animation-delay: 1.3s; }
@keyframes nudge {
  0%, 60%, 100% { box-shadow: 0 0 0 0 transparent; }
  30% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--blue) 24%, transparent); }
}
.eq-hint { font-family: var(--sans); font-size: 16px; color: var(--muted); margin: 6px 0 0; transition: opacity .2s ease; }
.eqwrap.seen .eq-hint { opacity: 0; }      /* the hint has done its job once a factor has been opened */
.eq-hint .h-tap { display: none; }
@media (hover: none) {
  .eq-hint .h-hover { display: none; }
  .eq-hint .h-tap { display: inline; }
}
.eqpop {
  position: absolute; z-index: 10; left: 50%; top: calc(100% + 14px);
  width: min(400px, 100vw - 32px); padding: 16px 18px 14px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 16px 44px rgba(0,0,0,.2); font-family: var(--sans);
  opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, 6px);
  transition: opacity .18s ease, transform .18s ease, visibility 0s .18s;
}
.eqpop.open { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .18s ease, transform .18s ease; }
.eqpop::before {
  content: ""; position: absolute; left: var(--nx, 50%); top: -8px; width: 14px; height: 14px; margin-left: -7px;
  background: var(--card); border-left: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg);
}
.eqpop canvas { width: 100%; display: block; }
.pop-title { font-weight: 600; font-size: 18px; line-height: 1.3; margin: 0 0 6px; }
.eqpop[data-term="g"] .pop-title { color: var(--blue); }
.pop-note { font-size: 16px; line-height: 1.4; color: var(--ink-2); margin: 8px 0 0; }

/* ── viz shell ── */
.viz {
  width: min(100% - 24px, 860px); margin: 28px auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: clamp(16px, 2.4vw, 24px);
  font-family: var(--sans); font-size: 17px; color: var(--ink);
}
.viz.bare { padding: 0; overflow: hidden; width: min(100% - 24px, 560px); }
.viz canvas { width: 100%; display: block; touch-action: pan-y; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.seg button {
  font: 500 17px/1.2 var(--sans); color: var(--ink-2);
  padding: 10px 18px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:focus-visible, .btn:focus-visible, .copy:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.viz-status { font-family: var(--serif); font-size: 21px; line-height: 1.3; margin: 14px 0 6px; min-height: 1.3em; transition: opacity .25s ease; }
.viz-status.swap { opacity: 0; }

/* puzzle */
.layerstrip { display: grid; grid-template-columns: repeat(23, 1fr); gap: clamp(2px, 0.6vw, 6px); margin: 26px 0 8px; }
.layerstrip i {
  aspect-ratio: 1 / 1.25; border-radius: clamp(3px, 0.6vw, 7px);
  background: var(--c); opacity: .16; transform: scaleY(.72);
  transition: opacity .5s ease, transform .5s cubic-bezier(.3,1.4,.5,1);
  transition-delay: calc(var(--i) * 18ms);
}
.layerstrip i.on { opacity: 1; transform: none; }
.striplabels { display: flex; justify-content: space-between; color: var(--muted); font-size: 16px; margin-bottom: 22px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tile { border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; background: var(--bg); }
.tile-label { color: var(--ink-2); font-size: 16px; }
.tile-value { font-size: clamp(34px, 4vw, 44px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; margin: 4px 0; }
.tile-value small { font-size: 0.45em; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.tile-value s { color: var(--muted); font-weight: 400; text-decoration-thickness: 2px; font-size: 0.62em; }
.tile-value .to { color: var(--muted); font-weight: 400; font-size: 0.6em; margin: 0 0.3em; }
.tile-value b { font-weight: 600; color: var(--blue); }
.tile-note { color: var(--muted); font-size: 16px; line-height: 1.4; }
.tile-note.better { color: var(--good); }
.tile-note.worse { color: var(--red); }
#viz-headline .tile:nth-child(3) .tile-value b { color: var(--amber); }

/* interface */
.interface-grid { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 20px; align-items: center; }
.decoded { display: grid; gap: 12px; }
.decoded figure { margin: 0; }
.decoded img { width: 100%; border-radius: 10px; aspect-ratio: 1; object-fit: cover; }
.decoded figcaption { font-size: 16px; margin-top: 4px; color: var(--ink-2); text-align: center; }
.stack { position: relative; aspect-ratio: 1; }
.stack img { position: absolute; inset: 0; opacity: 0; transition: opacity .6s ease; }
.stack img.on { opacity: 1; }
.stack::after { content: ""; position: absolute; inset: 0; border-radius: 10px; box-shadow: inset 0 0 0 4px var(--red); opacity: 0; transition: opacity .6s ease; pointer-events: none; }
.stack.bad::after { opacity: 1; }

.legend-row { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 0; margin: 12px 0 0; font-size: 16px; color: var(--ink-2); }
.legend-row li { display: inline-flex; align-items: center; gap: 8px; }
.legend-row svg { width: 34px; height: 20px; flex: none; }
.k-tol { fill: var(--blue-fill); stroke: var(--blue); stroke-width: 2; }
.k-err { fill: none; stroke: var(--dot); stroke-width: 1.6; stroke-dasharray: 3 3; }
.k-dot { fill: var(--dot); }
.k-x { fill: none; stroke: var(--red); stroke-width: 2.6; stroke-linecap: round; }
.k-sens { fill: none; stroke: var(--purple); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.k-insens { fill: none; stroke: var(--teal); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* pipeline */
.pipe { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 8px; margin: 18px 0 54px; }
.node { display: grid; place-items: center; min-height: 48px; padding: 8px 16px; border-radius: 12px; font-size: 17px; font-weight: 500; white-space: nowrap; }
.node.frozen { background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); }
.node.io { padding: 0; }
.node.io img { width: 52px; height: 52px; border-radius: 10px; }
.node.tap { width: 52px; height: 52px; padding: 0; border-radius: 50%; border: 2px solid var(--line); font-family: var(--serif); font-size: 22px; transition: border-color .5s ease, background .5s ease; }
.node.tap.active { border-color: var(--blue); background: var(--blue-fill); }
.arrow { width: 22px; height: 2px; background: var(--gray); position: relative; flex: none; }
.arrow::after { content: ""; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left-color: var(--gray); border-right: 0; }
.dit-badge {
  position: absolute; left: 0; top: 0; padding: 6px 16px; border-radius: 999px;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 17px;
  will-change: transform; visibility: hidden;
}
.dit-badge.ready { visibility: visible; transition: transform .8s cubic-bezier(.5,0,.2,1); }
.dit-badge::before { content: ""; position: absolute; left: 50%; top: -7px; margin-left: -7px; border: 7px solid transparent; border-top: 0; border-bottom-color: var(--blue); }

/* charts */
.chart-title { font: 600 18px/1.3 var(--sans); margin: 20px 0 4px; }
.chart-title span { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 16px; }
.chart { position: relative; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 16px; color: var(--ink-2); margin: 8px 0 2px; min-height: 26px; }
.chart .legend span { display: inline-flex; align-items: center; gap: 8px; }
.chart .legend i { width: 22px; height: 0; border-top: 3px solid var(--c); border-radius: 2px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font: 400 16px var(--sans); fill: var(--muted); }
.chart text.val { font-weight: 600; fill: var(--ink); }
.chart text.xt { fill: var(--ink-2); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 170px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12); font-size: 16px; line-height: 1.5;
}
.tip b { display: block; margin-bottom: 2px; }
.tip div { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip div span { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.tip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.tip strong { font-variant-numeric: tabular-nums; }

/* leaderboard */
.board { position: relative; margin-top: 20px; }
.brow {
  position: absolute; left: 0; right: 0; height: 34px;
  display: grid; grid-template-columns: 190px 118px minmax(0, 1fr); align-items: center; gap: 10px;
  transition: transform .7s cubic-bezier(.5,0,.2,1);
  font-size: 17px;
}
.brow .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow .ep { color: var(--muted); font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; padding-right: 8px; white-space: nowrap; }
.brow .track { display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; }
.brow .bar { height: 18px; border-radius: 0 4px 4px 0; background: var(--gray); width: 0; transition: width .8s cubic-bezier(.3,0,.2,1); flex: none; }
.brow .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.brow.ours .name { font-weight: 600; }
.brow.ours .bar { background: var(--blue); }
.brow:hover .bar { filter: brightness(1.12); }

/* code */
.code { position: relative; margin: 0 0 24px; }
.code pre {
  margin: 0; padding: 20px 22px; border-radius: 14px; overflow-x: auto;
  background: var(--code-bg); color: var(--code-ink);
  font: 400 16px/1.6 var(--mono); tab-size: 2;
}
.copy {
  position: absolute; right: 10px; top: 10px;
  font: 500 16px var(--sans); color: var(--code-ink);
  background: #3a424e; border: 0; border-radius: 8px; padding: 5px 12px; cursor: pointer;
}
.copy:hover { background: #4b5563; }

footer { margin-top: 72px; padding: 30px 0 46px; border-top: 1px solid var(--line); font-family: var(--sans); font-size: 16px; color: var(--muted); }
footer p { margin: 0; }

/* ── small screens ── */
@media (max-width: 760px) {
  body { font-size: 19px; }
  .hero { padding-top: 44px; }
  .topbar .brand { display: none; }
  .tiles, .tiles.three { grid-template-columns: 1fr; }
  .interface-grid { grid-template-columns: 1fr; }
  .viz-status { min-height: 2.6em; }        /* two lines, so the figure does not jump when the sentence changes */
  .decoded { grid-template-columns: 1fr 1fr; }
  .seg { display: flex; }
  /* the FuseLift figure has to fit one phone screen: short labels, the pipeline on one row */
  #viz-lift .wide { display: none; }
  #viz-lift .seg button::first-letter { text-transform: uppercase; }
  #viz-lift .viz-status { font-size: 19px; margin: 6px 0 2px; }
  .pipe { flex-wrap: nowrap; gap: 3px; margin: 14px 0 50px; }
  .pipe .io { display: none; }
  .node { min-height: 40px; padding: 6px 7px; font-size: 15px; }
  .node.tap { width: 38px; height: 38px; font-size: 19px; }
  .arrow { width: 9px; }
  .dit-badge { padding: 4px 13px; font-size: 16px; }
  .seg button { flex: 1 1 auto; padding: 10px 12px; }
  /* one line per method, so the 14-row board stays about one screen tall */
  .brow { grid-template-columns: 146px minmax(0, 1fr); height: 38px; gap: 6px; font-size: 15px; }
  .brow .bar { height: 16px; }
  .brow .track { gap: 7px; }
  .brow .ep { display: none; }
}

@media (max-width: 350px) {
  .pipe { flex-wrap: wrap; gap: 50px 3px; }     /* very narrow phones: two rows again */
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .strip, .term { animation: none !important; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
