/*
 * Print stylesheet shared by all 40 resume builders (loaded by
 * outputPlanCheckScript() in includes/plan-check.php, media="print").
 *
 * Prints the resume preview and nothing else: the "Templates" bar, the
 * form, buttons, modals, the cookie notice and the finder widget are hidden
 * whatever their class names, because everything that neither is, contains
 * nor sits inside #resumePreview is hidden. The preview's ancestors are
 * reset so a fixed-height, scrolling editor layout cannot clip the page.
 *
 * Template print rules still apply inside the preview; the rules here use
 * !important only where an editor layout would otherwise break printing.
 * Browsers without :has() (before Chrome 105 / Safari 15.4 / Firefox 121)
 * fall back to each template's own print rules.
 */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
    display: block !important;
  }

  /* Everything that is not the preview, inside it, or one of its ancestors. */
  body *:not(#resumePreview):not(#resumePreview *):not(:has(#resumePreview)) {
    display: none !important;
  }

  /* The preview's ancestors: no fixed heights, scrolling, padding or shadows. */
  body *:has(#resumePreview) {
    display: block !important;
    position: static !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: none !important;
    transform: none !important;
  }

  #resumePreview {
    width: 210mm !important;
    max-width: 210mm !important;
    min-width: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    transform: none !important;
    zoom: 1 !important;
  }

  /* Keep the template's colours (backgrounds are off by default in print). */
  #resumePreview,
  #resumePreview * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Repeat a column's padding at the top of each new page. */
  #resumePreview > * {
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  /* Page breaks: keep single entries and headings with what follows. */
  #resumePreview :is(li, p,
    [class*="-entry"], [class*="-card"],
    [class*="-item"]:not([class*="items"]):not([class*="list"])) {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  #resumePreview :is(h1, h2, h3, h4, [class*="section-title"], [class*="-title"]) {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Empty date pills and year lines (see assets/js/resume-dates.js). */
  #resumePreview [class*="date"]:empty,
  #resumePreview [class*="year"]:empty {
    display: none !important;
  }
}
