/* CORE: printing a reading page (App\Helpers\Core\PrintEngine, /assets/js/core/print-engine.js): #print-root holds the
   printed head (logo and address, title card), a copy of the content and a footer line; in the print tab
   (html.is-print-view) and while printing it is the only thing on the page; its toolbar is not printed. Page rules: margins, no breaks inside figures, tables, callouts and formulas. */
#print-root { display: none; }
.print-watermark { display: none; }

/* The print tab (?print=1): only the printed page, as a sheet on a grey desk */
html.is-print-view, html.is-print-view body { background: #e5e7eb !important; }
html.is-print-view body > *:not(#print-root) { display: none !important; }
html.is-print-view #print-root { display: block; max-width: 210mm; margin: 24px auto; padding: 14mm; background: #ffffff; border-radius: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); }
@media (max-width: 767.98px) { html.is-print-view #print-root { margin: 0; padding: 16px; border-radius: 0; box-shadow: none; } }

@media print {
    @page { margin: 14mm 14mm 16mm; }
    html, body { background: #ffffff !important; }
    body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    body.is-printing > *:not(#print-root), html.is-print-view body > *:not(#print-root) { display: none !important; }
    body.is-printing #print-root, html.is-print-view #print-root { display: block !important; max-width: none; margin: 0; padding: 0; box-shadow: none; border-radius: 0; }
    html.is-print-view, html.is-print-view body { background: #ffffff !important; }
    #print-root .print-toolbar { display: none !important; }

    #print-root .print-doc { position: relative; max-width: none; color: #111827; }
    #print-root .print-watermark {
        display: block; position: fixed; top: 50%; left: 50%; width: 55%; transform: translate(-50%, -50%);
        opacity: 0.05; filter: grayscale(100%); z-index: 0; pointer-events: none;
    }
    #print-root header, #print-root [data-print-body] { position: relative; z-index: 1; }
    .print-avoid-break { break-inside: avoid; page-break-inside: avoid; }

    /* The copy of the content: full width, wide tables and formulas wrap into the page */
    #print-root .editor-content { color: #1f2937; font-size: 11.5pt; line-height: 1.65; }
    #print-root .editor-content table { display: table !important; width: 100% !important; max-width: 100% !important; overflow: visible !important; }
    #print-root .editor-content .katex-display { overflow: visible !important; }
    #print-root [data-scroll-hint] { position: static; }
    #print-root h1, #print-root h2, #print-root h3, #print-root h4 { break-after: avoid; page-break-after: avoid; }
    #print-root img, #print-root figure, #print-root table, #print-root .callout, #print-root pre,
    #print-root blockquote, #print-root .katex-display { break-inside: avoid; page-break-inside: avoid; }
    #print-root figure, #print-root .img-figure { box-shadow: none !important; }
    #print-root p { orphans: 3; widows: 3; }
    #print-root a { color: inherit !important; text-decoration: none !important; }
}

/* Presentation (#print-root.print-mode-slides): landscape A4 pages (297 x 210 mm) with large type; a title bar, the
   text on the left and its figure on the right (repeated on every page the text needs: print-engine.js) */
@page slides { size: A4 landscape; margin: 0; }
#print-root.print-mode-slides .print-slide { page: slides; }
html.is-print-view #print-root.print-mode-slides { max-width: none; padding: 0; background: transparent; box-shadow: none; border-radius: 0; }
#print-root.is-measuring { display: block !important; position: absolute; left: -10000px; top: 0; }
.print-slides { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.print-slide {
    position: relative; box-sizing: border-box; width: 297mm; height: 210mm; overflow: hidden; background: #ffffff;
    padding: 14mm 16mm 18mm; display: flex; flex-direction: column; color: #111827;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); border-radius: 6px;
}
.print-slide-head { padding-bottom: 4mm; margin-bottom: 6mm; }
.print-slide-head h2 { font-size: 26pt; }
.print-slide-body { flex: 1; min-height: 0; display: flex; gap: 10mm; }
.print-slide .print-slide-text { flex: 1; min-width: 0; height: 100%; overflow: hidden; font-size: 17pt !important; line-height: 1.5 !important; }
.print-slide-text > *:first-child { margin-top: 0 !important; }
.print-slide-text h3 { font-size: 20pt; }
.print-slide .print-slide-text.is-small { font-size: 12pt !important; }
/* The text column is the page's width (not the reading column's two thirds) and every line takes its type */
.print-slide .print-slide-text > *, .print-slide .print-slide-text .callout { max-width: 100% !important; float: none !important; }
.print-slide .print-slide-text :is(p, li, td, th, blockquote, dd, dt, figcaption) { font-size: inherit !important; line-height: inherit !important; }
.print-slide-figure { width: 42%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; min-height: 0; }
.print-slide-figure:empty { display: none; }
.print-slide-figure figure, .print-slide-figure img { max-width: 100%; max-height: 100%; margin: 0 !important; }
.print-slide-figure figure { display: flex; flex-direction: column; align-items: center; max-height: 100%; }
.print-slide-figure img { object-fit: contain; height: auto; max-height: 150mm; }
.print-slide-figure figcaption { font-size: 11pt; text-align: center; margin-top: 3mm; }
.print-slide-foot {
    position: absolute; left: 16mm; right: 16mm; bottom: 6mm; display: flex; align-items: center; justify-content: space-between;
    gap: 6mm; font-size: 9pt; color: #6b7280;
}
.print-slide-cover { flex-direction: row; align-items: center; gap: 14mm; }
.print-slide-cover-text { flex: 1; min-width: 0; }
.print-slide-cover h1 { font-size: 40pt; }
.print-slide-cover .print-slide-summary { font-size: 16pt; }
.print-slide-cover-img { width: 38%; max-height: 150mm; object-fit: cover; border-radius: 12px; border: 1px solid #e5e7eb; }

@media print {
    #print-root.print-mode-slides .print-slides { display: block; }
    #print-root.print-mode-slides .print-slide { box-shadow: none; border-radius: 0; break-after: page; page-break-after: always; }
    #print-root.print-mode-slides .print-slide:last-child { break-after: auto; page-break-after: auto; }
    #print-root.print-mode-slides .print-watermark { display: none; }
}
