/*
 * Intermod Studio — css/print.css
 * Print / PDF-export styling for the site coordination report.
 *
 * Goal: when an engineer prints or exports to PDF, the dark instrument UI
 * disappears entirely and only a formal, high-density, monochrome engineering
 * document remains — suitable for municipal boards or federal coordinators.
 *
 * Linked in app.html as:  <link rel="stylesheet" href="css/print.css" media="print" />
 * (media="print" means these rules only ever apply during printing.)
 */

@media print {

  /* ---- Reset the canvas to white paper --------------------------------- */
  html, body {
    background: #fff !important;
    color: #000 !important;
    background-image: none !important;
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 10.5pt;
    line-height: 1.35;
  }

  /* ---- Show ONLY the report document ------------------------------------
     Hide the app chrome by display:none on the top-level regions, and let the
     report render in normal document flow (absolute positioning collapsed its
     height, so we avoid it). We keep #report-doc's ancestors displayed but
     strip their instrument skin. */
  header { display: none !important; }
  /* Column 1 (config) and Column 2 (parameters) — hide entirely. */
  main > div > section:nth-child(1),
  main > div > section:nth-child(2) { display: none !important; }
  /* In Column 3: hide the KPI strip and the tab bar, keep the report panel. */
  main > div > section:nth-child(3) > .grid:first-child { display: none !important; }
  .panel-head { display: none !important; }
  #panel-matrix, #panel-products { display: none !important; }
  #btn-print, #pro-modal { display: none !important; }
  #panel-report > .flex:first-child { display: none !important; }

  /* Make the layout wrappers plain full-width blocks with no instrument skin. */
  main,
  main > div,
  main > div > section:nth-child(3),
  main > div > section:nth-child(3) > .panel,
  #panel-report {
    display: block !important;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    min-height: 0 !important;
  }

  /* ---- The report document itself -------------------------------------- */
  #report-doc {
    background: #fff !important;
    color: #000 !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    font-size: 10.5pt !important;
  }

  /* Formal header block. The report's own header div carries the title;
     reinforce it with a heavy rule and ensure the masthead prints black. */
  #report-doc > div:first-child {
    border-bottom: 2.5pt solid #000 !important;
    padding-bottom: 6pt !important;
    margin-bottom: 10pt !important;
  }
  #report-doc .text-base { font-size: 14pt !important; font-weight: 700 !important; letter-spacing: 0.02em; }
  #report-doc .text-xs { font-size: 8.5pt !important; }

  /* Section subheadings (Verdict / Transmitters analyzed / Flagged products) */
  #report-doc .uppercase {
    color: #000 !important;
    font-weight: 700 !important;
    font-size: 8.5pt !important;
    letter-spacing: 0.08em;
    border-bottom: 0.5pt solid #000;
    padding-bottom: 2pt;
    margin-top: 12pt !important;
    margin-bottom: 4pt !important;
  }

  /* ---- Tables: tight monochrome grid ----------------------------------- */
  #report-doc table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 8pt !important;
  }
  #report-doc thead { display: table-header-group; } /* repeat header per page */
  #report-doc th,
  #report-doc td {
    border: 0.75pt solid #000 !important;
    padding: 2.5pt 5pt !important;
    color: #000 !important;
    text-align: left;
    font-size: 9.5pt !important;
  }
  #report-doc th {
    background: #e8e8e8 !important;
    font-weight: 700 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* Right-align the numeric columns (freq, delta). */
  #report-doc td.text-right, #report-doc th.text-right { text-align: right !important; }
  /* Monospace the numeric data for column alignment. */
  #report-doc .font-mono { font-family: 'Courier New', monospace !important; }

  /* The metadata table (Site / Candidate / Guard) — lighter, no full grid. */
  #report-doc table:first-of-type td { border: none !important; padding: 1pt 8pt 1pt 0 !important; }

  /* ---- HIT emphasis: double top/bottom rule + gray hatch --------------- */
  /* app.js writes the flag word ("HIT"/"NEAR") in the last cell; we can't rely
     on a class, so emphasize via a row marker the report adds. If a row's flag
     cell contains HIT, the report tags it .row-hit (see app.js report build).
     Fallback: bold any cell whose text is HIT. */
  #report-doc tr.row-hit td {
    border-top: 2pt double #000 !important;
    border-bottom: 2pt double #000 !important;
    background: repeating-linear-gradient(45deg, #fff, #fff 3px, #dcdcdc 3px, #dcdcdc 4px) !important;
    font-weight: 700 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ---- Page-break discipline ------------------------------------------- */
  #report-doc tr,
  #report-doc table { page-break-inside: avoid !important; }
  #report-doc .uppercase { page-break-after: avoid !important; }  /* keep heading with its table */

  /* Disclaimer footer stays together at the end. */
  #report-doc > div:last-child {
    page-break-inside: avoid !important;
    margin-top: 12pt !important;
    padding-top: 6pt !important;
    border-top: 0.5pt solid #000 !important;
    font-size: 8pt !important;
    color: #000 !important;
  }

  /* Page geometry */
  @page {
    margin: 0.75in 0.7in;
    size: letter portrait;
  }
}
