/* ML Meanders - Print Stylesheet */

@page {
  margin: 2cm;
}

@media print {
  /* ============================================
     Reset to light theme
     ============================================ */
  * {
    color: #000 !important;
    background: #fff !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border-radius: 0 !important;
  }

  body {
    font-size: 11pt;
    line-height: 1.5;
  }

  /* ============================================
     Hide non-essential elements
     ============================================ */
  .site-header,
  .site-footer,
  .reading-progress-bar,
  .back-to-top,
  .toc-sidebar,
  .toc-mobile,
  .sidenote-column,
  .code-copy-button,
  .citation-copy-button,
  .lightbox,
  .header-anchor,
  .theme-toggle {
    display: none !important;
  }

  /* ============================================
     Post header: hide gradient, show clean title
     ============================================ */
  .post-header-hero {
    padding: 0 !important;
    margin: 0 !important;
  }

  .post-header-image {
    background: none !important;
  }

  .post-header-image svg {
    display: none !important;
  }

  .post-header-content {
    position: static !important;
    padding: 0 !important;
  }

  .post-title {
    font-size: 22pt !important;
    color: #000 !important;
  }

  .post-byline {
    border-bottom: 1px solid #ccc !important;
    padding-bottom: 0.5cm !important;
    margin-bottom: 0.5cm !important;
  }

  /* ============================================
     Layout: remove grid, full width
     ============================================ */
  .post-content-wrapper {
    display: block !important;
    max-width: 100% !important;
  }

  .post-body {
    max-width: 100% !important;
    width: 100% !important;
  }

  .main-content {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .post {
    max-width: 100% !important;
  }

  .l-page {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .post-footer {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .references {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* ============================================
     Links: show URLs for external links
     ============================================ */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555 !important;
    word-break: break-all;
  }

  /* Don't show URL for citation/reference links */
  .citation::after,
  .section-ref::after,
  .reference-content a::after {
    content: none;
  }

  /* ============================================
     Tables: keep booktabs style
     ============================================ */
  table {
    border-top: 2px solid #000 !important;
    border-bottom: 2px solid #000 !important;
    page-break-inside: avoid;
  }

  thead th {
    border-bottom: 1px solid #000 !important;
  }

  .table-wrapper {
    overflow: visible !important;
  }

  /* ============================================
     Figures: prevent page breaks
     ============================================ */
  figure {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  img {
    max-width: 100% !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* ============================================
     Code blocks: wrap for print
     ============================================ */
  pre {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    border: 1px solid #ccc !important;
    padding: 0.5cm !important;
    page-break-inside: avoid;
    overflow: visible !important;
  }

  code {
    border: 1px solid #ddd !important;
  }

  pre code {
    border: none !important;
  }

  /* ============================================
     Headings: avoid orphans
     ============================================ */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    break-after: avoid;
  }

  h2 {
    border-bottom: 1px solid #ccc !important;
  }

  /* ============================================
     Blockquotes
     ============================================ */
  blockquote {
    border-left: 3px solid #333 !important;
    padding: 0.3cm 0.5cm !important;
    margin: 0.5cm 0 !important;
  }

  /* ============================================
     Callouts: simplify for print
     ============================================ */
  .callout {
    border: 1px solid #999 !important;
    border-left: 4px solid #333 !important;
    padding: 0.3cm 0.5cm !important;
    page-break-inside: avoid;
  }

  /* ============================================
     Details/summary: show expanded
     ============================================ */
  details {
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }

  details summary::before {
    content: '' !important;
  }

  /* ============================================
     KaTeX: ensure formulas print
     ============================================ */
  .katex {
    font-size: 1em !important;
  }

  /* ============================================
     Citation block: always show
     ============================================ */
  .post-citation {
    border-top: 1px solid #ccc !important;
    page-break-inside: avoid;
  }

  .citation-bibtex {
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }

  /* ============================================
     Paragraph widows and orphans
     ============================================ */
  p {
    orphans: 3;
    widows: 3;
  }
}
