/* ---------- Farver og typografi ---------- */
:root {
  --bg: #f6f4ef;
  --surface: #fbfaf7;
  --ink: #1f2124;
  --ink-soft: #55595f;
  --ink-faint: #8a8d92;
  --rule: #dcd8cf;
  --accent: #3d5a73;      /* dæmpet blågrå */
  --accent-2: #9a6b4a;    /* dæmpet brun, til den anden kurve */
  --grid: #e6e2d9;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --measure: 40rem;
  --wide: 52rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b;
    --surface: #1c1f23;
    --ink: #e4e2dd;
    --ink-soft: #a9aaa8;
    --ink-faint: #75777a;
    --rule: #2f3338;
    --accent: #8fb0c9;
    --accent-2: #cf9f7c;
    --grid: #262a2f;
  }
}
:root[data-theme="dark"] {
  --bg: #16181b;
  --surface: #1c1f23;
  --ink: #e4e2dd;
  --ink-soft: #a9aaa8;
  --ink-faint: #75777a;
  --rule: #2f3338;
  --accent: #8fb0c9;
  --accent-2: #cf9f7c;
  --grid: #262a2f;
}

* { 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(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding: 0 16px;
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--accent); }

/* ---------- Læsestatus øverst ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 10; }
.progress-bar { height: 100%; width: 0; background: var(--accent); opacity: .7; }

/* ---------- Forside ---------- */
.hero {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 18vh 0 1.75rem;
}
.kicker, .part {
  font-family: var(--sans);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1rem;
}
h1 {
  font-weight: 400;
  font-size: clamp(2.3rem, 6vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: -.01em;
  margin: 0 0 1.5rem;
}
.lede {
  font-size: 1.35rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------- Brødtekst ---------- */
.prose {
  max-width: var(--measure);
  margin: 0 auto;
}
.prose p { margin: 0 0 1.35rem; }
section[id^="del"], section.chapter {
  padding-top: 5rem;
  margin-top: 3rem;
  border-top: 1px solid var(--rule);
}
h2 {
  font-weight: 400;
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  line-height: 1.2;
  margin: 0 0 1.75rem;
}
h3 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1rem;
  margin: 0 0 .35rem;
}

/* ---------- De fire skridt ---------- */
.chain {
  max-width: var(--measure);
  margin: 1rem auto 2rem;
}
.chain ol { list-style: none; margin: 0; padding: 0; }
.chain li + li { border-top: 1px solid var(--rule); }
.chain a {
  display: flex;
  gap: 1.25rem;
  align-items: baseline;
  padding: 1rem 0;
  text-decoration: none;
}
.chain .num {
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--accent);
  min-width: 1rem;
}
.chain a:hover .step { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }

/* ---------- Interaktive figurer ---------- */
.widget {
  max-width: var(--wide);
  margin: 2.5rem auto 3rem;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: .92rem;
  line-height: 1.5;
}
.widget figcaption p { margin: 0 0 1.25rem; color: var(--ink-soft); max-width: 36rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.slider { display: flex; flex-direction: column; gap: .4rem; flex: 1 1 16rem; color: var(--ink-soft); }
.slider output { color: var(--ink); font-variant-numeric: tabular-nums; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
button {
  font: inherit;
  font-size: .85rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .45rem .8rem;
  cursor: pointer;
}
button:hover { border-color: var(--ink-faint); }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--grid); }
.chart .axis text { fill: var(--ink-faint); font-size: 11px; font-family: var(--sans); }
.chart .axis-title { fill: var(--ink-faint); font-size: 11px; font-family: var(--sans); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-lin, .chart .line-base { stroke: var(--ink-faint); }
.chart .line-exp { stroke: var(--accent); }
.chart .line-base { stroke-dasharray: 4 4; }
.chart .dot-lin, .chart .dot-base { fill: var(--ink-faint); }
.chart .dot-exp { fill: var(--accent); }
.chart .ref line { stroke: var(--accent-2); stroke-dasharray: 2 4; }
.chart .ref text { fill: var(--accent-2); font-size: 11px; font-family: var(--sans); }

.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-top: .75rem; color: var(--ink-soft); font-size: .85rem; }
.key::before {
  content: "";
  display: inline-block;
  width: 1.1rem;
  height: 0;
  border-top: 2px solid;
  vertical-align: middle;
  margin-right: .5rem;
}
.key-lin::before { border-color: var(--ink-faint); }
.key-base::before { border-color: var(--ink-faint); border-top-style: dashed; }
.key-exp::before { border-color: var(--accent); }

.readout {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
  min-height: 3em;
}
.note { margin: .75rem 0 0; font-size: .8rem; color: var(--ink-faint); }

