:root {
  --bg: #fcfcfb;
  --panel: #f3f2ef;
  --line: #dddbd6;
  --text: #16161a;
  --muted: #5c5c63;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --figure-bg: #ffffff;
  --measure: 54rem;
  /* One colour per module, the same as its state in the replay: found, chosen, visiting. */
  --m-perception: #1a9e5c;
  --m-search: #2a78d6;
  --m-motion: #eb6834;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --panel: #1f1f22;
    --line: #34343a;
    --text: #ecebe8;
    --muted: #a4a3a9;
    --accent: #5b9ced;
    --accent-ink: #0d1520;
    --figure-bg: #f7f7f5;
    --m-perception: #3cbf7c;
    --m-search: #5b9ced;
    --m-motion: #f0844f;
  }
}
[data-m="perception"] { --m: var(--m-perception); }
[data-m="search"] { --m: var(--m-search); }
[data-m="motion"] { --m: var(--m-motion); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-text-size-adjust: 100%;
}
main, .hero-inner, footer { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }
h2 { font-size: 2rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -0.015em; }
h3 { font-size: 1.4rem; margin: 2.4rem 0 0.6rem; }
h3 + p { margin-top: 0; }
p, ul, ol { max-width: var(--measure); }
p, li, figcaption { text-wrap: pretty; }
.nb { white-space: nowrap; }
code { font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }
section { padding: 3.6rem 0; border-top: 1px solid var(--line); scroll-margin-top: 2.6rem; }
section.summary { border-top: 0; padding-top: 2.4rem; }
.note { color: var(--muted); font-size: 0.95rem; }
figure { margin: 0; }
figcaption { color: var(--muted); font-size: 0.95rem; margin-top: 0.5rem; max-width: var(--measure); }

