/* Print-only surface. One margin system: @page owns the 20mm margin, so
   .ws-page prints at its native 170mm content width with no extra
   wrapper padding (blueprint 8.5) — avoids doubling the margin. */

@page {
  size: A4 portrait;
  margin: 20mm;
}

@media print {
  html, body {
    margin: 0;
    padding: 0;
    background: #ffffff;
  }

  /* Hide the interactive UI and print #print-surface in normal document
     flow (upgrade blueprint v3, workstream A) — replaces the old
     visibility:hidden + position:absolute hack. That approach worked for
     content that was always exactly one page, but content taller than one
     page inside an absolutely-positioned box is not reliably fragmented
     across printed pages by every engine; normal flow is. .app-shell
     already carries the .no-print class below, so this rule is just the
     explicit, load-bearing version of the same hiding for this element. */
  .app-shell {
    display: none;
  }

  #print-surface {
    position: static;
  }

  .ws-page {
    width: 170mm;
    box-shadow: none;
    /* Packet printing puts more than one .ws-page into #print-surface —
       break after every sheet except the last (blueprint 8.5: "Use
       break-after: page between packet sheets and auto after the last
       sheet"). A lone single-worksheet print is unaffected: one page,
       breaking to auto right after it, same as before. */
    break-after: page;
  }

  .ws-page:last-child {
    break-after: auto;
  }

  /* Tint prints only when the teacher explicitly opted in (printTint) —
     otherwise fall back to white to save ink, regardless of the on-screen
     preview color (blueprint 8.5). */
  .ws-page.ws-page--tinted:not(.ws-page--print-tint) {
    background: #ffffff;
  }

  /* Same ink-saving default for zebra striping (blueprint 8.5/8.6). */
  .ws-page.ws-page--striped:not(.ws-page--print-stripes) .ws-line-stripes {
    display: none;
  }

  .no-print {
    display: none !important;
  }

  /* Gap-fill: the gap prints, its answer doesn't (the box keeps its size). */
  .ws-blank-answer {
    visibility: hidden;
  }

  .ws-body--answers .ws-blank-answer {
    visibility: visible;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
