@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Jost:wght@400;500&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500&display=swap");

/* Layout: a modular Bauhaus grid, with flat geometric shapes on warm paper. */
:root {
  --paper: #f0eee6;
  --panel: #faf9f5;
  --ink: #141413;
  --soft: #5e5d59;
  --hair: #d1cfc5;
  --clay: #d97757;
  --ochre: #e0ac3f;
  --slate: #3e6587;
  --display: "Jost", "Futura", "Century Gothic", sans-serif;
  --body: "Source Serif 4", Georgia, serif;
  --mono: "DM Mono", ui-monospace, Menlo, Consolas, monospace;
  --gutter: clamp(16px, 3.2vw, 52px);
  --bar: 50px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 18px/1.5 var(--body); }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--clay); }
:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
.wrap { max-width: 1360px; margin-inline: auto; padding-left: max(var(--gutter), env(safe-area-inset-left, 0px)); padding-right: max(var(--gutter), env(safe-area-inset-right, 0px)); }

.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); border-bottom: 1px solid var(--hair); }
.bar .wrap { position: relative; max-width: none; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: calc(var(--bar) - 1px); padding-block: 6px; }
.partners { display: flex; align-items: center; gap: 18px; }
.partners a { display: flex; }
.logo-bme { height: 30px; width: auto; mix-blend-mode: multiply; }
.logo-egroup { height: 22px; width: auto; }
.menu-button { flex: none; white-space: nowrap; padding: 5px 12px; border: 0; border-radius: 999px; background: var(--hair); font: 500 13px var(--display); }
.menu-button span { font: 12px var(--mono); color: var(--soft); }
.menu-button:hover, .menu-button[aria-expanded="true"] { background: var(--ink); color: var(--panel); }
.menu-button:hover span, .menu-button[aria-expanded="true"] span { color: var(--hair); }
.menu { position: absolute; top: calc(100% + 8px); right: max(var(--gutter), env(safe-area-inset-right, 0px)); display: grid; min-width: 210px; padding: 8px; background: var(--panel); box-shadow: 0 1px 1px rgba(20, 20, 19, .3), 2px 5px 16px rgba(20, 20, 19, .18); font: 14px var(--mono); }
.menu[hidden] { display: none; }
.menu a { padding: 7px 8px; text-decoration: none; }
.menu a:hover { background: var(--paper); color: var(--ink); }
.menu span, .side span { margin-right: 8px; color: var(--soft); }

.with-side { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: clamp(24px, 3vw, 48px); align-items: start; }
.side { position: sticky; top: var(--bar); display: grid; gap: 2px; padding: clamp(20px, 4vh, 40px) 0 0 14px; font: 13px var(--mono); animation: swap .35s ease-out; }
.side a { position: relative; padding-block: 5px; color: var(--soft); text-decoration: none; }
.side a:hover, .side a.active { color: var(--ink); }
.side a.active::before { content: ""; position: absolute; left: -14px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--clay); }

.content { min-width: 0; }
.page { min-height: calc(100svh - var(--bar)); padding-block: clamp(20px, 4vh, 40px); }
.page.leaving { position: fixed; z-index: 1; }
html.swapping { overflow: hidden; }
.page:focus { outline: none; }
.pager { display: none; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: clamp(24px, 4vw, 64px); align-items: center; padding-block: 24px; }
.hero-copy { min-width: 0; }
h1 { margin: 0 0 22px; font: 500 clamp(50px, 5.2vw, 92px)/0.94 var(--display); letter-spacing: -0.04em; }
.lede { font-size: clamp(20px, 1.65vw, 24px); line-height: 1.32; margin: 0 0 20px; max-width: 30em; }
.status { display: flex; align-items: center; gap: 9px; font: 13px var(--mono); color: var(--soft); margin: 0 0 24px; }
.status::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--ochre); border: 1.5px solid var(--ink); animation: pulse 1.8s ease-in-out infinite; }
.label { display: block; font: 12px var(--mono); color: var(--soft); margin-bottom: 7px; }
.command { display: flex; align-items: stretch; border: 2px solid var(--ink); background: var(--panel); max-width: 560px; }
.command code { flex: 1; min-width: 0; padding: 11px 12px; overflow-x: auto; white-space: nowrap; font: 13px var(--mono); }
.icon-button { flex: none; display: grid; place-items: center; width: 44px; padding: 0; border: 0; border-left: 2px solid var(--ink); background: var(--ochre); }
.icon-button:hover { background: var(--clay); }
.icon-button svg, .text-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.icon-done { display: none; }
.copied .icon-copy { display: none; }
.copied .icon-done { display: block; }
.text-button { display: inline-flex; align-items: center; gap: 7px; margin-top: 11px; padding: 0; border: 0; background: none; font: 12px var(--mono); color: var(--soft); }
.text-button:hover { color: var(--ink); }
.begin { display: inline-block; margin-top: 24px; padding: 10px 18px; background: var(--ink); color: var(--panel); border-radius: 999px; font: 500 16px var(--display); text-decoration: none; }
.begin:hover { background: var(--clay); color: var(--ink); }

