/* Print pass for the report screens (#3016). Hides interactive chrome so
   printing a report page yields a clean document. Since #4449 this is no longer
   the PDF path — Export PDF generates a real file server-side (board report
   first; management and identification follow) — but browser printing itself
   stays supported, so these rules remain. */
@media print {
    /* Navigation chrome and interactive controls.

       #6200 — THIS RULE HID NO BREADCRUMB FOR TWO ROUNDS, FOR TWO DIFFERENT REASONS. Recorded in
       full, because the second mistake was made while fixing the first and only a rendered pass
       caught it.

       Round 1: the selector was `.breadcrumb`, which is BOOTSTRAP's class. Nothing this stylesheet
       serves wears it, so every printed page led with its navigation trail.

       Round 2: it became `.breadcrumbs`, read off
       platform/src/OpusDatum.Platform.UI/Components/Shared/Breadcrumbs.razor. **RiskCheck does not
       render that component.** It has its own at Components/Shared/Breadcrumbs.razor, which shadows
       it deliberately — its own header says the shared one used house design tokens RiskCheck retired
       with app.css, so it rendered unthemed. The RiskCheck one emits only Bootstrap utilities:

           <nav class="d-flex align-items-center flex-wrap gap-2 small text-body-secondary mb-3"
                aria-label="breadcrumb">

       No breadcrumb class of any spelling. Measured in the running app at
       https://localhost:7222/assessments: the navbar matched a print hide rule, the breadcrumb did
       not. A file guard could not see it, because it was reading the component the app does not use.

       SO THE SELECTOR IS THE ACCESSIBLE NAME, not a class. `aria-label="breadcrumb"` is what MAKES
       the element a breadcrumb to a reader and to WCAG, both components carry it, and it cannot drift
       when somebody restyles one. A class here has now been wrong twice, in two different files.

       #6334 — THE SECTION RAIL, ONE ELEMENT OVER. Found by the print pass that ran against the
       signed-in app after the breadcrumb fix. SectionRail renders <aside class="rd-framework-rail">
       for every Framework, Catalogue and Reports page (and, since #6559, every assessment page, where
       the rail replaced the scope strip and the stage bar; the bar that opens it below 992px is a
       button, hidden below with every button), and shell.css styles it only from 992px up. Below
       that width it stacks "full-width … above the content", in its own comment's words, and a printed
       page is below that width. So every one of those pages printed a column of 7-10 links above the
       document — the Reports rail beside RiskAssessmentExtract, the page that calls itself "the
       document you hand over". Keyed on the class because SectionRail is the rail's only renderer and
       uses this one class for every rail. (Since #6559 the <aside> carries an accessible name, the
       section's, but the class is still the one fact every rail shares.) */
    nav.navbar,
    nav[aria-label="breadcrumb"],
    aside.rd-framework-rail,
    .btn,
    button,
    select,
    .alert .btn-close {
        display: none !important;
    }

    /* Full-width content; no viewport caps or sticky offsets. */
    .rd-page {
        max-width: none !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
    }

    /* #6835 — the document sheet is a screen device: it lifts a document off the grey canvas, and paper
       has no canvas. Its frame and inset would draw a box round every printed page's content. */
    .rd-sheet {
        border: 0 !important;
        border-radius: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    /* Keep tiles, table rows and callouts on one page each. */
    .card,
    tr,
    .alert {
        break-inside: avoid;
    }

    /* Bootstrap subtle backgrounds print too faint — force borders so the
       band badges stay legible in grayscale. */
    .badge {
        border: 1px solid #000 !important;
        color: #000 !important;
        background: #fff !important;
    }

    a {
        text-decoration: none !important;
        color: inherit !important;
    }

    /* #5911 — a section that promises "always printed" prints its content, collapsed or not.

       THE DEFECT. Every management-report section is a <details> whose summary ends "always printed",
       and four ship collapsed. Nothing forced them open, and a browser does not print what it does not
       render: measured on the live report, a closed section's body reported innerText.length 0 against
       185 open. Worst on "Known reporting gaps", whose whole job is to say what the assessment does NOT
       cover, and which read as "no caveats" when printed blank.

       THE MECHANISM. ::details-content is the pseudo-element the browser puts collapsed content in and
       sets content-visibility: hidden on. Overriding THAT is what works; forcing `display` on the
       children does not, because it is not the children that are hidden. Measured on Chrome 152: with
       this one declaration a closed section's body went from 0 characters to 1,061, and back to 0 when
       it was removed.

       WHY THE SELECTOR IS A MARKER CLASS AND NOT THE CONTAINER'S. It first read
       `details.card.rd-stack:not(.rd-disclose)` — the report-section container idiom. That is a
       different set from the one making the promise, and print.css is served for EVERY page: the
       idiom's twelfth user is AnalysisHub's ISO/IEC 31010 Table A.3 reference, which promises nothing,
       is collapsed precisely because nobody asked for it, and would have been force-expanded into every
       printout of that hub. Its summary span would have been deleted too — there the span is content
       ("This stage runs the consequence/likelihood matrix …"), not the report's "Click to expand"
       chrome (#5916 review).

       Excluding that one page by name would have been the sharpened proxy the next reuse defeats. So
       the rule selects on a class that MEANS the promise: the CSS and the summary's wording are one
       fact, pinned in both directions by ReportPrintDisclosureTests — every marked element carries the
       wording, and every summary with the wording carries the marker (docs/ONE_HOME_PER_RULE.md).

       STATED EXCLUSION. Four report panels — scope-planning, communication, risk criteria, external
       and internal context — ship open="open" and make no such promise, so they are unmarked. They
       print because they are open; collapse one and it prints blank, as it did before this change, and
       no claim is broken. Extending the promise to them is a product call, not this fix's.

       The consequence is a longer printed report: "Regulations not yet reviewed" alone adds ~28k
       characters at 193 rows. That is the honest length of a document that claims to carry them; M12
       judges a document surface by its contents map, not by a height budget. */
    details.rd-print-always::details-content {
        content-visibility: visible !important;
    }

    /* The summary's interaction hint is chrome once the content is on the page — "Click to expand" is
       an instruction nobody can follow on paper — and so is the disclosure triangle beside it. Scoped
       to the marked sections, where that span holds the hint and nothing else. */
    details.rd-print-always > summary > span.text-body-secondary {
        display: none !important;
    }

    details.rd-print-always > summary {
        list-style: none;
    }

    details.rd-print-always > summary::-webkit-details-marker {
        display: none;
    }

    /* #6559 — the ISO workflow note prints, and nothing else from the ⓘ does (Andrew, 2 October 2026,
       option A1).

       THE CHANGE THIS ANSWERS. #6559 moved the six workflow notes from the page into the ⓘ beside the
       title, a native <details> (IsoGuidanceTag). A closed <details> prints none of its content: measured
       with Chromium print-to-PDF under this stylesheet, the note went from printed to absent, and the
       ⓘ glyph printed alone, because the summary is not a button and the rule above hides buttons. Today
       the note had printed under the lede of every hub that cites a clause with one.

       WHY A MARKER OF ITS OWN, NOT rd-print-always. That marker MEANS a summary that promises "always
       printed", and ReportPrintDisclosureTests pins the two together in both directions. An ⓘ's
       summary is a glyph and promises nothing. Widening that marker, or opening every <details>, would
       be the blanket rule #5911 refused (AnalysisHub's ISO/IEC 31010 reference would print whole).
       rd-print-iso-note means "this ⓘ carries a workflow note": IsoGuidanceTag sets it only then, and
       IsoNotePrintDisclosureTests holds the marker, the note and these rules together, in a browser.

       WHAT PRINTS. The glyph of every page-title ⓘ is chrome on paper, as the button it replaced was,
       and the clause line, purpose and points did not print before #6559 either: both are d-print-none
       in IsoGuidanceTag, the estate's own print-hiding idiom, so no rule here reaches an ⓘ without a
       note. Where a note is inside, the content is opened, the card prints as plain text in the flow,
       and the note follows the lede, where #5778 had put it as a qualifier on the page's own
       description. That needs the title row flattened into the text column, so the order can place
       the note after the lede; it is scoped with :has() to a header whose ⓘ carries a note, so no
       other header changes on paper. Every rule here names the marker, which is what
       ReportPrintDisclosureTests asks of a print rule touching a <details>.

       Engines without ::details-content are not covered, as #5911 records for its own rule. */
    details.rd-print-iso-note::details-content {
        content-visibility: visible !important;
    }

    details.rd-print-iso-note .rd-iso-tag-card {
        position: static !important;
        width: auto !important;
        margin-top: .5rem !important;
        border: 0 !important;
        box-shadow: none !important;
        background: none !important;
    }

    details.rd-print-iso-note .rd-iso-tag-card > .card-body {
        padding: 0 !important;
    }

    details.rd-print-iso-note .rd-iso-note {
        margin-top: 0 !important;
        padding-top: 0 !important;
        border-top: 0 !important;
    }

    /* !important because the title row wears Bootstrap's d-flex, which is display: flex !important. Without
       it the row stayed a flex row and the note printed beside the title, above the lede (measured in
       IsoNotePrintDisclosureTests' first run). */
    .rd-page-header-text:has(details.rd-print-iso-note) {
        display: flex !important;
        flex-direction: column;
    }

    .rd-page-header-text:has(details.rd-print-iso-note) > .rd-page-header-title,
    .rd-page-header-text:has(details.rd-print-iso-note) .rd-page-header-tag {
        display: contents !important;
    }

    .rd-page-header-text:has(details.rd-print-iso-note) details.rd-print-iso-note {
        order: 1;
        display: block;
    }
}

/* ── Board report (#3884) ────────────────────────────────────────────────────
   "Export PDF" on Organisation status used to print the working view. The
   ReportDocumentPrintView component supplies the document furniture (cover, verdict,
   figures, exceptions, signatures) and these rules make it read as a board pack.

   #6200 — THIS COMMENT SAID BROWSERS IGNORE CSS MARGIN BOXES, AND THEY DO NOT. It read
   "Browsers ignore CSS margin boxes (@bottom-center and friends), so page numbers come from the
   browser's own print header/footer, not from here", and on that belief the HTML print path got no
   running footer while the generated PDF has had one since #4449. Two renderers of one
   ReportDocument, saying different things on paper — which is the drift #4449's own design says
   cannot happen.

   Measured on Chromium 1148, twice: through --print-to-pdf and through Page.printToPDF with
   preferCSSPageSize, which is the path scripts/render-surface.sh --print uses. @bottom-left and
   @bottom-right both render, counter(page) and counter(pages) both increment, and a margin box's
   content reads var(--x). What does NOT work is string(), the GCPM running-element proposal — so
   the page box cannot pull the title out of the document, and ReportDocumentPrintView pushes it in
   as --rd-report-footer instead.

   VERIFIED IN THE REAL PRINT DIALOG, not only headless: Chrome's own preview on the running app at
   /reports/board, signed in, 24 September 2026. Page 1 of 3 carried "Organisation compliance status
   · as at 24 September 2026" bottom-left and "Page 1 of 3" bottom-right. That was the one step the
   automated pass cannot take — opening the dialog blocks browser automation — so a person took it.

   Chrome's OWN header and footer were left on for that check, and the two do not collide: Chrome
   puts its date and page title at the top, these boxes sit at the foot. A reader who turns Chrome's
   off loses nothing of ours.

   Still not verified: Safari and Firefox. A browser that ignores the boxes loses the footer and
   prints everything else unchanged. */
@media print {
    /* The footer's default, defined where its READER lives (#6390 review).

       DarkThemeConventionTests enumerates every custom property the UI reads and requires each to be
       defined in a stylesheet — "a token nothing defines falls back to whatever hex was written
       beside it". It caught this one, correctly: the value was only ever set in
       ReportDocumentPrintView's own <style>, so a page that does not render that component read a
       token nothing declared.

       Empty is the right default rather than a placeholder. A page with no composed document has no
       document name to print, and an empty margin box is blank. The component's declaration comes
       later in the document than this link, so it wins wherever a report is rendered. */
    :root {
        --rd-report-footer: "";
    }

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

        /* Matched to MigraDocReportPdfWriter.NewPage byte for byte — "{Title} · as at {date}" on the
           left, "Page n of N" on the right — because the two renderers agreeing IS the point. The
           left value is empty on any page that is not a composed report, which leaves the box blank
           rather than printing the word "undefined". */
        @bottom-left {
            content: var(--rd-report-footer, "");
            font-size: 8pt;
            color: #666;
        }

        @bottom-right {
            content: "Page " counter(page) " of " counter(pages);
            font-size: 8pt;
            color: #666;
        }
    }

    /* The working view's own furniture is redundant once the cover exists. */
    .rd-report-hide-in-print {
        display: none !important;
    }

    .rd-report-document {
        font-size: 10.5pt;
        line-height: 1.45;
        color: #000;
    }

    /* The cover owns the first page; the working table follows it. */
    .rd-report-cover {
        break-after: page;
        padding-top: 24mm;
    }

    .rd-report-kicker {
        text-transform: uppercase;
        letter-spacing: .18em;
        font-size: 8.5pt;
        margin: 0 0 2mm;
    }

    .rd-report-title {
        font-size: 22pt;
        font-weight: 600;
        margin: 0 0 6mm;
    }

    /* The verdict is the one thing a board member must read. */
    .rd-report-verdict {
        font-size: 13pt;
        border-top: 2px solid #000;
        border-bottom: 1px solid #000;
        padding: 4mm 0;
        margin: 0 0 8mm;
    }

    .rd-report-facts {
        display: grid;
        grid-template-columns: 42mm 1fr;
        row-gap: 1.5mm;
        margin: 0;
    }

    .rd-report-facts dt { font-weight: 600; }
    .rd-report-facts dd { margin: 0; }

    .rd-report-caveat {
        margin-top: 8mm;
        padding: 3mm;
        border: 1px solid #000;
        font-size: 9.5pt;
    }

    .rd-report-section {
        break-inside: avoid;
        margin-bottom: 8mm;
    }

    .rd-report-section h3 {
        font-size: 11pt;
        font-weight: 600;
        margin: 5mm 0 2mm;
    }

    .rd-report-section > h2 {
        font-size: 12pt;
        font-weight: 600;
        border-bottom: 1px solid #000;
        padding-bottom: 1.5mm;
        margin: 0 0 3mm;
    }

    .rd-report-document table {
        width: 100%;
        border-collapse: collapse;
    }

    /* A long exception list must repeat its header on each page. */
    .rd-report-document thead { display: table-header-group; }

    /* #6200 — the section-name row inside thead. Set apart from the column headers so a reader can
       see it is a label for the table rather than another column, and quieter than the <h2> above it
       on page one, where the two sit a line apart by design. */
    .rd-report-document .rd-report-table-section th {
        font-size: 8.5pt;
        font-weight: 600;
        color: #444;
        border-bottom: none;
        padding-bottom: 0;
    }

    .rd-report-document th,
    .rd-report-document td {
        text-align: left;
        padding: 1.5mm 2mm;
        border-bottom: .3pt solid #666;
        vertical-align: top;
    }

    .rd-report-figures th[scope="row"] { font-weight: 400; }
    .rd-report-figures td { font-weight: 600; width: 28mm; }
    .rd-report-mark { width: 8mm; text-align: center !important; }

    /* Ruled lines to sign on. */
    .rd-report-signatures tbody td { height: 12mm; }
    .rd-report-signoff { break-before: page; }
}
