/* ==================================================================
   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
     153 warning 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.
     --------------------------------------------------------------- */

  .md-typeset .admonition.warning,
  .md-typeset details.warning {
    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 {
    color: #000;
  }
  .md-typeset .admonition.warning a,
  .md-typeset details.warning a,
  .md-typeset .admonition.warning code,
  .md-typeset details.warning 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);
  }

  /* note/example panels are a pale tint that adds nothing on paper */
  .md-typeset .admonition,
  .md-typeset details {
    background: #fff;
    border: 1px solid var(--rs-rule);
    border-left: 3px solid var(--rs-navy);
  }
  .md-typeset .admonition-title,
  .md-typeset summary {
    color: #000;
  }

  /* 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;
  }

  .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;
  }
}
