/* Modul D - Druckansicht. Greift in zwei Faellen: am Bildschirm ueber
 * body.print-mode (Vorschau) und im echten Druck ueber @media print.
 * Keine Hex-Werte; Druckfarben kommen aus CSS-Farbnamen. */

#print-root { display: none; }

.print-page {
  break-after: page;
  page-break-after: always;
  break-inside: avoid;
  padding: 0 0 28px;
  margin: 0 0 28px;
}

.print-page:last-child { break-after: auto; page-break-after: auto; }

/* ---- Bildschirm-Vorschau ------------------------------------------------ */

body.print-mode { background: white; overflow-y: auto; }

body.print-mode #gateway,
body.print-mode #app,
body.print-mode .topbar,
body.print-mode .main-stage,
body.print-mode .vault-root { display: none !important; }

body.print-mode #print-root {
  display: block;
  position: relative;
  z-index: 100;
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 32px 80px;
  background: white;
  color: black;
  font-family: var(--font-body), system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.6;
}

.print-exit {
  position: sticky;
  top: 12px;
  float: right;
  border: 1px solid black;
  border-radius: 8px;
  background: white;
  color: black;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
}

/* ---- Gemeinsame Typografie ---------------------------------------------- */

#print-root h1 {
  font-family: var(--font-headline), system-ui, sans-serif;
  font-size: 30px;
  line-height: 1.15;
  margin: 0 0 12px;
}

#print-root h2 {
  font-family: var(--font-headline), system-ui, sans-serif;
  font-size: 20px;
  line-height: 1.2;
  margin: 0 0 10px;
}

#print-root h5, #print-root h6 {
  font-family: var(--font-headline), system-ui, sans-serif;
  font-size: 13px;
  margin: 14px 0 6px;
}

#print-root p { margin: 0 0 8px; }
#print-root ul, #print-root ol { margin: 0 0 10px; padding-left: 20px; }
#print-root li { margin-bottom: 3px; }

.print-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: dimgray;
  margin: 0 0 6px;
}

.print-caption { font-size: 11px; color: dimgray; }

.print-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid lightgray;
  border-radius: 6px;
  padding: 10px;
  margin: 0 0 10px;
  background: whitesmoke;
  break-inside: avoid;
}

.print-image, #print-root .print-image svg, #print-root img {
  display: block;
  max-width: 100%;
  height: auto;
  break-inside: avoid;
  margin: 0 0 10px;
}

#print-root .vault-table-wrap { box-shadow: none; border: 1px solid lightgray; border-radius: 6px; overflow: visible; }
#print-root table { border-collapse: collapse; width: 100%; font-size: 11px; break-inside: auto; }
#print-root th, #print-root td { border-bottom: 1px solid lightgray; padding: 6px 8px; text-align: left; vertical-align: top; color: black; }
#print-root th { white-space: nowrap; }
#print-root tr { break-inside: avoid; }
#print-root code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

#print-root .vault-status,
#print-root .vault-chip { background: none; color: black; padding: 0; }

.print-cover { text-align: left; padding-top: 80px; }

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

@media print {
  @page { size: A4; margin: 16mm 14mm; }

  html, body { background: white !important; }

  #gateway, #app, .topbar, .main-stage, .vault-root, .print-exit { display: none !important; }

  #print-root {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    background: white;
    color: black;
    font-family: var(--font-body), system-ui, sans-serif;
    font-size: 11px;
    line-height: 1.55;
  }

  #print-root a { color: black; text-decoration: none; }
  #print-root h1, #print-root h2 { break-after: avoid; page-break-after: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  body.print-mode #print-root { animation: none; }
}
