/* =========================================================================
   Zomestruct — print stylesheet (paginated PDF)
   Renders the engineering-document aesthetic onto US Letter pages with
   running page-of-pages footer and a project title-strip top of every
   page (drawing-block convention).
   ========================================================================= */

@page {
    size: Letter;
    margin: 18mm 16mm 22mm;

    @top-left {
        content: "Zomestruct · ZS-2026-001-CALC-001";
        font-family: 'IBM Plex Mono', ui-monospace, monospace;
        font-size: 8pt;
        color: #5a6068;
        letter-spacing: 0.04em;
    }
    @top-right {
        content: "Rev. 0 · 2026-05-04";
        font-family: 'IBM Plex Mono', ui-monospace, monospace;
        font-size: 8pt;
        color: #5a6068;
    }
    @bottom-left {
        content: "Issued for EOR review";
        font-family: 'IBM Plex Mono', ui-monospace, monospace;
        font-size: 8pt;
        color: #5a6068;
        letter-spacing: 0.04em;
    }
    @bottom-right {
        content: "Page " counter(page) " of " counter(pages);
        font-family: 'IBM Plex Mono', ui-monospace, monospace;
        font-size: 8pt;
        color: #5a6068;
    }
}

@page :first {
    margin: 0;
    @top-left { content: ""; }
    @top-right { content: ""; }
    @bottom-left { content: ""; }
    @bottom-right { content: ""; }
}

@media print {
    html, body {
        background: white !important;
        color: #0b0d10 !important;
        font-size: 9.5pt;
        line-height: 1.45;
        font-family: 'IBM Plex Serif', Georgia, serif;
    }

    body::before { display: none !important; }

    /* Hide screen-only chrome */
    .toc, .toc__pdf, .skip-print, .footer, dialog.src-popup { display: none !important; }

    /* Single-column print body */
    .shell {
        display: block !important;
        max-width: none !important;
        padding: 0 !important;
        background: white !important;
    }
    .content {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        background: white !important;
    }

    /* Cover gets its own page */
    .cover {
        min-height: 100vh;
        page-break-after: always;
        break-after: page;
        padding: 22mm 16mm !important;
        border-bottom: none !important;
        box-shadow: none !important;
    }
    .cover__logo { right: 16mm !important; top: 30mm !important; opacity: 0.95 !important; }

    /* Each top-level section starts on a new page */
    .section {
        page-break-before: always;
        break-before: page;
        margin-bottom: 0 !important;
    }
    .section:first-of-type {
        page-break-before: auto;
        break-before: auto;
    }

    /* Findings keep within their parent section but try to avoid mid-result splits */
    .finding {
        page-break-before: auto;
        break-inside: avoid-page;
    }
    .finding__title, .finding__verdict { break-after: avoid; }

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

    figure.figure, .table-wrap, .verdict, .callout, .stat-grid, pre,
    .sigblock, .doc-control {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Tighter type so content fits */
    .section__title { font-size: 18pt; }
    .section__lede  { font-size: 10pt; }
    .section h3     { font-size: 13pt; }
    .section h4     { font-size: 10pt; }
    .finding__title { font-size: 13pt; }
    .stat__num      { font-size: 18pt; }
    table.data      { font-size: 8.5pt; }
    table.data th, table.data td { padding: 3pt 5pt; }

    /* Links: keep link colour but drop underline noise */
    a { color: #1a3556 !important; text-decoration: none !important; }

    /* Source-popup triggers print as plain text (no underline, no icon) */
    .src { border-bottom: none !important; cursor: default !important; }
    .src .src__icon { display: none !important; }

    /* Margin notes inline */
    .margin-note {
        background: #f4f5f7 !important;
        font-size: 9pt !important;
    }

    pre {
        background: #f4f5f7 !important;
        color: #0b0d10 !important;
        border: 1px solid #c8ccd2;
        font-size: 8pt;
    }

    /* D/C bar fills come from data-pct via JS — make sure they keep their
       width through print rendering by giving the element the inline
       style during page render. Headless Chrome runs JS first so this
       is fine; but we also fall back to a non-zero default visible bar. */
    .dc-bar__track { background: #ffffff !important; border-color: #0b0d10 !important; }
    .dc-bar__fill { background: #14633a !important; }
    .dc-bar__fill--warn { background: #8a5a06 !important; }
    .dc-bar__fill--fail { background: #a01818 !important; }

    /* Print-only: emit a dark-coloured horizontal rule between articles */
    .finding { border-top: 1.5pt solid #0b0d10 !important; }
}
