/* ============================================================================
   print.css — linked with media="print", so it costs nothing on screen.

   A PDF of this website is a graded deliverable, so printing is a first-class
   output, not an afterthought. /print assembles every lesson, all homework, all
   assessments and the whole final test into one document; this stylesheet makes
   that document read like a printed booklet.
   ========================================================================= */

@page {
  size: A4;
  margin: 18mm 16mm 20mm;
}

:root {
  /* Print on paper, in the light palette, whatever the visitor's screen theme
     is. light-dark() follows color-scheme, so pinning the scheme is enough. */
  color-scheme: light !important;
}

html, body {
  background: #fff !important;
  color: #111111 !important;
  font-size: 10.5pt;
  line-height: 1.55;
}

* { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* --- what does not belong on paper ------------------------------------- */
.site-nav, .site-footer, .skip-link, .theme-toggle,
.lesson-rail, .lesson-pager, .print-only-controls,
.no-print, .widget-controls, .scorebar .btn,
.q-options, .q-entry, .q-rubric input, .video-facade, .video-frame {
  display: none !important;
}

/* A widget's interactive shell prints as its readout and its figure only. */
.widget { border: 1px solid #111 !important; break-inside: avoid; }
.widget-head { border-bottom: 1px solid #111 !important; }
.widget-readout { border-top: 1px solid #111 !important; }

/* --- structure ---------------------------------------------------------- */
.wrap { max-width: none; padding-inline: 0; }
.section, .section-tight { padding-block: 0 0; }

/* The cover page exists only on paper. */
.print-cover {
  display: block !important;
  break-after: page;
  padding-block: 40mm 0;
}
.print-cover .title-hero { font-size: 40pt; }
.print-cover .lede { font-size: 12pt; }

.print-part { break-before: page; }
.print-part:first-of-type { break-before: auto; }
.print-lesson { break-before: page; }
.print-lesson:first-of-type { break-before: auto; }

h1, h2, h3, .title-hero, .title-section, .title-sub, .title-minor {
  break-after: avoid; break-inside: avoid; color: #111111 !important;
}
.title-hero    { font-size: 30pt; margin: 0 0 10pt; letter-spacing: -0.03em; }
.title-section { font-size: 18pt; margin: 0 0 8pt; }
.title-sub     { font-size: 13pt; }
.title-minor   { font-size: 11pt; }
.kicker, .label, .figcap .fig-no { color: #e30613 !important; }

figure, .panel, .aside, .worked, .watchout, .q-card, .card-out, table {
  break-inside: avoid;
}
p, li { orphans: 3; widows: 3; }

.plate, .plate-fig { border: 1px solid #111 !important; padding: 6pt !important; }
.dgm { max-height: 78mm; }
img, svg { max-width: 100% !important; }

/* --- solutions are always open on paper --------------------------------- */
details.reveal, details { display: block !important; }
details:not([open]) > *:not(summary) { display: revert !important; }
details::details-content { content-visibility: visible !important; block-size: auto !important; }
details.reveal > summary { list-style: none; }
details.reveal > summary::after { display: none; }
details.reveal > summary { font-size: 7.5pt; letter-spacing: .12em; color: #e30613 !important; }
details.reveal > summary::before { display: none; }

/* --- assessments on paper ----------------------------------------------
   The interactive answer UI is hidden above; what a marker needs to see is the
   question, its category, its marks and the full worked solution. */
.q-card { border: 1px solid #111 !important; padding: 10pt 12pt; margin-bottom: 10pt; }
.q-print-answer { display: block !important; }
.tag { border-color: #111 !important; color: #111 !important; background: transparent !important; }

.scorebar { display: none !important; }

/* --- links --------------------------------------------------------------
   In-page anchors are meaningless on paper; an external reference is not, so
   print its URL once, small, after the link text. */
a { color: #111111 !important; text-decoration: none; }
a[href^="http"]::after {
  content: " (" attr(href) ")";
  font-size: 8pt; color: #666666; word-break: break-all;
}

/* --- MathJax ------------------------------------------------------------ */
mjx-container[display="true"] { overflow: visible !important; break-inside: avoid; }
mjx-container svg { max-width: 100% !important; height: auto; }

/* Motion never applies to paper. */
* { transition: none !important; animation: none !important; }
