/*
 * Finance Toolkit — print.css  (media="print")
 * Print / "Save as PDF" styling for a tool page. Fluid layout so the same sheet
 * fits any paper size the browser dialog selects (A4, Letter, Legal, A5); the
 * optional .ftk-paper-* classes on <html> force a specific size when the site
 * wants one. No colour literals belong here except the print-only ink defaults,
 * which are greyscale system values, not brand palette tokens.
 */

@media print {
  /* Fluid margins in mm adapt to whatever paper the user picks. */
  @page {
    margin: 14mm;
  }

  /* Hide interactive-only chrome. */
  .ftk-export-bar,
  .ftk-fb,
  .ftk-share-menu,
  .ftk-lead-modal,
  .ftk-lead-backdrop {
    display: none !important;
  }

  /* Let the tool column use the full sheet width and avoid awkward breaks. */
  .ftk-tool-page {
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Keep small blocks whole, but do NOT keep a whole long tool/table together —
     that is what pushed a big schedule onto a fresh page and left the previous
     one half-empty. Only individual rows and cards stay unbroken. */
  .ftk-result-card,
  .ftk-results,
  .ftk-chart,
  table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Long tables flow across pages and repeat their header (and footer) row on
     each new page instead of breaking awkwardly. */
  table {
    break-inside: auto;
    page-break-inside: auto;
  }
  thead {
    display: table-header-group;
  }
  tfoot {
    display: table-footer-group;
  }

  /* Print-only branded header, injected by export.js before window.print(). */
  .ftk-print-head {
    display: flex !important;
    align-items: center;
    gap: 12px;
    border-bottom: 2pt solid currentColor;
    padding-bottom: 8pt;
    margin-bottom: 12pt;
  }

  .ftk-print-head img {
    max-height: 48px;
    width: auto;
  }

  .ftk-print-head__brand {
    font-size: 15pt;
    font-weight: 700;
  }

  .ftk-print-head__meta {
    font-size: 8pt;
    line-height: 1.4;
    margin-left: auto;
    text-align: right;
  }

  /* Print-only footer with contact/site details. */
  .ftk-print-foot {
    display: block !important;
    border-top: 1pt solid currentColor;
    margin-top: 14pt;
    padding-top: 6pt;
    font-size: 8pt;
    line-height: 1.4;
    opacity: 0.7;
  }

  /* Make links legible on paper without relying on colour. */
  .ftk-tool-page a {
    text-decoration: underline;
  }
}

/* Print helpers are hidden on screen; only the print media block reveals them. */
.ftk-print-head,
.ftk-print-foot {
  display: none;
}

/* Optional forced paper sizes: set <html class="ftk-paper-a4"> (etc.) before
   printing to pin the sheet; otherwise the browser dialog's choice wins. */
@page ftk-a4 { size: A4; }
@page ftk-letter { size: Letter; }
@page ftk-legal { size: Legal; }
@page ftk-a5 { size: A5; }
html.ftk-paper-a4 body { page: ftk-a4; }
html.ftk-paper-letter body { page: ftk-letter; }
html.ftk-paper-legal body { page: ftk-legal; }
html.ftk-paper-a5 body { page: ftk-a5; }
