/* styles/print.css: the print sheet and its progress panel.
   Printing renders every page of the open PDF into #kp-print-root as an image
   and calls window.print() on the main window (see js/tools/read-print.js).
   Those images must never show on screen, and nothing but those images may
   reach the paper. */

/* Off-screen on screen. The images exist in the document only so the print
   preview can find them. */
#kp-print-root { display: none; }

@media print {
  /* Only while a print job is staged: the class is added right before
     window.print() and removed on afterprint, so an ordinary Ctrl+P of some
     other page is left alone. */
  html.kp-printing body > *:not(#kp-print-root) { display: none !important; }
  html.kp-printing #kp-print-root { display: block; }

  html.kp-printing,
  html.kp-printing body {
    margin: 0;
    padding: 0;
    background: #fff;
  }

  /* One image per sheet. `break-after` is the current property and
     `page-break-after` the legacy one; both are listed because print engines
     are uneven about which they honour. */
  html.kp-printing .kp-print-page {
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
    margin: 0;
  }
  html.kp-printing .kp-print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  html.kp-printing .kp-print-page img {
    display: block;
    width: 100%;
    height: auto;
  }
}

/* ---- progress panel ----------------------------------------------------- */
/* A large document takes a few seconds to render, and silence there reads as
   the same "print does nothing" bug this route was written to fix. Bottom
   right, because the toast and the make-us-your-default prompt both own the
   bottom centre and a print job can be on screen at the same time as either. */
.kp-print-progress {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9500;
  width: min(360px, calc(100vw - 48px));
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
  animation: kpRise .22s cubic-bezier(.2, .7, .3, 1) both;
}
.kp-print-progress.is-leaving {
  animation: kpFadeDown .18s ease-in both;
}
.kp-print-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.kp-print-progress .progress-label {
  font-size: 13px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.kp-print-progress .progress-track {
  position: relative;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.kp-print-progress .progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width .2s ease;
}
.kp-print-progress .kp-print-cancel {
  flex-shrink: 0;
  transition: border-color .15s, box-shadow .15s, color .15s;
}
.kp-print-progress .kp-print-cancel:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.kp-print-progress .kp-print-cancel:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* The panel is chrome, never ink. Also covered by the body > * rule above,
   but stated here so it holds even when the print root is not staged. */
@media print {
  .kp-print-progress { display: none !important; }
}
