/**
 * Print stylesheet — Doc Hub reader only (see missionos_enqueue_doc_hub_assets()
 * in functions.php). This is the ONLY print stylesheet for this page —
 * a second, overlapping @media print block used to live in
 * css/doc-hub.css; the two together caused a real bug (see the
 * "Pagination" section below), so everything print-related now lives
 * here in one place.
 *
 * Loaded as a completely normal stylesheet (media="all", not "print")
 * so its rules are present on screen too — that matters because
 * .print-chrome (the branded header/footer, below) needs an ordinary
 * screen-media rule to stay hidden outside of print. Everything that
 * should behave differently only while actually printing is scoped
 * inside the @media print block.
 *
 * Approximates the exported PDF's branded header/footer (see
 * dhAddPdfHeader()/dhAddPdfFooter() in js/doc-hub.js) for the
 * browser's own native print output: same two logos at the top, same
 * favicon/WUM/title/version/date strip at the bottom, same #074f56
 * accent rule. This is a close approximation, not a pixel-identical
 * match — standard browsers (Chrome, Firefox, Safari) don't support
 * repeating custom content in the CSS Paged Media page-margin boxes,
 * so unlike the PDF, this header/footer appears once at the very
 * top/bottom of the printed output rather than being repeated on every
 * physical sheet of paper. #printFooterTitle/#printFooterVersion/
 * #printFooterDate are kept in sync with whichever doc is currently
 * open by js/doc-hub.js's loadDocument() (see updatePrintFooter()
 * there), so they're always accurate whenever Ctrl+P is pressed.
 */

/* Hidden on screen at all times (this rule MUST apply outside of
   @media print — see the docblock above about why this file isn't
   loaded with media="print"). Shown only inside @media print below. */
.print-chrome { display: none; }

@media print {
  /* ---- Force a plain, ink-friendly light appearance regardless of
     the visitor's current dark/light mode ---- */
  html, html.dark, body, html.dark body {
    background: #fff !important;
  }
  #docArticle,
  #docArticle * {
    color: #000 !important;
    text-shadow: none !important;
  }
  #docArticle {
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }
  .md-body a { text-decoration: underline !important; }

  /* ---- Hide everything that isn't the document itself ---- */
  #header, #docToolbar, #docSidebar, #docSidebarScrim,
  #mobileNavDrawer, #mobileNavOverlay,
  footer, footer[role="contentinfo"],
  #searchModal, #requestModal, #supportModal, #contactModal,
  #chapterPager, #docMoreQuestions, #docActionBar,
  section[aria-label="Page feedback"], #feedbackWidget,
  #articleToc, #docBreadcrumb, nav[aria-label="Breadcrumb"],
  #scrollTopBtn, #aiFloatingBubble, #backToTop, #toast,
  .related-topics {
    display: none !important;
  }

  /* Let the article take the full page width instead of the
     sidebar/article/TOC three-column grid — CSS Grid/Flexbox items
     don't reliably paginate (browsers tend to push an entire grid/flex
     item onto the next page as one unbreakable unit rather than
     splitting it), so this drops back to plain block flow, which
     paginates normally. */
  #docBodyGrid { display: block !important; }

  /* ---- Pagination ----
     Keep headings glued to what follows them, and keep small/rigid
     content types (tables, figures) from being split awkwardly across
     a page boundary. Deliberately does NOT apply break-inside:avoid to
     .doc-panel or #docArticle themselves — the whole document body is
     rarely short enough to fit on one page, and telling the browser
     never to split it forces the ENTIRE thing onto whichever page has
     room for all of it, which is exactly what caused a real bug here
     before: the branded header would print, then the rest of page 1
     would sit blank because the body got pushed to page 2 as one
     indivisible block. Paragraphs/lists/headings all break normally. */
  .md-body h1, .md-body h2, .md-body h3 { break-after: avoid; page-break-after: avoid; }
  .md-body table, .md-body figure, .md-figure { break-inside: avoid; page-break-inside: avoid; }

  /* ---- Branded header: two logos, same layout as the PDF ---- */
  .print-chrome { display: block !important; }
  .print-chrome__header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10pt;
    margin-bottom: 20pt;
    border-bottom: 1pt solid #cbd5e1;
  }
  .print-chrome__logo-left,
  .print-chrome__logo-right {
    max-height: 26pt;
    width: auto;
  }

  /* ---- Branded footer: favicon, WUM, title, version, date — matches
     the PDF's dhAddPdfFooter() content/order ---- */
  .print-chrome__footer {
    display: flex !important;
    align-items: center;
    flex-wrap: wrap;
    gap: 6pt;
    margin-top: 28pt;
    padding-top: 10pt;
    border-top: 3pt solid #074f56;
    font-size: 8pt;
    color: #64748b !important;
  }
  .print-chrome__footer * { color: inherit !important; }
  .print-chrome__favicon { height: 12pt; width: auto; margin-right: 2pt; }
  .print-chrome__wum { font-weight: 700; color: #0b1124 !important; margin-right: 4pt; }
  .print-chrome__title { font-weight: 600; color: #0b1124 !important; }
  .print-chrome__title:empty, .print-chrome__version:empty, .print-chrome__date:empty { display: none; }
  .print-chrome__title::after, .print-chrome__version::after { content: "\2022"; margin: 0 6pt; color: #cbd5e1 !important; }

  @page {
    margin: 2cm 1.5cm;
  }
}
