/* Simson S51 – Motor M 541 zusammenbauen
   Richtung: Werkstatthandbuch mit Explosionszeichnung. Tokens siehe DESIGN.md. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("../fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --papier: #f6f6f2;
  --papier-tief: #e9eae4;
  --tusche: #1f2326;
  --grau: #59616a;
  --linie: #cfd3cb;
  --signalrot: #b3261e;
  --signalrot-hell: #f8e7e5;
  --billard: #2f6b57;
  --billard-hell: #e4efea;
  --werkbank-hell: #c5cec6;
  --werkbank: #9da99f;
  --werkbank-tief: #76837a;

  --schrift: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --schrift-schmal: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;

  --r-klein: 3px;
  --r: 6px;
  --abstand: 1rem;
  --leiste-h: 4.25rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--schrift);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--tusche);
  background: var(--papier);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-family: var(--schrift-schmal); font-weight: 600; line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: var(--billard); text-underline-offset: 0.15em; }
a:hover { color: var(--tusche); }

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

.skip {
  position: absolute; left: 0.5rem; top: -3rem; z-index: 50;
  background: var(--tusche); color: var(--papier); padding: 0.5rem 0.9rem; border-radius: var(--r-klein);
}
.skip:focus { top: 0.5rem; }

/* ---------- Kopf ---------- */
.kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: var(--tusche); color: var(--papier);
}
.marke h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: 0.01em; }
.marke p { color: #c9cec9; font-size: 0.95rem; }
.kopf-nav { display: flex; gap: 0.5rem; flex-shrink: 0; }
.kopf .knopf { background: transparent; color: var(--papier); border-color: rgba(246, 246, 242, 0.45); }
.kopf .knopf:hover { background: rgba(246, 246, 242, 0.12); }

/* ---------- Knöpfe ---------- */
.knopf {
  font: 500 0.95rem/1.2 var(--schrift);
  color: var(--tusche);
  background: var(--papier);
  border: 1px solid rgba(31, 35, 38, 0.28);
  border-radius: var(--r-klein);
  padding: 0.55rem 0.9rem;
  min-height: 2.6rem;
  cursor: pointer;
}
.knopf:hover { background: var(--papier-tief); }
.knopf:disabled { opacity: 0.4; cursor: default; }
.knopf[aria-pressed="true"] { background: var(--tusche); color: var(--papier); border-color: var(--tusche); }
.knopf-klein { font-size: 0.875rem; padding: 0.4rem 0.7rem; min-height: 2.25rem; }
.knopf-haupt { background: var(--billard); border-color: var(--billard); color: #fff; }
.knopf-haupt:hover { background: #255646; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(22rem, 34rem);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "buehne schritt" "steuerung schritt";
  flex: 1;
  min-height: 0;
}
@media (min-width: 901px) {
  body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Bühne ---------- */
.buehne {
  grid-area: buehne;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 85% at 50% 30%, var(--werkbank-hell) 0%, var(--werkbank) 58%, var(--werkbank-tief) 100%);
}
.leinwand { position: absolute; inset: 0; }
.leinwand canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.labels { position: absolute; inset: 0; pointer-events: none; }

.buehne-leiste {
  position: absolute; top: 0.75rem; left: 0.75rem; right: 0.75rem;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  pointer-events: none;
}
.buehne-leiste .knopf { pointer-events: auto; background: rgba(246, 246, 242, 0.92); }
.buehne-leiste .knopf[aria-pressed="true"] { background: var(--tusche); }
.buehne-hilfe {
  position: absolute; left: 0.9rem; bottom: 0.6rem;
  font-size: 0.85rem; color: #24302a;
  pointer-events: none;
}
.buehne-status {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--schrift-schmal); font-size: 1.25rem; color: #24302a;
  background: rgba(246, 246, 242, 0.85); padding: 0.5rem 1rem; border-radius: var(--r-klein);
  max-width: 90%; text-align: center;
}
.buehne-status:empty { display: none; }

/* Positionsnummern wie in der Explosionszeichnung */
.callout { position: absolute; width: 0; height: 0; }
.callout::before {
  content: ""; position: absolute; left: 0; top: 0;
  width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px;
  border-radius: 50%; background: var(--tusche); box-shadow: 0 0 0 2px rgba(246, 246, 242, 0.9);
}
.callout::after {
  content: ""; position: absolute; left: 0; top: 0;
  width: 34px; height: 1.5px; background: var(--tusche);
  transform-origin: 0 50%; transform: rotate(-40deg);
}
.callout-text {
  position: absolute; left: 25px; bottom: 21px;
  display: flex; align-items: center; gap: 0.35rem;
  white-space: nowrap;
  font: 500 0.82rem/1 var(--schrift);
  color: var(--tusche);
  background: rgba(246, 246, 242, 0.94);
  border: 1px solid var(--tusche);
  border-radius: var(--r-klein);
  padding: 0.22rem 0.45rem 0.22rem 0.22rem;
}
.callout-nr {
  display: inline-grid; place-items: center;
  width: 1.3rem; height: 1.3rem; border-radius: 50%;
  background: var(--signalrot); color: #fff;
  font: 700 0.8rem/1 var(--schrift-schmal);
}
.callout.ist-fokus .callout-nr { background: var(--billard); }
.callout.nach-links::after { transform: rotate(-140deg); }
.callout.nach-links .callout-text { left: auto; right: 25px; }

/* ---------- Steuerleiste ---------- */
.steuerung {
  grid-area: steuerung;
  display: flex; align-items: center; gap: 0.75rem;
  min-height: var(--leiste-h);
  padding: 0.6rem 0.9rem;
  background: var(--papier);
  border-top: 1px solid var(--linie);
}
.knopf-nav { min-width: 6.5rem; }
.zeitleiste {
  flex: 1; display: flex; align-items: stretch; gap: 2px;
  list-style: none; margin: 0; padding: 0; height: 2.25rem;
}
.zeitleiste li { flex: 1; display: flex; }
.zeitleiste li.phasenstart { margin-left: 6px; }
.zeitleiste li:first-child { margin-left: 0; }
.zeitleiste button {
  flex: 1; border: 0; padding: 0; cursor: pointer;
  background: var(--linie); border-radius: 1px;
  position: relative;
}
.zeitleiste button::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; }
.zeitleiste li.erledigt button { background: #7d8a81; }
.zeitleiste li.aktuell button { background: var(--signalrot); }
.zeitleiste button:hover { background: var(--tusche); }
.zaehler { display: none; font-family: var(--schrift-schmal); font-weight: 600; font-size: 1.1rem; white-space: nowrap; }

/* ---------- Schritt-Text ---------- */
.schritt {
  grid-area: schritt;
  overflow-y: auto;
  padding: 1.6rem 2rem 3rem;
  border-left: 1px solid var(--linie);
  background: var(--papier);
  outline: none;
}
.schritt-kopf { display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; align-items: end; margin-bottom: 0.9rem; }
.schritt-nr { font: 700 3.6rem/0.85 var(--schrift-schmal); color: var(--signalrot); }
.schritt-meta { padding-bottom: 0.2rem; }
.schritt-von { font-size: 0.95rem; color: var(--grau); }
.schritt-phase { font: 600 1.05rem/1.2 var(--schrift-schmal); color: var(--billard); }
.schritt h2 { font-size: 2.05rem; font-weight: 700; margin-bottom: 0.5rem; text-wrap: balance; }
.schritt-kurz { font-size: 1.125rem; color: #3b4248; max-width: 62ch; }

.block { margin-top: 1.5rem; }
.block h3 { font-size: 1.2rem; padding-top: 0.6rem; border-top: 2px solid var(--tusche); margin-bottom: 0.55rem; }

.arbeit { list-style: none; counter-reset: arbeit; margin: 0; padding: 0; }
.arbeit li { counter-increment: arbeit; position: relative; padding: 0.4rem 0 0.4rem 2.3rem; border-bottom: 1px solid var(--linie); }
.arbeit li:last-child { border-bottom: 0; }
.arbeit li::before {
  content: counter(arbeit); position: absolute; left: 0; top: 0.42rem;
  width: 1.55rem; height: 1.55rem; border-radius: 50%;
  border: 1.5px solid var(--tusche);
  display: grid; place-items: center;
  font: 600 0.9rem/1 var(--schrift-schmal);
}

.liste { margin: 0; padding-left: 1.1rem; }
.liste li { padding: 0.12rem 0; }
.liste li::marker { color: var(--grau); }
.zwei-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }

.werte { width: 100%; border-collapse: collapse; table-layout: fixed; }
.werte th, .werte td { overflow-wrap: anywhere; hyphens: auto; }
.werte th, .werte td { text-align: left; vertical-align: top; padding: 0.45rem 0.5rem 0.45rem 0; border-bottom: 1px solid var(--linie); }
.werte th { font-weight: 400; color: #3b4248; width: 52%; }
.werte td { font-weight: 600; }
.werte .wert-notiz { display: block; font-weight: 400; font-size: 0.875rem; color: var(--grau); margin-top: 0.15rem; }
.quelle-link { font-weight: 500; font-size: 0.8rem; vertical-align: super; margin-left: 0.2rem; text-decoration: none; }
.quelle-link:hover { text-decoration: underline; }
.unbelegt {
  display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.35rem;
  font-size: 0.75rem; font-weight: 600; line-height: 1.3; vertical-align: 0.1em;
  color: var(--signalrot); border: 1px solid var(--signalrot); border-radius: var(--r-klein);
}

.kasten { margin-top: 1.5rem; padding: 0.8rem 1rem 0.9rem; border-left: 4px solid; border-radius: 0 var(--r-klein) var(--r-klein) 0; }
.kasten h3 { font-size: 1.1rem; margin-bottom: 0.35rem; }
.kasten ul { margin: 0; padding-left: 1.1rem; }
.kasten li { padding: 0.12rem 0; }
.kasten-warnung { border-color: var(--signalrot); background: var(--signalrot-hell); }
.kasten-warnung h3 { color: var(--signalrot); }
.kasten-tipp { border-color: var(--billard); background: var(--billard-hell); }
.kasten-tipp h3 { color: var(--billard); }

.schritt-fuss { margin-top: 2rem; display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; color: var(--grau); }
.schritt-fuss button { font: inherit; color: var(--billard); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 0.15em; }

/* ---------- Dialoge ---------- */
.fenster {
  width: min(44rem, calc(100vw - 2rem));
  max-height: min(85vh, 52rem);
  padding: 0; border: 0; border-radius: var(--r);
  background: var(--papier); color: var(--tusche);
  box-shadow: 0 18px 50px rgba(15, 20, 18, 0.35);
}
.fenster::backdrop { background: rgba(23, 29, 26, 0.55); }
.fenster[open] { display: flex; flex-direction: column; }
.fenster-kopf { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem 0.75rem; border-bottom: 2px solid var(--tusche); }
.fenster-kopf h2 { font-size: 1.6rem; }
.fenster-inhalt { overflow-y: auto; padding: 0.75rem 1.25rem 1.5rem; overflow-wrap: anywhere; }
.phase-titel { font-size: 1.15rem; color: var(--billard); margin: 1.1rem 0 0.3rem; }
.phase-titel:first-child { margin-top: 0.3rem; }
.schrittliste { list-style: none; margin: 0; padding: 0; }
.schrittliste a {
  display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.5rem; align-items: baseline;
  padding: 0.4rem 0.3rem; color: var(--tusche); text-decoration: none; border-bottom: 1px solid var(--linie);
}
.schrittliste a:hover { background: var(--papier-tief); }
.schrittliste .nr { font: 700 1.1rem/1 var(--schrift-schmal); color: var(--grau); text-align: right; }
.schrittliste a[aria-current="step"] .nr { color: var(--signalrot); }
.schrittliste a[aria-current="step"] { font-weight: 600; }
.hinweis-text { color: #3b4248; margin: 0.5rem 0 1rem; max-width: 70ch; }
.quellen { padding-left: 1.6rem; margin: 0 0 1rem; }
.quellen li { padding: 0.45rem 0; border-bottom: 1px solid var(--linie); }
.quellen li:target { background: var(--billard-hell); }
.quellen .q-titel { font-weight: 600; }
.quellen .q-notiz { display: block; font-size: 0.9rem; color: var(--grau); }
.quellen a { word-break: break-word; }

.noscript { padding: 2rem; font-size: 1.2rem; }
.txt-kurz { display: none; }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 900px) {
  :root { --leiste-h: 3.9rem; }
  body { font-size: 1rem; }
  .kopf { padding: 0.55rem 0.9rem; }
  .marke h1 { font-size: 1.3rem; }
  .marke p { font-size: 0.85rem; }
  .kopf-nav .knopf { padding: 0.45rem 0.6rem; font-size: 0.875rem; min-height: 2.4rem; }
  .layout { display: block; height: auto; }
  .buehne { position: sticky; top: 0; z-index: 3; height: 44svh; min-height: 15rem; border-bottom: 1px solid var(--werkbank-tief); }
  .marke .breit { display: none; }
  .txt-lang { display: none; }
  .txt-kurz { display: inline; }
  .buehne-leiste { top: auto; bottom: 0.45rem; left: 0; right: 0; padding: 0 0.5rem; gap: 0.3rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; pointer-events: auto; }
  .buehne-leiste::-webkit-scrollbar { display: none; }
  .buehne-leiste .knopf { font-size: 0.8rem; padding: 0.3rem 0.55rem; min-height: 2.2rem; white-space: nowrap; flex: 0 0 auto; }
  .buehne-hilfe { display: none; }
  .schritt { border-left: 0; padding: 1.2rem 1.1rem calc(var(--leiste-h) + 2rem); overflow: visible; }
  .schritt-nr { font-size: 2.9rem; }
  .schritt h2 { font-size: 1.7rem; }
  .zwei-spalten { grid-template-columns: 1fr; }
  .steuerung {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 18px rgba(15, 20, 18, 0.12);
  }
  .zeitleiste { position: absolute; left: 0; right: 0; top: 0; height: 4px; gap: 1px; }
  .zeitleiste li.phasenstart { margin-left: 0; }
  .zeitleiste button { border-radius: 0; pointer-events: none; }
  .zaehler { display: block; flex: 1; text-align: center; }
  .knopf-nav { min-width: 0; flex: 0 0 auto; padding-left: 1.1rem; padding-right: 1.1rem; }
  .callout-text { font-size: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
