/* What a page looks like on paper.
 *
 * Loaded from layout.html with media="print", so a browser fetches it at low
 * priority and it never touches the screen.
 *
 * This file had drifted out of true. It was written against an earlier set of
 * class names and still hid `.public-header` and `.public-footer`, neither of
 * which has existed since the header was rebuilt: the real ones are `.site-top`
 * and `.site-footer`. So printing any public page put the whole navigation band
 * and the entire footer on the sheet, and printing a portal page carried the
 * toast that happened to be on screen. The rule that follows from that is to
 * hide by ROLE rather than by remembering each name — anything that is a
 * control, a navigation aid or a transient message goes, and the remaining
 * selectors are checked against the markup rather than assumed.
 *
 * The certificate is not covered here. It is served as its own document by
 * lib/certificates and carries its own @page and print rules.
 */

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

  /* Paper is white and ink is black whatever the reader's theme. Forcing the
     scheme as well as the colours stops a dark-mode browser inverting it back. */
  :root { color-scheme: light; }
  html, body {
    background: #fff !important;
    color: #000 !important;
    font: 10.5pt/1.45 "EB Garamond", Georgia, serif;
  }

  /* Dzongkha still needs its own face on paper. Without this the Tibetan block
     falls back to whatever the printer driver substitutes, which is usually
     tofu. */
  :lang(dz), [lang="dz"] { font-family: "DDC Uchen", serif; }

  /* Chrome, navigation and transient messages.
     .site-top wraps the announcement band and the header together, which is why
     hiding .site-header alone was never enough. */
  .skip-link,
  .site-top,
  .site-header,
  .site-announcement,
  .site-footer,
  .portal-sidebar,
  .portal-topbar,
  .breadcrumbs,
  .filter-bar,
  .pagination,
  .toast-region,
  .noscript-note,
  .sidebar-toggle,
  [data-theme-toggle],
  .media-dialog,
  .record-move,
  .record-add,
  .dropzone-prompt,
  .button,
  .icon-button,
  .site-pill,
  form[method="post"] .button-row,
  [data-print-hide] {
    display: none !important;
  }

  /* The shells exist to hold a sidebar beside a scrolling column. On paper
     there is one column and it is the page. */
  .portal-shell,
  .portal-body,
  .portal-main,
  .public-main,
  .utility-main,
  .site-shell,
  .container {
    display: block !important;
    max-width: none !important;
    width: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Anything that scrolls on screen must not clip on paper: a table inside an
     overflow container prints one screen's worth and silently loses the rest. */
  [class*="scroll"],
  [style*="overflow"] {
    overflow: visible !important;
    max-height: none !important;
  }

  /* Cards keep their grouping but lose the elevation that costs toner. */
  .card,
  .panel,
  .record-row,
  .metric-card {
    box-shadow: none !important;
    border: 1px solid #999 !important;
    background: #fff !important;
  }

  /* A link is only useful on paper if the address comes with it — but only for
     addresses a reader could actually type. An internal href prints as text. */
  a { color: #000 !important; text-decoration: none; }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    word-break: break-all;
  }
  a[href^="#"]::after,
  a[href^="/"]::after,
  a[href^="mailto:"]::after { content: ""; }

  /* Keep a record intelligible across a page break: the head repeats, and a row
     is never split down the middle. */
  table { width: 100% !important; border-collapse: collapse; break-inside: auto; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr, .metric-card, .declaration, .record-row, figure { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  th, td { border-bottom: 1px solid #bbb; padding: 4pt 6pt; text-align: left; }

  /* Shown only on paper: the reference someone quotes when they ring up about
     the sheet in their hand. */
  .support-reference { display: block !important; }
  [data-print-only] { display: block !important; }

  /* An image that runs off the sheet takes the rest of the page with it. */
  img, svg { max-width: 100% !important; height: auto !important; }
}
