/* Compliance QC Tools: print stylesheet. A file-ready page for the loan or account file.
   Hides the nav, controls and the on-screen timeline; shows the file header with blank
   ruled lines for PII (printed lines, never input fields), the inputs used, results,
   the timeline as a table, Regulatory Basis with full URLs, calendar settings and the
   print date. Linked after base.css and components.css. */

@media print {
  @page { size: letter; margin: 0.55in 0.6in 0.6in; }

  :root { --gutter: 0px; }
  html, body { background: #FFFFFF; }
  body {
    padding: 0; margin: 0; overflow: visible;
    font-size: 10pt; line-height: 1.4; color: var(--ink);
  }

  /* Hidden in print */
  .site, .skip, .wave, .no-print, .tools, .tools-toggle,
  .inputs-panel, .tl-legend, .tl-scroll, .basis-toggle .chev, .basis-toggle .count,
  .cite .ext, .gate-print-hide { display: none !important; }

  /* Shown only in print */
  .print-only { display: block !important; }

  .wrap { max-width: none; padding: 0; gap: 14pt; }
  .page-head { gap: 2pt; }
  .page-head .sub { font-size: 9.5pt; }
  h1 { font-size: 17pt; margin: 0; }
  h2 { font-size: 12.5pt; }
  .panel h2, .print-inputs h2, .basis h2 { padding-bottom: 3pt; border-bottom: 1px solid var(--rule); }
  .work { display: block; }
  .panel { border: 0; padding: 0; gap: 8pt; break-inside: auto; }
  .panel + .panel, .work + .panel { margin-top: 14pt; }
  .flags { margin-top: 2pt; }

  /* Links print as text plus the full address. */
  a { color: var(--ink); text-decoration: none; }
  .cite { white-space: normal; font-size: inherit; color: var(--ink); font-weight: 600; }
  .cite .url {
    display: block; font-weight: 400; font-size: 7.5pt; color: var(--ink-2);
    word-break: break-all; overflow-wrap: anywhere; line-height: 1.3; margin-bottom: 2pt;
  }
  .cites .sep { display: none; }
  .cites .cite { display: block; }

  /* Tables: keep blue headers and status colors when the browser allows background
     printing; every status also has words, so nothing is lost if it does not. */
  thead { display: table-header-group; }
  thead th, .tag, .keyfact { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr, .keyfact, .pii-line, .note { break-inside: avoid; }
  .tablewrap { overflow: visible; border: 1px solid var(--rule); }
  table { font-size: 9pt; }
  th, td { padding: 5pt 7pt; }
  thead th { font-size: 8.5pt; }
  .tag { border-color: currentColor; font-size: 7.5pt; padding: 1pt 4pt; }

  /* Phone-style stacked tables never apply on paper. */
  .stack-table { display: table !important; }
  .stack-table thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: table-header-group !important; }
  .stack-table tbody { display: table-row-group !important; }
  .stack-table tr { display: table-row !important; padding: 0; }
  .stack-table th, .stack-table td { display: table-cell !important; width: auto; padding: 5pt 7pt; border-bottom: 1px solid var(--rule); }
  .stack-table td[data-label]::before { content: none; }

  /* Key results */
  .keyfacts { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6pt; }
  .keyfact { padding: 6pt 8pt; }
  .keyfact .k { font-size: 7pt; }
  .keyfact .v { font-size: 11pt; }
  .keyfact .c { font-size: 8pt; }

  /* Regulatory Basis: always open, no button look. */
  .basis { border: 0; }
  .basis-toggle { padding: 0; min-height: 0; font-size: 12.5pt; color: var(--title); }
  .basis-body, .basis-body[hidden] { display: flex !important; padding: 6pt 0 0; }
  .basis-table th:first-child, .basis-table td:first-child { width: 30%; }
  .basis-table th:last-child, .basis-table td:last-child { width: 30%; }

  /* Timeline as a table */
  .timeline { container-type: normal; }
  .tl-table { display: table; width: 100%; border: 1px solid var(--rule); }
  .tl-table caption { text-align: left; font-weight: 600; font-size: 9pt; padding-bottom: 3pt; color: var(--ink-2); caption-side: top; }
  .tl-table .tl-note { display: block; font-size: 8pt; color: var(--ink-2); margin-top: 2pt; }
  .tl-table td.date { white-space: nowrap; }

  .tl-table caption { display: none; }
  .tl-table td.date { white-space: normal; width: 24%; }

  /* Screen sizes are in px; bring every secondary line down to the print scale. */
  .panel-head .hint { display: none; }
  table .cite, .basis-table .exam .cite { font-size: 9pt; }
  .results-table .daytype, td .tl-note, .basis-table .src { font-size: 8pt; }
  .basis-intro { font-size: 9pt; }
  .keyfact .cite .url { display: none; } /* the same cite prints with its URL in the table below */

  .note { padding: 6pt 8pt; font-size: 9pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .calendars pre, .calendars p { font-size: 8.5pt; }

  /* ---------- File header with blank PII lines ---------- */
  .print-head { margin-bottom: 12pt; }
  .ph-top {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 12pt;
    padding-bottom: 6pt; border-bottom: 2px solid var(--head); margin-bottom: 10pt;
  }
  .ph-top .mark b { font-size: 15pt; }
  .ph-top .mark span { font-size: 7.5pt; }
  .ph-top .mark span::before, .ph-top .mark span::after { width: 18px; height: 1.5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ph-title { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 1pt; }
  .ph-title strong { font-size: 11.5pt; color: var(--title); }
  .ph-date { font-size: 8.5pt; color: var(--ink-2); }

  .pii { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18pt; row-gap: 10pt; }
  .pii-line { display: grid; grid-template-columns: auto 1fr; align-items: end; column-gap: 6pt; row-gap: 12pt; }
  .pii-line.wide { grid-column: 1 / -1; }
  .pii-label { font-size: 8.5pt; font-weight: 600; white-space: nowrap; grid-column: 1; }
  .pii-rule { grid-column: 2; display: block; height: 14pt; border-bottom: 1px solid var(--ink); }
  .pii-rule + .pii-rule { grid-column: 1 / -1; }

  /* Footer */
  .foot { border-top: 1px solid var(--rule); padding-top: 6pt; font-size: 8pt; break-inside: avoid; }
  .foot .print-date { font-weight: 600; color: var(--ink); }
}

/* Tool pages (trid.html): counting detail stays on screen; the calendars block carries it. */
@media print {
  .results-table details { display: none; }
  .results-table tr.group-row th { -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 8pt; padding-block: 3pt; }
  .results-table .test-text, .results-table .row-notes, .results-table .second-line, .results-table .guidance-cites { font-size: 8pt; }
  .basis-toggle .tag { font-size: 7.5pt; }

  /* ---------- "File copy" (trid.html, body.file-copy): the default printout ----------
     Inputs entered, results with status, the timeline as a table and one compact sources list.
     Citations print as labels; their addresses print once, in the sources list. The full
     Regulatory Basis prints only when "Include full Regulatory Basis in print" is ticked. */
  .file-copy .results .cite .url, .file-copy .timeline .cite .url { display: none; }
  .file-copy:not(.print-basis) .basis { display: none !important; }
  .file-copy .results-table .row-notes { display: none; }
  .file-copy .page-head .sub { display: none; }
  .file-copy:not(.print-basis) .results .cite.is-comment,
  .file-copy:not(.print-basis) .timeline .cite.is-comment { display: none !important; }
  .file-copy .tl-table .tl-note { display: none; }
  .file-copy .tl-table th, .file-copy .tl-table td { padding: 2.5pt 6pt; font-size: 8pt; }
  .file-copy .tl-table td.date { width: 16%; }
  .file-copy .tl-table td:nth-child(3) { width: 11%; }
  .file-copy .tl-table td:nth-child(4) { width: 25%; }
  .file-copy .keyfacts { display: none; }
  /* Citations run inline, separated by semicolons (hidden commentary has no separator). */
  .file-copy:not(.print-basis) .results .cites .cite, .file-copy:not(.print-basis) .timeline .cites .cite { display: inline; }
  .file-copy:not(.print-basis) .results .cites .sep, .file-copy:not(.print-basis) .timeline .cites .sep { display: inline; }
  .file-copy:not(.print-basis) .cites .sep.print-hide { display: none; }
  .file-copy .results-table .guidance-cites { display: block; }
  /* Guidance titles are long: the File copy lists them under Sources. */
  .file-copy:not(.print-basis) .results-table .guidance-cites .cites { display: none; }
  .file-copy:not(.print-basis) .results-table .gc-see { display: inline; }
  /* Timeline: Date, Event, Type. Every date is also a results row, which carries its citation. */
  .file-copy:not(.print-basis) .tl-table th:nth-child(4), .file-copy:not(.print-basis) .tl-table td:nth-child(4) { display: none; }
  .file-copy:not(.print-basis) .tl-table td:nth-child(3) { width: 14%; }
  .file-copy .print-basis .tl-print-note, .file-copy.print-basis .tl-print-note { display: none !important; }
  .tl-print-note { font-size: 8pt; color: var(--ink-2); max-width: none; }
  .file-copy .results > .panel-head, .file-copy #timeline-panel > .panel-head { break-after: avoid; page-break-after: avoid; }
  .file-copy #messages, .file-copy #results-body, .file-copy #results-body > .tablewrap { break-before: avoid; page-break-before: avoid; }
  .file-copy .tl-table td.date { white-space: nowrap; }

  /* Calendars: one line per calendar. */
  .file-copy .calendars > :not(h3):not(.cal-compact) { display: none; }
  .file-copy .calendars .cal-compact { display: flex; flex-direction: column; gap: 2pt; }
  .file-copy .calendars .cal-compact p { font-size: 8pt; color: var(--ink); max-width: none; }

  /* Sources: one line each, label then address. */
  .file-copy .sources-list { columns: 1; padding-left: 18pt; }
  .file-copy .sources-list li { margin-bottom: 1pt; }
  .file-copy .sources-list .src-label, .file-copy .sources-list .src-url { display: inline; }
  .file-copy .sources-list .src-label { margin-right: 6pt; font-size: 7.5pt; }
  .file-copy .sources-list .src-url { word-break: normal; overflow-wrap: anywhere; }
  .file-copy .results-table th, .file-copy .results-table td { padding: 3pt 6pt; font-size: 8pt; line-height: 1.2; }
  .file-copy .results-table .cite, .file-copy .results-table .guidance-cites { font-size: 8pt; }
  .file-copy .results-table thead th:nth-child(1) { width: 24%; }
  .file-copy .results-table thead th:nth-child(2) { width: 20%; }
  .file-copy .results-table thead th:nth-child(3) { width: 19%; }
  .file-copy .results-table .daytype { white-space: nowrap; }
  .file-copy .results-table tbody tr:not(.group-row) { break-inside: auto; }
  .file-copy .tl-print-note, .file-copy #timeline { break-before: avoid; page-break-before: avoid; }
  /* Flex boxes split poorly across pages; the timeline table flows as a block. */
  .file-copy .timeline, .file-copy .wrap { display: block; }
  /* The file header already carries the title; the draft tag stays. */
  .file-copy .page-head .eyebrow, .file-copy .page-head h1 { display: none; }
  .file-copy .results-table thead { break-after: avoid; page-break-after: avoid; }
  .file-copy .sources-list { font-size: 7pt; line-height: 1.15; }
  .file-copy .sources-list .src-label { font-size: 7pt; }
  .file-copy .tl-table th, .file-copy .tl-table td { padding-top: 1.5pt; padding-bottom: 1.5pt; line-height: 1.25; }
  .file-copy .wrap > * + * { margin-top: 10pt; }
  .file-copy .foot { font-size: 7.5pt; padding-top: 4pt; gap: 2pt; }
  .file-copy .print-sources .sources-intro { margin: 2pt 0 4pt; }
  /* Block flow (not flex) so a panel heading can stay with the table that follows it. */
  .file-copy .results, .file-copy #timeline-panel { display: block; }
  .file-copy .results > * + *, .file-copy #timeline-panel > * + * { margin-top: 8pt; }
  .file-copy .results-table .test-text { font-size: 8pt; margin-top: 2pt; }

  .inputs-table.pairs th, .inputs-table.pairs td { padding: 2pt 6pt; font-size: 8pt; line-height: 1.2; }
  .inputs-table.pairs th { width: 34%; }
  .inputs-table.pairs td { width: 16%; white-space: nowrap; }
  .inputs-table.pairs thead th { font-size: 7.5pt; }

  .print-sources h2 { padding-bottom: 3pt; border-bottom: 1px solid var(--rule); }
  .print-sources .sources-intro { font-size: 8pt; color: var(--ink-2); margin: 4pt 0 6pt; max-width: none; }
  .sources-list { columns: 2; column-gap: 18pt; margin: 0; padding-left: 16pt; font-size: 7.5pt; line-height: 1.3; }
  .sources-list li { break-inside: avoid; margin-bottom: 3pt; }
  .sources-list .src-label { display: block; font-weight: 600; font-size: 8pt; }
  .sources-list .src-url { display: block; color: var(--ink-2); word-break: break-all; overflow-wrap: anywhere; }
  /* Keep a section heading with what follows it. */
  .basis h2, .results-table tr.group-row { break-after: avoid; page-break-after: avoid; }
}
