/* blog-print.css
 * Print stylesheet for MW Blogs
 *
 * Goals:
 *  - Print article content cleanly (no nav/rails/CTAs)
 *  - Remove scroll/overflow clipping and sticky/fixed positioning
 *  - Improve readability and page-break behavior
 *
 * Uses optional server-side hooks:
 *  - body.mw-print-mode
 *  - .mw-print-root (wraps the article content)
 */

/* ---------- Global print reset ---------- */
@media print {

  /* Global exclusions */
  #mw_blogs_title,
  #nav_toggle,
  .left-panel,
  #subnav,
  .subnav {
    display: none !important;
  }

  /* Page box & margins */
  @page {
    margin: 0.75in;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
    height: auto !important;
    min-height: auto !important;
  }

  /* Reduce ink and remove effects */
  * , *::before, *::after {
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
  }

  /* Ensure all containers can expand (prevents clipped print output) */
  * , *::before, *::after {
    overflow: visible !important;
  }

  /* Kill “screen layout” constraints */
  [style*="height:"],
  [style*="max-height:"],
  [style*="min-height:"],
  [style*="overflow:"] {
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  /* ---------- Hide non-content UI ---------- */
  header,
  nav,
  footer,
  aside,
  .toc,
  .table-of-contents,
  .sidebar,
  .right-rail,
  .left-rail,
  .share,
  .share-bar,
  .social,
  .newsletter,
  .subscribe,
  .cta,
  .promo,
  .cookie,
  .cookie-banner,
  .banner,
  .notification,
  .alert,
  .breadcrumbs,
  .comments,
  .comment,
  .related,
  .related-posts,
  .recommended,
  .pagination,
  .back-to-top,
  .print-button,
  button,
  .btn,
  .button {
    display: none !important;
  }

  /* If you add a “print root” wrapper, prefer it */
  body.mw-print-mode .mw-print-root {
    display: block !important;
  }

  /* ---------- Flatten sticky/fixed positioning ---------- */
  * {
    position: static !important;
  }

  /* Exception: keep images/figures as normal flow blocks */
  img, figure, svg, video {
    position: static !important;
  }

  /* ---------- Article layout: single column ---------- */
  main,
  article,
  .content,
  .post,
  .post-content,
  .entry-content,
  .blog-post,
  .mw-print-root {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
  }

  /* Undo common grid/flex layouts */
  .grid,
  .row,
  .columns,
  .container,
  .layout,
  .wrap,
  .wrapper,
  .content-wrapper,
  .page-layout {
    display: block !important;
    width: auto !important;
    max-width: none !important;
  }

  /* ---------- Typography ---------- */
  body {
    font-size: 11pt !important;
    line-height: 1.4 !important;
  }

  h1 { font-size: 18pt !important; }
  h2 { font-size: 14pt !important; }
  h3 { font-size: 12.5pt !important; }

  p, li {
    orphans: 3;
    widows: 3;
  }

  /* Links: show URL after text (optional but useful) */
  a, a:visited {
    color: #000 !important;
    text-decoration: underline !important;
  }
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    word-break: break-word;
  }

  /* ---------- Media handling ---------- */
  img, figure {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Code blocks and tables */
  pre, code {
    white-space: pre-wrap !important;
    word-break: break-word !important;
  }
  pre, blockquote, table {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  table {
    width: 100% !important;
    border-collapse: collapse !important;
  }
  th, td {
    border: 1px solid #999 !important;
    padding: 6px !important;
  }

  /* Prevent headings from being stranded at bottom of page */
  h1, h2, h3, h4 {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* Avoid splitting list items / figure captions */
  li, figcaption {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}