/*
 * Vereinario – Handbuch (vereinario.de/handbuch/).
 * Baut auf /vereinario.css auf (Farben, Schrift, Kopf, Fuß, Knöpfe, Ablaufdiagramm).
 * Wie dort: kein JavaScript, keine Inline-Stile (strenge CSP).
 */

/* ---------------------------------------------------------------- Titel */

.hb-titel {
  padding-block: clamp(48px, 7vw, 88px) clamp(36px, 5vw, 56px);
  border-bottom: 1px solid var(--linie);
}

.hb-titel h1 {
  margin: 0;
  font-size: clamp(50px, 7vw, 88px);
  line-height: 0.95;
}

.hb-titel .einleitung {
  margin-top: 20px;
}

.hb-stand {
  margin: 20px 0 0;
  color: var(--text-leise);
  font-size: 14px;
}

/* ---------------------------------------------------------------- Raster */

.hb-raster {
  display: grid;
  gap: 32px;
  padding-block: 40px 80px;
}

@media (min-width: 1000px) {
  .hb-raster {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 56px;
  }

  .nur-schmal {
    display: none;
  }
}

/* ---------------------------------------------------------------- Verzeichnis */

.hb-verzeichnis {
  align-self: start;
  padding: 20px;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  font-size: 15px;
}

@media (min-width: 1000px) {
  .hb-verzeichnis {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
    padding: 4px 0 4px 2px;
    border: 0;
    background: none;
  }
}

.hb-verzeichnis .marke-klein {
  margin-bottom: 10px;
}

.hb-verzeichnis ol,
.hb-verzeichnis ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hb-verzeichnis > ol > li + li {
  margin-top: 2px;
}

.hb-verzeichnis a {
  display: flex;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
}

.hb-verzeichnis a:hover {
  background: var(--flaeche-2);
}

.hb-verzeichnis .nr {
  flex: none;
  width: 1.6em;
  color: var(--akzent-text);
  font-family: var(--schrift-anzeige);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.hb-verzeichnis ul {
  margin: 2px 0 6px 2.2em;
}

.hb-verzeichnis ul a {
  padding: 2px 8px;
  color: var(--text-leise);
  font-size: 14px;
}

/* ---------------------------------------------------------------- Text */

.hb-text {
  min-width: 0;
  max-width: 860px;
}

.kapitel + .kapitel {
  margin-top: clamp(56px, 8vw, 88px);
  padding-top: clamp(40px, 6vw, 56px);
  border-top: 1px solid var(--linie);
}

.hb-text h2 {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 20px;
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.05;
  text-wrap: balance;
}

.hb-text h2 .nr {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 1.4em;
  height: 1.4em;
  padding-inline: 0.2em;
  border-radius: 8px;
  background: var(--glut);
  color: var(--akzent-text);
  font-size: 0.62em;
  font-weight: 700;
}

.hb-text h3 {
  margin: 44px 0 12px;
  font-size: 25px;
  line-height: 1.2;
}

.hb-text h4 {
  margin: 20px 0 6px;
  font-size: 17px;
  font-weight: 600;
}

.hb-text p,
.hb-text ul,
.hb-text ol,
.hb-text dl {
  margin: 0 0 14px;
}

.hb-text ul,
.hb-text ol {
  padding-left: 22px;
}

.hb-text li + li {
  margin-top: 6px;
}

.hb-text li > ul {
  margin-top: 6px;
}

.hb-text a {
  color: var(--akzent-text);
  text-underline-offset: 3px;
}

.hb-text b {
  font-weight: 620;
}

.hb-text code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--flaeche-2);
  font-family: var(--schrift-mono);
  font-size: 0.88em;
}

/* Nummerierte Schritte mit Kreisen */
.schritte,
.checkliste {
  counter-reset: schritt;
  padding-left: 0 !important;
  list-style: none;
}

.schritte > li,
.checkliste > li {
  position: relative;
  padding-left: 40px;
  counter-increment: schritt;
}

.schritte > li + li,
.checkliste > li + li {
  margin-top: 10px;
}

.schritte > li::before {
  content: counter(schritt);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--knopf);
  color: #fff;
  font-family: var(--schrift-anzeige);
  font-size: 15px;
  font-weight: 700;
}

.checkliste > li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 3px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--linie-stark);
  border-radius: 6px;
  background: var(--flaeche);
}

/* Hinweiskästen */
.tipp,
.achtung {
  padding: 14px 18px;
  border-radius: 14px;
  border-left: 4px solid;
  font-size: 16px;
}

.tipp {
  border-color: var(--gruen);
  background: var(--gruen-grund);
}

.achtung {
  border-color: var(--akzent);
  background: var(--glut);
}

/* Tabellen */
.tabelle {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--linie);
  border-radius: 14px;
  background: var(--flaeche);
}

.tabelle table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.tabelle th,
.tabelle td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--linie);
  text-align: left;
  vertical-align: top;
}

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

.tabelle th {
  background: var(--flaeche-2);
  color: var(--text-leise);
  font-size: 14px;
  font-weight: 600;
}

/* Etiketten und Status wie in der App */
.etikett,
.status-gelb,
.status-gruen,
.status-rot,
.pill-ok,
.pill-bad {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1.6;
  white-space: nowrap;
}

.etikett-art {
  background: #d6f2ee;
  color: #135f55;
}

.etikett-ver {
  background: #eee0fa;
  color: #5b2a86;
}

.etikett-konto {
  background: #dce8fb;
  color: #1d4f99;
}

.status-gelb {
  background: #fdf0c9;
  color: #7a5600;
}

