/* Lernlandschaft Tutorial – "Schulheft"-Look: Karopapier, Königsblau, Rotstift, Textmarker */
:root {
  --paper: #fbfcfd;
  --grid: #dce6f2;
  --ink: #1d3b9a;
  --ink-soft: #4a62b3;
  --graphite: #23262e;
  --muted: #5b6170;
  --rule: #e3e7ee;
  --red: #c4302b;
  --marker: #ffe94a;
  --code-bg: #f1f4f9;
  --focus: #1d3b9a;

  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Typo-Skala 1.25 */
  --t-sm: 0.875rem;
  --t-base: 1.0625rem;
  --t-lg: 1.25rem;
  --t-xl: 1.5625rem;
  --t-2xl: 2.4rem;

  --rail: 19rem;
  --sq: 20px; /* Kästchengröße */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14171d;
    --grid: #222937;
    --ink: #9db3ff;
    --ink-soft: #7f95e0;
    --graphite: #e4e7ee;
    --muted: #a3a9b6;
    --rule: #2a303c;
    --red: #ff7a72;
    --marker: #6b5d00;
    --code-bg: #1c2029;
    --focus: #9db3ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14171d; --grid: #222937; --ink: #9db3ff; --ink-soft: #7f95e0; --graphite: #e4e7ee;
  --muted: #a3a9b6; --rule: #2a303c; --red: #ff7a72; --marker: #6b5d00; --code-bg: #1c2029; --focus: #9db3ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--graphite);
  font: 400 var(--t-base)/1.6 var(--font);
}
a { color: var(--ink); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
button { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--rule);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--sq) var(--sq);
  padding: calc(var(--sq) * 1.5) var(--sq) var(--sq);
  display: flex; flex-direction: column; gap: var(--sq);
}
.brand { display: block; text-decoration: none; color: var(--graphite); background: var(--paper); padding: 4px 6px; margin: -4px -6px; width: fit-content; }
.brand strong { display: block; font-size: var(--t-lg); line-height: 1.2; letter-spacing: -0.01em; }
.brand span { font-size: var(--t-sm); color: var(--muted); }

/* ---------- Der Lernpfad ---------- */
.path { list-style: none; margin: 0; padding: 0; position: relative; }
.path-level { margin: 0; padding: 0; list-style: none; }
.path-level + .path-level { margin-top: 6px; }
.level-name {
  display: inline-block; font-size: var(--t-sm); color: var(--muted); background: var(--paper);
  padding: 0 6px; margin: 10px 0 4px 26px;
}
.station { position: relative; }
.station a {
  display: grid; grid-template-columns: 26px 1fr; align-items: start; gap: 8px;
  padding: 5px 6px 5px 0; text-decoration: none; color: var(--graphite); line-height: 1.35;
  font-size: 0.95rem;
}
/* Tintenlinie zwischen den Stationen */
.station::before {
  content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 2px;
  background: var(--ink); opacity: 0.85;
}
.path-level:first-child .station:first-child::before { top: 14px; }
.path-level:last-child .station:last-child::before { bottom: calc(100% - 14px); }
.node {
  position: relative; z-index: 1; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  font: 700 0.72rem/1 var(--mono);
}
.station.done .node { background: var(--ink); color: var(--paper); }
.station-title { background: var(--paper); padding: 1px 4px; border-radius: 2px; margin-top: 2px; }
.station.current .station-title {
  background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%);
  font-weight: 700;
}
.station a:hover .station-title { text-decoration: underline; text-underline-offset: 0.2em; }

.progress { font-size: var(--t-sm); color: var(--muted); background: var(--paper); width: fit-content; padding: 0 4px; margin-left: -4px; }

.tools { margin-top: auto; background: var(--paper); border: 1px solid var(--rule); padding: 12px 14px; }
.tools h2 { font-size: var(--t-sm); margin: 0 0 6px; color: var(--muted); font-weight: 400; }
.tools ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tools a { font-size: 0.95rem; }
/* Container-Zustand in der Seitenleiste */
.stack-h { margin-top: 14px !important; }
.stack { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: var(--t-sm); }
.stack li { display: grid; grid-template-columns: 10px auto 1fr; gap: 8px; align-items: center; }
.stack li i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--muted); }
.stack li.ok i { background: var(--ink); border-color: var(--ink); }
.stack li.warn i { background: var(--marker); border-color: var(--graphite); }
.stack li.down i { background: var(--red); border-color: var(--red); }
.stack .svc { font-family: var(--mono); font-size: 0.8rem; }
.stack .st { color: var(--muted); text-align: right; }
.stack.offline li { grid-template-columns: 10px 1fr; }
.stack.offline .st { text-align: left; }
.stack .ports { font-family: var(--mono); font-size: 0.75rem; }

