/* print.css — the paper layer.
 *
 * Loaded by every page with media="print", so it costs a screen reader nothing and
 * only exists when someone hits Cmd-P or the deploy script renders a PDF.
 *
 * Written for one specific consumer: a hiring reader at American Alchemy opening a
 * PDF attachment. That reader is on US Letter, is likely to print in colour but might
 * not, and is being asked to judge evidence discipline — so the two rules that matter
 * most here are (a) an evidence class must survive a black-and-white printer, and
 * (b) a link must still be checkable when the paper cannot be clicked.
 */

@page {
  size: letter;
  margin: 18mm 16mm 20mm;
}

/* First page of a document gets a tighter top margin so the name/title sits high
   rather than floating in the middle of nothing. */
@page :first {
  margin-top: 14mm;
}

@media print {

  /* ---------------------------------------------------------------- foundations */

  html, body {
    background: #fff !important;
    color: #101418 !important;
    font-size: 10.5pt;
    line-height: 1.45;
  }

  body {
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* The site's max-width containers fight the page box. Let paper set the measure. */
  .aa-wrap, .aa-shell, .aa-main, main, .wrap, .container {
    max-width: none !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ------------------------------------------------------------------- chrome off */

  .aa-nav,
  .aa-nav__group,
  .aa-backlink,
  .aa-toc--sticky,
  .aa-skip,
  nav[aria-label="Site"],
  .no-print,
  .screen-only,
  button,
  input[type="search"],
  .aa-filterbar,
  .aa-controls,
  details.aa-nav__group,
  #ab7-print-hint {
    display: none !important;
  }

  /* Things written for paper and hidden on screen. */
  .print-only { display: block !important; }
  span.print-only, a.print-only { display: inline !important; }

  /* A <details> on paper must be open — a reader cannot click it. */
  details { display: block !important; }
  details > summary { list-style: none; font-weight: 600; }
  details > summary::-webkit-details-marker { display: none; }
  details:not([open]) > *:not(summary) { display: revert !important; }

  /* ------------------------------------------------------------------ typography */

  h1, h2, h3, h4 {
    color: #0b0f14 !important;
    break-after: avoid-page;
    page-break-after: avoid;
    break-inside: avoid;
  }

  h1 { font-size: 19pt; line-height: 1.15; margin: 0 0 4pt; letter-spacing: -0.01em; }
  h2 { font-size: 13pt; margin: 16pt 0 5pt; }
  h3 { font-size: 11pt; margin: 12pt 0 3pt; }

  p, li {
    orphans: 3;
    widows: 3;
  }

  p { margin: 0 0 7pt; }
  ul, ol { margin: 0 0 8pt; padding-left: 14pt; }
  li { margin: 0 0 3pt; }

  blockquote {
    margin: 8pt 0 8pt 10pt;
    padding-left: 9pt;
    border-left: 1.5pt solid #c9d1d9;
    color: #39424c !important;
    font-style: normal;
    break-inside: avoid;
  }

  code, pre, .aa-mono {
    font-size: 9pt;
    background: #f5f6f8 !important;
    border: 0.5pt solid #e3e6ea;
  }

  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 6pt 8pt;
    break-inside: avoid;
  }

  /* ------------------------------------------------------------------------ links */

  a { color: #12304d !important; text-decoration: none; border-bottom: 0.5pt solid #b9c6d2; }

  /* Inside a research document, an unresolvable link is an unverifiable claim, so the
     URL is printed after it. Opt-in per container, because doing this to a résumé's
     header would be unreadable. Internal and anchor links stay bare — the reader
     already has the site. */
  [data-print-urls] a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #5b6672 !important;
    word-break: break-all;
    border: 0;
  }

  /* ------------------------------------------------------------- evidence classes */

  /* The whole point of this application is that a claim carries its class. If the
     reader prints greyscale, the tint collapses to indistinguishable pale grey — so
     every chip also gets a left rule whose weight differs, and the label text itself
     stays visible. Colour is the nicety; the rule and the word are the guarantee. */
  .aa-chip, .chip, [class*="chip--"] {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 0.5pt solid #aab4be !important;
    padding: 0.5pt 3pt;
    font-size: 8pt;
    white-space: nowrap;
  }

  .aa-claim, .claim, .evidence-row, [data-class] {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* --------------------------------------------------------------- blocks & cards */

  .aa-card, .aa-panel, .aa-figure, figure, table, .aa-callout, .aa-note {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
  }

  .aa-card, .aa-panel, .aa-callout, .aa-note {
    border: 0.5pt solid #d8dde3 !important;
    background: #fbfcfd !important;
    padding: 7pt 9pt !important;
    margin: 0 0 8pt !important;
    border-radius: 2pt !important;
  }

  /* Multi-column grids collapse: two columns of prose on Letter is a magazine, and
     this is a document. Card grids keep two-up because they are short blocks. */
  .aa-grid, [class*="grid"] {
    display: block !important;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }
  th, td {
    border: 0.5pt solid #d8dde3;
    padding: 3pt 5pt;
    text-align: left;
    vertical-align: top;
  }
  thead { display: table-header-group; }  /* repeat header on each page */
  tr { break-inside: avoid; }

  img, svg, canvas {
    max-width: 100% !important;
    height: auto !important;
    break-inside: avoid;
  }

  /* An interactive visualisation is a blank box on paper unless it has a still.
     Hide the live canvas, show the fallback. */
  .aa-viz--interactive { display: none !important; }
  .aa-viz__print-still { display: block !important; }

  /* ------------------------------------------------------------------ page breaks */

  .page-break-before { break-before: page; page-break-before: always; }
  .page-break-after  { break-after: page;  page-break-after: always; }
  .keep-together     { break-inside: avoid; page-break-inside: avoid; }

  /* ------------------------------------------------------------------- colophon */

  /* Chrome prints its own header/footer with the URL and date, but a reader may have
     that switched off, and a document that cannot say where it came from is exactly
     the kind of artefact this application argues against. So each page carries its
     own source line, set by the page itself. */
  .print-colophon {
    display: block !important;
    margin-top: 14pt;
    padding-top: 6pt;
    border-top: 0.5pt solid #d8dde3;
    font-size: 8pt;
    color: #5b6672 !important;
    break-inside: avoid;
  }
}
