/* /sword/manual/assets/print.css · v5 (round 10 PROFESSIONAL) · 2026-05-25 · v94j NUCLEAR + front matter + figure polish */
@media print {
  @page { size: A4; margin: 18mm 15mm 22mm 15mm; }

  /* NUCLEAR BASELINE (keep v94j proven) */
  *, *::before, *::after {
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border-color: #ddd !important;
    letter-spacing: normal !important;
  }
  html, body {
    background: #fff !important; color: #1a1a1a !important;
    font-family: 'Sarabun', 'Tahoma', sans-serif;
    font-size: 10.5pt; line-height: 1.65;
  }
  p, li, span, div, td, th, strong, em, b, i, dd, dt, blockquote, figcaption { color: #1a1a1a !important; }

  /* FRONT MATTER · cover / warning / TOC display only in print */
  /* explicit white bg overrides web dark parent containers (bleeds through transparent baseline) */
  .manual-cover, .manual-warning, .manual-toc {
    display: block !important;
    page-break-after: always;
    background: #fff !important;
    background-color: #fff !important;
  }
  .manual-cover *, .manual-warning *, .manual-toc * {
    background-color: transparent !important;
  }
  .manual-cover {
    text-align: center; padding: 60mm 10mm 20mm; min-height: 240mm;
  }
  .cover-logo {
    max-width: 80mm !important;
    max-height: 45mm !important;
    width: auto !important;
    height: auto !important;
    margin: 0 auto 12mm !important;
    display: block !important;
    opacity: 0.9 !important;
  }
  .cover-title { font-size: 32pt; color: #c00 !important; margin: 0 0 4mm; border: 0 !important; }
  .cover-subtitle { font-size: 14pt; color: #666 !important; margin: 0 0 20mm; }
  .cover-meta { font-size: 11pt; color: #333 !important; margin: 4mm 0; }
  .cover-author { font-size: 10pt; color: #888 !important; margin-top: 30mm; font-style: italic; }

  .manual-warning { padding: 20mm 10mm; }
  .warning-heading { font-size: 22pt; color: #c00 !important; border-bottom: 2pt solid #c00; padding-bottom: 3mm; page-break-before: avoid !important; }
  .manual-warning p { font-size: 11pt; line-height: 1.7; margin: 6mm 0; }
  .manual-warning ul { margin: 6mm 0 6mm 8mm; }
  .manual-warning li { margin: 3mm 0; line-height: 1.6; }
  .warning-cta { background: #fff5f5 !important; padding: 4mm; border-left: 3pt solid #c00 !important; font-weight: 700; }

  .manual-toc { padding: 15mm 10mm; }
  .toc-heading { font-size: 22pt; color: #c00 !important; border-bottom: 2pt solid #c00; padding-bottom: 3mm; page-break-before: avoid !important; }
  .toc-list { list-style: none; padding: 0; margin: 8mm 0; }
  .toc-list li { padding: 2.5mm 0; border-bottom: 0.5pt dashed #ddd !important; font-size: 12pt; }
  .toc-list a { color: #1a1a1a !important; text-decoration: none; }

  /* HEADINGS · keep v94j + sticky to content */
  h1 { font-size: 24pt; color: #c00 !important; border-bottom: 2pt solid #c00; padding-bottom: 3mm; margin-bottom: 6mm; }
  h2 { font-size: 18pt; color: #c00 !important; page-break-before: always; page-break-after: avoid !important; break-after: avoid !important; margin-top: 0; padding-top: 0; }
  h2:first-of-type, .manual-cover h2, .manual-warning h2, .manual-toc h2 { page-break-before: avoid !important; }
  h3 { font-size: 13pt; color: #333 !important; page-break-after: avoid !important; break-after: avoid !important; margin-top: 5mm; }
  h4 { font-size: 11pt; font-weight: 700; color: #1a1a1a !important; page-break-after: avoid !important; }
  h2 + p, h2 + figure, h3 + p, h3 + figure, h3 + table { page-break-before: avoid !important; }

  /* LINKS */
  a, a * { color: #c00 !important; }
  a { text-decoration: underline; word-break: break-word; }
  a::after { content: "" !important; }

  /* TABLES · keep v94j nuclear */
  table { border-collapse: collapse; width: 100%; margin: 4mm 0; page-break-inside: avoid; font-size: 9.5pt; background: #fff !important; }
  thead, tbody, tfoot, tr, th, td { background-color: transparent !important; background-image: none !important; color: #1a1a1a !important; border: 0.5pt solid #ccc !important; }
  th { background-color: #f3f3f3 !important; font-weight: 700; padding: 2mm 3mm; text-align: left; }
  td { padding: 2mm 3mm; text-align: left; }

  /* CALLOUTS */
  blockquote, .tldr, .pro-tip, .faq, .warning {
    border-left: 3pt solid #c00 !important; padding: 3mm 4mm; margin: 4mm 0;
    background-color: #fafafa !important; page-break-inside: avoid; color: #1a1a1a !important;
  }
  code, pre { background-color: #f5f5f5 !important; color: #1a1a1a !important; padding: 0.5mm 1.5mm; border-radius: 2pt; }

  .video-link-print {
    display: inline-block !important;
    background-color: #fff !important; border: 1.2pt solid #c00 !important; color: #c00 !important;
    padding: 2mm 4mm; margin: 4mm 0; text-decoration: none !important; font-weight: 700; border-radius: 4px;
  }

  /* FIGURE · professional polish (Wiley/Klariti standard) */
  figure, figure *, .manual-figures, .manual-figures *,
  [class*="figure"], [class*="image-wrap"], [class*="img-container"] {
    background-color: transparent !important; background-image: none !important;
  }
  figure, .manual-figures {
    margin: 3mm auto; padding: 2mm; text-align: center;
    border: 0.5pt solid #ddd !important;
    page-break-inside: avoid; break-inside: avoid;
    max-width: 80%;
  }
  figure img, .manual-figures img, figure picture img {
    max-width: 100%; height: auto;
    border-radius: 4px;
    box-shadow: 0 1pt 2pt rgba(0,0,0,0.08) !important;
    display: block; margin: 0 auto;
    background: #fff !important;
  }
  /* small icon buttons = smaller display */
  figure img[src*="/buttons/"], .manual-figures img[src*="/buttons/"] {
    max-width: 50% !important;
  }
  figure img[src*="/indicators/"], .manual-figures img[src*="/indicators/"] {
    max-width: 75% !important;
  }
  figcaption {
    font-size: 8.5pt; color: #666 !important;
    margin-top: 2mm; padding-top: 1.5mm;
    border-top: 0.5pt dotted #ddd !important;
    font-style: italic;
    background: transparent !important;
    page-break-before: avoid !important;
  }

  /* DOCS-FOOTER · keep v94j 23 links */
  .docs-footer { display: block !important; background-color: transparent !important;
    border-top: 1pt solid #ccc !important; margin-top: 8mm; padding: 4mm 0 !important;
    page-break-before: auto; color: #1a1a1a !important; }
  .docs-footer * { background-color: transparent !important; color: #1a1a1a !important; }
  .docs-footer a, .docs-footer a * { color: #c00 !important; display: inline !important; }
  .docs-footer h2, .docs-footer h3, .docs-footer h4 { color: #333 !important; page-break-before: avoid !important; border: 0 !important; }
  .footer-app-badges, .footer-app-badges a, .footer-content, .footer-content a, .footer-brand-wrap { display: revert !important; background: transparent !important; }
  .footer-app-badges img { max-width: 40mm !important; }

  /* XM affiliate banner · v94L→v94M hotfix · kill broken stub + inner alt text · clean CTA
     · iter2 specificity bump (HEAD inline 'a.xm-banner-link img' is 0,1,2 — must beat with 0,2,2+) */
  a.xm-banner-link img[src],
  a.xm-banner-link picture,
  a.xm-banner-link img,
  .xm-banner-link img[src*="pipaffiliates"],
  img[src*="pipaffiliates.com"][alt],
  img[src*="ads.pipaffiliates"][alt],
  a.cta-broker img[src],
  .cta-broker img[src*="pipaffiliates"] {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    max-width: 0 !important;
    max-height: 0 !important;
    font-size: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
  }
  .xm-banner-link, .xm-banner-link * {
    font-size: 0 !important;
    color: transparent !important;
    line-height: 0 !important;
  }
  .xm-banner-link {
    display: block !important;
    background: #fff !important;
    border: 1.5pt solid #c00 !important;
    color: #c00 !important;
    padding: 6mm 8mm !important;
    margin: 4mm auto !important;
    text-decoration: none !important;
    border-radius: 5px !important;
    text-align: center !important;
    width: 80% !important;
    max-width: 140mm !important;
    box-sizing: border-box !important;
    line-height: 1.4 !important;
    overflow: hidden !important;
  }
  .xm-banner-link::before {
    display: block !important;
    font-size: 12pt !important;
    color: #c00 !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    content: "◆ เปิดบัญชี XM Global · iCafeFX Partner 13+ ปี";
  }
  .xm-banner-desktop::before {
    content: "◆ เปิดบัญชี XM Global · iCafeFX Partner 13+ ปี · กดที่นี่";
  }
  .xm-banner-mobile::before {
    content: "▸ XM Global · เปิดบัญชี (Mobile)";
  }
  /* cta-broker (header) keep visible span text · just hide img */
  .cta-broker { font-size: 10pt !important; color: #c00 !important; }

  /* FontAwesome icons · webfont not loaded in headless print
     · hide all <i class="fa-*"> + their ::before glyphs to prevent tofu rects */
  i.fas, i.fab, i.far, i.fal, i.fad, i.fa,
  i[class*="fa-"],
  i[class*="fa-"]::before,
  i[class*="fa-"]::after,
  .fa::before, .fas::before, .fab::before, .far::before {
    display: none !important;
    content: "" !important;
    font-family: inherit !important;
    width: 0 !important;
    visibility: hidden !important;
  }
  /* ensure parent <a> tag still shows its text content (chapter 14 contact links) */
  a > i + *, a i + * { display: inline !important; }

  /* HIDE chrome */
  nav, .toc-sidebar, .floating-cta, .scroll-top, .breadcrumb-fixed, .ad, .affiliate-banner, .sidebar,
  iframe, button:not(.video-link-print) { display: none !important; }

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

/* SCREEN · hide front matter (only print sees them) */
@media screen {
  .manual-cover, .manual-warning, .manual-toc { display: none !important; }
}
