/* ============================================================================
   print.css — the exported/printed Keepsake Chronicle. This is the single
   screen most likely to justify the product's price on Etsy, so it gets the
   same care as the wax seal: real @page rules, real color in print, and a
   hard ban on max-height/overflow tricks (a clipped keepsake is a support
   ticket and a bad review).

   Only ever active inside @media print — nothing here leaks into screen
   rendering. Depends on tokens.css (colors), decor.css (.keepsake and
   friends), components.css (#awModalOverlay/#awModalPanel/.card/.meter
   selectors it neutralizes for print).

   ---------------------------------------------------------------------------
   CONTRACT
   ---------------------------------------------------------------------------
   - The real print flow (js/print.js + app.js's btnExportKeepsake handler):
     app.js opens #awModalOverlay/#awModalPanel with the keepsake HTML
     already injected (js/print.js's `.keepsake` article) BEFORE the user
     ever clicks "Print / Save PDF", so by the time window.print() runs the
     modal is already unhidden — print.css does not need to fight `hidden`.
     Its job is purely to stop that modal from behaving like a small,
     scrollable, fixed-position overlay once it's on paper: below,
     #awModalOverlay/.modal-overlay and #awModalPanel/.modal-panel are
     forced to plain, fully-expanding, non-clipped blocks, and `.keepsake`
     itself (plus every descendant) is forced `overflow: visible`.
   - Anything that must NEVER appear on paper (header, nav tabs, the particle
     canvas, toasts, modal close/footer controls — `.modal-foot` already
     carries `no-print` in app.js's real markup, `.modal-head` does not, so
     it's hidden explicitly below) gets `class="no-print"` from index.html.
     Add it liberally — it is pure opt-out, zero behavioral cost on screen.
   - `.keepsake-export`/`.print-area` are kept as generic fallback hooks with
     the same forcing behavior, for printing something that isn't routed
     through the real #awModalOverlay flow (e.g. a lone Character Sheet).
   ============================================================================ */

@media print {

  @page {
    size: A4 portrait;
    margin: 14mm 12mm;
  }

  /* real ink in print — without this most browsers strip our dark surfaces
     and gold foil down to plain black text on white by default */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html, body {
    background: #fff !important;
    width: auto !important;
    height: auto !important;
  }
  body::before, body::after { display: none !important; } /* screen grain/vignette layer */

  /* ---- opt-out chrome ----
     .app-header/.nav-tabs/.app-main are the app shell that sits BEHIND the
     modal in the real DOM (index.html: <header class="app-header">, <nav
     class="nav-tabs">, <main class="app-main"> hold the 6 views). Printing
     never removes them from the document, so without an explicit hide they
     render on paper stacked underneath/after the keepsake — confirmed via a
     real generated PDF showing the live app tab (e.g. Sanctuary's dragon
     card) bleeding past the page margins alongside the keepsake content. */
  .no-print,
  .app-header, .nav-tabs, .app-main, #particleCanvas, .toast-stack,
  #toastStack, .toast, #awToast, .modal-close, .modal-footer, .modal-foot,
  .modal-header, .modal-head {
    display: none !important;
  }

  /* ---- the print target itself: no fixed/overlay behavior, no clipping ----
     #awModalOverlay/.modal-overlay is the REAL container the keepsake sits
     in at print time (app.js's generic modal host); .keepsake-export/
     .print-area stay supported as fallback hooks for any other flow. */
  #awModalOverlay, .modal-overlay, .keepsake-export, .print-area {
    position: static !important;
    inset: auto !important;
    display: block !important;
    opacity: 1 !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    transform: none !important;
  }
  #awModalPanel, .modal-panel {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    transform: none !important;
    background: #fff !important;
  }

  /* zero dependency on max-height/overflow ANYWHERE under the print target —
     every descendant is forced to expand to its real content height */
  #awModalOverlay, #awModalOverlay *,
  .modal-overlay, .modal-overlay *,
  .keepsake-export, .keepsake-export *,
  .print-area, .print-area * {
    max-height: none !important;
    overflow: visible !important;
  }

  /* the keepsake keeps its gold foil + parchment (color-adjust above makes
     that survive print), just loses the screen drop-shadow that only makes
     sense floating over the app background */
  .keepsake, .keepsake-frame, .keepsake-frame-inner {
    box-shadow: none !important;
  }

  /* ---- pagination discipline ---- */
  .card, .species-card, .sheet-section, .chronicle-column, .journal-page,
  .keepsake-seal, .keepsake-sheet, .keepsake-entry, .keepsake-facts,
  .stage-row, .meter, .attribute-card,
  blockquote, figure, table, tr {
    break-inside: avoid;
  }
  h1, h2, h3, h4, h5, h6,
  .view-header, .card-title, .sheet-section h3,
  .keepsake-heading, .keepsake-subheading, .keepsake-title {
    break-after: avoid;
  }

  /* local-first product handed off as a file — no URL/link noise on paper */
  a[href]::after { content: none !important; }
  a { color: inherit !important; text-decoration: none !important; }
}
