/* Shared pagination for SORA input, checklist and BVLOS authorisation. */
@page { size: A4; margin: 15mm 10mm; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html, body { height: auto !important; min-height: 0 !important; overflow: visible !important; background: white !important; }
  body:has(#printForm) > :not(main) { display: none !important; }
  main:has(#printForm), main :has(#printForm) {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: 0 !important;
  }
  main:has(#printForm) > :not(:has(#printForm)):not(#printForm),
  form:has(> #printForm) > :not(#printForm),
  .no-print, .print\:hidden, #checklist-loading, #landing-loading,
  #loading-overlay, #tmi-pathways-modal, #scrollToTopBtn { display: none !important; }
  #printForm {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: visible !important;
  }
  #printForm * { visibility: visible !important; }
  /* Grow to the text at paper width instead of keeping the screen height. */
  #printForm textarea {
    field-sizing: content;
    height: auto !important;
    max-height: none !important;
    overflow-wrap: anywhere;
    overflow: hidden !important;
  }
  #printForm :is(.overflow-x-auto, .overflow-auto, .overflow-hidden):not(textarea) {
    overflow: visible !important;
    max-height: none !important;
  }
  #printForm table { width: 100% !important; min-width: 0 !important; border-collapse: collapse !important; break-inside: auto; }
  #printForm table, #printForm th, #printForm td { border: 1px solid #000 !important; }
  /* Print headers once, keeping them with the first content row. */
  #printForm thead {
    display: table-row-group !important;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: avoid;
    page-break-after: avoid;
  }
  #printForm thead + tbody > tr:first-child {
    break-before: avoid;
    page-break-before: avoid;
  }
  #printForm tr:has(> th) {
    break-after: avoid;
    page-break-after: avoid;
  }
  #printForm tr { break-inside: avoid; page-break-inside: avoid; }
  #printForm h1, #printForm h2, #printForm h3,
  #printForm h4, #printForm h5, #printForm h6 {
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: avoid;
    page-break-after: avoid;
  }
  /* Preserve the heading-to-table link across scroll wrappers. */
  #printForm :is(h1, h2, h3, h4, h5, h6) + :is(.overflow-x-auto, .overflow-auto, table) {
    break-before: avoid;
    page-break-before: avoid;
  }
  #printForm img, #printForm canvas, #printForm svg {
    max-width: 100% !important;
    max-height: 220mm !important;
    object-fit: contain;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  #printForm img {
    display: block !important;
    width: auto !important;
    height: auto !important;
    margin-left: auto;
    margin-right: auto;
  }
  /* Leave room below the authorisation map for the signature and date. */
  #bvlosAuthorisationForm img { max-height: 180mm !important; }
  #bvlosAuthorisationForm tr:has(+ tr img) { break-after: avoid; page-break-after: avoid; }
  #printForm .print-image-stack { display: block !important; }
  #printForm .print-image-card { break-inside: avoid; page-break-inside: avoid; margin-bottom: 6mm; }
}