/* ---------- Pladsholdere og kladder ---------- */
.placeholder {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--ink-faint);
}
.placeholder p { margin: 0 !important; }
.todo {
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--accent-2);
  border-left: 2px solid var(--accent-2);
  padding-left: .75rem;
}

.upcoming { margin-top: 5rem; padding-top: 3rem; border-top: 1px solid var(--rule); color: var(--ink-soft); }
.upcoming h2 { font-size: 1.3rem; }

/* ---------- Kilder ---------- */
footer {
  margin-top: 5rem !important;
  padding: 3rem 0 6rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--ink-soft);
}
footer h2 { font-family: var(--serif); font-size: 1.3rem; }
.sources { padding-left: 1.25rem; }
.sources li { margin-bottom: .4rem; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  body { font-size: 1.0625rem; }
  .widget { padding: 1.1rem; }
  .hero { padding-top: 12vh; }
}

/* ---------- Almindelig kode (første del) ---------- */
.code-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.code {
  list-style: none;
  margin: 0;
  padding: .75rem 0;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  counter-reset: line;
}
.code li {
  counter-increment: line;
  position: relative;
  padding: .45rem .9rem .45rem 2.6rem;
  border-left: 2px solid transparent;
  color: var(--ink-faint);
  transition: color .2s, background .2s;
}
.code li::before {
  content: counter(line);
  position: absolute;
  left: .9rem;
  top: .5rem;
  font-size: .75rem;
  color: var(--ink-faint);
}
.code code {
  display: block;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .82rem;
  overflow-wrap: anywhere;
}
.code .explain {
  display: block;
  font-size: .8rem;
  margin-top: .1rem;
  visibility: hidden;
}
.code li.done { color: var(--ink); }
.code li.done .explain { visibility: visible; color: var(--ink-soft); }
.code li.current { border-left-color: var(--accent); background: var(--surface); }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  min-height: 12rem;
  padding: 1rem;
  border: 1px dashed var(--rule);
  border-radius: 3px;
  text-align: center;
}
.stage-empty { margin: 0; color: var(--ink-faint); font-size: .85rem; }
.stage-msg { margin: 0; min-height: 1.5em; color: var(--ink-soft); font-size: .85rem; }
.demo-btn {
  min-width: 7rem;
  min-height: 2.6rem;
  padding: .6rem 1.4rem;
  font-size: .95rem;
  color: #222;
  background: #e9e7e2;
  border: 1px solid #bdbab3;
  border-radius: 4px;
}
.demo-btn.green { background: #3f7d4e; border-color: #336640; color: #fff; }
.demo-btn[hidden] { display: none; }
button:disabled { opacity: .45; cursor: default; }

/* ---------- Video ---------- */
.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #1b1d20;
  border-radius: 3px;
  overflow: hidden;
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-play {
  position: absolute;
  inset: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: #e4e2dd;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 1rem;
}
.video-play:hover { background: #24272b; }
.play-icon {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border: 1px solid #6b6e72;
  border-radius: 50%;
  font-size: 1.1rem;
  padding-left: .2rem;
}
.video-note { font-size: .75rem; color: #8a8d92; }

@media (max-width: 600px) {
  .code-grid { grid-template-columns: 1fr; }
  .stage { min-height: 8rem; }
}

/* ---------- Groet AI (første del) ---------- */
.weights-wrap {
  padding: .75rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.weights {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
}
.weights .w {
  --v: 0;
  padding: .3rem 0;
  border: 0;
  border-radius: 2px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--accent) calc(var(--v) * 28%), transparent);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
.weights .w:hover { color: var(--ink); outline: 1px solid var(--ink-faint); }
.weights .w.picked { outline: 2px solid var(--accent-2); color: var(--ink); }
.weights-hint { margin: .6rem 0 0; font-size: .78rem; color: var(--ink-faint); }
.grown-btn { cursor: default; white-space: pre; transition: background .15s; }
.grown-btn:hover { border-color: #bdbab3; }

/* ---------- To grafer side om side (tredje del) ---------- */
.widget.pair { max-width: 68rem; }
.pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
}
.pair-grid { grid-template-rows: repeat(5, auto); column-gap: 2.5rem; row-gap: 0; }
.pair .panel { display: grid; grid-row: span 5; grid-template-rows: subgrid; min-width: 0; }
.pair .panel .chart { align-self: end; }
.pair .panel .legend { margin-bottom: 1rem; }
.pair .panel .readout { align-self: start; }
.chart .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; cursor: pointer; }
.chart .pt.hollow { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .pt.active, .chart .pt:hover, .chart .pt:focus { stroke: var(--accent-2); stroke-width: 3; outline: none; }
.key-dot::before, .key-hollow::before {
  width: .6rem; height: .6rem; border: 0; border-radius: 50%;
  background: var(--accent); vertical-align: -1px;
}
.key-hollow::before { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }

@media (max-width: 860px) {
  .pair-grid { grid-template-columns: 1fr; gap: 3rem; }
  .pair-grid { grid-template-rows: none; }
  .pair .panel { display: block; }
  .controls-spacer { display: none; }
}
.readout:empty { display: none; }
.widget figcaption h3:last-child { margin-bottom: 1rem; }

/* ---------- Sidenavigation med de fire dele ---------- */
.rail {
  position: fixed;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  font-family: var(--sans);
  font-size: .8rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity .4s, visibility .4s;
}
.rail.visible { opacity: 1; visibility: visible; }
.rail ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; justify-content: space-between; height: min(48.75rem, 80vh); position: relative; }
.rail-track {
  position: absolute;
  left: .8125rem;             /* midt under prikkerne */
  top: .8rem;
  bottom: .8rem;
  width: 1px;
  background: var(--rule);
}
.rail-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .15s linear;
}
.rail a {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: var(--ink-faint);
}
.rail-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--bg);
  font-size: .72rem;
  transition: background .3s, color .3s, border-color .3s;
}
.rail-label { white-space: nowrap; transition: color .3s; }
.rail li.passed .rail-dot { border-color: var(--accent); color: var(--accent); }
.rail li.active .rail-dot { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.rail li.active .rail-label { color: var(--ink); }
.rail a:hover .rail-label, .rail a:hover .rail-dot { color: var(--ink); }
.rail li.active a:hover .rail-dot { color: var(--bg); }

/* Plads til sidenavigationen: den brede graf-figur gøres lidt smallere */
.widget.pair { max-width: min(68rem, calc(100vw - 30rem)); }

/* Mellemstore skærme: kun prikkerne; titlen vises, når man holder musen over */
@media (max-width: 1320px) {
  .rail { left: 1rem; }
  .rail-label {
    position: absolute;
    left: 2.4rem;
    padding: .2rem .5rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 3px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .rail a:hover .rail-label, .rail a:focus-visible .rail-label { opacity: 1; }
  .widget.pair { max-width: min(68rem, calc(100vw - 8rem)); }
}

/* Små skærme: ingen sidenavigation, kun læsebjælken øverst */
@media (max-width: 960px) {
  .rail { display: none; }
  .widget.pair { max-width: 68rem; }
}
@media (min-width: 961px) {
  .progress { display: none; }
}
.upcoming { padding-bottom: 6rem; }
.caveat { color: var(--ink-soft); font-style: italic; }

/* ---------- Kritik ---------- */
.critiques { list-style: none; counter-reset: crit; margin: 2rem 0 0; padding: 0; }
.critiques li {
  counter-increment: crit;
  position: relative;
  padding: 1.5rem 0 .25rem 2.75rem;
  border-top: 1px solid var(--rule);
}
.critiques li::before {
  content: counter(crit);
  position: absolute;
  left: 0;
  top: 1.65rem;
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--accent);
}
.critiques h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.2rem;
  margin: 0 0 .5rem;
}

