/* The slow way, made survivable — one stylesheet for every page.
   Colour is meaning. Five meanings, one colour each, never alone.
   See RESEARCH-NOTES.md, Track C. */

:root {
  --paper: #FBFAF7;
  --ink: #1B1B1B;
  --muted: #5A5A5A;
  --rule: #C9C6BF;
  --surface: #F1EFE9;

  --value: #0072B2;   --value-t: #005A8E;   --value-f: #D1E6F1;
  --price: #E69F00;   --price-t: #8A5A00;   --price-f: #FAEED1;
  --pass: #009E73;    --pass-t: #00714F;    --pass-f: #D1EEE6;
  --fail: #D55E00;    --fail-t: #A34500;    --fail-f: #F7E2D1;
  --miss: #767676;    --miss-t: #5C5C5C;    --miss-f: #E6E6E6;
  --owner: #CC79A7;   --owner-t: #8B4A70;   --owner-f: #F6E7EF;

  --measure: 34em;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 1000px) { body { font-size: 18px; } }

/* ---------- focus and skip ---------- */

:focus-visible {
  outline: 3px solid var(--value-t);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 8px; top: -60px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  z-index: 10;
  text-decoration: none;
}
.skip:focus { top: 8px; }

/* ---------- frame ---------- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.top .brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.top .where {
  color: var(--muted);
  font-size: 0.9em;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 1000px) {
  .frame { grid-template-columns: 270px minmax(0, 1fr); }
}

/* ---------- chapter list (sidebar on wide, toggled menu on narrow) ---------- */

.chapters {
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.menu-toggle {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.menu-label {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 600;
  user-select: none;
}
.menu-label::before {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--ink);
  margin-right: 10px;
  transition: transform 120ms;
}
.menu-toggle:checked ~ .menu-label::before { transform: rotate(180deg); }
.menu-toggle:focus-visible ~ .menu-label {
  outline: 3px solid var(--value-t);
  outline-offset: -3px;
}
.chapters nav { display: none; }
.menu-toggle:checked ~ nav { display: block; }

.chapters ol {
  list-style: none;
  margin: 0;
  padding: 0 8px 12px;
}
.chapters .part {
  margin: 12px 8px 4px;
  font-size: 0.78em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.chapters li a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--ink);
  text-decoration: none;
  border-left: 4px solid transparent;
  border-radius: 0 4px 4px 0;
  line-height: 1.3;
}
.chapters li a:hover { background: var(--surface); }
.chapters li a[aria-current="page"] {
  border-left-color: var(--ink);
  background: var(--surface);
  font-weight: 600;
}
.chapters li a .n {
  flex: 0 0 1.6em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
}
.chapters li a .short {
  margin-left: auto;
  font-size: 0.72em;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0 7px;
  white-space: nowrap;
  align-self: center;
}
.chapters .home a { font-weight: 600; }

@media (min-width: 1000px) {
  .chapters {
    border-bottom: 0;
    border-right: 1px solid var(--rule);
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
  }
  .menu-label, .menu-toggle { display: none; }
  .chapters nav, .menu-toggle:checked ~ nav { display: block; }
  .chapters ol { padding: 12px 8px 24px; }
}

/* ---------- main column ---------- */

main {
  padding-block: 8px 48px;
  padding-inline: 16px;
  min-width: 0;
}
.article {
  max-width: var(--measure);
  margin: 0 auto;
}
@media (min-width: 1000px) {
  main { padding-inline: 40px; }
  .article { margin: 0; }
}
@media (min-width: 1360px) {
  .article { margin-right: 17em; position: relative; }
}

.crumb {
  color: var(--muted);
  font-size: 0.9em;
  margin: 12px 0 0;
}
h1 {
  font-size: 1.9em;
  line-height: 1.15;
  font-weight: 600;
  margin: 0.2em 0 0.3em;
  letter-spacing: -0.01em;
}
.lede {
  font-size: 1.08em;
  color: var(--muted);
  margin: 0 0 1.6em;
  padding-bottom: 1em;
  border-bottom: 1px solid var(--rule);
}
.lede .time { white-space: nowrap; }
h2 {
  font-size: 1.32em;
  font-weight: 600;
  line-height: 1.25;
  margin: 2em 0 0.5em;
}
h3 {
  font-size: 1.05em;
  font-weight: 600;
  margin: 1.6em 0 0.4em;
}
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
strong { font-weight: 600; }

