/* ================================================================
   print.css — COHO Analytics
   Print-friendly stylesheet: B&W optimized, URLs shown,
   interactive UI removed.
   ================================================================ */

@media print {

  /* ----------------------------------------------------------------
     1. PAGE SETUP
     ---------------------------------------------------------------- */
  @page {
    margin: 2cm 1.5cm;
    size: A4 portrait;
  }

  @page :first {
    margin-top: 3cm;
  }

  /* ----------------------------------------------------------------
     2. BASE RESET FOR PRINT
     ---------------------------------------------------------------- */
  *,
  *::before,
  *::after {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border-color: #ccc !important;
    transition: none !important;
    animation: none !important;
  }

  html, body {
    font-size: 11pt;
    line-height: 1.5;
    background: #fff !important;
    color: #000 !important;
    overflow: visible !important;
  }

  /* ----------------------------------------------------------------
     3. HIDE INTERACTIVE / NAVIGATION ELEMENTS
     ---------------------------------------------------------------- */
  header.site-header,
  footer.site-footer,
  nav,
  .site-nav,
  .nav-wrap,
  .mobile-menu-btn,
  .dark-mode-toggle,
  .skip-link,
  .btn,
  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  select,
  .toolbar,
  .controls-row,
  .leaflet-control,
  .leaflet-control-container,
  [role="complementary"],
  aside {
    display: none !important;
  }

  /* ----------------------------------------------------------------
     4. LAYOUT — full-width, no shell styling
     ---------------------------------------------------------------- */
  main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .container,
  .wrap,
  .page-container {
    max-width: 100% !important;
    padding: 0 !important;
  }

  /* ----------------------------------------------------------------
     5. TYPOGRAPHY
     ---------------------------------------------------------------- */
  h1 { font-size: 20pt; break-after: avoid; }
  h2 { font-size: 16pt; break-after: avoid; }
  h3 { font-size: 13pt; break-after: avoid; }
  h4, h5, h6 { font-size: 11pt; break-after: avoid; }

  p, li, td { font-size: 10pt; }

  /* ----------------------------------------------------------------
     6. SHOW URLS FOR LINKS
     ---------------------------------------------------------------- */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #555 !important;
    word-break: break-all;
  }

  /* Don't show URLs for internal anchors or JS-only links */
  a[href^="#"]::after,
  a[href^="javascript"]::after,
  nav a::after,
  .btn::after {
    content: none;
  }

  /* ----------------------------------------------------------------
     7. PAGE BREAKS
     ---------------------------------------------------------------- */
  h1, h2, h3, h4 { break-after: avoid; }

  .card,
  .panel,
  .kpi-card,
  .stat-card,
  .feature-card,
  figure {
    break-inside: avoid;
  }

  tr    { break-inside: avoid; break-after: auto; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }

  /* ----------------------------------------------------------------
     8. PRINT-FRIENDLY CARD SIZING
     ---------------------------------------------------------------- */
  .card,
  .panel,
  .kpi-card,
  .stat-card {
    border: 1px solid #ccc !important;
    padding: 12pt !important;
    margin-bottom: 10pt !important;
    border-radius: 0 !important;
  }

  .kpi-grid,
  .census-grid,
  .features-grid,
  .metric-grid {
    display: block !important;
  }

  .kpi-grid > *,
  .census-grid > *,
  .features-grid > *,
  .metric > * {
    display: block !important;
    width: 100% !important;
    margin-bottom: 8pt !important;
  }

  /* ----------------------------------------------------------------
     9. TABLES
     ---------------------------------------------------------------- */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    break-inside: auto;
  }

  th, td {
    border: 1px solid #ccc !important;
    padding: 6pt 8pt !important;
  }

  th { font-weight: 700; }

  /* ----------------------------------------------------------------
     10. IMAGES
     ---------------------------------------------------------------- */
  img {
    max-width: 100% !important;
    break-inside: avoid;
  }

  /* Leaflet maps: print placeholder */
  .leaflet-container {
    border: 1px solid #ccc !important;
    min-height: 200pt;
  }

  .leaflet-container::after {
    content: "[Map — visible in browser only]";
    display: block;
    text-align: center;
    padding: 20pt;
    font-style: italic;
    color: #666 !important;
  }

  /* ----------------------------------------------------------------
     11. CHARTS
     ---------------------------------------------------------------- */
  canvas {
    max-width: 100% !important;
    break-inside: avoid;
  }

  /* ----------------------------------------------------------------
     12. BRAND FOOTER FOR PRINT
     ---------------------------------------------------------------- */
  body::after {
    content: "COHO Analytics — cohoanalytics.com";
    display: block;
    text-align: center;
    font-size: 8pt;
    color: #666 !important;
    margin-top: 20pt;
    border-top: 1px solid #ccc !important;
    padding-top: 6pt;
  }

  /* ================================================================
     L3 — Deal Calculator IC-packet print layout
     Scoped to body.dc-print-mode (set by Export button click) so the
     calculator's inputs/results collapse into a single-column IC submission
     packet: deal summary + capital stack + sources/uses + 30-yr pro forma.
     ================================================================ */

  /* Hide methodology, formula-panel, educational copy at print time.
     These are useful in-app but bloat the IC packet PDF. */
  body.dc-print-mode .dc-edu-section,
  body.dc-print-mode #dc-formulas-panel,
  body.dc-print-mode details summary {
    display: none !important;
  }
  /* When a <details> is opened we still want the body to print. */
  body.dc-print-mode details {
    display: block !important;
  }
  body.dc-print-mode details > div {
    display: block !important;
  }
  /* Hide controls users can no longer interact with on paper: sliders,
     range inputs, "Add tranche" button, refresh buttons. */
  body.dc-print-mode input[type="range"],
  body.dc-print-mode #dc-add-tranche,
  body.dc-print-mode .dc-tr-remove,
  body.dc-print-mode #dcSaveBtn,
  body.dc-print-mode #dcExportBtn {
    display: none !important;
  }
  /* Force single-column flow — inputs above results above pro forma. */
  body.dc-print-mode .dc-grid,
  body.dc-print-mode [style*="display:grid"] {
    display: block !important;
    grid-template-columns: none !important;
  }
  /* Tighten tranche row display for print (was an interactive card).
     Show as a flat row with label-value pairs. */
  body.dc-print-mode [data-tranche-id] {
    background: #f8f8f8 !important;
    border: 1px solid #ccc !important;
    padding: 6pt 8pt !important;
    margin-bottom: 4pt !important;
    break-inside: avoid;
  }
  body.dc-print-mode [data-tranche-id] select,
  body.dc-print-mode [data-tranche-id] input {
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
    font-weight: 600;
  }
  body.dc-print-mode [data-tranche-id] select {
    appearance: none;
    -webkit-appearance: none;
  }
  /* Sources & Uses + per-tranche detail rows should print as one table. */
  body.dc-print-mode #dc-su-table {
    break-inside: avoid;
    width: 100% !important;
    font-size: 10pt !important;
  }
  body.dc-print-mode #dc-su-tranches-detail tr {
    display: table-row !important;
  }
  /* IC packet cover header — synthesized at print time via ::before so the
     in-app layout isn't affected. Shows deal name + date. */
  body.dc-print-mode main::before {
    content: "LIHTC Deal Calculator — IC Submission Packet\A\AGenerated " attr(data-print-date) "\A————————————————";
    display: block;
    white-space: pre;
    font-size: 12pt;
    font-weight: 700;
    margin-bottom: 14pt;
    border-bottom: 2px solid #000 !important;
    padding-bottom: 8pt;
  }
}