.api-status { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); margin-top: 8px; color: var(--muted); }
.api-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.api-status.ok i { background: var(--ink); }
.api-status.down i { background: var(--red); }
.rail-foot { display: flex; gap: 8px; align-items: center; background: var(--paper); font-size: var(--t-sm); color: var(--muted); width: fit-content; padding: 2px 4px; }
.rail-foot { flex-wrap: wrap; }
.rail-foot select { font: inherit; color: inherit; background: var(--paper); border: 1px solid var(--rule); padding: 2px 4px; }

/* ---------- Inhalt ---------- */
main:focus { outline: none; }
main { padding: 56px clamp(16px, 5vw, 72px) 96px; min-width: 0; }
.page { max-width: 72ch; }
.context { color: var(--muted); font-size: var(--t-sm); margin: 0 0 6px; }
.page h1 {
  font-size: var(--t-2xl); line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 12px; font-weight: 800;
  text-wrap: balance;
}
.meta code { font: 0.85rem var(--mono); background: var(--code-bg); padding: 0.05em 0.35em; border-radius: 3px; color: var(--graphite); }
.claude-chip { display: inline-flex; align-items: center; gap: 6px; }
.meta .chip-copy { position: static; padding: 0 6px; font-size: 0.78rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; color: var(--muted); font-size: var(--t-sm); margin: 0 0 36px; }
.page h2 { font-size: var(--t-xl); line-height: 1.25; margin: 2.4em 0 0.5em; letter-spacing: -0.01em; }
.page h3 { font-size: var(--t-lg); margin: 1.8em 0 0.4em; }
.page p, .page ul, .page ol { margin: 0 0 1em; }
.page li { margin: 0.25em 0; }
.page li > ul, .page li > ol { margin: 0.25em 0 0; }
.page hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }
.page blockquote { margin: 1.2em 0; padding: 0 0 0 16px; border-left: 3px solid var(--ink-soft); color: var(--muted); }
.page strong { font-weight: 700; }
.page img { max-width: 100%; }
.page code { font: 0.92em/1.4 var(--mono); background: var(--code-bg); padding: 0.08em 0.3em; border-radius: 3px; }
.page kbd { font: 0.85em var(--mono); border: 1px solid var(--rule); border-bottom-width: 2px; padding: 0 0.35em; border-radius: 3px; }

