/* ==================================================================
   PRINT

   There is no PDF target (MIGRATION.md §4.4) — this exists so that a
   topic printed from the browser comes out as a usable page.

   Material already hides the chrome in @media print: header, tabs,
   sidebars, footer, copy buttons, back-to-top, heading anchors. None of
   that is repeated here. What is left is the part Material cannot know
   about — direction C's inverted panels, which are a genuine print
   hazard, and break control for the constructs this corpus is made of.

   Loaded last, so it wins on equal specificity.
   ================================================================== */

@media print {
  /* ---------------------------------------------------------------
     THE INVERTED PANELS

     Browsers do not print background colours unless the user turns on
     "background graphics", and it is off by default. Direction C paints
     the warning-type admonitions and every table header as light text on a
     navy fill — with the fill dropped, that is white text on white
     paper. The content does not print at all.

     So on paper the inversion is undone rather than forced: the panels
     become bordered light blocks that read the same whether or not the
     user opted into backgrounds.
     --------------------------------------------------------------- */

  /* The pale panels first: their tint adds nothing on paper. [class]
     brings them up to the weight of Material's per-type border colours,
     as editorial.css does on screen. At (0,2,0) every type but note kept
     Material's colour on three sides, purple on an example. The navy
     rules that follow are just as heavy and come later, so they win. */
  .md-typeset .admonition[class],
  .md-typeset details[class] {
    background: #fff;
    border: 1px solid var(--rs-rule);
    border-left: 3px solid var(--rs-navy);
  }
  .md-typeset .admonition-title,
  .md-typeset summary {
    color: #000;
  }

  .md-typeset .admonition.warning,
  .md-typeset details.warning,
  .md-typeset .admonition.important,
  .md-typeset details.important,
  .md-typeset .admonition.danger,
  .md-typeset details.danger,
  .md-typeset .admonition.failure,
  .md-typeset details.failure {
    background: #fff;
    color: #000;
    border: 1px solid var(--rs-navy);
    border-left: 3px solid var(--rs-navy);
  }
  .md-typeset .warning > .admonition-title,
  .md-typeset .warning > summary,
  .md-typeset .important > .admonition-title,
  .md-typeset .important > summary,
  .md-typeset .danger > .admonition-title,
  .md-typeset .danger > summary,
  .md-typeset .failure > .admonition-title,
  .md-typeset .failure > summary {
    color: #000;
  }
  .md-typeset .admonition.warning a,
  .md-typeset details.warning a,
  .md-typeset .admonition.warning code,
  .md-typeset details.warning code,
  .md-typeset .admonition.important a,
  .md-typeset details.important a,
  .md-typeset .admonition.important code,
  .md-typeset details.important code,
  .md-typeset .admonition.danger a,
  .md-typeset details.danger a,
  .md-typeset .admonition.danger code,
  .md-typeset details.danger code,
  .md-typeset .admonition.failure a,
  .md-typeset details.failure a,
  .md-typeset .admonition.failure code,
  .md-typeset details.failure code {
    color: #000;
    background: none;
    border-bottom-color: #666;
  }

  /* Table headers: navy fill, white text — same failure. */
  .md-typeset table:not([class]) th {
    background: #fff;
    color: #000;
    border-bottom: 2px solid var(--rs-navy);
  }

  /* The h2 rule and the function-card accent are decoration that survives
     without colour; make them grey so they still separate sections when
     printed on a mono printer. */
  .md-typeset h2::before {
    background: #000;
  }

  /* ---------------------------------------------------------------
     MEASURE
     @page owns the margin, so the on-screen 46rem measure and its
     padding only fight it.
     --------------------------------------------------------------- */

  @page {
    margin: 18mm 16mm;
  }

  .md-content__inner {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .md-typeset {
    font-size: 9.5pt;
    line-height: 1.45;
    color: #000;
  }

  /* the landing hero is a navy full-bleed block with a search button —
     none of it means anything on paper */
  .rs-hero,
  .rs-hero__search {
    display: none;
  }
  .md-content__inner:has(.rs-hero) {
    max-width: none;
  }

  /* ---------------------------------------------------------------
     BREAK CONTROL

     Material already sets page-break-inside:avoid on admonitions. The
     rest of the corpus vocabulary is function cards (183), screenshots
     (1,407) and tables, and a screenshot split across a page break is
     the most common way a printed topic becomes unusable.
     --------------------------------------------------------------- */

  .md-typeset .fn,
  .md-typeset figure,
  .md-typeset img,
  .md-typeset pre,
  .md-typeset table:not([class]),
  .md-typeset .video {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* PAPER CANNOT SCROLL. brand.css makes data listings scroll rather than wrap
     (DOCS-138), which is right on screen and would silently CLIP here: a wide
     CSV or fixed-width sample would print missing its right-hand columns, with
     nothing on the page to say so. Wrap them back.

     check_overflow does not exercise print, so nothing in the build would have
     caught this. It is paired with the brand.css rule by hand. */
  .md-typeset pre > code {
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }

  .md-typeset h1,
  .md-typeset h2,
  .md-typeset h3,
  .md-typeset h4 {
    break-after: avoid;
    page-break-after: avoid;
    /* a heading immediately before a break is a heading on the wrong page */
    break-inside: avoid;
  }

  .md-typeset p,
  .md-typeset li {
    orphans: 3;
    widows: 3;
  }

  /* Screenshots are captured at UI scale and some are wider than the
     printable column. */
  .md-typeset img {
    max-width: 100%;
    height: auto;
    box-shadow: none;
  }

  /* A collapsed dropdown prints as its title and nothing else. All 11 in
     the corpus are `???+` (open by default), but a reader may have closed
     one before hitting print. */
  .md-typeset details:not([open]) > *:not(summary) {
    display: block;
  }
  .md-typeset summary::after {
    display: none;
  }

  /* ---------------------------------------------------------------
     LINKS

     Only external ones get their target spelled out. Doing it for every
     link would append a URL to several thousand cross-references and
     bury the prose; an off-site reference is the one a reader cannot
     resolve from the printout.
     --------------------------------------------------------------- */

  .md-typeset a {
    color: #000;
    border-bottom: 1px solid #999;
  }
  /* Scheme alone does not identify an external link. Material's
     navigation.instant rewrites every internal href to an absolute URL in the
     DOM, so by print time `a[href^="http"]` matches the cross-references too
     and attr(href) hands each one its own full URL — verified with JS on and
     off: the built HTML says href="../s300-order-import/", the live DOM says
     http://host/quick-start-guide/sample-integrations/s300-order-import/.
     The site lives under /support/documentation/, so excluding that path
     leaves exactly the off-site links.

     Caveat worth knowing rather than hiding: under a localhost preview the
     origin is different, so internal links do pick up a URL there. It is a
     preview artefact — in production, and in anything printed from the real
     site, the exclusion holds. */
  .md-typeset a[href^="http"]:not([href*="/support/documentation/"])::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #555;
    word-break: break-all;
    border: none;
  }
  /* the function index is a list of in-page jumps — useless on paper, but
     harmless, so it stays; it just must not gain URLs */
  .md-typeset .fn-index a::after {
    content: none;
  }
}
