/* Printing an exam (js/pages/teacher-print.js). On screen it is a sheet of paper under a toolbar; when printing,
   everything but the paper goes away. The paper is always black on white, whatever theme is on. */

.print-layout { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.print-side { position: sticky; top: 4.2rem; }
.print-controls { display: grid; gap: 1.1rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.print-set { display: grid; gap: 0.4rem; }
.print-set-label { font-weight: 600; font-size: 0.9em; }
.print-checks { display: grid; gap: 0.3rem; }
.print-set .seg { display: flex; }
.print-set .seg-btn { flex: 1; padding: 0 0.3rem; }
.print-controls .btn { width: 100%; justify-content: center; }
.print-note { font-size: 0.8em; margin: 0; }
.print-paper { min-width: 0; }
@media (max-width: 52rem) { .print-layout { grid-template-columns: 1fr; } .print-side { position: static; } }
/* A paper is a stack of A4 pages (.print-pg), made in js/lib/paginate.js. On screen each page is a white sheet; in print
   each is exactly one page, with the margin kept by its own padding (@page has none, so no browser header or footer). */
.print-paper { min-width: 0; overflow-x: auto; }
.print-doc { color: #000; font-size: 11pt; line-height: 1.45; text-transform: none; }
.print-pg {
  position: relative; display: flex; flex-direction: column; width: 21cm; min-height: 29.65cm; padding: 1.2cm; margin: 0 auto 1rem;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.print-cols { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr; gap: 0 1.2cm; }
.print-cols.cols-2 { grid-template-columns: 1fr 1fr; background: linear-gradient(#bbb, #bbb) center / 1px 100% no-repeat; }
.print-col { min-width: 0; }
.print-warn { display: grid; gap: 0.3rem; margin: 0 0 1rem; padding: 0.6rem 0.8rem; border: 1px solid var(--warn); border-radius: var(--radius); }
.print-warn ul { margin: 0; padding-left: 1.2rem; }
/* The page counter: in the bottom margin (inside the page's own padding), so the questions' room is unchanged. */
.print-foot { position: absolute; left: 1.2cm; right: 1.2cm; bottom: 0.3cm; display: flex; justify-content: space-between; gap: 1cm; padding-top: 0.2cm; border-top: 1px solid #999; font-size: 9pt; align-items: center; line-height: 1.2; color: #444; }
.print-foot-start { display: flex; align-items: center; gap: 0.35cm; min-width: 0; }
.print-foot-start span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.print-foot > span:last-child { flex: none; }
.print-foot-mark { flex: none; height: 0.55cm; width: auto; }
/* Measuring (invisible): the same paper laid out off-screen at its real widths. */
.print-measure { --col-w: 18.6cm; position: absolute; left: -400cm; top: 0; width: 18.6cm; visibility: hidden; pointer-events: none; }
.print-measure-col { width: var(--col-w, 18.6cm); }
.print-doc.size-small { font-size: 9.5pt; }
.print-doc.size-large { font-size: 13pt; }
.print-doc *, .print-doc a { color: #000; text-transform: none; }
/* The header: a brand strip, the title, then name / class / date / grade as labelled lines. */
.print-head { padding-bottom: 0.7cm; } /* padding, not margin: it is part of the height that is measured */
.print-brand { display: flex; align-items: center; gap: 0.35cm; padding-bottom: 0.25cm; border-bottom: 2.5px solid #000; margin-bottom: 0.4cm; }
.print-logo { height: 0.85cm; width: auto; display: block; }
.print-school { padding-left: 0.35cm; border-left: 1.5px solid #000; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.85em; }
.print-meta { margin: 0.2cm 0 0; font-size: 0.85em; color: #444; }
.print-brand .print-meta { margin: 0 0 0 auto; font-size: 0.8em; color: #333; white-space: nowrap; }
.print-titlerow { display: flex; align-items: stretch; gap: 0.6cm; }
.print-titles { flex: 1 1 auto; min-width: 0; }
.print-head h1 { font-size: 1.7em; line-height: 1.15; margin: 0 0 0.15cm; }
.print-desc { margin: 0 0 0.3cm; color: #222; }
.print-fields { display: flex; flex-wrap: wrap; gap: 0.35cm 0.6cm; margin-top: 0.35cm; padding: 0.3cm 0.4cm 0.25cm; border: 1px solid #888; border-radius: var(--radius); }
.print-field { display: flex; flex-direction: column; justify-content: flex-end; flex: 1 1 3.2cm; min-width: 0; }
.print-field-wide { flex: 3 1 8cm; }
.print-field-label { font-size: 0.75em; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase !important; color: #333; margin-bottom: 0.05cm; }
.print-field i, .print-filled { display: block; min-height: 0.75cm; border-bottom: 1px solid #000; }
.print-filled { font-weight: 400; padding-top: 0.2cm; }
/* dia / mês / ano: three short lines with slashes between, filled in when the date is known */
.print-field-date { flex: 0 0 auto; }
.print-date { display: flex; align-items: flex-end; gap: 0.15cm; min-height: 0.75cm; }
.print-part { display: inline-block; text-align: center; border-bottom: 1px solid #000; min-height: 0.75cm; padding-top: 0.2cm; box-sizing: border-box; }
.print-part-day, .print-part-month { width: 1.1cm; }
.print-part-year { width: 1.7cm; }
.print-slash { padding-bottom: 0.05cm; }
.print-piece { display: flow-root; padding-bottom: 0.18cm; } /* flow-root: the text's own margins stay inside, so what is measured is what is laid out */
.print-q { break-inside: auto; }
.print-piece.print-last { padding-bottom: 0.6cm; }
.print-option { display: flex; gap: 0.25cm; align-items: baseline; padding-bottom: 0.1cm; }
.print-qhead { margin-bottom: 0.15cm; }
.print-qtitle { font-weight: 400; color: #333; }
.print-stem { margin-bottom: 0.2cm; }
.print-stem p { margin: 0 0 0.2cm; }
.print-piece img { max-width: 100%; max-height: 11cm; width: auto; height: auto; object-fit: contain; }
.print-doc.cols-2 .print-piece img { max-height: 8cm; } /* a figure can never be taller than a column */
.print-letter { flex: none; width: 1.4em; height: 1.4em; display: inline-grid; place-items: center; border: 1px solid #000; border-radius: var(--radius-round); font-weight: 700; font-size: 0.85em; }
.print-opt { min-width: 0; overflow-wrap: anywhere; }

.print-key h2 { margin: 0 0 0.2cm; }
.key-grid { list-style: none; margin: 0.6cm 0 0; padding: 0; column-count: 3; column-gap: 1cm; }
.key-line { display: flex; align-items: center; gap: 0.25cm; break-inside: avoid; margin-bottom: 0.2cm; }
.key-num { width: 1.6em; text-align: right; font-weight: 700; }
/* The cartão-resposta is one SVG drawn in millimetres (js/lib/omr.js): it fills the page, no margin of its own. */
.print-omr { padding: 0; height: 29.65cm; overflow: hidden; }
.omr-sheet { display: block; width: 210mm; height: 297mm; letter-spacing: normal; word-spacing: normal; } /* a reader's dyslexia spacing must not move the machine-read labels */
.omr-fiducial, .omr-orientation { fill: #000; }
.omr-bubble { fill: none; stroke: #000; }
.omr-row, .omr-block { stroke-linecap: round; }
.omr-band { fill: #e9e9e9; } /* every other row, pale enough not to be mistaken for a mark */
.omr-frame { fill: none; stroke: #888; }
.omr-qr { fill: #000; shape-rendering: crispEdges; } /* sharp edges: a QR reader wants hard modules */
.omr-logo { image-rendering: auto; }

@page { size: A4; margin: 0; }
@media print {
  html, body, main, #app { background: #fff !important; color: #000 !important; }
  body.exam-mode .site-header, .site-header, .toasts, .print-toolbar, .skip-link, noscript { display: none !important; }
  main { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  .print-layout { display: block; }
  .print-paper { overflow: visible; }
  .print-fit { zoom: 1 !important; }
  .print-pg { margin: 0; border: 0; border-radius: 0; break-after: page; }
  .print-doc:last-of-type > .print-pg:last-child { break-after: auto; }
  .print-letter, .print-doc img, .omr-sheet *, .omr-band { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-cols.cols-2 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { text-decoration: none; }
  * { animation: none !important; transition: none !important; }
}
.print-page { min-width: 0; }

/* One copy per student (js/pages/teacher-print-class.js). The copy's own look comes from data attributes that js/lib/paper.js
   sets from the student's settings; they are not data-dyslexia / data-cb, which restyle the whole interface. */
.print-copies { min-width: 0; }
.paper-filters { position: absolute; width: 0; height: 0; overflow: hidden; }
.print-roll { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; max-height: 22rem; overflow: auto; }
.print-roll-row { display: grid; gap: 0.1rem; }
.print-roll-note { padding-left: 1.7rem; }

/* Dyslexia: the open font, looser spacing, ragged right edge, no justification. Maths keeps its own spacing. */
.print-doc[data-paper-dyslexia="true"] { font-family: "OpenDyslexic", "Comic Sans MS", "Trebuchet MS", sans-serif; letter-spacing: 0.05em; word-spacing: 0.16em; line-height: 1.8; text-align: left; }
.print-doc[data-paper-dyslexia="true"] .katex { letter-spacing: normal; word-spacing: normal; }
.print-doc[data-paper-dyslexia="true"] .print-piece.print-last { padding-bottom: 0.9cm; }
/* Colour vision: pictures are shifted onto colours the reader can tell apart (js/lib/paper.js). */
.print-doc[data-paper-cb="protanopia"] img { filter: url(#paper-cb-protanopia); }
.print-doc[data-paper-cb="deuteranopia"] img { filter: url(#paper-cb-deuteranopia); }
.print-doc[data-paper-cb="tritanopia"] img { filter: url(#paper-cb-tritanopia); }
