/* ============================================================
   Print — tool pages (enqueued with media="print").
   When a tool asks to print (OppTools.print(root) sets data-print-root
   on the A4 .op-doc and calls window.print()), ONLY that element prints:
   A4, 18 mm margins, black on white, no chrome, the document's own
   lang/dir (set on .op-doc) decides alignment. Without a print root
   (Ctrl+P on the page) the page prints without site chrome or tool UI.
   ============================================================ */
@media print {
  @page { size: A4; margin: 18mm; }

  html, body { background: #fff !important; color: #000 !important; }
  body { display: block !important; min-block-size: 0 !important; padding: 0 !important; margin: 0 !important; }

  /* Site chrome and tool controls never print */
  .op-header, .op-footer, .op-skip-link, .op-breadcrumb, .op-nl, .op-follow, .op-sticky-cta,
  .opp-ad-slot, .op-ad, .op-toasts, .op-modal, .op-tool__account, .op-toolbar, .op-sop__tabs,
  .op-sop__toolbar, .op-steps, .op-tips, button, [role="button"], dialog, noscript, .op-tool__boot { display: none !important; }

  /* ---- With a print root: everything except the root and its ancestors disappears ---- */
  body:has([data-print-root]) *:not(:has([data-print-root])):not([data-print-root]):not([data-print-root] *) { display: none !important; }

  /* Ancestors of the root become plain blocks: no boxes, no grid, no offsets */
  body:has([data-print-root]) *:has([data-print-root]) {
    display: block !important; position: static !important; inset: auto !important; transform: none !important;
    inline-size: auto !important; max-inline-size: none !important; min-block-size: 0 !important; block-size: auto !important;
    margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
    background: none !important; box-shadow: none !important; overflow: visible !important;
    container-type: normal !important;
  }

  /* The sheet: page margins come from @page, so the element itself has none */
  [data-print-root] {
    display: block !important; position: static !important;
    inline-size: auto !important; max-inline-size: none !important; aspect-ratio: auto !important; min-block-size: 0 !important;
    margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
    background: #fff !important; color: #000 !important;
    font-size: 11pt !important; line-height: 1.55 !important;
    -webkit-print-color-adjust: economy; print-color-adjust: economy;
  }
  [data-print-root][lang="ar"], [data-print-root]:lang(ar) { line-height: 1.8 !important; }
  [data-print-root].op-doc--small { font-size: 10pt !important; }
  [data-print-root] * { color: #000 !important; background: none !important; box-shadow: none !important; }
  [data-print-root] a { text-decoration: none !important; }
  [data-print-root] a[href]::after { content: none !important; }

  /* Page breaks: keep the letter head together, never strand a heading or 1–2 lines */
  .op-doc__head, .op-doc__to, .op-doc__sign { break-inside: avoid; page-break-inside: avoid; }
  .op-doc__h { break-after: avoid; page-break-after: avoid; }
  .op-doc p { orphans: 3; widows: 3; }
  .op-doc__head { border-block-end-color: #999 !important; }
  .op-doc__placeholder { display: none !important; } /* empty-field hints are screen-only */

  /* ---- Without a print root: readable page, no tool UI ---- */
  body:not(:has([data-print-root])) .op-tool { display: none !important; }
  body:not(:has([data-print-root])) .op-faq__item { break-inside: avoid; }
  body:not(:has([data-print-root])) a { color: #000 !important; text-decoration: none !important; }
}
