/* Printed pages: the documentation's PDFs (Weblitz prints them, tools/WeblitzSite/make_pdfs.sh) and a reader's own print.
   Both sites' layouts load it.

   Page breaks go between blocks, never through one. Chrome's print (and so Weblitz, which breaks where Chrome does: checked
   on 2026-11-08 at several positions) honors break-inside: avoid and forced breaks, but break-after: avoid only among
   siblings and not always: a heading first in its section stayed at the bottom of a page. So headings are kept with their
   content by structure: the reference's items (an option's example, an API type) and the SSRS2 documentation's sections
   start a page, other sections move whole to the next page when they fit on one, and a block (code, a card, a figure with
   its rendered page, an API member, a table row) is never split unless it is taller than a page. */
@media print {
  pre, pre code { white-space: pre-wrap !important; overflow-wrap: anywhere; overflow: visible !important; }

  h1, h2, h3, h4, h5, h6, figcaption, summary { break-after: avoid; break-inside: avoid; }
  h2 + p, h3 + p, h4 + p, h5 + p { break-after: avoid; }
  p { orphans: 3; widows: 3; }

  pre, figure, img, svg, table thead, tr, blockquote, li,
  [data-variant], [data-member], .rounded-lg, .rounded-xl, .rounded-2xl { break-inside: avoid; }

  /* Grid items are not kept whole across pages (an example's code was printed apart from its rendered page): printed,
     the examples' grids and the card grids are plain blocks, one under the other */
  [data-example] > .grid, main .grid:has(> .rounded-xl), main .grid:has(> figure) { display: block !important; }
  [data-example] > .grid > * + *, main .grid:has(> .rounded-xl) > * + *, main .grid:has(> figure) > * + * { margin-top: 1.25rem; }

  /* A page's title banner stays whole */
  main > section:first-child { break-inside: avoid; }

  /* An example's rendered pages, smaller on paper: the example's heading, its first code and its pages share a page */
  [data-variant] img { width: auto !important; max-width: 100%; max-height: 420px; }
  [data-variant] img:not(:only-child) { max-height: 300px; }

  /* The reference: an option's example and an API type each start a page */
  [data-example], [data-type] { break-before: page; border-top: 0 !important; padding-top: 0 !important; margin-top: 0 !important; }

  /* ssrs2.net/documentation: each numbered section starts a page; other pages' sections move whole when they fit */
  section[id].scroll-mt-32 + section[id].scroll-mt-32 { break-before: page; }
  article section, main section[id]:not(.scroll-mt-32), .wl-guide > section { break-inside: avoid; }

  /* the full documentation: each page of the site a chapter */
  [data-docs-chapter] { break-before: page; }
}
