/* Printing the actionability report.
 *
 * "Download PDF" is the browser's own print-to-PDF. Nothing renders a PDF on
 * the server: WeasyPrint needs cairo and pango as system packages and costs
 * tens of megabytes per render, on a 512 MB single-worker box that has been
 * OOM-killed once already. The browser also prints the SVG figures as vector,
 * which is what a journal asks for and what a server-side rasteriser would
 * have thrown away.
 *
 * Included only by the report page. Everything here is inside @media print, so
 * it cannot affect the screen layout.
 */

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

  /* Paper is white and toner is the reader's. Backgrounds go, borders stay,
     because the layout reads through the rules rather than the fills. */
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 10.5pt;
    line-height: 1.45;
  }
  .rep section,
  .rep .hd,
  .rep .chip {
    background: #fff !important;
    color: #000 !important;
  }

  /* Anything that only exists to be clicked. */
  nav, header.site, footer.site,
  .btn, button, .upload, .filters, .share, .jobs-ad,
  [data-print="hide"] {
    display: none !important;
  }

  /* A figure or a table split across a page break is the main way a printed
     report goes wrong, and it is one declaration. */
  .rep section,
  figure, svg, img, tr, .fig {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  h1, h2, h3, .sh {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* A table running onto a second page needs its header again, or the columns
     are unlabelled for the rest of the document. */
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }

  /* Hairlines survive; colour does not. */
  .rep th, .rep td { border-color: #bbb !important; }
  .rep .chip { border: 1pt solid #666 !important; }

  /* On paper a link is a dead end unless it says where it goes. Internal
     anchors and javascript: are left alone -- printing "(#top)" helps nobody. */
  a { color: #000 !important; text-decoration: underline; }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8.5pt;
    word-break: break-all;
  }

  /* SVG keeps its own colours: the figures encode meaning in them, and the
     shapes carry a second cue (dashes, hatching) so they survive greyscale. */
  svg { max-width: 100% !important; height: auto !important; }
  svg text { fill: #000; }

  /* The figures are drawn against a theme that may be dark on screen. Print is
     always light, so pin the custom properties the report uses. */
  :root {
    --surface-0: #fff; --surface-1: #fff; --surface-2: #fff;
    --text-primary: #000; --text-secondary: #333; --text-muted: #555;
    --border: #bbb; --border-strong: #888;
  }

  /* Provenance belongs on the paper copy, not only on the page: a printed
     report with no date and no source is not auditable. attr() can only read
     the element the pseudo-element hangs off, so these two data- attributes go
     on the .rep container itself, not on <body>. */
  .rep::after {
    content: "BioTransfer · " attr(data-report-source) " · retrieved " attr(data-report-date);
    display: block;
    margin-top: 10mm;
    padding-top: 3mm;
    border-top: 0.5pt solid #bbb;
    font-size: 8.5pt;
    color: #444;
  }
}
