/* =========================================================================
 * Print rules — the site's one deferred stylesheet (Module 12).
 *
 * Served from /styles/ rather than bundled, and fetched with the
 * media="print" swap by `src/components/perf/DeferredStylesheet.tsx`, so it
 * never blocks a first paint. Nothing here participates in the screen
 * render, which is exactly what makes it the right sheet to defer.
 *
 * What it does: strips the shell down to the argument. A printed page of
 * this site should read like the document it is — a capability brief, an
 * article, a set of contact details — not a screenshot of a website with a
 * navigation bar and a call-to-action button that cannot be pressed.
 * ========================================================================= */

@media print {
  /* Ink is expensive and a dark hero is a solid black page. Everything
   * prints as dark text on white regardless of the visitor's theme. */
  :root,
  :root[data-theme="dark"],
  [data-tone="dark"],
  [data-tone="light"] {
    color-scheme: light;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-sunken: #ffffff;
    --fg: #000000;
    --fg-muted: #333333;
    --line: #999999;
    --accent: #000000;
    --fg-accent: #000000;
  }

  html,
  body,
  .shell {
    background: #ffffff !important;
    color: #000000 !important;
    min-height: auto;
  }

  /* Interface, not content. */
  .shell-header,
  .shell-nav,
  .shell-skip,
  .shell-footer__meta,
  [data-print="hide"] {
    display: none !important;
  }

  .shell-header:not([data-solid]) ~ .shell-main {
    margin-block-start: 0;
  }

  /* A section's vertical rhythm is a screen affordance; on paper it is four
   * blank pages. */
  main section {
    padding-block: 12pt;
    break-inside: auto;
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
    color: #000000;
  }

  p,
  li,
  figure,
  table {
    break-inside: avoid;
  }

  /* A URL the reader cannot click is worth printing next to its text. */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    word-break: break-all;
  }

  a[href^="/"]::after,
  a[href^="#"]::after {
    content: "";
  }

  /* Reserved media boxes collapse: on paper the diagram is either there at
   * its own size or it is not there at all. */
  .perf-media-frame {
    aspect-ratio: auto !important;
    break-inside: avoid;
  }

  @page {
    margin: 16mm;
  }
}
