/* ============================================================
   print.css
   Print stylesheet — aims for parity with Word output.
   8.5x11 letter, 1" margins, page header (logo + title),
   page footer (classification + page numbers).
   ============================================================ */

@media print {

  /* -- Page setup -------------------------------------------- */
  @page {
    size: letter;
    margin: 1in;

    @top-left {
      content: element(pageHeader);
    }

    @bottom-left {
      content: string(doc-classification);
      font-family: Calibri, sans-serif;
      font-size: 9pt;
      color: #666;
    }

    @bottom-right {
      content: "Page " counter(page) " of " counter(pages);
      font-family: Calibri, sans-serif;
      font-size: 9pt;
      color: #666;
    }
  }

  /* First page: full header band shows. Subsequent pages:
     a compact running header is generated via @top-left. */
  @page :first {
    @top-left { content: none; }
  }

  /* -- Clean up screen-only chrome -------------------------- */
  body { background: #FFFFFF; }

  .gov-page {
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
    min-height: 0;
  }

  .gov-footer { display: none; }   /* Use @page footer instead */

  /* -- Capture classification for the running footer -------- */
  .gov-header__title .doc-classification {
    string-set: doc-classification content();
  }

  /* -- Compact running header for pages 2+ ------------------ */
  .gov-running-header {
    position: running(pageHeader);
    font-family: Calibri, sans-serif;
    font-size: 9pt;
    color: #666;
    border-bottom: 1px solid #CCC;
    padding-bottom: 4px;
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  /* -- Page break controls ---------------------------------- */
  h1, h2 { page-break-after: avoid; }
  h1 + p, h2 + p, h3 + p { page-break-before: avoid; }
  table, blockquote, pre { page-break-inside: avoid; }

  /* Force a page break before major sections if marked */
  .page-break-before { page-break-before: always; }

  /* -- Links: show URL in print for cross-references -------- */
  a.gov-xref {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: none;
  }

  /* Internal references: leave clean.
     External (out-of-corpus) links: show the URL.
     Use a class to distinguish, applied by the renderer. */
  a.gov-external::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666;
    font-weight: normal;
  }

  /* -- Avoid orphans/widows --------------------------------- */
  p, li {
    orphans: 3;
    widows: 3;
  }

  /* -- Tables: repeat headers across page breaks ------------ */
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
}
