/* VirtualBytes print stylesheet
 * Optimizes single-post and page printing for offline reference
 * (lab settings, air-gapped environments, paper backups).
 *
 * Goals:
 *   - White background, black text (readable + ink-friendly)
 *   - Hide nav, sidebar, comments, related posts, ads, social
 *   - Expand external URLs after their link text so paper readers can find them
 *   - Keep code blocks readable in monospace with subtle gray background
 *   - Force page breaks before H2s on long posts so sections don't split
 *   - Show the full URL of the post in the header
 *   - Maintain the VirtualBytes brand mark in the footer
 */

@media print {
  /* ── Page setup ────────────────────────────────────────────────────────── */
  @page {
    margin: 18mm 16mm 22mm 16mm;
    size: auto;
  }

  /* ── Reset to print-friendly colors ───────────────────────────────────── */
  * {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    /* Override the dark theme entirely */
    border-color: #999 !important;
  }
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-family: Georgia, "Times New Roman", serif !important;
    font-size: 11pt !important;
    line-height: 1.55 !important;
  }

  /* ── Hide all chrome ──────────────────────────────────────────────────── */
  .site-header,
  .main-navigation,
  .menu-toggle,
  .nav-search-toggle,
  .nav-search-panel,
  .vb-breadcrumbs,
  .post-rail,
  .post-toc,
  .vb-related-tools,
  .vb-prev-next,
  .vb-more-from-cat,
  .related-posts,
  .sidebar,
  .site-footer,
  .reading-progress,
  .back-to-top,
  .comments-area,
  .comment-respond,
  .post-tags,
  .post-author-card,
  .copy-code-btn,
  .vb-pre-wrap .code-lang-label,
  .vb-comments-top,
  .post-series-strip,
  .archive-hero,
  .archive-filter,
  .vb-featured-hero,
  /* Floating/fixed UI from 2.7/2.9 — must be hidden so they don't overlap print */
  .vb-reading-progress,
  .vb-back-to-top,
  .vb-lightbox,
  .vb-toast,
  .vb-resume-banner,
  .vb-upnext-card,
  .vb-hover-preview,
  .vb-share-row,
  .vb-rating,
  .vb-print-runbook-btn,
  .vb-status-indicator,
  .vb-search-open,
  /* Hide AdSense / Google ads */
  .adsbygoogle,
  ins.adsbygoogle,
  iframe[src*="googlesyndication"],
  iframe[src*="doubleclick"],
  /* Hide AI/social embeds that don't print */
  .twitter-tweet,
  .instagram-media,
  /* Decorative SVGs */
  svg[aria-hidden="true"] {
    display: none !important;
  }

  /* ── Hero ──────────────────────────────────────────────────────────────── */
  .single-post-hero {
    padding: 0 !important;
    margin: 0 0 16pt !important;
    border-bottom: 2pt solid #000 !important;
    padding-bottom: 12pt !important;
    background: #fff !important;
  }
  .post-hero-meta {
    font-size: 9pt !important;
    color: #555 !important;
    margin-bottom: 6pt !important;
  }
  .post-hero-meta * { color: #555 !important; }
  .post-hero-cat {
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: .04em !important;
  }
  .post-hero-title {
    font-family: Georgia, "Times New Roman", serif !important;
    font-size: 22pt !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    color: #000 !important;
    margin: 0 0 6pt !important;
    page-break-after: avoid;
  }
  .post-hero-excerpt {
    font-size: 12pt !important;
    color: #333 !important;
    font-style: italic !important;
    margin: 0 !important;
  }

  /* ── Layout ────────────────────────────────────────────────────────────── */
  .single-layout,
  .single-main,
  .single-top,
  .post-content,
  .entry-content,
  .container {
    display: block !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ── Featured image ───────────────────────────────────────────────────── */
  .post-featured-image {
    margin: 0 0 14pt !important;
    page-break-inside: avoid;
  }
  .post-featured-image img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 0 !important;
  }

  /* ── Body typography ──────────────────────────────────────────────────── */
  .entry-content p,
  .post-content p {
    orphans: 3;
    widows: 3;
    margin: 0 0 10pt !important;
  }
  .entry-content h2,
  .post-content h2 {
    font-family: Georgia, serif !important;
    font-size: 16pt !important;
    font-weight: 700 !important;
    margin: 18pt 0 8pt !important;
    page-break-before: auto;
    page-break-after: avoid;
    border-bottom: 1pt solid #999 !important;
    padding-bottom: 4pt !important;
  }
  .entry-content h3,
  .post-content h3 {
    font-family: Georgia, serif !important;
    font-size: 13pt !important;
    font-weight: 700 !important;
    margin: 14pt 0 6pt !important;
    page-break-after: avoid;
  }
  .entry-content h4,
  .post-content h4 {
    font-family: Georgia, serif !important;
    font-size: 11pt !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: .04em !important;
    margin: 10pt 0 4pt !important;
    page-break-after: avoid;
  }

  /* ── Lists ─────────────────────────────────────────────────────────────── */
  .entry-content ul,
  .entry-content ol {
    margin: 0 0 10pt 24pt !important;
  }
  .entry-content li {
    margin-bottom: 4pt !important;
    page-break-inside: avoid;
  }

  /* ── Links: expand external URLs after text ───────────────────────────── */
  .entry-content a {
    color: #000 !important;
    text-decoration: underline !important;
  }
  .entry-content a[href^="http"]:not([href*="virtualbytes.io"])::after {
    content: " (" attr(href) ")";
    font-size: 9pt !important;
    color: #555 !important;
    word-break: break-all;
    /* External link icon hidden in print */
  }
  /* Don't print URLs for in-page anchors or intra-site links */
  .entry-content a[href^="#"]::after,
  .entry-content a[href*="virtualbytes.io"]::after {
    content: "";
  }
  /* Hide external link icon */
  .entry-content a.vb-external::after {
    background-image: none !important;
  }

  /* ── Code blocks ──────────────────────────────────────────────────────── */
  pre,
  pre.vb-numbered,
  .vb-pre-wrap {
    background: #f4f4f4 !important;
    border: 1pt solid #ccc !important;
    border-radius: 0 !important;
    padding: 8pt !important;
    margin: 10pt 0 !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9.5pt !important;
    line-height: 1.4 !important;
    color: #000 !important;
    page-break-inside: avoid;
    overflow: visible !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
  }
  pre code,
  pre.vb-numbered code {
    font-family: "Courier New", Courier, monospace !important;
    background: transparent !important;
    color: #000 !important;
    padding: 0 !important;
  }
  /* Line numbers in print — keep them but lighten */
  pre.vb-numbered .vb-code-line::before {
    color: #888 !important;
  }
  pre.vb-numbered .vb-code-line.highlight {
    background: #fff8dc !important;
    border-left: 2pt solid #888 !important;
  }
  /* Inline code */
  .entry-content code {
    background: #f4f4f4 !important;
    border: 0.5pt solid #ddd !important;
    padding: 0 3pt !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9.5pt !important;
  }
  /* Keyboard keys */
  kbd {
    background: #fff !important;
    border: 1pt solid #999 !important;
    border-bottom-width: 2pt !important;
    border-radius: 2pt !important;
    padding: 0 4pt !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9pt !important;
    color: #000 !important;
  }

  /* ── Callouts (Note/Tip/Warning) ──────────────────────────────────────── */
  blockquote.vb-callout {
    background: #f9f9f9 !important;
    border-left: 3pt solid #666 !important;
    padding: 8pt 10pt !important;
    margin: 10pt 0 !important;
    border-radius: 0 !important;
    page-break-inside: avoid;
  }
  blockquote.vb-callout::before { display: none !important; }
  blockquote.vb-callout .vb-callout-label {
    color: #000 !important;
    font-weight: 700 !important;
    font-family: Georgia, serif !important;
    font-size: 9.5pt !important;
    text-transform: uppercase !important;
    letter-spacing: .06em !important;
    margin-bottom: 4pt !important;
  }
  blockquote.vb-warning,
  blockquote.vb-important,
  blockquote.vb-danger {
    border-left-color: #000 !important;
    border-left-width: 4pt !important;
  }

  /* ── Figures ──────────────────────────────────────────────────────────── */
  figure {
    page-break-inside: avoid;
    margin: 12pt 0 !important;
  }
  figure img {
    max-width: 100% !important;
    height: auto !important;
  }
  figcaption {
    font-size: 9.5pt !important;
    color: #555 !important;
    font-style: italic !important;
    text-align: center !important;
    margin-top: 4pt !important;
  }

  /* ── Tables ───────────────────────────────────────────────────────────── */
  .entry-content table {
    border-collapse: collapse !important;
    width: 100% !important;
    margin: 10pt 0 !important;
    page-break-inside: auto;
  }
  .entry-content table th,
  .entry-content table td {
    border: 0.5pt solid #999 !important;
    padding: 4pt 6pt !important;
    font-size: 9.5pt !important;
    text-align: left !important;
  }
  .entry-content table th {
    background: #f0f0f0 !important;
    font-weight: 700 !important;
  }
  .entry-content table tr {
    page-break-inside: avoid;
  }

  /* ── Footnotes ────────────────────────────────────────────────────────── */
  .entry-content .vb-footnote-ref {
    background: transparent !important;
    color: #000 !important;
    text-decoration: none !important;
  }
  .entry-content .vb-footnote-ref::before { content: "["; }
  .entry-content .vb-footnote-ref::after  { content: "]"; }
  .entry-content .vb-footnotes {
    border-top: 1pt solid #000 !important;
    padding-top: 8pt !important;
    margin-top: 18pt !important;
    font-size: 9.5pt !important;
    page-break-before: auto;
  }
  .entry-content .vb-footnote-back { display: none !important; }

  /* ── Print-only: VirtualBytes mark in footer of every page ───────────── */
  body::after {
    content: "virtualbytes.io";
    position: fixed;
    bottom: 6mm;
    right: 16mm;
    font-family: Georgia, serif;
    font-size: 8pt;
    color: #888;
    font-style: italic;
  }

  /* ── Print-only: source URL after title ───────────────────────────────── */
  .post-hero-title::after {
    display: block;
    margin-top: 4pt;
    content: attr(data-print-url);
    font-family: "Courier New", monospace;
    font-size: 8.5pt;
    font-weight: normal;
    color: #777;
    word-break: break-all;
  }

  /* ── Page breaks ──────────────────────────────────────────────────────── */
  h2, h3, h4 { page-break-after: avoid; }
  img, figure, pre, blockquote, table { page-break-inside: avoid; }
}