/* Header */
.hero {
  text-align: center; padding: 5rem 0 2.4rem;
  background: radial-gradient(70% 90% at 50% 0%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%);
}
.eyebrow { color: var(--muted); font-size: 0.85rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 auto 0.7rem; }
.hero h1 { font-size: clamp(2.8rem, 8vw, 4rem); line-height: 1; margin: 0; letter-spacing: -0.035em; }
.subtitle { font-size: clamp(1.1rem, 2.6vw, 1.45rem); color: var(--muted); margin: 0.9rem auto 1.8rem; max-width: 40ch; line-height: 1.35; text-wrap: balance; }
.authors { list-style: none; padding: 0; margin: 0 auto 1.8rem; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 2.2rem; max-width: none; }
.authors li { display: flex; flex-direction: column; }
.authors span { color: var(--muted); font-size: 0.85rem; }
.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.button {
  display: inline-block; padding: 0.55rem 1.15rem; border-radius: 999px; border: 1.5px solid var(--text);
  background: var(--text); color: var(--bg); text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
.button.ghost { background: transparent; color: var(--text); }
.button:hover { opacity: 0.85; }
.button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Page navigation */
.toc { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.toc-inner { max-width: 1040px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 1rem; }
.toc ul { list-style: none; display: flex; gap: 1.4rem; margin: 0; padding: 0.6rem 0; flex: 1; min-width: 0; max-width: none; overflow-x: auto; white-space: nowrap; font-size: 0.9rem; scrollbar-width: none; }
.lang { flex: none; display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-size: 0.82rem; }
.lang button { font: inherit; background: none; color: var(--muted); border: 0; padding: 0.2rem 0.75rem; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 600; }
.lang button:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.toc a[aria-current] { color: var(--text); font-weight: 600; }

/* Side contents: wide screens only (it needs the margin left of the 1040 px column) */
.rail { display: none; }
.rail ul { list-style: none; margin: 0; padding: 0; max-width: none; }
.rail a { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.3rem 0; color: var(--muted); text-decoration: none; font-size: 0.85rem; line-height: 1.35; font-weight: 500; }
.rail a::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--m, var(--muted)); opacity: 0.55; transform: translateY(-1px); transition: transform 0.15s, opacity 0.15s; }
.rail a:hover { color: var(--text); }
.rail a[aria-current] { color: var(--text); font-weight: 700; }
.rail a[aria-current]::before { opacity: 1; transform: translateY(-1px) scale(1.5); }
.rail a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (min-width: 1360px) {
  .toc { position: static; height: 0; background: none; border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .toc-inner { padding: 0; }
  /* The language switch stays at the top, in the margin right of the column (the contents list is in the left one). */
  .toc .lang { position: fixed; top: 1rem; left: calc(50vw + 516px); z-index: 11; background: var(--bg); }
  .toc ul { display: none; }
  .rail { display: block; position: fixed; top: 5.5rem; left: calc((100vw - 1040px) / 2 - 146px); width: 150px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .rail.on { opacity: 1; pointer-events: auto; }
}
html[lang="ko"] body { word-break: keep-all; overflow-wrap: break-word; }
.toc li { white-space: nowrap; }   /* text-wrap: pretty on li would otherwise let the links wrap */
.toc a { color: var(--muted); text-decoration: none; font-weight: 500; }
.toc a:hover, .toc a:focus-visible { color: var(--text); }

/* Summary */
.summary .lead { font-size: 1.22rem; line-height: 1.6; margin: 0 0 1.6rem; max-width: 58.75rem; }
.summary figure img { border-radius: 10px; }
.lead-sm { font-size: 1.08rem; margin: 0 0 1.6rem; }

/* Key numbers */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1.4rem 0; }
.stat { background: var(--panel); border-radius: 12px; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.3rem; }
.stat .value { font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 1rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat .metric { order: -1; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat .label { color: var(--muted); font-size: 0.88rem; line-height: 1.4; }


/* Module sections */
.module-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.module-num { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; color: var(--m); font-variant-numeric: tabular-nums; }
.module-head h2 { margin: 0; }
.owner { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.95rem; }
.module > figure, .module > .cards, .module > .two-col { margin-top: 1.6rem; }
@media (min-width: 761px) { .module > .cards { grid-template-columns: repeat(3, 1fr); } }

/* Cards and columns */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0.9rem; }
.cards.one { grid-template-columns: 1fr; }
.cards.dense p { font-size: 0.93rem; line-height: 1.5; }
.card { background: var(--panel); border-radius: 12px; padding: 1rem 1.15rem 1.05rem; }
.card h3, .card h4 { margin: 0 0 0.35rem; font-size: 1.08rem; }
.card p { margin: 0; font-size: 1rem; line-height: 1.58; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; align-items: start; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.figure-card img { background: var(--figure-bg); border-radius: 10px; padding: 8px; border: 1px solid var(--line); width: 100%; }
/* A figure with small labels keeps a readable size on phones and scrolls sideways. */
figure.scroll { overflow-x: auto; }
figure.scroll img { min-width: 640px; }
figure.scroll.strip img { min-width: 900px; }
figure.scroll figcaption { position: sticky; left: 0; }
@media (min-width: 761px) { .two-col > .figure-card { position: sticky; top: 3.4rem; } }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0.8rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.85rem; border-bottom: 2px solid var(--line); }
tr.ours td { font-weight: 700; }
.facts { padding-left: 1.2rem; }
.facts li { margin: 0.3rem 0; }
@media (max-width: 640px) { table { min-width: 560px; } }

footer { color: var(--muted); font-size: 0.9rem; padding-bottom: 3rem; }
footer::before { content: ""; display: block; border-top: 1px solid var(--line); margin-bottom: 1.6rem; }

/* Placement by placement: paired dots, one row per placement */
:root { --c-base: #7b7b83; }
@media (prefers-color-scheme: dark) { :root { --c-base: #a4a3a9; } }
.pairs { background: var(--panel); border-radius: 14px; padding: 1rem 1.1rem; margin: 1rem 0; --name: 9.5rem; --val: 3.6rem; }
.pairs-legend { list-style: none; padding: 0; margin: 0 0 0.6rem; display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; font-size: 0.85rem; color: var(--muted); max-width: none; }
.pairs-legend li { display: flex; align-items: center; gap: 0.45rem; }
.pairs-legend .pairs-key { margin-left: auto; }
.pairs-legend b { color: var(--text); font-weight: 600; }
.pairs .dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; }
.pairs .dot.trained { background: var(--accent); }
.pairs .dot.base { width: 18px; height: 18px; border: 2px solid var(--c-base); background: var(--panel); }
.pairs .dot.fail { background: none; border: 0; border-radius: 0; width: 16px; height: 16px; display: inline-grid; place-items: center; font-style: normal; font-weight: 800; font-size: 21px; line-height: 1; box-shadow: none !important; }
.pairs .dot.fail::before { content: "×"; }
.pairs .dot.fail { color: var(--c-base); }
.pairs .dot.fail[data-v="trained"] { color: var(--accent); }
.pairs-group { margin: 0.9rem 0 0.2rem; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.pairs-axis, .pair { display: grid; grid-template-columns: var(--name) 1fr var(--val); gap: 0.6rem; align-items: center; width: 100%; }
.pairs-axis { font-size: 0.8rem; color: var(--muted); height: 1.3rem; }
.pairs-axis .ticks { position: relative; height: 100%; margin: 0 10px; }
.pairs-axis .ticks span { position: absolute; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.pairs-axis .unit { text-align: right; }
.pair { font: inherit; font-size: 0.92rem; color: var(--text); background: none; border: 0; border-radius: 8px; padding: 0.12rem 0.3rem; margin: 0 -0.3rem; width: calc(100% + 0.6rem); text-align: left; cursor: pointer; }
.pair:hover, .pair:focus-visible { background: var(--bg); }
.pair:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.pair-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pair-name b { font-weight: 600; }
.pair-name span { color: var(--muted); }
.pair-track { position: relative; height: 1.5rem; margin: 0 10px; background: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px calc(100% / var(--ticks, 6))); border-right: 1px solid var(--line); }
.pair-track i { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.pair-track .link { height: 2px; background: var(--c-base); opacity: 0.55; transform: translateY(-50%); }
.pair-track .dot.trained { box-shadow: 0 0 0 2px var(--panel); }
.pair:hover .dot.trained, .pair:focus-visible .dot.trained { box-shadow: 0 0 0 2px var(--bg); }
.pair:hover .dot.base, .pair:focus-visible .dot.base { background: var(--bg); }
.pair-val { text-align: right; color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pair-val b { color: var(--text); font-weight: 600; }
.pairs-status { margin: 0.8rem 0 0; min-height: 3em; font-size: 0.92rem; color: var(--muted); max-width: none; }
@media (max-width: 560px) { .pairs { --name: 6.6rem; --val: 3rem; padding: 0.9rem 0.7rem; } .pair { font-size: 0.86rem; } }

/* Search replay */
:root { --c-cand: #2a78d6; --c-chosen: #2a78d6; --c-found: #1a9e5c; --c-visit: #eb6834; --c-searched: #b9b8b3; }
@media (prefers-color-scheme: dark) { :root { --c-cand: #5b9ced; --c-chosen: #5b9ced; --c-found: #3cbf7c; --c-visit: #f0844f; --c-searched: #55545a; } }
#replay { scroll-margin-top: 3.2rem; }
.replay { background: var(--panel); border-radius: 14px; padding: 1rem; margin: 1rem 0 0.5rem; }
.replay-controls { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; margin-bottom: 0.8rem; font-size: 0.92rem; }
.replay-controls label { display: flex; align-items: center; gap: 0.4rem; min-width: 0; max-width: 100%; }
.replay-controls label:first-child { flex: 1 1 280px; }
.replay-controls label:first-child select { flex: 1; min-width: 0; width: 100%; }
.replay-controls select, .replay-controls button { font: inherit; font-size: 0.9rem; padding: 0.35rem 0.6rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); max-width: 100%; }
.replay-controls button { cursor: pointer; font-weight: 600; }
.replay-controls button:focus-visible, .replay-controls select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.replay-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 820px) { .replay-panels { grid-template-columns: minmax(0, 1fr); } }
.replay-panel { background: var(--bg); border-radius: 10px; padding: 0.7rem 0.8rem 0.4rem; border: 1px solid var(--line); }
.replay-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.95rem; }
.replay-clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.replay-status { margin: 0.3rem 0 0.2rem; min-height: 2.8em; font-size: 0.95rem; color: var(--text); }
.replay-graph { width: 100%; height: auto; display: block; }
.replay-graph .edge { stroke: var(--line); stroke-width: 1.5; }
.replay-graph .node { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; transition: fill .25s, stroke .25s; }
.replay-graph .node.home { fill: var(--text); stroke: none; }
.replay-graph .home + .label { fill: var(--bg); }
.replay-graph .label { font-size: 13px; fill: var(--text); text-anchor: middle; font-weight: 600; }
.replay-graph .label.start, .replay-graph .sub.start { text-anchor: start; }
.replay-graph .sub { font-size: 10.5px; fill: var(--muted); }
.replay-graph .standalone .node { stroke-dasharray: 3 2; }
.replay-graph .cand .node { stroke: var(--c-cand); stroke-width: 2; }
.replay-graph .chosen .node { fill: var(--c-chosen); stroke: var(--c-chosen); }
.replay-graph .chosen .label, .replay-graph .chosen .sub { fill: #ffffff; }
.replay-graph .visiting .node { fill: var(--c-visit); stroke: var(--c-visit); animation: pulse 1.1s ease-in-out infinite; }
.replay-graph .visiting .label, .replay-graph .visiting .sub { fill: #ffffff; }
.replay-graph .searched .node { fill: var(--c-searched); stroke: var(--c-searched); }
.replay-graph .searched .label { fill: var(--muted); text-decoration: line-through; }
.replay-graph .found .node { fill: var(--c-found); stroke: var(--c-found); }
.replay-graph .found .label, .replay-graph .found .sub { fill: #ffffff; font-weight: 700; }
.replay-graph .placed .node { stroke-dasharray: none; outline: none; }
.replay-graph .placed:not(.found):not(.visiting):not(.chosen) .node { stroke: var(--c-found); stroke-width: 2; stroke-dasharray: 5 3; }
@keyframes pulse { 50% { opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .replay-graph .visiting .node { animation: none; } .replay-graph .node { transition: none; } }
.replay-legend { list-style: none; padding: 0; margin: 0.8rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font-size: 0.9rem; color: var(--muted); max-width: none; }
.replay-legend li { display: flex; align-items: center; gap: 0.4rem; }
.key { width: 18px; height: 12px; border-radius: 3px; border: 1.5px solid var(--line); background: var(--panel); display: inline-block; }
.key.cand { border-color: var(--c-cand); border-width: 2px; }
.key.chosen { background: var(--c-chosen); border-color: var(--c-chosen); }
.key.visiting { background: var(--c-visit); border-color: var(--c-visit); }
.key.searched { background: var(--c-searched); border-color: var(--c-searched); }
.key.found { background: var(--c-found); border-color: var(--c-found); }
.key.placed { border: 2px dashed var(--c-found); }

/* Videos */
.replay-figure { overflow-x: auto; }
@media (max-width: 640px) { .replay-graph { min-width: 440px; } }
.pair.static { cursor: default; }
.pair .rec { font-style: normal; font-size: 0.7em; color: var(--accent); }
.hero-video { margin: 0 0 1.6rem; }
.flow-video { margin-top: 1.4rem; }
.hero-video video { width: 100%; display: block; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; }
.replay-video { width: 100%; display: block; aspect-ratio: 800 / 578; background: #000; border-radius: 8px; margin-top: 0.6rem; }

/* scroll reveal (reveal.js); the .js class is only set when motion is welcome */
html.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity .5s ease, transform .5s ease; }
html.js .reveal.in { opacity: 1; transform: none; transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0s); }
