/* Print Stylesheet */

@media print {
  /* Hide non-essential elements */
  header nav,
  footer,
  .social-share,
  #dark-mode-toggle,
  .post-tags {
    display: none !important;
  }

  /* Reset colors for print */
  body {
    background: white !important;
    color: black !important;
    background-image: none !important;
  }

  main, header, .page-title, .posts, .post {
    background-color: white !important;
    box-shadow: none !important;
    border: none !important;
  }

  a {
    color: black !important;
    text-decoration: underline !important;
  }

  /* Show URLs after links */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    font-weight: normal;
  }

  /* Don't show URLs for internal links or anchors */
  a[href^="#"]:after,
  a[href^="/"]:after {
    content: "";
  }

  /* Keep header simple */
  header {
    border-bottom: 2px solid black !important;
    padding-bottom: 1em;
  }

  header .main {
    font-size: 1.5rem !important;
  }

  /* Optimize typography for print */
  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  h1 { font-size: 18pt; page-break-after: avoid; }
  h2 { font-size: 16pt; page-break-after: avoid; }
  h3 { font-size: 14pt; page-break-after: avoid; }
  h4, h5, h6 { font-size: 12pt; page-break-after: avoid; }

  /* Avoid breaking inside elements */
  p, blockquote, pre, ul, ol {
    page-break-inside: avoid;
  }

  /* Code blocks */
  pre, code {
    border: 1px solid #999;
    background: #f5f5f5 !important;
    color: black !important;
    font-size: 10pt;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  pre {
    padding: 0.5em;
    margin: 1em 0;
  }

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

  /* Tables */
  table {
    border-collapse: collapse;
    width: 100%;
  }

  table, th, td {
    border: 1px solid black !important;
  }

  th, td {
    padding: 0.5em;
  }

  /* Page breaks */
  .page-break {
    page-break-after: always;
  }

  /* Orphans and widows */
  p {
    orphans: 3;
    widows: 3;
  }
}
