/* ==========================================================================
   MARQUEE — Print
   The board report is this buyer's most important artefact. Ctrl/Cmd-P on
   report-preview.html must produce something they can hand to a committee.
   ========================================================================== */

@page {
  size: A4;
  margin: 16mm 14mm 18mm;
}
@page :first {
  margin-top: 0;
}

@media print {
  :root {
    /* Ink-economical but still on-brand. Backgrounds are printed where they
       carry meaning, dropped where they are only decoration. */
    --shadow-xs: none; --shadow-sm: none; --shadow-md: none;
    --shadow-lg: none; --shadow-xl: none;
  }

  html, body {
    background: #fff;
    font-size: 10.5pt;
    line-height: 1.45;
    color: var(--ink);
  }

  /* Everything that is app chrome disappears */
  .sidebar, .topbar, .rail, .toaster, .tooltip, .menu, .scrim, .palette,
  .no-print, .page-actions, .tabs, .toolbar, .skip-link, .drawer,
  .nav-toggle, .board-col-head .btn { display: none !important; }

  .app { display: block; }
  .main { display: block; }
  .page { padding: 0; max-width: none; }

  a { color: inherit; text-decoration: none; }
  /* Only expose URLs for genuinely external links, never for in-app nav */
  a[href^='http']::after {
    content: ' (' attr(href) ')';
    font-size: 8pt;
    color: var(--muted);
    word-break: break-all;
  }

  /* ------------------------------------------------------------------------
     Report document
     ------------------------------------------------------------------------ */
  .doc { max-width: none; margin: 0; box-shadow: none; border: 0; }
  .doc-page {
    box-shadow: none;
    border: 0;
    margin: 0;
    padding: 0;
    width: auto;
    min-height: 0;
    break-after: page;
    page-break-after: always;
  }
  .doc-page:last-child { break-after: auto; page-break-after: auto; }

  /* Cover bleeds to the page edge */
  .doc-cover {
    background: var(--chrome) !important;
    color: var(--chrome-ink) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    margin: -16mm -14mm 0;
    padding: 32mm 14mm;
    min-height: 297mm;
    break-after: page;
    page-break-after: always;
  }
  .doc-cover * { color: inherit !important; }

  h1, h2, h3, h4 { break-after: avoid; page-break-after: avoid; }
  h2 { font-size: 15pt; margin-top: 0; }
  h3 { font-size: 12pt; }

  p, li { orphans: 3; widows: 3; }

  .panel, .card-link, .callout, figure, .chart-wrap, .stat {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .panel { border: 1px solid var(--line-strong); border-radius: 0; }
  .panel-head { background: transparent; border-bottom: 1px solid var(--line-strong); }
  .panel-quiet { background: transparent; border: 1px solid var(--line); }

  /* Tables must repeat their header across pages */
  table { break-inside: auto; width: 100%; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  .table thead th {
    position: static;
    background: var(--surface-2) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 8.5pt;
  }
  .table tbody td { padding: 4pt 6pt; font-size: 9.5pt; }
  .table-stack tbody tr { display: table-row; border: 0; padding: 0; margin: 0; }
  .table-stack tbody td { display: table-cell; }
  .table-stack tbody td::before { content: none; }
  .table-stack thead { display: table-header-group; }

  /* Charts and badges keep their colour — they carry the meaning */
  svg, .badge, .progress-bar, .meter span, .dot, .ring-fill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .badge { border: 1px solid var(--line-strong); }

  /* Running header/footer band inside each doc page */
  .doc-running {
    display: flex !important;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 4pt;
    margin-bottom: 10pt;
    font-size: 8pt;
    color: var(--muted);
  }

  .print-only { display: block !important; }
  .scroll-x { overflow: visible !important; }

  /* No motion in print */
  * { animation: none !important; transition: none !important; }
}

/* Hidden on screen, revealed in print */
.print-only { display: none; }

/* --------------------------------------------------------------------------
   On-screen document preview — an A4 sheet on a desk, so what the user sees
   is what the PDF gives them
   -------------------------------------------------------------------------- */
.doc-stage {
  background: var(--surface-3);
  padding: var(--s-7) var(--s-5) var(--s-10);
  min-height: 100%;
}
.doc {
  max-width: 210mm;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}
.doc-page {
  width: 100%;
  min-height: 297mm;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  padding: 18mm 16mm;
  display: flex;
  flex-direction: column;
}
.doc-cover {
  background: var(--chrome);
  color: var(--chrome-ink);
  padding: 26mm 16mm;
  justify-content: space-between;
}
.doc-running { display: none; }

@media (max-width: 760px) {
  .doc-stage { padding: var(--s-4) var(--s-2) var(--s-8); }
  .doc-page { min-height: 0; padding: var(--s-6) var(--s-4); }
  .doc-cover { padding: var(--s-8) var(--s-4); }
}