/* ---------- FAQ ---------- */
.faq { margin-top: 1rem; border-bottom: 1px solid var(--rule); }
.faq details { border-top: 1px solid var(--rule); }
.faq summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1.1rem 0;
  font-size: 1.2rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-family: var(--sans);
  color: var(--accent);
  transition: transform .2s;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq summary:hover { color: var(--accent); }
.faq summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.faq details p { margin: 0 0 1.35rem; color: var(--ink-soft); }
.subhead {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5rem;
  margin: 3rem 0 1.25rem;
}
main { padding-bottom: 8rem; }
.byline { font-family: var(--sans); font-size: .9rem; color: var(--ink-soft); margin: -.5rem 0 1.75rem; }

/* ---------- Sprogskifter ---------- */
body[data-lang="da"] [data-t="en"] { display: none !important; }
body[data-lang="en"] [data-t="da"] { display: none !important; }

.langswitch {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  display: flex;
  gap: .25rem;
  padding: .9rem 1.25rem;
  font-family: var(--sans);
}
.langswitch button {
  border: 0;
  background: transparent;
  padding: .3rem .45rem;
  font-size: .82rem;
  color: var(--ink-faint);
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.langswitch button:hover { color: var(--ink); }
.langswitch button[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.code-col { min-width: 0; }

@media (max-width: 600px) {
  .langswitch { padding: .5rem .5rem; }
}
#faq details { scroll-margin-top: 4rem; }
