/* Connect+ Dashboard Editor - print stylesheet ("Export PDF").
   Operator ruling 2026-10-20: PDF export is the browser's print-to-PDF, so
   this file IS the PDF renderer. js/print.js fills #print-header at
   `beforeprint`; screens/dash.js swaps the grid to its paged flow
   (.dash-grid--print) for the same window. Screen rendering is untouched
   except for keeping the header hidden. */

.print-header { display: none; }

@media print {
  @page { margin: 12mm; }

  /* Light, high-contrast palette whatever theme/palette is active on screen.
     `!important` because the theme and palette rules are attribute selectors
     on :root that would otherwise outrank this. Accent is darkened: the
     on-screen neon greens are illegible on white paper. */
  html:root {
    --bg: #FFFFFF !important;
    --sf: #FFFFFF !important;
    --sf2: #F2F2F2 !important;
    --ln: rgba(0, 0, 0, .35) !important;
    --tx: #000000 !important;
    --tx2: #333333 !important;
    --ac: #0A6E00 !important;
    --acT: rgba(10, 110, 0, .12) !important;
    --acFg: #FFFFFF !important;
    --amb: #8A5300 !important;
    --red: #B00020 !important;
    color-scheme: light;
  }

  /* The app is a fixed full-viewport shell that scrolls internally; paper
     needs the document to flow and paginate instead. */
  html, body,
  #screen-root, .dash-screen, .dash-body, .dash-grid-wrap {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  body { display: block !important; background: #FFFFFF !important; color: #000000 !important; }
  #screen-root, .dash-grid-wrap { padding: 0 !important; }
  .dash-body { display: block !important; }

  *, *::before, *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
    /* Keep card backgrounds/status colours - they carry meaning. */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Chrome: top bar, impersonation banner, editor tray/rails, toasts,
     modals, menus, drag affordances, and every button. */
  #topbar-root,
  #impersonation-banner,
  #toast-root,
  .cp-modal-scrim,
  .cp-modal,
  .menu,
  .menu-backdrop,
  .edit-toolbar,
  .lib-rail,
  .settings-rail,
  .dash-small-edit-note,
  .grid-ghost,
  .drag-chip,
  .w-cfg,
  .w-resize-handle,
  .sa-controls,
  button {
    display: none !important;
  }

  /* Print header: what this is, whose it is, and for when. */
  .print-header {
    display: block;
    margin: 0 0 6mm;
    padding: 0 0 3mm;
    border-bottom: 2px solid #000000;
    color: #000000;
    font-family: var(--font-body);
  }
  .print-header-title {
    font: 600 18pt var(--font-display);
    margin: 0 0 2mm;
  }
  .print-header-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 1mm 4mm;
    margin: 0;
    font-size: 10pt;
  }
  .print-header-meta dt { font-weight: 600; }
  .print-header-meta dd { margin: 0; }

  /* Dashboard: flowed grid (column shares kept by dash.js), and no widget is
     ever split across two pages. */
  .dash-grid--print {
    display: flex !important;
    flex-flow: row wrap !important;
    align-items: flex-start;
    gap: 0 !important;
  }
  .dash-grid--print .widget-slot { padding: 1.5mm !important; }
  .widget-slot,
  .widget-card-outer,
  .sa-card,
  .sa-metric,
  .sa-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .widget-card-outer { border-color: rgba(0, 0, 0, .35) !important; }

  /* Settings → Reports "Export PDF" prints only the Reports card. */
  body[data-print-scope="report"] .sa-head,
  body[data-print-scope="report"] .sa-card:not(#sa-reports) {
    display: none !important;
  }
  body[data-print-scope="report"] .sa-screen { max-width: none; padding: 0; }
  body[data-print-scope="report"] .sa-card { border: 0; padding: 0; }
}
