/* Meth. Wayfinding world: chapters are lines, task types are stations. */

@font-face { font-family: "Overpass"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/overpass-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/overpass-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/overpass-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/overpass-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Overpass"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/overpass-latin-800-normal.woff2") format("woff2"); }

:root {
  --ground: #ffffff;
  --ground-2: #f2f5f7;
  --ink: #15202b;
  --ink-2: #4b5966;
  --rule: #d3dae0;
  --rule-strong: #15202b;
  --l1: #00915a; --l1-ink: #00774a;
  --l2: #0072bc; --l2-ink: #005f9e;
  --l3: #ef6a1a; --l3-ink: #b24a0b;
  --l4: #8b48a3; --l4-ink: #763a8b;
  --bad: #c22f2f;
  --line: var(--ink);
  --line-ink: var(--ink);
  --sign: #15202b;
  --sign-ink: #ffffff;
  --font: "Overpass", "Segoe UI", system-ui, sans-serif;
  --measure: 68ch;
  --margin-w: 13rem;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0e161d; --ground-2: #16212a; --ink: #e6ecf0; --ink-2: #a3b1bc; --rule: #2b3946; --rule-strong: #e6ecf0;
    --l1: #2fc184; --l1-ink: #4fd197; --l2: #3d9be0; --l2-ink: #6ab4ea; --l3: #ff8a3d; --l3-ink: #ff9d5c; --l4: #b77bd0; --l4-ink: #c895dc;
    --bad: #ff7a70; --sign: #e6ecf0; --sign-ink: #0e161d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0e161d; --ground-2: #16212a; --ink: #e6ecf0; --ink-2: #a3b1bc; --rule: #2b3946; --rule-strong: #e6ecf0;
  --l1: #2fc184; --l1-ink: #4fd197; --l2: #3d9be0; --l2-ink: #6ab4ea; --l3: #ff8a3d; --l3-ink: #ff9d5c; --l4: #b77bd0; --l4-ink: #c895dc;
  --bad: #ff7a70; --sign: #e6ecf0; --sign-ink: #0e161d; color-scheme: dark;
}
body.c1 { --line: var(--l1); --line-ink: var(--l1-ink); }
body.c2 { --line: var(--l2); --line-ink: var(--l2-ink); }
body.c3 { --line: var(--l3); --line-ink: var(--l3-ink); }
body.c4 { --line: var(--l4); --line-ink: var(--l4-ink); }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font); font-size: 1.0625rem; line-height: 1.6; font-variant-numeric: tabular-nums; }
::selection { background: color-mix(in srgb, var(--line) 28%, transparent); }
:focus-visible { outline: 3px solid var(--line); outline-offset: 2px; border-radius: 3px; }
a { color: var(--line-ink); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0; text-wrap: balance; font-weight: 800; letter-spacing: -.012em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
p + p { margin-top: .8em; }
ul, ol { margin: 0; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em; }
.muted { color: var(--ink-2); }
.wrap { max-width: calc(var(--measure) + var(--margin-w) + 4rem); margin: 0 auto; padding: 0 1.25rem; }
html { scrollbar-color: var(--rule) transparent; }

/* ---------- header ---------- */
.site-head { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--ground) 94%, transparent); backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; gap: 1rem; min-height: 3.5rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; color: var(--ink); text-decoration: none; white-space: nowrap; letter-spacing: -.01em; }
.brand svg { flex: none; }
.site-nav { display: flex; gap: .15rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .6rem; border-radius: var(--r); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.site-nav a:hover { background: var(--ground-2); }
.site-nav a[aria-current="page"] { background: var(--sign); color: var(--sign-ink); }
.site-nav .bar { width: 1.1rem; height: .3rem; border-radius: 2px; background: var(--c); }
.theme-btn { border: 1px solid var(--rule); background: none; color: var(--ink); border-radius: var(--r); width: 2.2rem; height: 2.2rem; display: grid; place-items: center; cursor: pointer; flex: none; }
.theme-btn:hover { border-color: var(--ink-2); }
@media (max-width: 720px) { .brand .long { display: none; } }

/* ---------- chapter opener + strip map ---------- */
.opener { padding: 3rem 0 1rem; display: grid; gap: .9rem; }
.opener h1 { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.line-badge { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; padding: 0 .3em; border-radius: var(--r); background: var(--line-ink); color: var(--ground); font-weight: 800; font-size: .8em; }
.opener .lede { color: var(--ink-2); font-size: 1.15rem; max-width: 60ch; }

.strip { position: relative; margin: 1.5rem 0 1rem; overflow-x: auto; padding: 0 0 .5rem; }
.strip ol { list-style: none; padding: 0 .5rem; display: flex; min-width: max-content; position: relative; }
.strip ol::before { content: ""; position: absolute; left: 1rem; right: 1rem; top: .7rem; height: 6px; background: var(--line); border-radius: 3px; }
.strip li { position: relative; width: 8.2rem; flex: none; }
.strip a { display: grid; justify-items: start; gap: .55rem; text-decoration: none; color: var(--ink); padding-right: .6rem; font-weight: 600; font-size: .88rem; line-height: 1.25; }
.strip a::before { content: ""; width: 1.25rem; height: 1.25rem; margin-top: .1rem; border-radius: 50%; background: var(--ground); border: 4px solid var(--line); position: relative; z-index: 1; transition: background .15s; }
.strip a:hover::before, .strip a:focus-visible::before { background: var(--line); }
.strip a:hover span { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .18em; }

/* ---------- page grid with margin ---------- */
.doc { display: grid; grid-template-columns: minmax(0, var(--measure)) var(--margin-w); column-gap: 3rem; }
.doc > * { grid-column: 1; }
.ref { grid-column: 2; font-size: .82rem; color: var(--ink-2); line-height: 1.4; }
@media (max-width: 1000px) { .doc { grid-template-columns: minmax(0, 1fr); } .ref { grid-column: 1; } }

/* ---------- station (task-type block) ---------- */
.station { padding: 3.5rem 0 1rem; border-top: 1px solid var(--rule); margin-top: 2rem; display: grid; gap: 1.4rem; }
.station:first-of-type { border-top: 0; margin-top: 0; }
.station-head { display: grid; grid-template-columns: auto 1fr; column-gap: .9rem; align-items: start; }
.station-head::before { content: ""; width: 1.5rem; height: 1.5rem; margin-top: .3rem; border-radius: 50%; border: 5px solid var(--line); background: var(--ground); }
.station-head .refs { grid-column: 2; margin-top: .35rem; font-size: .88rem; color: var(--ink-2); }
.part { display: grid; gap: .6rem; }
.part > h3 { display: flex; align-items: baseline; gap: .6rem; }
.part > h3 .tag { font-size: .78rem; font-weight: 700; color: var(--line-ink); letter-spacing: .01em; }
.recognise { font-style: italic; color: var(--ink-2); }
.recognise q { font-style: normal; color: var(--ink); }

/* ---------- route (the signature) ---------- */
.route { list-style: none; padding: 0; margin: .2rem 0 0; position: relative; display: grid; }
.route > li { position: relative; padding: 0 0 1.05rem 2.4rem; }
.route > li::before { content: ""; position: absolute; left: .55rem; top: .55rem; bottom: -.55rem; width: 5px; background: var(--line); border-radius: 2px; }
.route > li:last-child { padding-bottom: 0; }
.route > li:last-child::before { display: none; }
.route > li::after { content: ""; position: absolute; left: .21rem; top: .2rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 3px var(--ground); }
.route > li.start::after { background: var(--ground); border: 4px solid var(--line); }
.route > li.signal::after { background: var(--ground); border: 4px solid var(--ink); width: 1.35rem; height: 1.35rem; left: .09rem; top: .08rem; }
.route > li.end::after { border-radius: 2px; width: 1.4rem; height: .45rem; left: .07rem; top: .55rem; background: var(--ink); }
.route .lbl { display: block; font-weight: 700; }
.route li.signal .lbl { font-size: .8rem; letter-spacing: .02em; color: var(--ink); }
.route li.signal { padding-top: .1rem; }
.route li.signal .sig { display: grid; gap: .15rem; }
.route li.signal .then { font-weight: 700; }
.route .note { color: var(--ink-2); font-size: .95rem; }

/* signals table */
.signals { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.signals > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.signals dt { font-weight: 600; }
.signals dd { margin: 0; }
.signals dd::before { content: ""; display: inline-block; width: .9rem; height: 2px; background: var(--ink-2); vertical-align: .3em; margin-right: .5rem; }
@media (max-width: 560px) { .signals > div { grid-template-columns: 1fr; gap: .1rem; } }

/* ---------- demo panel ---------- */
.demo { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); border: 1px solid var(--rule); border-radius: var(--r); background: var(--ground-2); overflow: hidden; }
.demo .stage { position: relative; background: var(--ground); border-right: 1px solid var(--rule); }
.demo .side { padding: 1rem 1.1rem; display: grid; gap: .8rem; align-content: start; font-size: .97rem; }
.demo canvas { display: block; width: 100%; aspect-ratio: 1 / 1; touch-action: none; }
.demo .hint { position: absolute; left: .6rem; bottom: .5rem; font-size: .78rem; color: var(--ink-2); background: color-mix(in srgb, var(--ground) 85%, transparent); padding: .1rem .4rem; border-radius: 3px; pointer-events: none; }
.doc .demo { grid-column: 1 / -1; }
@media (max-width: 760px) { .demo { grid-template-columns: 1fr; } .demo .stage { border-right: 0; border-bottom: 1px solid var(--rule); } }

/* ---------- controls ---------- */
.btn { appearance: none; font: inherit; font-weight: 700; font-size: .92rem; line-height: 1; padding: .6rem .85rem; border-radius: var(--r); border: 1px solid var(--rule); background: var(--ground); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: .45rem; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--sign); color: var(--sign-ink); border-color: var(--sign); }
.btn.primary:hover { background: color-mix(in srgb, var(--sign) 85%, var(--line)); }
.btn.on { border-color: var(--line); box-shadow: inset 0 0 0 1px var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
label.slider { display: grid; grid-template-columns: 1.4rem 1fr 3.2rem; gap: .6rem; align-items: center; font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--line); }
.val { text-align: right; font-variant-numeric: tabular-nums; }
select, textarea, input[type="number"], input[type="search"] { font: inherit; color: var(--ink); background: var(--ground); border: 1px solid var(--rule); border-radius: var(--r); padding: .45rem .6rem; }
textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9rem; min-height: 5.5em; width: 100%; resize: vertical; }
.field { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.status { padding: .55rem .75rem; border-radius: var(--r); font-weight: 600; font-size: .95rem; border: 1px solid var(--rule); background: var(--ground); }
.status.yes { border-color: var(--l1); }
.status.no { border-color: var(--bad); }

/* ---------- example task ---------- */
.example { display: grid; gap: 1rem; }
.task { border: 1px solid var(--rule-strong); border-radius: var(--r); padding: 1rem 1.1rem; display: grid; gap: .5rem; }
.task .src { font-size: .82rem; font-weight: 700; color: var(--ink-2); }
details.solution { border-left: 1px solid var(--rule); padding-left: 1.1rem; }
details.solution > summary { cursor: pointer; font-weight: 700; color: var(--line-ink); list-style: none; display: inline-flex; align-items: center; gap: .5rem; margin-left: -1.1rem; padding-left: 1.1rem; }
details.solution > summary::-webkit-details-marker { display: none; }
details.solution > summary::before { content: ""; width: .55rem; height: .55rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
details.solution[open] > summary::before { transform: rotate(45deg); }
.sol { display: grid; gap: .8rem; padding-top: .8rem; }
.sol .idea { font-style: italic; }
.sol .idea b { font-style: normal; }
.sol .check { color: var(--ink-2); }
.sol .answer { font-weight: 700; padding-top: .5rem; border-top: 1px solid var(--rule); }
.math-scroll { overflow-x: auto; overflow-y: hidden; padding: .2rem 0; }
.katex-display { margin: .4em 0; overflow-x: auto; overflow-y: hidden; padding: .15em 0; }

/* ---------- mistakes ---------- */
ul.mistakes { list-style: none; padding: 0; display: grid; gap: .45rem; }
ul.mistakes li { position: relative; padding-left: 1.6rem; }
ul.mistakes li::before, ul.mistakes li::after { content: ""; position: absolute; left: .2rem; top: .72rem; width: .85rem; height: 2px; background: var(--bad); transform: rotate(45deg); }
ul.mistakes li::after { transform: rotate(-45deg); }

/* ---------- stepper ---------- */
.stepper { border: 1px solid var(--rule); border-radius: var(--r); background: var(--ground-2); padding: 1rem; display: grid; gap: .9rem; grid-column: 1 / -1; }
.stepper .title { font-weight: 700; }
.stepper .board { display: flex; justify-content: center; padding: 1.2rem .5rem; background: var(--ground); border: 1px solid var(--rule); border-radius: var(--r); overflow-x: auto; }
.smat { display: inline-grid; position: relative; padding: .2rem .9rem; font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.smat::before, .smat::after { content: ""; position: absolute; top: 1.7rem; bottom: 0; width: .45rem; border: 2px solid var(--ink); }
.smat::before { left: 0; border-right: 0; }
.smat::after { right: 0; border-left: 0; }
.srow { display: grid; grid-template-columns: var(--tpl); column-gap: .9rem; padding: .15rem .35rem; border-radius: 4px; }
.srow.head { font-size: .72rem; color: var(--ink-2); font-weight: 700; padding-bottom: .35rem; }
.scell { text-align: right; padding: .1rem .25rem; border-radius: 3px; white-space: nowrap; }
.scell.sep { border-left: 2px solid var(--ink); padding-left: .7rem; }
.srow.head .scell.sep { border-left-color: transparent; }
.scell.pivot { background: var(--line-ink); color: var(--ground); }
.srow.zero .scell { color: var(--ink-2); }
.srow.bad .scell.aug { color: var(--bad); font-weight: 800; }
.srow.zero.flag { box-shadow: inset 0 0 0 2px var(--ink); }
@keyframes rowflash { from { background: color-mix(in srgb, var(--line) 30%, transparent); } to { background: transparent; } }
.srow.chg { animation: rowflash 1.2s ease-out; }
@media (prefers-reduced-motion: reduce) { .srow.chg { animation: none; background: color-mix(in srgb, var(--line) 16%, transparent); } }
.op { text-align: center; font-size: 1.25rem; font-weight: 800; min-height: 1.6em; }
.opnote { text-align: center; color: var(--ink-2); max-width: 60ch; margin: 0 auto; font-size: .95rem; }
.progress { list-style: none; padding: 0; margin: 0 auto; display: flex; align-items: center; max-width: 100%; overflow-x: auto; }
.progress li { width: .85rem; height: .85rem; border-radius: 50%; border: 3px solid var(--line); background: var(--ground); flex: none; position: relative; }
.progress li + li { margin-left: 1.1rem; }
.progress li + li::before { content: ""; position: absolute; right: 100%; top: 50%; width: 1.1rem; height: 3px; margin-top: -1.5px; background: var(--rule); }
.progress li.done { background: var(--line); }
.progress li.done + li::before, .progress li.cur::before { background: var(--line); }
.progress li.cur { background: var(--line); transform: scale(1.25); }
.progress li:last-child { border-radius: 2px; width: 1.1rem; }
.result { border-top: 1px solid var(--rule); padding-top: .8rem; display: grid; gap: .5rem; }
.result[hidden] { display: none; }
.err { color: var(--bad); font-weight: 600; }

/* ---------- front page network ---------- */
.network { margin: 1.5rem 0 3rem; display: grid; gap: 2.2rem; }
.netline { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 1rem; align-items: start; }
.netline .name { display: grid; gap: .3rem; text-decoration: none; color: var(--ink); }
.netline .name b { font-size: 1.05rem; }
.netline .name span { font-size: .85rem; color: var(--ink-2); }
.netline .name:hover b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .18em; }
@media (max-width: 720px) { .netline { grid-template-columns: 1fr; } }
.search { display: grid; gap: .5rem; max-width: 40rem; }
.search input { font-size: 1.1rem; padding: .7rem .9rem; border: 2px solid var(--ink); }
.hits { list-style: none; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--rule); }
.hits:empty { display: none; }
.hits a { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; padding: .55rem .2rem; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.hits a:hover, .hits a:focus-visible { background: var(--ground-2); }
.hits .dot { width: .9rem; height: .9rem; border-radius: 50%; border: 3px solid var(--c); }
.hits .where { font-size: .82rem; color: var(--ink-2); }

/* ---------- koekortti ---------- */
.cards { columns: 2 22rem; column-gap: 2.5rem; }
.card { break-inside: avoid; padding: 1rem 0 1.4rem; border-top: 3px solid var(--c, var(--ink)); margin-bottom: .5rem; display: grid; gap: .5rem; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card ol { padding-left: 1.2rem; display: grid; gap: .2rem; }
.card .sigs { font-size: .93rem; display: grid; gap: .15rem; }
@media print {
  .site-head, .no-print, .theme-btn { display: none !important; }
  body { font-size: 10.5pt; }
  .cards { columns: 2; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- footer ---------- */
.site-foot { margin-top: 5rem; border-top: 1px solid var(--rule); padding: 1.5rem 0 3rem; color: var(--ink-2); font-size: .88rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.next-line { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; flex-wrap: wrap; }
.next-line a { font-weight: 700; }

/* ---------- product demo tables ---------- */
.demo-wide { grid-template-columns: 1fr; }
.mt-row { display: flex; align-items: center; gap: .6rem; overflow-x: auto; padding: .3rem 0; }
.mt-op { font-weight: 800; font-size: 1.3rem; }
table.mt { border-collapse: separate; border-spacing: 2px; box-shadow: inset 2px 0 0 var(--ink), inset -2px 0 0 var(--ink); padding: 0 .35rem; background: var(--ground); }
table.mt caption { font-weight: 800; font-size: .85rem; padding-bottom: .2rem; }
table.mt td { min-width: 2.6rem; text-align: right; padding: .3rem .45rem; border-radius: 3px; }
table.mt.prod td { cursor: pointer; }
table.mt.prod td:hover { background: var(--ground-2); }
table.mt td.hl { background: color-mix(in srgb, var(--line) 22%, transparent); font-weight: 700; }
table.mt td.sel { background: var(--line-ink); color: var(--ground); font-weight: 800; }
.vecgrid { display: grid; grid-template-columns: auto repeat(3, minmax(0, 3.6rem)); gap: .35rem .5rem; align-items: center; }
.vecgrid input { width: 100%; padding: .3rem .4rem; font-variant-numeric: tabular-nums; }
.vecgrid .muted { text-align: center; font-size: .85rem; }
.demo .route > li { padding-bottom: .8rem; }

/* grid children may shrink; wide math and matrices scroll inside their own box */
.doc > *, .station > *, .part > *, .example > *, .sol > *, .task > *, .stepper > *, .demo > *, .side > *, details.solution { min-width: 0; }
.task p, .sol p, .route .note, .route .lbl, .recognise, .signals dt, .signals dd { overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.station-head h2 { overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .brand > span { display: none; }
  .site-nav a { padding: .35rem .45rem; font-size: .9rem; }
  body { font-size: 1rem; }
  .route > li { padding-left: 2.1rem; }
}
.field { min-width: 0; }
.field select { width: 100%; min-width: 0; text-overflow: ellipsis; }
