/*
 * Stil des Handbuchs.
 *
 * Aufbau und Werkzeug stammen aus dem Handbuch von calhelp/myLucara, die
 * Farben aus eVorgang (packages/evorgang-ui/app/assets/css/evorgang.css):
 * Nachtblau im dunklen Thema, kuehles Weiss im hellen, Blau als Akzent. Sie
 * stehen hier als Kopie und nicht als Import, weil GitHub Pages nur docs/
 * ausliefert -- ein Verweis in die Layer waere ein toter Link. Wandert die
 * Palette dort, wandert diese Datei mit. Die Kontraste an den Werten sind
 * dieselben, die frontend/tests/design-tokens.spec.ts dort misst; sie halten
 * WCAG 2.2 AA (4,5:1 fuer Text) mit Abstand.
 *
 * Zwei Themen, eine Datei, keine Umschalter: das Handbuch folgt der
 * Einstellung des Geraets. Ein Knopf, der nach jedem Seitenwechsel wieder
 * auf Anfang steht, ist schlechter als keiner.
 *
 * Ueberschriften stehen in derselben serifenlosen Schrift wie der Text: die
 * App ist ein Arbeitsplatz, kein Magazin.
 */

:root {
  color-scheme: dark;

  --bg: #04070d;
  --bg-deep: #020409;
  --surface: #0a111b;
  --surface-raised: #131c28;

  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);

  --text: #e3e9f1;            /* 14.04:1 gegen die gehobene Flaeche */
  --text-soft: #b4bfcc;       /* 9.20:1 */
  --text-muted: #8d99a8;      /* 5.92:1 */

  --accent: #5b9be8;          /* Blau, 6.58:1 gegen die Karte */
  --accent-rgb: 91, 155, 232;
  --accent-ink: #06101e;
  --focus: #9cc4f5;

  --tone-info: #9fb4dd;
  --tone-good: #98c5a0;
  --tone-care: #e5b28a;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: var(--font-sans);
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius-s: 6px;
  --radius-m: 8px;
  --radius-l: 12px;
  --radius-pill: 999px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;

    --bg: #eef2f7;
    --bg-deep: #e3e9f1;
    --surface: #ffffff;
    --surface-raised: #e8edf4;

    --line: rgba(0, 0, 0, 0.1);
    --line-strong: rgba(0, 0, 0, 0.22);

    --text: #1b2838;          /* 12.69:1 gegen die gehobene Flaeche */
    --text-soft: #42526a;     /* 6.74:1 */
    --text-muted: #56667c;    /* 4.98:1 */

    --accent: #1f5fae;        /* Blau, 6.35:1 gegen die Karte */
    --accent-rgb: 31, 95, 174;
    --accent-ink: #ffffff;
    --focus: #1f5fae;

    --tone-info: #55688f;
    --tone-good: #3f6b49;
    --tone-care: #8a5326;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- Kopf */

.h-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.75rem 1rem;
  border-radius: 0 0 var(--radius-s) 0;
  z-index: 20;
}

.h-skip:focus { left: 0; }

.h-top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.h-top__inner {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
}

.h-mark {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.h-mark span { color: var(--accent); }

.h-top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.9375rem;
}

.h-top nav a {
  color: var(--text-soft);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.h-top nav a:hover { color: var(--text); }

.h-top nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* -------------------------------------------------------------- Gerüst */

.h-shell {
  max-width: 78rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
  display: grid;
  gap: 2.5rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 60rem) {
  .h-shell {
    grid-template-columns: 17rem minmax(0, 1fr);
    align-items: start;
  }
}

/* ---------------------------------------------------- Inhaltsverzeichnis */

.h-toc {
  font-size: 0.9375rem;
}

@media (min-width: 60rem) {
  .h-toc {
    position: sticky;
    top: 5rem;
    max-height: calc(100dvh - 7rem);
    overflow-y: auto;
  }
}

.h-toc > summary {
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  list-style: none;
}

.h-toc > summary::-webkit-details-marker { display: none; }

.h-toc > summary::after {
  content: " ▾";
  color: var(--text-muted);
}

.h-toc[open] > summary::after { content: " ▴"; }

@media (min-width: 60rem) {
  .h-toc > summary {
    border: 0;
    background: none;
    padding: 0 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: default;
    pointer-events: none;
  }

  /* Beide Zustaende: die Regel fuer [open] ist spezifischer als die fuer
     summary allein und behielte ihren Pfeil sonst auch hier. */
  .h-toc > summary::after,
  .h-toc[open] > summary::after { content: ""; }
}

.h-toc ol {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  counter-reset: kapitel;
}

.h-toc li { margin: 0; }

.h-toc a {
  display: block;
  padding: 0.3rem 0.5rem 0.3rem 2.25rem;
  color: var(--text-soft);
  text-decoration: none;
  border-left: 2px solid var(--line);
  position: relative;
}

.h-toc a::before {
  counter-increment: kapitel;
  content: counter(kapitel);
  position: absolute;
  left: 0.6rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
}

.h-toc a:hover {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--surface);
}

