/* THE PAPER (Wave 49) — the engine hands you a document.
 *
 * Printing is a crossing: the page leaves the engine and becomes an object that
 * outlives the session. So the printed sheet is not a screenshot of a dark room —
 * it is an archival document. Cream stock, dry ink, the hand-drawn plates carried
 * over as line art, the chrome left behind. Every sheet is stamped with what the
 * engine actually read at the moment the paper was asked for (see browser-character.js).
 *
 * Linked with media="print" on every room. It has no effect on screen.
 */

@media print {

  /* ---------------------------------------------------------------- the stock */
  @page {
    margin: 16mm 15mm 20mm;
  }

  :root { color-scheme: light; }

  html, body {
    background: #faf7f0 !important;
    color: #17130d !important;
    font-size: 10.2pt !important;
    line-height: 1.55 !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* strip the room's atmosphere; keep the document's structure */
  body *:not(svg):not(svg *) {
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    backdrop-filter: none !important;
    animation: none !important;
    transition: none !important;
    color: #17130d !important;
    opacity: 1 !important;
    max-height: none !important;
    transform: none !important;
  }

  /* Positioning is left intact on purpose. Forcing position:static strips the
   * containing block out from under absolutely-positioned pseudo-elements — the
   * ledger rivets and the certificate's double rule — and they pile up in the
   * page corner. The designed insets are archival detail; they cross to paper. */

  /* the screen's atmosphere is a fixed film over everything; paper has its own grain */
  body::before, body::after { display: none !important; }

  /* the dry ink-amber: the ember does not glow on paper, it stains */
  [class*="eyebrow"] :not(svg),
  [class*="eyebrow"],
  [class*="stamp"]:not(#atr-print-stamp),
  [class*="glyph"],
  [class*="sigil"],
  .cert-mark, .cert-calib, .cert-key, .log-date, .ledger-stamp, .badge {
    color: #8a5906 !important;
  }

  /* rules and frames become dry ruled lines */
  body *:not(svg):not(svg *) {
    border-color: rgba(23, 19, 13, 0.22) !important;
  }
  .certificate, .cert-doc, .log-paper, .ledger, .link-card, .artifact {
    border-color: rgba(23, 19, 13, 0.42) !important;
  }

  /* ------------------------------------------------- what does not reach paper */
  nav, .nav, .nav-links, .nav-back, .nav-brand, .nav-ticker, .loom-nav,
  .foundry-nav, .principle-nav, .back-strip, .skip-to-content,
  .departures, .dep-track, .dep-cell, .dep-sep,
  .scroll-thread, .wildmode-scanline, .event-horizon, .banner-wind,
  .signon-shell, .signon-beat, .signon-glyph, .signon-line, .signon-math, .signon-skip,
  .marginalia, .marginalia-pair, .marginalia-thinspot,
  .summon-btn, .btn-primary, .btn-ghost, .copy-btn, .cert-copy-btn, .cert-copy-note,
  .hero-cta-group, .loom-audio, .live-pulse, .footer-links,
  button, audio, video, iframe, canvas,
  [data-cert-copy], [hidden] {
    display: none !important;
  }

  /* -------------------------------------------------------------- the plates */
  /* Hand-drawn line art crosses to paper as line art: amber on cream is the
   * register the blueprints were drawn in to begin with. */
  svg {
    max-width: 100% !important;
    height: auto !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    break-inside: avoid;
  }

  /* Luminous instruments need their dark ground — a star chart on cream is a blank
   * sheet. These print as inset plates, the way photogravure sat in an old volume. */
  .constellation-wrap, .chart-frame, .loom-canvas, .gravity-core, .loom-memory-canvas {
    background: #080705 !important;
    padding: 6mm !important;
    border-radius: 2mm !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    break-inside: avoid;
  }
  .constellation-wrap *, .chart-frame *, .gravity-core * {
    color: #d9a441 !important;
  }

  /* The banner art is drawn on black. Ink-dark type over it is unreadable, so the
   * whole band crosses as a plate and its type goes back to the amber it was set in. */
  .banner {
    background: #080705 !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    break-inside: avoid;
  }
  .banner .banner-title, .banner .banner-title * { color: #f2ead8 !important; }
  .banner .banner-eyebrow, .banner .banner-eyebrow * { color: #d9a441 !important; }
  .banner img { max-width: 100% !important; height: auto !important; }

  /* "Redactions are not decoration — the seal is the content." The bars are drawn
   * with a background, so the blanket background strip erases them and the working
   * log prints as blank ruled gaps. On paper the seal must still read as a seal:
   * solid dry ink, the way a redacted document has always looked. (The spans are
   * empty by construction — there is no text under the bar to leak.) */
  .redact {
    background: #17130d !important;
    border-bottom-color: rgba(23, 19, 13, 0.5) !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }

  /* The pins and rivets mount a dark card on a dark wall. There is no card on paper —
   * the sheet IS the paper — so the pin has nothing to hold and reads as a stray dot. */
  .log-paper::before, .ledger-entry::before { display: none !important; }

  /* The engraved chord is stroke-drawn on first view. Paper has no first view —
   * print it finished, in dry ink, rather than frozen mid-stroke. */
  .equation-engraved .eq-glyph {
    stroke-dashoffset: 0 !important;
    stroke-dasharray: none !important;
    animation: none !important;
    stroke: #8a5906 !important;
  }

  /* -------------------------------------------------------- the document flow */
  h1, h2, h3, h4 { break-after: avoid; page-break-after: avoid; }
  h1 { font-size: 19pt !important; }
  h2 { font-size: 14pt !important; }
  h3 { font-size: 11.5pt !important; }

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

  .certificate, .cert-doc, .cert-row, .ledger-entry, .log-entry, .link-card,
  .artifact, .bul-card, .cont-card, .cl-grid, .duty-grid, figure, table {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* archival citation: a printed link that hides its destination is not a record */
  a[href^="http"]:not([class*="nav"]):not([class*="btn"])::after {
    content: " ⟨" attr(href) "⟩";
    font-size: 7.6pt;
    letter-spacing: 0.02em;
    color: rgba(23, 19, 13, 0.55) !important;
    word-break: break-all;
  }
  a { text-decoration: none !important; }

  /* ---------------------------------------------------------------- the stamp */
  /* Written by browser-character.js at the moment the paper is asked for.
   * A colophon, not a running footer: position:fixed puts it at the bottom of the
   * page CONTENT box, where Chrome prints it straight over the last lines of body
   * text. It closes the document instead — which is where a colophon belongs. */
  .atr-print-only { display: block !important; }

  #atr-print-stamp {
    display: block !important;
    margin: 10mm 0 0 !important;
    padding-top: 2.5mm !important;
    text-align: center;
    font-size: 7.2pt;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: rgba(23, 19, 13, 0.62) !important;
    border-top: 0.4pt solid rgba(23, 19, 13, 0.3) !important;
    break-inside: avoid;
  }
}
