/*
 * Print: A4, one exhibit per page, the exhibit id and file band at the top,
 * black on white, no interface chrome. Loaded with media="print" by the app
 * shell; the rules are also wrapped in @media print so the file is safe to
 * link without a media attribute. tokens.css supplies the print palette.
 */

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

  html,
  body {
    color: var(--ink);
    background: var(--bg);
  }

  /* ---------- interface chrome ---------- */
  .skip-link,
  .toast,
  .dialog,
  .doc-transcript-wrap,
  .doc-zoom__bar,
  .nd-pencil,
  .doc-svg-desc > summary,
  .doc-unlock,
  .doc-sealed__tape,
  .doc-cipher__actions,
  .doc-cipher__clear,
  .doc-band__opened {
    display: none !important;
  }

  .doc-svg-desc:not([open]) {
    display: none;
  }

  /* ---------- one exhibit per page ---------- */
  .doc-exhibit {
    display: block;
    break-before: auto;
    color: var(--ink);
  }

  .doc-exhibit + .doc-exhibit {
    break-before: page;
    page-break-before: always;
  }

  /* Id and file band. */
  .doc-band {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2mm 4mm;
    margin: 0 0 5mm;
    padding: 2mm 0 2.5mm;
    border-top: 2.5pt solid var(--ink);
    border-bottom: 0.75pt solid var(--ink);
    break-after: avoid;
    page-break-after: avoid;
  }

  .doc-band__tab {
    padding: 0;
    font-size: 10pt;
    color: var(--ink);
    background: none;
    border: 0;
  }

  .doc-band__tab .doc-band__id {
    font-size: 12pt;
    font-weight: 400;
  }

  .doc-band__file {
    font-size: 9pt;
    color: var(--ink);
  }

  .doc-band__file::before {
    content: "/ ";
  }

  .doc-band__title {
    font-size: 17pt;
    line-height: 1.15;
  }

  .doc-band__summary {
    font-size: 9.5pt;
    color: var(--ink-muted);
  }

  /* The print view (#/print) already prints its own band and title. */
  .app-print-sheet__doc .doc-band__tab,
  .app-print-sheet__doc .doc-band__file,
  .app-print-sheet__doc .doc-band__title {
    display: none;
  }

  .app-print-sheet__doc .doc-band {
    border: 0;
    padding: 0;
  }

  /* ---------- documents: flat paper ---------- */
  .doc,
  .doc-exhibit--compact .doc {
    max-width: none;
    margin: 0;
    padding: 6mm 7mm;
    font-size: 10.5pt;
    line-height: 1.45;
    color: var(--paper-ink);
    background: none;
    background-color: transparent;
    background-image: none;
    border: 0.75pt solid var(--rule-strong);
    border-radius: 0;
    transform: none;
    text-shadow: none;
    -webkit-mask: none;
    mask: none;
    box-shadow: none;
  }

  .doc--receipt {
    max-width: 90mm;
  }

  .doc--note,
  .doc--chat,
  .doc--photo,
  .doc--ticket {
    max-width: 150mm;
  }

  .doc--chat {
    border-width: 0.75pt;
    border-radius: 0;
  }

  .doc-exhibit .doc--ticket,
  .doc--ticket {
    flex-direction: row;
    padding: 0;
  }

  .doc--ticket .doc-ticket__stub {
    flex: 0 0 24mm;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    border-top: 0;
    border-inline-start: 1pt dashed var(--ink);
    writing-mode: vertical-rl;
  }

  .paper--lined,
  .doc--note .doc-body,
  .paper--lined .doc-hand {
    line-height: 1.6;
  }

  .paper--lined {
    padding-inline-start: 7mm;
  }

  .doc-head {
    break-after: avoid;
    page-break-after: avoid;
  }

  .doc--form .doc-head,
  .doc--form .doc-h {
    margin-inline: -7mm;
  }

  .doc--form .doc-head {
    margin-top: -6mm;
  }

  .doc--form .doc-h,
  .doc--form .doc-table th,
  .doc--log .doc-table th,
  .doc-email__head,
  .doc--email .doc-head,
  .doc-lang__tr {
    background: none;
  }

  .doc--calendar .doc-table th {
    color: var(--ink);
    background: none;
    border-bottom: 1.5pt solid var(--ink);
  }

  .doc--calendar .doc-table td {
    height: 18mm;
  }

  .doc--log .doc-table tbody tr:nth-child(even) td,
  .doc--calendar .doc-table td:empty {
    background: none;
  }

  .doc--newspaper .doc-body {
    column-count: 2;
    column-gap: 6mm;
  }

  .doc--chat .doc-body,
  .doc--email .doc-body,
  .doc--answering-machine .doc-body {
    padding-inline: 0;
  }

  .doc--email .doc-head::before {
    display: none;
  }

  /* Answering machine deck and film strips print as outlines. */
  .doc-am__deck {
    color: var(--ink);
    background: none;
    border: 0.75pt solid var(--ink);
  }

  .doc-am__deck .doc-head__org,
  .doc-am__deck .doc-head__title,
  .doc-am__deck .doc-head__class,
  .doc-am__deck .doc-head__item dt {
    color: var(--ink);
  }

  .doc-am__grille {
    display: none;
  }

  .doc-am__lcd {
    background: none;
    border: 0.75pt solid var(--ink);
  }

  .doc--contact-sheet .doc-body {
    color: var(--ink);
    background: none;
    padding: 0;
  }

  .doc--contact-sheet .doc-figure::before,
  .doc--contact-sheet .doc-figure__caption,
  .doc--contact-sheet .doc-p,
  .doc--contact-sheet .doc-h,
  .doc--contact-sheet .doc-margin,
  .doc--contact-sheet .doc-stamp {
    color: var(--ink);
  }

  .doc--telegram .doc-body .doc-p .doc-p__text {
    background: none;
    box-shadow: none;
  }

  /* ---------- blocks ---------- */
  .doc-stamp {
    opacity: 1;
    mix-blend-mode: normal;
  }

  /* Bars are drawn as borders so they print even with backgrounds off. */
  .doc-redact {
    height: 0;
    background: none;
    border-top: 1.05em solid var(--redact);
  }

  .doc-margin {
    color: var(--pen);
  }

  .doc-msg,
  .doc-msg--me,
  .doc-msg--them {
    background: none;
    border: 0.75pt solid var(--rule-strong);
  }

  .doc-post__avatar {
    color: var(--ink);
    background: none;
    border: 0.75pt solid var(--ink);
  }

  .doc-audio,
  .doc-cipher,
  .doc-email,
  .doc-transcript,
  .doc-sealed {
    background: none;
  }

  .doc-qa__a .doc-qa__mark {
    color: var(--ink);
    background: none;
    border-color: var(--ink);
  }

  .doc--form .doc-head__meta {
    background: none;
  }

  .doc--form .doc-head__item + .doc-head__item {
    border-inline-start: 0.75pt solid var(--ink);
  }

  .doc-audio__wave {
    fill: var(--ink-muted);
  }

  /* A playable entry prints as its label and transcript; the controls stay on screen,
     and so does the note that the recordings are in English. */
  .doc-tape,
  .doc-rec-note {
    display: none !important;
  }

  .doc-cipher__input {
    border: 0;
    border-bottom: 1pt solid var(--ink);
  }

  .doc-cipher__workarea {
    min-height: 30mm;
    border: 0.75pt solid var(--rule-strong);
    resize: none;
  }

  .doc-zoom {
    border: 0;
  }

  .doc-zoom__viewport {
    overflow: visible;
    border: 0.75pt solid var(--rule);
  }

  .doc-zoom__stage {
    transform: none !important;
  }

  .doc-img {
    max-height: 170mm;
    background: none;
  }

  .doc-figure,
  .doc-figure--svg,
  .doc-qa__item,
  .doc-kv__row,
  .doc-post,
  .doc-msg,
  .doc-audio,
  .doc-sig,
  .doc-stamp,
  .doc-lang,
  .doc-quote,
  .doc-table tr,
  .doc-cipher__key {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .doc-h {
    break-after: avoid;
    page-break-after: avoid;
  }

  .doc-table-wrap {
    overflow: visible;
  }

  .doc-table thead {
    display: table-header-group;
  }

  /* A sealed artefact prints as a plain notice. */
  .doc-sealed {
    padding: 6mm;
    border: 1pt dashed var(--ink);
  }

  .doc-sealed__note {
    color: var(--ink);
  }

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