/* -------------------------------------------------------------- Inhalt */

.h-main { min-width: 0; }

.h-lede {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.55;
  color: var(--text-soft);
  margin: 0 0 1.5rem;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0 0 0.5rem;
}

.h-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--accent);
  margin: 0 0 0.5rem;
  font-family: var(--font-sans);
}

section.h-chapter {
  margin: 3.5rem 0 0;
  scroll-margin-top: 5rem;
}

section.h-chapter > h2 {
  font-size: clamp(1.5rem, 3.5vw, 1.875rem);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.5rem;
}

h4 {
  font-size: 1.0625rem;
  margin: 1.5rem 0 0.25rem;
  color: var(--text-soft);
}

p { margin: 0 0 1rem; }

a { color: var(--accent); text-underline-offset: 0.2em; }

a:hover { color: var(--text); }

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

ul, ol { margin: 0 0 1rem; padding-left: 1.35rem; }

li { margin: 0 0 0.4rem; }

strong { font-weight: 600; color: var(--text); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 0.1em 0.4em;
}

pre {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.9375rem;
}

pre code { background: none; border: 0; padding: 0; }

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

/* --------------------------------------------------------------- Karte */

.h-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 1.25rem 1.5rem;
  margin: 0 0 1.25rem;
}

.h-card > :last-child { margin-bottom: 0; }

.h-card > h3:first-child, .h-card > h4:first-child { margin-top: 0; }

/* ------------------------------------------------------------- Hinweis */

.h-note {
  border-left: 3px solid var(--tone-info);
  background: var(--surface);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
  padding: 1rem 1.25rem;
  margin: 0 0 1.25rem;
}

.h-note > :last-child { margin-bottom: 0; }

.h-note--care { border-left-color: var(--tone-care); }
.h-note--good { border-left-color: var(--tone-good); }
.h-note--info { border-left-color: var(--tone-info); }

.h-note__label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

/* -------------------------------------------------------------- Schritte */

ol.h-steps {
  list-style: none;
  padding: 0;
  counter-reset: schritt;
}

ol.h-steps > li {
  counter-increment: schritt;
  position: relative;
  padding: 0 0 0 3rem;
  margin: 0 0 1.25rem;
  min-height: 2rem;
}

ol.h-steps > li::before {
  content: counter(schritt);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

ol.h-steps > li > :last-child { margin-bottom: 0; }

/* -------------------------------------------------------------- Tabelle */

.h-scroll { overflow-x: auto; margin: 0 0 1.25rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  min-width: 32rem;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom-color: var(--line-strong);
}

tbody tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- Weg */

.h-path {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-soft);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.7rem;
  white-space: nowrap;
}

/* ------------------------------------------------------------- Bilder */

/*
 * Bildschirmfotos zeigen die helle Oberflaeche; ein Rahmen trennt sie im
 * dunklen Thema von der Seite. Die Bildunterschrift sagt, was zu sehen ist,
 * damit das Bild nie allein traegt; der Alternativtext beschreibt das Bild
 * fuer alle, die es nicht sehen.
 */
.h-shot {
  margin: 0 0 1.5rem;
}

.h-shot img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
}

.h-shot figcaption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Hochformat (iPad) schmaler, zwei nebeneinander, am Telefon untereinander */
.h-shot--hoch img { max-width: 24rem; }

.h-shot__paar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  max-width: 49rem;
  gap: 1rem;
}

/* ------------------------------------------------------------- Tasten */

kbd {
  display: inline-block;
  min-width: 1.6em;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-s);
  padding: 0.05rem 0.4rem;
}

/* ------------------------------------------------------------- Fusszeile */

.h-foot {
  border-top: 1px solid var(--line);
  background: var(--bg-deep);
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.h-foot__inner {
  max-width: 78rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.h-foot p { margin: 0 0 0.5rem; }

/* --------------------------------------------------------------- Druck */

@media print {
  .h-top, .h-toc, .h-skip { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .h-shell { display: block; padding: 0; }
  .h-card, .h-note, pre { border: 1px solid #ccc; background: none; }
  section.h-chapter { break-inside: auto; }
  h2, h3 { break-after: avoid; }
  a { color: #000; }
}
