/* ============================================================================
   print.css — Printable / "Save as PDF" styles for the textbook reader
   ============================================================================
   Loaded on reader.html. All rules are scoped to `@media print` so they only
   apply when the browser renders the page for print / "Save as PDF".

   Goals:
   - Produce a clean, selectable-text study copy of a chapter.
   - EXCLUDE interactive mini-tools (replaced by a print-only "view online" note
     injected by reader-pdf.js).
   - EXCLUDE self-check / quiz answer UI (question prompts stay; a note points
     students to the online version for answer checking).
   - Reveal collapsed deep-dives / code snippets so nothing is hidden on paper.
   - Show a print-only header banner carrying the chapter title, last-updated
     date, and the generated-on date + disclaimers.

   Screen-side styles for the button and confirmation modal live in reader.css.
   ============================================================================ */

/* Print-only elements are hidden on screen; revealed only when printing. */
.pdf-print-only {
  display: none;
}

@media print {
  /* ---- Page setup ---- */
  @page {
    margin: 18mm 16mm;
  }

  html,
  body {
    background: #fff !important;
    color: #111 !important;
    font-size: 11.5pt;
  }

  /* ---- Hide app chrome / interactive-only UI ---- */
  .auth-bar,
  #reader-breadcrumb,
  #reader-toc,
  .toc-collapsed-tab,
  #reader-progress-bar,
  #reader-divider,
  #reader-tool-panel,
  .reader-focus-overlay,
  #module-reading-time,
  #module-resources,
  .toc-pdf-export,
  .pdf-export-modal-overlay,
  .onboarding-tutorial-overlay,
  .onboarding-tutorial-pill,
  .badge-notification,
  #llm-chat-container,
  .professor-minimize-pill {
    display: none !important;
  }

  /* Collapse the split-screen grid down to a single readable column. */
  .reader-layout,
  .reader-layout.split-open,
  .reader-layout.tool-expanded {
    display: block !important;
  }

  /* Printing with a tool open: release the viewport-locked split layout. */
  body.reader-split-active {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .reader-content,
  .reader-layout.split-open .reader-content {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .module-body {
    max-width: 100% !important;
  }

  /* ---- Print-only header banner (injected by reader-pdf.js) ---- */
  .pdf-print-only {
    display: block !important;
  }

  .pdf-print-header {
    border-bottom: 2px solid #111;
    padding-bottom: 10px;
    margin-bottom: 18px;
  }

  .pdf-print-header .pdf-ph-brand {
    font-size: 10pt;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #444;
  }

  .pdf-print-header .pdf-ph-title {
    font-size: 17pt;
    font-weight: 800;
    margin: 4px 0 2px;
  }

  .pdf-print-header .pdf-ph-meta {
    font-size: 9.5pt;
    color: #333;
    margin: 2px 0;
  }

  .pdf-print-header .pdf-ph-disclaimer {
    font-size: 9pt;
    color: #444;
    margin-top: 6px;
    font-style: italic;
    line-height: 1.4;
  }

  /* ---- Mini-tools: hide the live widget, show injected placeholder note ---- */
  .mini-tool-container,
  .plotly-graph-div {
    display: none !important;
  }

  /* ---- Videos: not printable ---- */
  .chapter-block.video .video-wrapper,
  .chapter-block.video iframe {
    display: none !important;
  }

  /* ---- Reveal collapsed content so nothing is hidden on paper ---- */
  .deep-dive-body,
  .chapter-block.block-collapsed .deep-dive-body,
  .chapter-block .deep-dive-body[hidden] {
    display: block !important;
  }

  .deep-dive-toggle,
  .code-copy-btn,
  .block-collapse-toggle {
    display: none !important;
  }

  /* Reveal any element hidden purely via the [hidden] attribute inside blocks. */
  .chapter-block [hidden] {
    display: revert !important;
  }

  /* ---- Self-check / assessment blocks: keep the prompt, drop answer UI ---- */
  .chapter-block.assessment .assessment-actions,
  .chapter-block.assessment .assessment-submit-btn,
  .chapter-block.assessment .assessment-feedback,
  .chapter-block.assessment .assessment-option-marker {
    display: none !important;
  }

  .chapter-block.assessment .assessment-option {
    list-style: disc;
    margin-left: 1.2rem;
  }

  /* ---- Chapter check-up quiz: hide the interactive start UI ---- */
  #chapter-quiz .chapter-quiz-start-btn,
  #chapter-quiz .chapter-quiz-icon {
    display: none !important;
  }

  /* Injected "view online" note styling. */
  .pdf-online-note {
    display: block !important;
    border: 1px dashed #999;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 8px 0;
    font-size: 9.5pt;
    color: #444;
    background: #f7f7f7;
  }

  /* ---- Typography & page-break hygiene ---- */
  a {
    color: #111 !important;
    text-decoration: none;
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .chapter-block,
  figure,
  table,
  .comparison-grid,
  pre,
  blockquote,
  img {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Keep references with readable numbering. */
  #module-references {
    display: block !important;
    margin-top: 24px;
  }

  .references-list li {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