.table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.page table { border-collapse: collapse; font-size: 0.95rem; min-width: 100%; }
.page th, .page td { text-align: left; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.page th { font-weight: 700; }

/* Codeblöcke */
.code { position: relative; margin: 0 0 1.2em; }
.code pre {
  margin: 0; overflow-x: auto; background: var(--code-bg); padding: 14px 16px; border-radius: 4px;
  font: 0.88rem/1.55 var(--mono); tab-size: 2;
}
.code pre code { background: none; padding: 0; font: inherit; }
.copy {
  position: absolute; top: 6px; right: 6px; font-size: var(--t-sm); background: var(--paper); border: 1px solid var(--rule);
  border-radius: 3px; padding: 2px 8px; cursor: pointer; color: var(--muted);
}
.copy:hover { color: var(--ink); border-color: var(--ink-soft); }

/* Diagramme (inline SVG, Farben über die Seiten-Variablen) */
.diagram { margin: 1.6em 0 2em; }
.diagram-svg {
  overflow-x: auto; padding: 18px 16px; border: 1px solid var(--rule); border-radius: 4px;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--sq) var(--sq); background-position: -1px -1px;
}
.diagram svg { display: block; width: 100%; min-width: 600px; height: auto; }
.diagram figcaption { margin-top: 8px; font-size: var(--t-sm); color: var(--muted); max-width: 64ch; }
.dg text { font-family: var(--font); fill: var(--graphite); font-size: 13px; }
.dg .dg-title { font-size: 14.5px; font-weight: 800; }
.dg .dg-name { font-weight: 700; }
.dg .dg-sub { fill: var(--muted); font-size: 11.5px; }
.dg .dg-small { font-size: 12px; }
.dg .dg-mono, .dg .dg-field { font-family: var(--mono); font-size: 11.5px; }
.dg .dg-mono { fill: var(--muted); }
.dg .dg-field { font-size: 12px; }
.dg .dg-pk { font-weight: 700; }
.dg .dg-fk, .dg .dg-ink { fill: var(--ink); }
.dg .dg-red { fill: var(--red); font-weight: 700; }
.dg .dg-card { fill: var(--ink); font-family: var(--mono); font-size: 12px; font-weight: 700; }
.dg .dg-box { fill: var(--paper); stroke: var(--graphite); stroke-width: 1.25; }
.dg .dg-key { stroke: var(--ink); stroke-width: 2; }
.dg .dg-marker { fill: var(--marker); }
.dg .dg-zone { fill: none; stroke: var(--muted); stroke-width: 1.25; }
.dg .dg-rule { stroke: var(--rule); stroke-width: 1.25; }
.dg .dg-line { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.dg .dg-flow { fill: none; stroke: var(--ink); stroke-width: 2; }
.dg .dg-dashed { stroke-dasharray: 6 4; }
.dg .dg-port { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.dg .dg-port-label { font-size: 10.5px; font-weight: 700; }
.dg .dg-big { font-size: 15px; font-weight: 800; }
.dg .dg-warnbox { fill: var(--paper); stroke: var(--red); stroke-width: 1.5; }
.dg .dg-panel { fill: var(--code-bg); stroke: none; }
.dg .dg-bar { fill: var(--ink); }
.dg .dg-bar-soft { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 3; }
.dg .dg-axis { stroke: var(--muted); stroke-width: 1.25; fill: none; }
.dg .dg-sketch { fill: none; stroke: var(--muted); stroke-width: 1.25; }
.dg .dg-flow-red { fill: none; stroke: var(--red); stroke-width: 2; }
.dg .dg-head-red { fill: var(--red); }
.dg .dg-head { fill: var(--ink); }
.dg .dg-head-mut { fill: var(--muted); }

/* Aktions-Karte: ein Befehl, den der Runner ausführt */
.action { margin: 0 0 1.6em; }
.action-card { border: 1px solid var(--rule); border-left: 4px solid var(--ink); border-radius: 4px; background: var(--paper); padding: 14px 16px; }
.action-head h3 { margin: 0; font-size: 1.05rem; }
.action-head p { margin: 2px 0 10px; color: var(--muted); font-size: var(--t-sm); }
.action-params { display: flex; flex-wrap: wrap; gap: 10px 14px; margin: 0 0 12px; }
.action-params .field { display: grid; gap: 2px; font-size: var(--t-sm); flex: 0 1 9rem; }
.action-params .field.narrow { flex-basis: 7rem; }
.action-params .field.wide { flex: 1 1 18rem; }
.action-params label { color: var(--muted); }
.action-params input, .action-params select {
  font: 0.9rem var(--mono); padding: 5px 8px; border: 1px solid var(--muted); border-radius: 3px;
  background: var(--paper); color: var(--graphite); min-width: 0; width: 100%;
}
.action-cmd { display: flex; gap: 10px; align-items: flex-start; background: var(--code-bg); border-radius: 3px; padding: 8px 10px; }
.action-cmd code { flex: 1; font: 0.82rem/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; background: none; padding: 0; }
.action-cmd code::before { content: "$ "; color: var(--muted); }
.action-cmd .copy { position: static; flex: none; }
.action-bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 12px; }
.action-bar .btn { padding: 6px 14px; }
.action-state { font-size: var(--t-sm); color: var(--muted); }
.action-state.ok { color: var(--ink); font-weight: 700; }
.action-state.fail, .action-state.warn { color: var(--red); font-weight: 700; }
.action-out {
  margin: 12px 0 0; max-height: 22rem; overflow: auto; padding: 12px 14px; border-radius: 3px;
  background: var(--graphite); color: var(--paper); font: 0.78rem/1.5 var(--mono); white-space: pre-wrap; word-break: break-word;
}
.action-card.offline p { margin: 0 0 8px; }
.action-cmd-plain { margin: 0; font: 0.85rem var(--mono); background: var(--code-bg); padding: 8px 10px; border-radius: 3px; }

/* Prompt-Karte: das, was man Claude Code sagt */
.prompt {
  margin: 0 0 1.4em; border: 1.5px solid var(--ink); border-radius: 4px; background: var(--paper);
}
.prompt header {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--rule); color: var(--ink); font-size: var(--t-sm); font-weight: 700;
}
.prompt header .copy { position: static; }
.prompt blockquote { all: unset; display: block; padding: 12px 14px; white-space: pre-wrap; font-size: 1rem; line-height: 1.55; }

