/* Shared report pagination. Load after the report-family styles.
   These rules affect the temporary print clone only. The browser keeps a
   section on one page whenever it fits, and may split an oversized section
   at its normal content boundaries. No report content or page height is
   rewritten, so the repeated letterhead and QR footer keep their own space. */
@media print {
  body.cnb-printing .cnb-print-root .cnb-report.cnb-report :is(
    section, article, details, aside, figure, blockquote, footer,
    .cnb-report-cover, .cnb-report-summary, .cnb-report-chart,
    .cnb-report-scale, .cnb-report-context, .cnb-report-source,
    .cnb-report-note, .cnb-assessment-identity,
    .cnb-experience-card, .cnb-experience-context,
    .cnb-experience-symptom, .cnb-experience-trend-series,
    .cnb-xp-card, .cnb-xp-topic, .cnb-xp-episode,
    .cnb-original-experiment, .cnb-report-profile-block
  ):not(.cnb-report) {
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
  }

  /* A section too large for one page must still keep its title, any short
     eyebrow, and the beginning of its content together. Title wrappers are
     used by the custom, structured, and experience report renderers. */
  body.cnb-printing .cnb-print-root .cnb-report.cnb-report :is(
    h1, h2, h3, h4, h5, h6, summary, caption,
    section > header:not(.cnb-report-cover), article > header:not(.cnb-report-cover),
    section > b:first-child, section > strong:first-child,
    article > b:first-child, article > strong:first-child,
    [class$="-eyebrow"], [class$="-kicker"],
    [class$="-section-title"], [class$="-card-title"],
    [class$="-tracker-heading"], [class$="-facet-heading"], article > [class$="-topics"],
    .cnb-assessment-bar-head, .cnb-original-domain
  ) {
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
    page-break-after: avoid !important;
    break-after: avoid-page !important;
  }

  body.cnb-printing .cnb-print-root .cnb-report.cnb-report :is(
    h1, h2, h3, h4, h5, h6, summary,
    section > header:not(.cnb-report-cover), article > header:not(.cnb-report-cover),
    section > b:first-child, section > strong:first-child,
    article > b:first-child, article > strong:first-child,
    [class$="-section-title"], [class$="-card-title"],
    [class$="-tracker-heading"], [class$="-facet-heading"], article > [class$="-topics"],
    .cnb-assessment-bar-head, .cnb-original-domain
  ) + :is(p, blockquote) {
    page-break-before: avoid !important;
    break-before: avoid-page !important;
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
  }

  body.cnb-printing .cnb-print-root .cnb-report.cnb-report :is(p, li, dd) {
    orphans: 3;
    widows: 3;
  }

  /* Let long tables continue across pages, repeating their column labels.
     A normal row remains intact; an exceptionally long row may split by
     the same native oversized-block fallback as a report section. */
  body.cnb-printing .cnb-print-root .cnb-report.cnb-report .cnb-table-wrap {
    overflow: visible !important;
  }
  body.cnb-printing .cnb-print-root .cnb-report.cnb-report table {
    page-break-inside: auto !important;
    break-inside: auto !important;
  }
  body.cnb-printing .cnb-print-root .cnb-report.cnb-report thead {
    display: table-header-group !important;
    page-break-after: avoid !important;
    break-after: avoid-page !important;
  }
  body.cnb-printing .cnb-print-root .cnb-report.cnb-report tr {
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
  }
}