.paper-art { position: relative; aspect-ratio: 1.12; width: 100%; max-height: calc(100svh - var(--bar) - 48px); justify-self: center; background: var(--panel); border: 2px solid var(--ink); overflow: hidden; }
.paper-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.heading { display: flex; align-items: center; gap: 16px; margin-bottom: clamp(16px, 3vh, 30px); }
.mark { flex: none; width: clamp(28px, 2.8vw, 42px); aspect-ratio: 1; }
.mark.circle { border-radius: 50%; background: var(--clay); }
.mark.square { background: var(--slate); }
.mark.triangle { background: var(--ochre); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.mark.quarter { background: var(--ink); border-radius: 100% 0 0 0; }
.mark.ring { border-radius: 50%; border: clamp(7px, .7vw, 11px) solid var(--slate); }
.mark.slab { background: var(--clay); aspect-ratio: 2 / 1; width: clamp(40px, 4vw, 60px); }
.mark.half { background: var(--clay); border-radius: 100px 100px 0 0; aspect-ratio: 2 / 1; width: clamp(40px, 4vw, 60px); }
h2 { margin: 0; font: 500 clamp(34px, 4vw, 58px)/1 var(--display); letter-spacing: -0.03em; text-wrap: balance; }
h3 { font: 500 23px/1.15 var(--display); letter-spacing: -0.01em; margin: 0 0 7px; }
section p { max-width: 62ch; margin-top: 0; }
.note { max-width: none; font: 12px var(--mono); color: var(--soft); }

.pair.even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(24px, 4vw, 64px); align-items: start; }

