/* ==========================================================================
   Print — the certificate of completion and a completed envelope on paper.
   Everything interactive is dropped; the record itself is kept.
   ========================================================================== */

@media print {
  @page {
    size: letter portrait;
    margin: 14mm 13mm;
  }

  /* Force the light record palette regardless of the on-screen theme. */
  :root,
  :root[data-theme="dark"] {
    --bg-app: #ffffff;
    --bg-canvas: #ffffff;
    --bg-surface: #ffffff;
    --bg-sunken: #ffffff;
    --bg-raised: #ffffff;
    --bg-hover: #ffffff;
    --bg-selected: #ffffff;
    --tx-1: #14181d;
    --tx-2: #333c46;
    --tx-3: #55636f;
    --tx-4: #6d7d8e;
    --br-1: #d7dde3;
    --br-2: #c3ccd5;
    --br-3: #aab4bf;
    --paper: #ffffff;
    --paper-ink: #14181d;
  }

  html, body {
    height: auto !important;
    background: #fff !important;
    color: #14181d !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* --------------------------------------------------------- chrome away */
  #boot,
  #toasts,
  #overlays,
  .skip-link,
  .sh-top,
  .sh-nav,
  .sh-navscrim,
  .tip,
  .menu,
  .no-print,
  .ag-bulk,
  .ag-toolbar,
  .ag-chips,
  .ag-saved,
  .ag-pager,
  .ph__actions,
  .cert-actions,
  .env-actions,
  .env-tabs,
  .tabs,
  .iconbtn,
  .btn {
    display: none !important;
  }

  .sh, .sh-main, .sh-content { display: block !important; min-height: 0 !important; }
  .sh-content { overflow: visible !important; }

  .page {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
  }

  /* ------------------------------------------------------------- generic */
  .card,
  .cert-paper {
    border: 1px solid #d7dde3 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: #fff !important;
  }

  .card,
  .cert-block,
  .cert-erow,
  .env-doc,
  .recip-row,
  .tl__row,
  .trail__step {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  h1, h2, h3, .cert-h, .card__title { page-break-after: avoid; break-after: avoid; }

  .skel { display: none !important; }
  .card__foot { background: #fff !important; }
  a[href]:after { content: ""; }

  /* ----------------------------------------------------------- envelope */
  .env-head { margin-bottom: 10mm; }
  .env-head__meta { color: #55636f !important; }
  .env-banner .banner {
    border: 1px solid #c3ccd5 !important;
    background: #fff !important;
    border-radius: 0 !important;
  }
  .env-grid { display: block !important; }
  .env-grid > .col { display: block !important; }
  .env-grid .card { margin-bottom: 6mm; }
  .env-recip__chev { display: none !important; }
  /* expand every recipient so the printed record is complete */
  .env-recip .env-recipdetail { display: block !important; }
  .env-recipdetail { background: #fff !important; }
  .env-message { border-left-color: #c3ccd5 !important; }
  .env-tabpanel { display: block !important; }

  /* ---------------------------------------------------------- certificate */
  .cert { max-width: none !important; }
  .cert-paper {
    padding: 0 !important;
    border: 0 !important;
    max-width: none !important;
    font-size: 10.5pt;
  }
  .cert-head {
    border-bottom: 2pt solid #1b2128 !important;
    page-break-after: avoid;
  }
  .cert-head__title h1 { font-size: 18pt; }
  .cert-block { margin-bottom: 7mm; }
  /* paper is narrow, but the certificate keeps its two-column record layout */
  .cert-head { flex-direction: row; gap: var(--s-9); }
  .cert-head__title { margin-left: auto; text-align: right; }
  .cert-head__title p { max-width: 34ch; }
  .cert-summary, .cert-track { grid-template-columns: 1fr 1fr; gap: 4mm 7mm; }
  .cert-row { grid-template-columns: 108px 1fr; gap: var(--s-4); }
  .cert-row dt { margin-top: 0; }
  .cert-ehead { display: grid; }
  .cert-erow { grid-template-columns: 1.2fr 1fr 1fr; }
  .cert-table { display: table; overflow: visible; }
  .cert-consent { background: #fff !important; border-left: 2pt solid #2c5ce6 !important; }
  .cert-hash, .cert-nonerow { background: #fff !important; }
  .cert-foot { margin-top: 8mm; }

  /* signature ink must survive the print pipeline */
  .sigvis__type, .sigvis__img { color: #14181d !important; }
  .env-fv__txt, .env-fv--sig .sigvis__type { color: #14181d !important; }
}
