/* =========================================================================
   print.css — shared print / export-to-PDF worksheet stylesheet.
   Loaded via <link rel="stylesheet" href="print.css" media="print">.
   All rules live inside @media print, so this file is inert on screen even
   if the <link> is added without a media attribute.

   Goals:
     - hide chrome / interactive-only UI (header, nav, presenter, floating btns…)
     - ink-on-white: white background + dark text (save toner, read on paper)
     - respect the active data-lang (print only the selected language — do NOT
       force both AR + HE; the existing .Lar/.he rules keep working)
     - keep lessons / challenges / notes from splitting across pages
     - expand scroll areas so nothing is clipped
     - render links minimally (plain dark text)
   ========================================================================= */

@media print {

  /* ---------- page setup ---------------------------------------------- */
  @page { margin: 1.5cm; }

  /* ---------- ink-on-white: kill dark surfaces & light text ----------- */
  html, body {
    background: #ffffff !important;
    color: #111111 !important;
  }
  /* Neutralize every dark panel / gradient / light-on-dark text so the
     whole document reads as black ink on white paper. */
  *, *::before, *::after {
    background: transparent !important;
    background-image: none !important;
    color: #111111 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* Gradient / clipped headings use transparent fill on screen — restore
     them to solid ink so they don't vanish on paper. */
  .grad {
    color: #111111 !important;
    -webkit-text-fill-color: #111111 !important;
    -webkit-background-clip: border-box !important;
    background-clip: border-box !important;
  }
  /* decorative animated aurora / grid backgrounds */
  body::before, body::after,
  .enh body::before, .enh body::after { display: none !important; content: none !important; }

  /* ---------- hide chrome / interactive-only elements ----------------- */
  header.bar,                 /* sticky top header bar */
  .cn,                        /* sticky module nav strip */
  #enh-prog,                  /* scroll progress bar */
  .pprogress,                 /* per-page student progress bar */
  .lang-btn,                  /* AR/HE language toggle */
  .mode-btn,                  /* student/teacher mode toggle */
  .pr-launch,                 /* "start presentation" floating button */
  .pr-bar, .pr-foot,          /* presenter top/bottom bars */
  .pr-jump, .pr-jump-wrap,    /* presenter jump-to-lesson menu */
  .pr-btn, .pr-clock, .pr-count, .pr-prog,  /* presenter controls */
  .spy, .spy-bar, .spy-sheet, /* scroll-spy rail / mobile bar / sheet */
  .no-print,                  /* explicit opt-out marker */
  [data-no-print],
  [aria-hidden="true"]:not(.em):not(.dot) {
    display: none !important;
  }

  /* ---------- presenter stage: if printed while presenting, un-fix it
       so its content flows inline instead of staying a clipped overlay */
  .pr-stage {
    position: static !important;
    inset: auto !important;
    overflow: visible !important;
    max-height: none !important;
    padding: 0 !important;
    font-size: 1rem !important;
  }
  html.pr-on, html.pr-on body { overflow: visible !important; }

  /* ---------- expand any scroll / clipped areas ----------------------- */
  .cn-in, pre, code, .mono, .tryit, .box, .say,
  [style*="overflow"], [class*="scroll"] {
    overflow: visible !important;
    max-height: none !important;
  }

  /* ---------- structure: light borders so cards still read as boxes --- */
  .lesson, .pchal, .note, .module, .sec, .card, .fcard,
  .unit-card, .box, .tryit {
    border: 1px solid #999999 !important;
    background: #ffffff !important;
    border-radius: 6px;
  }

  /* ---------- avoid awkward page breaks ------------------------------- */
  .lesson, .pchal, .note, .sec, .box, .tryit, .card,
  figure, table, pre, blockquote, li {
    break-inside: avoid;
    page-break-inside: avoid;   /* legacy alias */
  }
  h1, h2, h3, h4 {
    break-after: avoid;
    page-break-after: avoid;
  }
  h2, h3 { break-before: auto; }

  /* ---------- links: minimal, unobtrusive ink ------------------------- */
  a, a:link, a:visited {
    color: #111111 !important;
    text-decoration: none;
  }
  /* NOTE: we intentionally do NOT print href URLs after links — worksheets
     read cleaner without them. */

  /* ---------- language visibility ------------------------------------
     Re-assert the on-screen data-lang rules so print shows ONLY the active
     language, even if this file loads before present.css. We never force
     both languages visible. */
  html[data-lang="ar"] .he,
  html[data-lang="ar"] .cn-he { display: none !important; }
  html[data-lang="he"] .Lar   { display: none !important; }

  /* keep text crisp & full-width on the page */
  .wrap { max-width: 100% !important; padding: 0 !important; }
  img, svg { max-width: 100% !important; height: auto !important; }
}