/* Hinweise (aufklappbar) und Infokästen */
details.tip { border-left: 3px solid var(--marker); padding: 2px 0 2px 14px; margin: 0 0 1.2em; }
details.tip summary { cursor: pointer; font-weight: 700; }
details.tip[open] summary { margin-bottom: 8px; }
.note { border-left: 3px solid var(--ink-soft); padding: 2px 0 2px 14px; margin: 0 0 1.2em; }
.note.warn { border-left-color: var(--red); }
.note > :last-child, details.tip > :last-child { margin-bottom: 0; }

/* ---------- Prüfen ---------- */
.check {
  margin-top: 3em; padding: 20px 22px; border: 1px solid var(--rule); border-radius: 4px;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--sq) var(--sq); background-position: -1px -1px;
}
.check > * { background: var(--paper); }
.check h2 { margin: 0 0 4px; font-size: var(--t-lg); width: fit-content; padding: 0 4px; margin-left: -4px; }
.check-intro { margin: 0 0 14px; color: var(--muted); font-size: var(--t-sm); width: fit-content; }
.check ul { list-style: none; margin: 0 0 16px; padding: 8px 12px; display: grid; gap: 8px; border-radius: 3px; }
.check li { display: grid; grid-template-columns: 24px 1fr; gap: 6px; align-items: start; }
.check li .mark { font: 700 1.05rem/1.4 var(--font); color: var(--muted); text-align: center; }
.check li.pass .mark { color: var(--ink); }
.check li.fail .mark { color: var(--red); }
.check li .msg { display: block; font-size: var(--t-sm); color: var(--muted); }
.check li.fail .msg { color: var(--red); }
.check label { cursor: pointer; }
.check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ink); margin: 3px 0 0; }
.check input[type="text"] {
  font: inherit; width: 100%; max-width: 22rem; margin-top: 4px; padding: 4px 8px;
  border: 1px solid var(--muted); border-radius: 3px; background: var(--paper); color: var(--graphite);
}
.check-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; width: fit-content; padding: 4px; margin: -4px; }
.btn {
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 4px;
  font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn.quiet { background: var(--paper); color: var(--ink); }
.done-banner { font-weight: 700; color: var(--ink); }

/* Vor/Zurück */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--rule); }
.pager a { display: grid; text-decoration: none; max-width: 48%; }
.pager a span { color: var(--muted); font-size: var(--t-sm); }
.pager a strong { color: var(--ink); }
.pager a:hover strong { text-decoration: underline; }
.pager .next { text-align: right; margin-left: auto; }

.lang-note { font-size: var(--t-sm); color: var(--muted); border-left: 3px solid var(--rule); padding-left: 12px; margin-bottom: 24px; }
.error-state { color: var(--red); }

/* ---------- Mobil ---------- */
.rail-toggle { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); padding: 16px; }
  .rail-toggle {
    display: inline-block; background: var(--paper); border: 1px solid var(--ink); color: var(--ink);
    border-radius: 4px; padding: 4px 10px; font-weight: 700; cursor: pointer; width: fit-content;
  }
  .rail:not(.open) .path, .rail:not(.open) .tools, .rail:not(.open) .rail-foot { display: none; }
  main { padding-top: 32px; }
  .page h1 { font-size: 1.95rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .station.current .station-title { animation: mark 600ms ease-out both; background-size: 100% 100%; }
  @keyframes mark { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }
  .station-title { background-repeat: no-repeat; }
}

/* Hell/Dunkel-Schalter */
.rail-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.theme-switch { flex: none; background: none; border: 0; padding: 2px; cursor: pointer; border-radius: 13px; }
.ts-track {
  display: block; width: 44px; height: 24px; border-radius: 12px; position: relative;
  background: var(--paper); border: 1.5px solid var(--ink);
}
.ts-knob {
  position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--ink); display: grid; place-items: center; transition: transform 160ms ease;
}
.ts-knob svg { width: 12px; height: 12px; fill: none; stroke: var(--paper); stroke-width: 2.2; stroke-linecap: round; }
.ts-moon { display: none; fill: var(--paper) !important; stroke: none !important; }
.theme-switch[aria-checked="true"] .ts-knob { transform: translateX(20px); }
.theme-switch[aria-checked="true"] .ts-sun { display: none; }
.theme-switch[aria-checked="true"] .ts-moon { display: block; }
@media (prefers-reduced-motion: reduce) { .ts-knob { transition: none; } }
