/*
 * Print / "Save as PDF" layout rules.
 *
 * The docs are read on-screen in MkDocs Material, but the System Design &
 * Administrator Manual is also exported to PDF via the browser's print dialog.
 * On screen these rules do nothing; they only apply when printing.
 */
@media print {
  /* Each Part (##) and numbered subsection (###) starts on a fresh page. */
  .md-typeset h2,
  .md-typeset h3 {
    break-before: page;
    page-break-before: always; /* legacy alias for older print engines */
  }

  /* A subsection that immediately opens a Part shouldn't leave a near-empty
     page (e.g. "Part 1" followed straight away by "1.1"). */
  .md-typeset h2 + h3 {
    break-before: auto;
    page-break-before: auto;
  }

  /* Keep the document title on the first page. */
  .md-typeset h1 {
    break-before: avoid;
  }

  /* Never strand a heading alone on a page, split from the content that
     follows it. This previously left "1.4 Deployment diagram" on an otherwise
     blank page, with the tall diagram pushed onto further blank pages. */
  .md-typeset h1,
  .md-typeset h2,
  .md-typeset h3,
  .md-typeset h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Don't split a diagram, table, or code block across a page boundary. */
  .mermaid,
  .md-typeset table,
  .md-typeset pre {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Bound a tall diagram to a single page so it sits directly under its
     heading instead of overflowing onto blank pages. */
  .mermaid svg {
    max-height: 235mm;
    height: auto;
  }
}
