/* Owner: B (design system), with contributions from C and D (spec §8, decision T18). Loaded with <link media="print">
   and in the last layer. The light theme applies automatically (the dark tokens exist only inside @media screen).
   No colour values. Views: answer with evidence, mail, attachment, Vorgang, Chronik, Fristen. The reading pane is
   never printed with the page – it has its own command "Diese Mail drucken". C and D add the print rules of their
   own components in their own files, inside @media print { @layer print { … } }.
   --druck-titel: the view title for the page margin box, a CSS string set via CSSOM before printing
   (document.documentElement.style.setProperty("--druck-titel", JSON.stringify("Mailarchiv · Fragen · …"))). */

@layer print {
  @page {
    size: A4;
    margin: 18mm 16mm 20mm;
    @top-left { content: var(--druck-titel, "Mailarchiv"); font: 500 8pt/1.2 "Inter", sans-serif; color: var(--text-3); }
    @top-right { content: "vertraulich"; font: 600 8pt/1.2 "Inter", sans-serif; color: var(--text-3); }
    @bottom-left { content: var(--druck-fuss, "Mailarchiv"); font: 400 8pt/1.2 "Inter", sans-serif; color: var(--text-3); }
    @bottom-right { content: "Seite " counter(page) " von " counter(pages); font: 400 8pt/1.2 "Inter", sans-serif; color: var(--text-3); }
  }

  html, body { background: var(--surface); }
  body { font-size: 10pt; line-height: 1.45; }

  /* Header on the first page: archive, view or #Nr, print date, user, "vertraulich" (markup: .druckkopf, C/D) */
  .druckkopf {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2mm 6mm; margin-bottom: 6mm; padding-bottom: 2.5mm;
    border-bottom: 1px solid var(--border-strong); font-size: 8.5pt; color: var(--text-2);
  }
  .druckkopf b { color: var(--text); font-weight: 650; }
  .druckkopf > * { min-width: 0; overflow-wrap: anywhere; }   /* a long subject wraps inside the sheet */

  /* No navigation, forms, buttons, operating links or floating parts */
  .appkopf, .lesefenster, .composer, .seitenkopf__aktionen, .werkzeugleiste, .werkzeuge, .rundenaktionen, .stelle__aktionen,
  .filterleiste, .mails-kopfzeile, .chronik-werkzeuge, .sprunglink, .ikon, .knopf, .markiert__aktion, .anhang-leiste .werkzeuge,
  .belegliste__hinweis, .warum > summary, .liste-ende, .brotkrume, .reihenfolge, .composer__hinweis,
  .tip, .menue, .vorschau, .toasts, .mailref__kopie, .palette { display: none !important; }

  .rahmen, .rahmen[data-lesen="offen"] { display: block; }
  .rahmen::after { content: none !important; }
  .haupt { margin: 0; border: 0; border-radius: 0; min-height: 0; container-type: normal; }
  .seite { padding: 0; max-width: none; }
  .seitenkopf { padding: 0 0 4mm; }
  .zweispaltig, .lage, .runde { display: block; }
  .zweispaltig__seite, .runde__belege { position: static; margin-top: 6mm; }
  .monat, .monatskopf, .tabelle th, .anhang-leiste { position: static; }
  .klappe > summary { margin: 0; padding: 0; min-height: 0; }   /* the screen bleed (−8 px) would widen the printed line */
  /* Disclosures print open (beforeprint): their chevrons go – also those of the month heads of a mail history */
  summary .klappe__pfeil, summary > .icon-chevron-right, summary > .icon-chevron-down { display: none; }

  /* Lists print complete: table cells wrap instead of truncating (only dates, times and numbers stay on one line) */
  .tabelle td { height: auto; padding-block: 1.5mm; white-space: normal; }
  .tabelle td.zahl, .tabelle td.k-nr { white-space: nowrap; }
  .tabelle .schnitt { max-width: none; overflow: visible; text-overflow: clip; }
  /* No ellipsis on paper (spec §8): the row links, subjects, names and tags that the screen cuts to one line wrap –
     only dates, times and #Nr stay on one line */
  .zeile__link, .vmail__betreff, .mzeile__betreff, .mzeile__wer, .verlauf__wer, .tabelle td.k-bereich, .tabelle td .tag,
  .pzeile__name, .pzeile__aktion, .pzeile__text, .person__name b, .person__name span {
    white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere;
  }
  .tabelle td .tag { display: inline; height: auto; max-width: none; }

  /* Keep cards and rows whole – but never a whole document (a long mail must flow over pages) */
  .beleg, .kartei, .frist, .eintrag, .vmail, .mzeile, .vzeile, .hinweis, .box__teil { break-inside: avoid; }
  .beleg, .papier, .box { box-shadow: none; }
  h1, h2, h3, .runde__frage, .belegliste__kopf, .abschnitt__kopf { break-after: avoid; }

  /* Completeness: no clamping; closed details are opened by beforeprint and closed again by afterprint */
  .auszug, .vzeile__stand, .vorschau__kern { -webkit-line-clamp: unset; line-clamp: none; display: block; overflow: visible; }
  details::details-content { content-visibility: visible; }

  /* Evidence without background graphics: passage = side rule, key sentence = fill + underline, marks as text */
  mark.kern, mark.treffer, .auszug, .strich, .stelle-block, .marke--dok, .fristmarke, .fristnr, .pille { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  mark.kern { text-decoration: underline 1.5px; text-underline-offset: 3px; }
  .marke { display: inline; background: none; border: 0; padding: 0; margin: 0 0 0 2px; height: auto; font: inherit; font-weight: 600; vertical-align: baseline; color: var(--text); }
  .marke .icon { display: none; }
  .marke::before { content: "["; position: static; inset: auto; }
  .marke::after { content: "]"; }
  .marke--kat::before { content: "[Katalog "; }
  .marke[aria-current] { outline: 0; }
  .mailref { display: inline; background: none; padding: 0; height: auto; font-weight: 600; }
  .mailref-gruppe { display: inline; }
  .antwort p[data-verknuepft]::before { content: none; }
  .papier { border: 0; padding: 0; }
  .papier__marke { margin: 0 0 3mm; }
  .stelle-block { margin-left: 0; padding-left: 3mm; }
  .tabelle--karten td.k-bereich { display: table-cell; }
  .beleg[aria-current], .kartei[aria-current], .zeile[aria-current], .beleg[data-hervor] { box-shadow: none; background: none; }
}
