/* Print rules: hide the app chrome, render only the preview as a clean document.
   PDF generation happens via the browser's "Save as PDF" in window.print(). */

@page {
  size: A4;
  margin: 22mm 20mm;
}

@media print {
  /* Force light backgrounds in PDF, regardless of OS dark mode */
  :root {
    --bg: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-subtle: #F4F4F6;
    --border: #D8D8DE;
    --border-strong: #B5B5BD;
    --text: #1A1A22;
    --text-muted: #4A4A55;
    --text-faint: #777783;
  }

  html, body {
    background: #FFFFFF !important;
    color: #1A1A22 !important;
    height: auto;
    overflow: visible;
  }

  body {
    display: block;
  }

  /* Hide everything that isn't the preview */
  .app-header,
  .app-footer,
  .splitter,
  .pane-editor,
  .drop-overlay {
    display: none !important;
  }

  .workspace {
    display: block;
    overflow: visible;
    height: auto;
  }

  .pane-preview {
    overflow: visible;
    background: #FFFFFF !important;
  }

  .preview {
    max-width: none;
    margin: 0;
    padding: 0;
    min-height: 0;
    font-size: 11pt;
  }

  /* Avoid breaking these elements across pages */
  pre,
  blockquote,
  table,
  img,
  figure {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Headings should stay with their following content */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    break-after: avoid;
  }

  /* Force long URLs and code to wrap so they don't blow out the page */
  pre, code {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  a {
    color: #1A1A22 !important;
    text-decoration: none !important;
  }

  /* Show URLs after links for printed reference, but only for external ones */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #6B6B7B;
    word-break: break-all;
  }

  /* Theme-specific print tweaks */
  .preview[data-theme="academic"] {
    font-size: 11pt;
    line-height: 1.55;
  }

  .preview[data-theme="github"] {
    font-size: 10.5pt;
    line-height: 1.5;
  }

  .preview[data-theme="minimal"] {
    font-size: 10.5pt;
    line-height: 1.65;
  }
}
