/* ==========================================================================
   BookTo — Buch drucken (js/drucken.js)

   Zwei Teile:
     1. der Dialog „Buch drucken" (Papier, Ausrichtung)
     2. die Druckfassung #druckbuch — am Bildschirm unsichtbar, beim Drucken
        das Einzige, was aufs Papier kommt

   ⚠️ Alle Druckregeln hängen an `html[data-druck]`. Ohne diesen Schalter
   druckte Strg+P auf jeder anderen Seite ein leeres Blatt, weil
   `body > *` ausgeblendet wäre.
   ========================================================================== */

/* ── 1. Dialog ─────────────────────────────────────────────────────────── */

.dr { max-width: 760px; }
.dr__koerper { display: flex; flex-direction: column; gap: var(--space-5); }
.dr__h3 {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 1.375rem;
  margin: 0 0 var(--space-3);
}
.dr__wahlen {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
.dr-wahl {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 96px;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.dr-wahl:hover { border-color: var(--color-primary-light); }
.dr-wahl:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.dr-wahl.is-on {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}
[dir="rtl"] .dr-wahl { text-align: right; }
.dr-wahl__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dr-wahl__titel { font-family: var(--font-label); font-weight: 600; font-size: 1.5rem; line-height: 1.2; }
.dr-wahl__erkl { font-size: var(--text-min); color: var(--color-text-secondary); line-height: 1.3; }

/* Das kleine Blatt: zeigt Größe (A5 kleiner als A4) und Ausrichtung
   (Bild oben / Bild links) — ein Blick statt eines Satzes. */
.dr-mini {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  border: 2px solid var(--color-text-secondary);
  border-radius: 3px;
  background: #fff;
  box-sizing: border-box;
}
.dr-mini--a5.dr-mini--hoch { width: 34px; height: 48px; }
.dr-mini--a4.dr-mini--hoch { width: 44px; height: 62px; }
.dr-mini--a5.dr-mini--quer { width: 48px; height: 34px; flex-direction: row; }
.dr-mini--a4.dr-mini--quer { width: 62px; height: 44px; flex-direction: row; }
.dr-mini__b { flex: 1 1 60%; background: var(--color-primary-light, #8fb0d6); border-radius: 1px; }
.dr-mini__t {
  flex: 0 0 30%;
  background: repeating-linear-gradient(to bottom, #555 0 2px, transparent 2px 5px);
}

.dr__hinweis {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  font-size: var(--text-min);
  line-height: 1.45;
}
.dr__hinweis-ico { width: 22px; height: 22px; flex: 0 0 auto; color: var(--color-primary); margin-top: 1px; }

@media (max-width: 560px) {
  .dr__wahlen { grid-template-columns: minmax(0, 1fr); }
  .dr-wahl { min-height: 80px; gap: var(--space-3); padding: var(--space-3); }
  /* „Querformat" lief bei sehr großer Schrift auf 390 px 30–40 px über den
     Knopf (Layout-Prüfung 17.09.2026) — Wörter dürfen hier getrennt werden. */
  .dr-wahl__titel, .dr-wahl__erkl { hyphens: auto; overflow-wrap: break-word; }
}

/* ── 2. Druckfassung ───────────────────────────────────────────────────── */

#druckbuch { display: none; }

/* Messen vor dem Drucken: echt gesetzt, aber außerhalb des Bildschirms. */
html[data-druck] #druckbuch {
  display: block;
  position: absolute;
  left: -100000px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}

.druckbuch {
  color: #111;
  background: #fff;
  font-family: var(--font-body);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.dr-blatt {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 6mm;
  overflow: hidden;
  background: #fff;
  break-after: page;
  page-break-after: always;
}
.dr-blatt:last-child { break-after: auto; page-break-after: auto; }

.dr-bild {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dr-bild img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 2mm;
}

/* Der Buchtext: Schriftart aus den Leseeinstellungen (.booktext in
   css/reading.css), aber schwarz auf weiß und ohne Silbentrennung — wie
   im Reader. Umbrüche aus dem Buch bleiben stehen. */
.druckbuch .dr-text {
  flex: 0 0 auto;
  color: #111;
  line-height: var(--book-line, 1.5);
  letter-spacing: var(--book-letter-space, 0);
  word-spacing: var(--book-word-space, 0);
  white-space: pre-line;
  hyphens: none;
  -webkit-hyphens: none;
  overflow-wrap: break-word;
}
.dr-nurtext .dr-text { margin: auto 0; }
/* Das grosse Zeichen der ABC-Buecher („Mm"), wie im Reader. `display:
   block`, weil der Textblock `pre-line` hat — ein Zeilenumbruch im HTML
   davor wuerde sonst als Leerzeile gedruckt. */
.druckbuch .dr-zeichen {
  display: block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 2.2em;
  line-height: 1.1;
  margin-bottom: .1em;
}

/* Querformat: Bild links, Text rechts — beide mittig in der Höhe. */
.dr-quer { flex-direction: row; align-items: stretch; }
.dr-quer .dr-bild { flex: 1 1 55%; }
.dr-quer .dr-text { flex: 0 1 45%; align-self: center; }
.dr-quer.dr-nurtext .dr-text { flex: 1 1 auto; }

.dr-nr {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5mm;
  text-align: center;
  font-size: 10pt;
  color: #555;
}

/* Titelseite */
.dr-titel .dr-bild { flex: 1 1 auto; }
.dr-titeltext { flex: 0 0 auto; text-align: center; }
.dr-quer .dr-titeltext { flex: 0 1 45%; align-self: center; }
.dr-h1 {
  font-family: var(--font-headline);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  color: #111;
  overflow-wrap: break-word;
}
.dr-autor { margin: 4mm 0 0; font-size: 14pt; color: #333; }

/* Schlussseite */
.dr-schluss { justify-content: flex-start; font-size: 10pt; line-height: 1.45; }
.dr-h2 { font-family: var(--font-headline); font-size: 16pt; margin: 0 0 2mm; color: #111; }
.dr-liste { margin: 0; padding-left: 5mm; }
[dir="rtl"] .dr-liste { padding-left: 0; padding-right: 5mm; }
.dr-liste li { margin-bottom: 2mm; }
.dr-url { color: #444; word-break: break-all; }
.dr-hinweis { margin: 4mm 0 0; font-weight: 600; }
.dr-fuss { margin-top: auto; color: #555; }

/* QR-Code unten auf der Schlussseite (Lars 15.09.2026: „in groß").
   Die Größe setzt js/drucken.js je Format (A5 55 mm, A4 80 mm, quer 80 %)
   und nimmt sie zurück, wenn viele Bildnachweise Platz brauchen. */
.dr-qr {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3mm;
  text-align: center;
}
.dr-qr__rahmen { flex: 0 0 auto; }
.dr-qr__code { display: block; width: 100%; height: 100%; }
.dr-qr__text { margin: 0; max-width: 120mm; font-size: 12pt; font-weight: 600; color: #111; line-height: 1.35; }
.dr-qr .dr-fuss { margin-top: 0; }
/* Zwei Codes nebeneinander: BookTo und die Webseite der Reihe (17.09.2026). */
.dr-qrs { display: flex; justify-content: center; align-items: flex-start; gap: 8mm; }
.dr-qrs__eins { display: flex; flex-direction: column; align-items: center; gap: 2mm; min-width: 0; }
.dr-qrs .dr-qr__text { max-width: 70mm; }
/* Die Adresse in EINER Zeile — auf A5 brach sie nach „einmal-" um, und dann
   ist nicht zu sehen, ob der Strich zur Adresse gehört. */
.dr-qrs .dr-url { margin: 0; font-size: 10pt; font-weight: 600; word-break: normal; white-space: nowrap; }

@media print {
  html[data-druck],
  html[data-druck] body {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }
  html[data-druck] body > *:not(#druckbuch) { display: none !important; }
  html[data-druck] #druckbuch {
    display: block !important;
    position: static !important;
    visibility: visible !important;
  }
}

/* Lange Woerter („Querformat") duerfen getrennt werden — mit Comic Sans MS
   und sehr großer Schrift liefen sie auch auf 1280 px ueber den Knopf. */
.dr-wahl__titel, .dr-wahl__erkl { hyphens: auto; overflow-wrap: break-word; }

/* ── Comicseiten: Sprechblasen über dem Bild (23.09.2026) ────────────────
   Im Bild steht nie Text (js/blasen.js), also muss ihn der Druck darüber
   setzen — sonst käme ein Comic als Folge stummer Bilder aus dem Drucker.
   Die Prozentwerte sind dieselben wie im Reader; damit sie stimmen, ist der
   Bildkasten hier genau das Bild. */
.dr-comic .dr-bild { position: relative; display: inline-flex; margin: 0 auto; }
.dr-comic .dr-bild img { width: auto; }

.dr-blasen { position: absolute; inset: 0; }

.dr-blase {
  position: absolute;
  box-sizing: border-box;
  padding: 1.5mm 2.5mm;
  border: 0.6mm solid #1a1a1a;
  border-radius: 4mm;
  background: #fff;
  color: #000;
  font-size: 0.8em;
  line-height: 1.25;
  text-align: center;
}

.dr-blase--denk { border-radius: 9mm; }
.dr-blase--ruf { border-radius: 1mm; font-weight: 700; }
.dr-blase--geraeusch { border-style: dashed; font-style: italic; }
