/* Print-only (linked with media="print"). Active only while certificates.js sets html[data-printing];
   otherwise Ctrl+P prints the page as it is. The @page rule itself is added by certificates.js
   (PAGE_RULES) only while printing: A4 landscape with margin 0 for certificates, so Chrome and Edge
   have no room for their header and footer, and A4 portrait, also margin 0, for «قائمة الأوائل». */

html[data-printing], html[data-printing] body {
    background: #fff !important; color: #000; min-height: 0 !important; height: auto !important; display: block !important;
    margin: 0 !important; padding: 0 !important; overflow: visible !important; zoom: 1 !important;
}
/* nothing from the site prints: only the print container */
html[data-printing] body > *:not(#print-root) { display: none !important; }
html[data-printing] #print-root {
    display: block !important; position: static !important; margin: 0 !important; padding: 0 !important;
    width: auto !important; transform: none !important;
}
html[data-printing] * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; animation: none !important; transition: none !important; }

/* one certificate = one page: the same fixed A4 box on every page, nothing spills past its frame */
html[data-printing="certs"] .cert-sheet { display: block; margin: 0; padding: 0; }
html[data-printing="certs"] .cert-page {
    display: block; position: relative; box-sizing: border-box; margin: 0; padding: 0;
    width: 297mm; height: 210mm; min-height: 210mm; max-height: 210mm; overflow: hidden;
    break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;
    box-shadow: none; border: 0; transform: none;
}
html[data-printing="certs"] .cert-page:last-child { break-after: auto; page-break-after: auto; }
/* printNode wraps each certificate in a .cert-slot: the slot owns the page break */
html[data-printing="certs"] .cert-slot { display: block; margin: 0 auto; break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid; }
html[data-printing="certs"] .cert-slot:last-child { break-after: auto; page-break-after: auto; }
html[data-printing="certs"] .cert-slot > .cert-page { break-after: auto; page-break-after: auto; }
/* iPhone / iPad (html[data-print-turn], set by printNode): Safari there ignores `size: A4 landscape` and
   prints portrait, so the certificate is turned sideways and shrunk a little to fill the page inside the
   phone's own margins. 176 × 248.9 mm is the 297 × 210 mm board at .8381, standing up.
   (Not a `(orientation: portrait)` query: Chrome evaluates that against its default page and would turn
   a correctly landscape print.) */
html[data-printing="certs"][data-print-turn] .cert-slot { position: relative; width: 176mm; height: 248.9mm; overflow: hidden; }
html[data-printing="certs"][data-print-turn] .cert-slot > .cert-page {
    position: absolute; top: 0; left: 0; transform-origin: 0 0;
    transform: translateX(176mm) rotate(90deg) scale(.8381);
}
