/*
 * Trashed Crash Pandas — Print Stylesheet
 * ----------------------------------------
 * Loaded via extra_css in mkdocs.yml.
 * Screen styles are intentionally minimal; all heavy lifting is
 * inside @media print so the live MkDocs Material site is unaffected.
 *
 * TO GENERATE PDF:
 *   Open the live site (or mkdocs serve) in Chrome.
 *   File → Print → Save as PDF.
 *   Paper: US Letter, Portrait.
 *   Margins: None (this file handles all margins).
 *   Enable: Background graphics.
 *
 * KNOWN EXCEPTIONS (print-only layout with no Markdown equivalent):
 *   - Two-column RW random tables grid: print-only.
 *   - Title page full-page layout: handled in the standalone print HTML.
 *   These live only here, not in the source .md files.
 */

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {

  /* ----------------------------------------------------------
     PAGE GEOMETRY — US Letter, double-sided
     ---------------------------------------------------------- */
  @page {
    size: letter portrait;
    margin: 0.85in 0.75in 0.85in 1.0in; /* top outer bottom inner */
  }

  /* Recto (right / odd pages): binding gutter on left */
  @page :right {
    margin-left:  1.0in;
    margin-right: 0.75in;
  }

  /* Verso (left / even pages): binding gutter on right */
  @page :left {
    margin-left:  0.75in;
    margin-right: 1.0in;
  }

  /* ----------------------------------------------------------
     HIDE MKDOCS MATERIAL CHROME
     ---------------------------------------------------------- */
  .md-header,
  .md-sidebar,
  .md-footer,
  .md-tabs,
  .md-search,
  .md-top,
  [data-md-component="skip"],
  .headerlink,
  a.md-content__button {
    display: none !important;
  }

  /* Remove Material's left-margin offset for the sidebar */
  .md-main__inner,
  .md-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .md-content__inner {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ----------------------------------------------------------
     BASE TYPOGRAPHY
     ---------------------------------------------------------- */
  body {
    font-size: 11pt;
    line-height: 1.55;
    color: #1a1a1a;
    background: #fff;
  }

  /* ----------------------------------------------------------
     ORPHAN / WIDOW CONTROL — the core fix
     ---------------------------------------------------------- */
  p {
    orphans: 3;
    widows: 3;
    margin-bottom: 0.7em;
  }

  li {
    orphans: 2;
    widows: 2;
    page-break-inside: avoid;
    break-inside:      avoid;
  }

  /* ----------------------------------------------------------
     HEADINGS — never strand a heading at the bottom of a page
     ---------------------------------------------------------- */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    break-after:      avoid;
  }

  /* H1 (Part breaks) always start on a fresh page */
  h1 {
    page-break-before: always;
    break-before:      page;
  }

  /* ----------------------------------------------------------
     TABLES — the other main pain point
     ---------------------------------------------------------- */
  table {
    page-break-inside: avoid;
    break-inside:      avoid;
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    margin: 1em 0 1.2em;
  }

  /* If a table MUST span pages, repeat the header row */
  thead {
    display: table-header-group;
  }

  /* Individual rows must never split across a page break */
  tr {
    page-break-inside: avoid;
    break-inside:      avoid;
  }

  th {
    background: #1a1a1a !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 5pt 8pt;
    text-align: left;
    border: 1px solid #1a1a1a;
    font-weight: 700;
  }

  td {
    padding: 4pt 8pt;
    border: 1px solid #ccc;
    vertical-align: top;
  }

  tr:nth-child(even) td {
    background: #f5f4f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ----------------------------------------------------------
     ADMONITIONS (Material callout blocks)
     ---------------------------------------------------------- */
  .admonition,
  details {
    page-break-inside: avoid;
    break-inside:      avoid;
    border-left-width: 4px;
    margin: 0.9em 0;
  }

  /* ----------------------------------------------------------
     BLOCKQUOTES
     ---------------------------------------------------------- */
  blockquote {
    page-break-inside: avoid;
    break-inside:      avoid;
    orphans: 3;
    widows: 3;
  }

  /* ----------------------------------------------------------
     IMAGES
     ---------------------------------------------------------- */
  img {
    page-break-inside: avoid;
    break-inside:      avoid;
    max-width: 100%;
  }

  /* ----------------------------------------------------------
     CODE BLOCKS
     ---------------------------------------------------------- */
  pre, code {
    page-break-inside: avoid;
    break-inside:      avoid;
  }

  /* ----------------------------------------------------------
     LINKS — print the URL inline for reference
     ---------------------------------------------------------- */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #666;
    word-break: break-all;
  }

  /* Suppress URL expansion for anchor links and nav */
  a[href^="#"]::after,
  .md-nav a::after {
    content: none;
  }

  /* ----------------------------------------------------------
     HORIZONTAL RULES
     ---------------------------------------------------------- */
  hr {
    page-break-after: avoid;
    break-after:      avoid;
    border: none;
    border-top: 1px solid #888;
    margin: 1.5em 0;
  }

} /* end @media print */
