/* ============================================================
   Print view — the ?print=1 document (visitech-core templates/print.php).

   Loaded LAST on that document, after the theme chain and after every
   block sheet the render pass enqueued, so anything here wins. Two jobs:
   the SCREEN look (a paper-shaped preview: grey backdrop, white sheet,
   options toolbar) and the PRINT mechanics (page breaks, fragmentation).
   The @page rule itself lives in an inline <style id="vt-page-size"> in the
   template so the size select can rewrite it — and note @page `size` is
   honored by Chromium only; elsewhere the reader picks paper in the dialog,
   which is fine because the sheet layout never depends on it.

   There is no .vt-section on this document, so the blocks' @container
   vt-section queries never match and every block renders its desktop
   (un-queried) layout — that is relied on, not an accident.
   ============================================================ */

body.print-view {
  margin: 0;
  background: #eae8ee;
  color: var(--color-text);
  font-family: var(--font-body);
}

/* ---- toolbar (screen only) ---------------------------------- */

.print-toolbar {
  max-width: 620px;
  margin: 0 auto;
  padding: 40px 20px 48px;
}

.print-toolbar__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: 24px;
  color: var(--color-text);
}

.print-toolbar__hint {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.print-toolbar__options {
  padding: 6px 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.print-toolbar__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  font-size: 15px;
}
.print-toolbar__row + .print-toolbar__row { border-top: 1px solid var(--color-divider); }

.print-toolbar__row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--color-dark-purple);
}

.print-toolbar__row--size { justify-content: space-between; }
.print-toolbar__row--size select {
  padding: 6px 10px;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}

.print-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.print-toolbar__back {
  font-size: 15px;
  color: var(--color-link);
  text-decoration: none;
}
.print-toolbar__back:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

.print-toolbar__noscript {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ---- the sheet ----------------------------------------------- */

.print-page {
  box-sizing: border-box;
  width: 210mm;
  max-width: calc(100% - 32px);
  min-height: 297mm;
  margin: 0 auto 64px;
  padding: 14mm 16mm;
  background: var(--color-bg);
  border-radius: 6px;
  box-shadow: 0 16px 48px rgba(42, 42, 50, 0.2);
}
body[data-size="a3"] .print-page {
  width: 297mm;
  min-height: 420mm;
}

.print-brandbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--color-dark-purple);
}
.print-brandbar__logo { height: 26px; width: auto; }
.print-brandbar__date { font-size: 12px; color: var(--color-text-muted); }

/* Atoms carry no margins — the container owns the spacing, and on this
   document the container is the part. */
.print-part { margin: 0 0 9mm; }
.print-part > * + * { margin-top: 12px; }

.print-part__heading {
  margin: 0 0 4mm;
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: 19px;
  color: var(--color-dark-purple);
}

/* identity: the document header */
.print-identity__title {
  margin: 6px 0 2px;
  font-family: var(--font-display);
  font-weight: 200; /* a real Amplitude 200 outline now backs this (2026-09-04) — see assets/fonts/README.md */
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.print-part--identity .vt-text { color: var(--color-text-muted); }

/* overview: content stack beside the product image */
.print-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 8mm;
  align-items: start;
}
.print-overview__body > * + * { margin-top: 12px; }
.print-overview__media { margin: 0; }
.print-overview__img { max-width: 100%; height: auto; }

/* paper-friendly sizes for the re-rendered blocks */
.print-page .vt-lenses { --vt-lenses-pad-x: 10px; } /* the block declares this token on itself, so the override must too */
.print-page .vt-lenses__table { font-size: 12.5px; }
.print-page .vt-lenses__name,
.print-page .vt-lenses__cell { padding-block: 8px; }
.print-page .vt-metrics {
  /* 160px tracks are the band's; four of them overflow a 178mm sheet by 22px
     and wrap 3+1. 140px keeps the mockup's four-up row on A4. */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.print-page .vt-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: 20px;
  line-height: 1.2;
  color: var(--color-text);
}
.print-page .vt-text { font-size: 14px; line-height: 1.55; }
.print-page .vt-text--small { font-size: 11.5px; color: var(--color-text-muted); }
.print-page .vt-metric { padding: 12px; }
.print-page .vt-card {
  padding: 16px;
  box-shadow: none;
}
.print-page .vt-cards {
  /* 280px tracks give 2-up on a 178mm sheet and orphan the third card onto
     the next page; 180px keeps the mockup's three-up row. */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.print-footer {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 10mm;
  padding-top: 4mm;
  border-top: 1px solid var(--color-border);
  font-size: 10.5px;
  color: var(--color-text-muted);
}

/* ---- paper --------------------------------------------------- */

@media print {
  body.print-view { background: #fff; }

  .print-toolbar { display: none; }

  .print-page {
    width: auto;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .print-page,
  .print-page * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* never orphan a heading from what it announces */
  .print-brandbar,
  .print-part__heading,
  .print-page .vt-title,
  .vt-specs__label { break-after: avoid; }

  .print-brandbar,
  .print-overview__media,
  .vt-metric,
  .vt-card,
  .vt-specs__row,
  .print-footer { break-inside: avoid; }

  /* The spec GRID fragments badly across pages (a grid row is atomic);
     multicol fragments correctly, so paper swaps the mechanism. */
  .print-part--specs .vt-specs,
  .print-part--specs .vt-specs--cols-2 {
    display: block;
    column-count: 2;
    column-gap: 8mm;
  }
  .print-part--specs .vt-specs__group {
    break-inside: avoid;
    margin-bottom: 5mm;
  }

  /* the lens table may outgrow a page: let it break BETWEEN rows and
     repeat its header on each page; the scroll wrapper would clip that */
  .vt-lenses__scroll { overflow: visible; }
  .vt-lenses__table { break-inside: auto; }
  .vt-lenses__table thead { display: table-header-group; }
  .vt-lenses__row { break-inside: avoid; }

  .print-overview__img { max-height: 70mm; width: auto; }

  /* paper links: no browser-appended URLs, no dead underlines */
  .print-page a[href]::after { content: none; }
  .print-page a {
    color: inherit;
    text-decoration: none;
  }
}
