/* 017 Sales Report PDF — print-only rules.
 *
 * Served by Propshaft and linked ONLY from layouts/report_print.html.erb (the headless
 * renderer's target). Everything is scoped under @media print so it is inert on screen
 * and only shapes the printToPDF output. Selector names MUST match the HTML hooks the
 * report partials render (data-report-level, .report-field-group, .report-photo-strip,
 * .report-entry) — a following agent adds those hooks. */
@media print {
  html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  section[data-report-level="1"] { break-before: page; }
  section[data-report-level="1"]:first-of-type { break-before: avoid; }
  .report-field-group, .report-photo-strip, .report-entry { break-inside: avoid; }
  .rpt-row { break-inside: avoid; }
  figure, img { break-inside: avoid; }

  /* FIX 1 (018) — a section/subsection heading or banner must never be orphaned at the
     foot of a page. `break-after: avoid` pushes the heading to the next page WITH the
     content beneath it (e.g. the green "LEFT SLOPE" banner must travel to its photos). */
  .rpt-h1, .rpt-band, .rpt-dirbanner, .rpt-accent-subhead,
  h1, h2, h3, h4 { break-after: avoid; }

  /* 018 — the reference gives the signature sections and each reference chapter its own
     page (cover p1, TOC p2, Claim & Inspection Details p3, then a page per group). The
     cover is naturally the first page; the TOC and every group start a fresh one. Each
     group heading stays with the content beneath it, so no chapter title is orphaned. */
  .report-toc { break-before: page; }
  .report-group { break-before: page; }
  .report-group > h2 { break-after: avoid; }

  /* T-021 — Claim & Inspection Details is the first section of the dynamic Project
     group (which already starts a fresh page). Break AFTER it so the first dynamic
     chapter starts on its own page (p4), keeping claim details contained to page 3. */
  .report-claim { break-after: page; }
}