dfn {
  font-style: normal;
  font-weight: 600;
  border-bottom: 2px dotted var(--muted);
}

blockquote {
  margin: 1.2em 0;
  padding: 0.2em 0 0.2em 1em;
  border-left: 3px solid var(--rule);
  color: var(--ink);
}
blockquote p { margin-bottom: 0.4em; }
blockquote cite { color: var(--muted); font-style: normal; font-size: 0.9em; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }

/* ---------- the worked example, NAME A ---------- */

.example {
  background: var(--surface);
  border-radius: 6px;
  padding: 14px 16px 4px;
  margin: 1.2em 0 1.4em;
}
.example .tag {
  display: block;
  font-size: 0.78em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ---------- the wrong way first (refutation) ---------- */

.wrong {
  border: 2px solid var(--fail);
  border-radius: 6px;
  padding: 12px 16px 2px;
  margin: 1.2em 0;
}
.wrong .tag, .right .tag {
  display: block;
  font-size: 0.78em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.wrong .tag { color: var(--fail-t); }
.wrong .tag::before { content: "\2717\00a0"; }
.right {
  border: 2px solid var(--pass);
  border-radius: 6px;
  padding: 12px 16px 2px;
  margin: 1.2em 0;
}
.right .tag { color: var(--pass-t); }
.right .tag::before { content: "\2713\00a0"; }

/* ---------- decision record ---------- */

.decision {
  border-left: 4px solid var(--ink);
  padding: 4px 0 4px 16px;
  margin: 1.4em 0;
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  gap: 4px 12px;
}
.decision dt {
  font-size: 0.78em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.35em;
}
.decision dd { margin: 0; }
@media (max-width: 420px) {
  .decision { grid-template-columns: minmax(0, 1fr); }
  .decision dd { margin-bottom: 8px; }
}

/* ---------- stage cards (the funnel walk) ---------- */

.stage {
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin: 1em 0;
  overflow: hidden;
}
.stage h3 {
  margin: 0;
  padding: 10px 14px;
  background: var(--surface);
  font-size: 1em;
}
.stage dl {
  margin: 0;
  padding: 8px 14px 4px;
  display: grid;
  grid-template-columns: 8.5em minmax(0, 1fr);
  gap: 2px 12px;
}
.stage dt { color: var(--muted); font-size: 0.9em; padding-top: 0.2em; }
.stage dd { margin: 0 0 8px; }
@media (max-width: 480px) {
  .stage dl { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- limits (two columns) ---------- */

.limits { margin: 0; padding: 0; list-style: none; }
.limits li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}
.limits li:last-child { border-bottom: 1px solid var(--rule); }
.limits .what { font-weight: 600; }
.limits .does { color: var(--ink); }
.limits .does::before {
  content: "What is done about it";
  display: block;
  font-size: 0.75em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
@media (max-width: 560px) {
  .limits li { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- folds: exactly one level ---------- */

details.fold {
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin: 1em 0;
}
details.fold summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 6px 14px;
  font-weight: 600;
  list-style: none;
}
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::before {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid var(--ink);
  margin-right: 10px;
  transition: transform 120ms;
}
details.fold[open] summary::before { transform: rotate(90deg); }
details.fold .inner { padding: 4px 14px 2px; border-top: 1px solid var(--rule); }
details.fold .inner p:last-child { margin-bottom: 0.8em; }
details.fold code { font-size: 0.9em; }

/* ---------- notes (beside the sentence on wide, after it on narrow) ---------- */

.noteref {
  font-size: 0.72em;
  vertical-align: super;
  line-height: 0;
  text-decoration: none;
  color: var(--value-t);
  font-weight: 600;
  padding: 0 2px;
}
.note {
  display: block;
  font-size: 0.86em;
  line-height: 1.45;
  color: var(--muted);
  border-left: 3px solid var(--rule);
  padding: 2px 0 2px 10px;
  margin: 0.5em 0 0.8em;
}
.note .nn { font-weight: 600; color: var(--value-t); margin-right: 4px; }
.note:target { background: var(--surface); }
@media (min-width: 1360px) {
  .note {
    float: right;
    clear: right;
    width: 15em;
    margin: 0 -17em 0.6em 0;
    border-left: 0;
    padding-left: 0;
  }
}

/* ---------- figures ---------- */

figure.fig {
  margin: 1.4em 0 1.6em;
}
figure.fig svg {
  width: 100%;
  height: auto;
  display: block;
  font-family: var(--font);
}
figure.fig figcaption {
  font-size: 0.9em;
  color: var(--muted);
  margin-top: 8px;
}

/* ---------- tables ---------- */

.tbl { overflow-x: auto; margin: 1em 0 1.2em; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95em;
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-top: 1px solid var(--rule);
}
th { font-weight: 600; border-top: 0; }
tr:last-child td { border-bottom: 1px solid var(--rule); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- colour legend swatches ---------- */

.sw {
  display: inline-block;
  width: 0.9em; height: 0.9em;
  border-radius: 2px;
  vertical-align: -0.1em;
  margin-right: 4px;
  border: 2px solid;
}
.sw-value { background: var(--value-f); border-color: var(--value); }
.sw-price { background: var(--price-f); border-color: var(--price-t); }
.sw-pass { background: var(--pass-f); border-color: var(--pass); }
.sw-fail { background: var(--fail-f); border-color: var(--fail); }
.sw-miss { background: repeating-linear-gradient(45deg, var(--miss-f), var(--miss-f) 2px, var(--miss) 2px, var(--miss) 3px); border-color: var(--miss); }
.sw-owner { background: var(--owner-f); border-color: var(--owner-t); }

/* ---------- explorable (reverse DCF) ---------- */

.explore {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 1.2em 0;
}
.explore label { display: block; font-weight: 600; margin-bottom: 6px; }
.explore input[type="range"] { width: 100%; height: 44px; }
.explore output {
  display: block;
  font-size: 1.15em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.explore .hint { font-size: 0.9em; color: var(--muted); margin: 6px 0 0; }

/* ---------- pager ---------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 2.5em 0 0;
  padding-top: 1.2em;
  border-top: 1px solid var(--rule);
}
.pager a {
  flex: 1 1 14em;
  min-height: 44px;
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.pager a:hover { background: var(--surface); }
.pager a .lab {
  display: block;
  font-size: 0.78em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.pager a.next { text-align: right; }
.pager a.short-next { flex: 1 1 100%; border-style: dashed; }
.pager .keys {
  flex: 1 1 100%;
  font-size: 0.85em;
  color: var(--muted);
}

/* ---------- index page ---------- */

.routes { display: grid; gap: 14px; grid-template-columns: minmax(0,1fr); margin: 1.2em 0; }
@media (min-width: 640px) { .routes { grid-template-columns: 1fr 1fr; } }
.route {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 16px;
}
.route h2 { margin: 0 0 0.3em; font-size: 1.1em; }
.route p { margin-bottom: 0.6em; color: var(--muted); font-size: 0.95em; }
.route a.go {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.route a.go:hover { background: var(--surface); }

.toc { list-style: none; padding: 0; margin: 0; }
.toc .part { margin: 1.6em 0 0.4em; font-size: 0.85em; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.toc li a {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr);
  gap: 0 8px;
  min-height: 44px;
  padding: 8px 8px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 4px;
}
.toc li a:hover { background: var(--surface); }
.toc .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.toc .t { font-weight: 600; }
.toc .s { grid-column: 2; color: var(--muted); font-size: 0.92em; }
.toc .m { grid-column: 2; color: var(--muted); font-size: 0.8em; }
.toc .m .short { border: 1px solid var(--rule); border-radius: 10px; padding: 0 7px; margin-left: 6px; }

#continue { margin: 1em 0; }
#continue a {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 0 14px; border: 1px solid var(--rule); border-radius: 6px;
  color: var(--ink); text-decoration: none;
}

/* ---------- sources ---------- */

.sources ol { padding-left: 1.6em; }
.sources li { margin-bottom: 0.6em; font-size: 0.95em; }
.sources a { color: var(--value-t); word-break: break-all; }
.sources .how { color: var(--muted); }

/* ---------- footer ---------- */

.foot {
  margin-top: 3em;
  font-size: 0.85em;
  color: var(--muted);
}

/* ---------- print ---------- */

@media print {
  .chapters, .top, .pager, .skip { display: none; }
  .frame { display: block; }
  main { padding: 0; }
  .article { max-width: none; margin: 0; }
  .note { float: none; margin: 0.4em 0 1em; width: auto; border-left: 3px solid var(--rule); padding-left: 10px; }
  details.fold { break-inside: avoid; }
  details.fold[open] .inner, details.fold .inner { display: block; }
}

/* Language switch (2026-10-05): English <-> Swedish, same chapter. */
.top .lang {
  color: var(--ink);
  font-size: 0.9em;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-underline-offset: 3px;
}