.status-gruen,
.pill-ok {
  background: #dcf1e3;
  color: #1c6b3a;
}

.status-rot,
.pill-bad {
  background: #fbe0dd;
  color: #a12a1e;
}

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

.bild {
  margin: 20px 0 24px;
}

.bild img {
  width: 100%;
  border: 1px solid var(--linie-stark);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--schatten);
}

.bild figcaption {
  margin-top: 10px;
  color: var(--text-leise);
  font-size: 14px;
  line-height: 1.45;
}

.bild figcaption span {
  margin-right: 4px;
  color: var(--akzent-text);
  font-family: var(--schrift-anzeige);
  font-size: 15px;
  font-weight: 600;
}

/* Handy-Bildschirme */
.bild-hoch {
  max-width: 300px;
  margin-inline: auto;
}

.bild-hoch img {
  border: 6px solid #16181d;
  border-radius: 26px;
}

/* Dialoge und Karten in mittlerer Größe */
.bild-mittel {
  max-width: 560px;
}

/* Schmale Leisten */
.bild-streifen img {
  border-radius: 10px;
}

.zwei,
.zwei-gleich,
.drei {
  display: grid;
  gap: 8px 28px;
  align-items: start;
  margin: 8px 0 12px;
}

.zwei > .bild,
.zwei-gleich > .bild,
.drei > .bild {
  margin-top: 8px;
}

@media (min-width: 760px) {
  .zwei {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  }

  .zwei-gleich {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drei {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .zwei > .bild-hoch {
    max-width: 320px;
  }
}

/* Ablaufdiagramm aus vereinario.css etwas kompakter */
.hb-text .fluss {
  margin: 8px 0 32px;
}

.hb-text .fluss ol,
.hb-text .fluss ul {
  padding-left: 0;
}

.hb-text .fluss li + li {
  margin-top: 0;
}

@media screen and (max-width: 819px) {
  .hb-text .fluss li + li {
    margin-top: 28px;
  }

  .hb-text .fluss-enden li + li {
    margin-top: 14px;
  }
}

/* Fragen */
.hb-text .fragen {
  max-width: none;
}

.hb-text .fragen p {
  margin: 0;
}

/* Begriffe */
.glossar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--linie);
  border-radius: 14px;
  background: var(--flaeche);
  overflow: hidden;
}

@media (min-width: 640px) {
  .glossar {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

.glossar dt,
.glossar dd {
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--linie);
}

.glossar dt {
  font-weight: 620;
}

.glossar dd {
  color: var(--text-leise);
}

@media (max-width: 639px) {
  .glossar dt {
    padding-bottom: 0;
    border-bottom: 0;
  }
}

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

@page {
  size: A4;
  margin: 16mm 15mm 18mm;
}

@media print {
  :root {
    color-scheme: light;
    /* Druck immer hell, Farben wie auf dem Bildschirm (vereinario.css) */
    --grund: #fff;
    --flaeche: #fff;
    --flaeche-2: #eef2ee;
    --text: #1a1d21;
    --text-leise: #4a5157;
    --linie: #d3ddd6;
    --linie-stark: #afbdb4;
    --akzent: #af2b1e;
    --akzent-text: #9c2418;
    --knopf: #af2b1e;
    --glut: rgb(175 43 30 / 0.08);
    --gruen: #1d6b45;
    --gruen-grund: rgb(29 107 69 / 0.08);
    --rot: #af2b1e;
    --rot-grund: rgb(175 43 30 / 0.07);
    --bernstein: #a86a00;
    --bernstein-grund: rgb(168 106 0 / 0.08);
    --schatten: none;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.5;
  }

  .kopf,
  .fuss,
  .sprungmarke,
  .hb-titel .knoepfe {
    display: none;
  }

  .hb-titel {
    display: flex;
    align-items: center;
    min-height: 240mm;
    border: 0;
    break-after: page;
  }

  .hb-titel h1 {
    font-size: 54pt;
  }

  .hb-raster {
    display: block;
    padding: 0;
  }

  .hb-verzeichnis {
    position: static;
    max-height: none;
    padding: 0;
    border: 0;
    break-after: page;
    font-size: 11pt;
  }

  .hb-verzeichnis ul a {
    font-size: 10pt;
  }

  .hb-text {
    max-width: none;
  }

  .kapitel {
    break-before: page;
  }

  .kapitel + .kapitel {
    margin-top: 0;
    padding-top: 0;
    border: 0;
  }

  .hb-text h2 {
    font-size: 22pt;
  }

  .hb-text h3 {
    margin-top: 22pt;
    font-size: 14pt;
    break-after: avoid;
  }

  .bild,
  .tipp,
  .achtung,
  .fluss,
  .tabelle,
  .zwei > div,
  .schritte > li {
    break-inside: avoid;
  }

  .bild img {
    box-shadow: none;
  }

  .bild:not(.bild-hoch):not(.bild-mittel) img {
    max-height: 125mm;
    width: auto;
    max-width: 100%;
  }

  .bild-hoch {
    max-width: 62mm;
  }

  .drei .bild-hoch {
    max-width: 52mm;
  }

  .bild-mittel {
    max-width: 105mm;
  }

  .zwei {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  }

  .zwei-gleich {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drei {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fluss-schritte,
  .fluss-enden {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  .fluss-gabel {
    display: none;
  }

  .fluss-enden {
    margin-top: 12px !important;
  }

  .schritt + .schritt::before {
    display: none;
  }

  .hb-text a {
    color: inherit;
    text-decoration: none;
  }

  .fragen details {
    break-inside: avoid;
  }

  .fragen summary::after {
    display: none;
  }
}