.terminal { background: var(--ink); color: var(--panel); font: 14.5px/1.55 var(--mono); }
.term-title { display: flex; justify-content: space-between; padding: 8px 24px; border-bottom: 1px solid #3d3d3a; font-size: 12px; color: #a8a69c; }
.term-tabs { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 24px; padding: 8px 24px; border-bottom: 1px solid #3d3d3a; font-size: 13px; }
.term-steps, .term-nav { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.terminal button { padding: 3px 0; border: 0; border-bottom: 1px solid transparent; background: none; color: #a8a69c; font: inherit; }
.terminal button:hover { color: var(--panel); }
.term-steps button[aria-pressed="true"] { color: var(--panel); border-bottom-color: var(--panel); font-weight: 500; }
.term-body { min-height: clamp(300px, 52vh, 500px); padding: 18px 24px 22px; overflow-x: auto; white-space: pre; }
.t-mark { color: var(--clay); }
.t-good { color: var(--ochre); }
.t-you { color: var(--clay); }
.t-bold { font-weight: 500; }
.t-dim { color: #a8a69c; }
.t-box { display: inline-block; margin-block: 6px; padding: 6px 26px; border: 1px solid #5e5d59; border-radius: 6px; text-align: center; }
.t-bar { position: relative; display: inline-block; width: 22ch; height: 2px; margin-inline: 1.5ch; vertical-align: middle; background: #4a4a46; }
.t-bar i { position: absolute; top: -1px; left: 0; height: 4px; background: #8f8d84; }
.t-bar .t-gain { background: var(--ochre); }
.t-bar.you .t-gain { background: var(--clay); }
.t-bar .t-tick { top: -7px; width: 2px; height: 16px; background: #a8a69c; }
.caret { display: inline-block; width: .6em; height: 1em; vertical-align: -2px; background: var(--panel); animation: caret 1s steps(2) infinite; }
.terminal + .note { margin: 8px 0 0; }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 22px; margin: 22px 0 0; }
.facts dt { font: 13px/1.9 var(--mono); color: var(--soft); }
.facts dd { margin: 0; }
.memory-bar { position: relative; height: 38px; margin: 12px 0 10px; background: var(--panel); box-shadow: 0 1px 1px rgba(20, 20, 19, .28), 1px 3px 7px rgba(20, 20, 19, .13); }
.memory-bar::after { content: ""; position: absolute; inset: 0; background: url(/grain.svg); mix-blend-mode: multiply; pointer-events: none; }
.memory-fill { position: absolute; inset: 5px auto 5px 5px; width: 0; background: var(--ink); box-shadow: 0 1px 1px rgba(20, 20, 19, .3), 1px 2px 4px rgba(20, 20, 19, .18); transition: width 1.4s cubic-bezier(.2, .7, .2, 1); }
.in .memory-fill { width: calc(71.5% - 5px); }
.memory-keys { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 10px; font: 12px var(--mono); color: var(--soft); }

.stages { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 4px; border: 2px solid var(--ink); background: url(/grain.svg), var(--panel); background-blend-mode: multiply; }
.stage { min-width: 0; padding: clamp(12px, 1.8vh, 18px) 18px; border-right: 2px solid var(--ink); }
.stage:nth-child(2n) { border-right: 0; }
.stage:nth-child(-n+2) { border-bottom: 2px solid var(--ink); }
.stage canvas { display: block; width: 100%; max-width: 400px; aspect-ratio: 5 / 3; margin-bottom: clamp(8px, 1.5vh, 18px); }
.stage p { font-size: 16px; line-height: 1.38; margin: 0; color: var(--soft); }
@keyframes swap { from { opacity: 0; } }
@keyframes pulse { 50% { background: var(--panel); } }
@keyframes caret { 50% { opacity: 0; } }

.awards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 2px solid var(--ink); }
.awards > div { padding: 22px; min-width: 0; }
.awards > div:first-child { background: var(--ochre); border-right: 2px solid var(--ink); }
.awards > div:last-child { background: var(--panel); }
.awards p { margin: 0; }
.places { list-style: none; margin: 0; padding: 0; }
.places li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-top: 1px solid rgba(20, 20, 19, .25); }
.places li:first-child { border-top: 0; padding-top: 2px; }
.places span { font: 14px var(--mono); }
.places strong { font: 500 22px var(--display); white-space: nowrap; }
.places li:first-child strong { font-size: 30px; }
.awards + .note { margin-top: 14px; }

.table-wrap { overflow-x: auto; background: var(--panel); border: 2px solid var(--ink); }
table { width: 100%; border-collapse: collapse; font: 13px var(--mono); font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 400; color: var(--soft); font-size: 12px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tr.reference td { color: var(--soft); }

.rule-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 3vw, 44px); margin-top: 18px; }
.rule-columns > div { min-width: 0; padding-top: 12px; border-top: 2px solid var(--ink); }
.rule-columns ol { margin: 0; padding-left: 1.2em; font-size: 16px; line-height: 1.4; }
.rule-columns li { margin-bottom: 9px; }
.update { border-top: 1px solid var(--hair); padding-top: 14px; margin-top: 14px; }

[hidden] { display: none !important; }

.home .with-side { grid-template-columns: minmax(0, 1fr); }
.home .side { display: none; }
.hero h1 { font-size: clamp(50px, 6.6vw, 108px); }
.hero h1 .subtitle { display: block; margin-top: 0.12em; font-size: 0.5em; line-height: 1; letter-spacing: -0.03em; }

@media (min-width: 861px) {
  .stage canvas { --plot: clamp(120px, 17.5vh, 240px); width: calc(var(--plot) * 5 / 3); max-width: 100%; }
  .table-wrap { max-height: calc(100svh - var(--bar) - 210px); overflow-y: auto; }
}
@media (min-width: 861px) and (max-height: 819px) {
  .stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; align-content: start; }
  .stage canvas { grid-row: span 2; width: 100%; margin: 0; }
  .stage p { font-size: 14px; line-height: 1.3; }
  .stage h3 { font-size: 20px; }
}
@media (max-width: 1180px) {
  .with-side { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .page { min-height: calc(100svh - var(--bar) - 56px); }
  .pager { display: flex; justify-content: space-between; padding-block: 16px; border-top: 1px solid var(--hair); font: 13px var(--mono); }
  .pager a { text-decoration: none; }
  .pager a:last-child { margin-left: auto; }
}
@media (max-width: 1000px) {
  .rule-columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .hero, .pair.even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .stages, .awards { grid-template-columns: minmax(0, 1fr); }
  .stage { border-right: 0; border-bottom: 2px solid var(--ink); }
  .stage:last-child { border-bottom: 0; }
  .awards > div:first-child { border-right: 0; border-bottom: 2px solid var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .memory-fill { width: calc(71.5% - 5px); }
}
