/* ============================================================
   EU Trade Dashboard — PRINT layer: loaded last for browser print and
   the WeasyPrint PDF pipeline. Shared base/content rules establish the
   design; this layer adapts it to a paginated, physical document.

   Holds the report webfonts so PDFs keep consistent typefaces whatever
   fonts the build server happens to carry — the server has none of its
   own. Two voices (see graphic_charter.md's typography section):

   - Epunda Slab for the document text: a
     printed report is a document, not a UI.
   - Trispace for headings and the ledger data voice: codes, figures,
     dates, axis ticks, table number cells.

   Both are built by render/build/fonts.py, cut to French, English and
   German (other scripts fall through to the server's system fonts), as
   unsplit single-file-per-face fonts — split files with unicode-range
   make weasyprint render latin-ext codepoints (ż, ł, ę…) with the latin
   file's glyph table (same glyph IDs, wrong glyphs: ż → ">"). The
   chart figure renderer (reports/figures.py) registers the same
   fixed-weight Trispace with its canvas backend.

   Hand-written: registered in vite.config.js's HAND_WRITTEN_CSS so
   the build's owned-outputs cleanup never deletes it. The block below
   is not: render/build/fonts.py writes it.
   ============================================================ */

/* Fixed-weight faces instead of the variable `font-weight: 400 800`
   range syntax: weasyprint rejects the range as invalid and then ignores
   the whole @font-face, silently falling back to whatever system sans the
   build server carries. */
/* GENERATED:fonts:start — do not edit by hand; run render/build/fonts.py */
@font-face {
    font-family: "Trispace";
    src: url("trispace-regular-fdc8a910df.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Trispace";
    src: url("trispace-bold-e21e8fa74a.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Epunda Slab";
    src: url("epundaslab-medium-efa968afc9.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Epunda Slab";
    src: url("epundaslab-bold-3a738c551e.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Epunda Slab";
    src: url("epundaslab-medium-italic-d7968df13b.woff2") format("woff2");
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: "Epunda Slab";
    src: url("epundaslab-bold-italic-e671b82785.woff2") format("woff2");
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}
/* GENERATED:fonts:end */

/* Force the document font directly instead of overriding --font-stack:
   this weasyprint version parses var() in font-family without error but
   then fails to match the @font-face through it and silently falls back
   to the server's system fonts. A plain font-family on html/body
   sidesteps the custom property entirely. html+body because some
   templates set font-family on one or the other. */
html,
body {
    font-family: "Epunda Slab", Georgia, "Times New Roman", serif;
}

body h1,
body h2,
body h3,
body h4,
body h5,
body h6 {
    font-family: "Trispace", sans-serif;
}

/* Same story for the mono voice: the mono selectors name the family
   directly instead of inheriting var(--font-mono)'s system stack. */
body code,
body kbd,
body article .num,
body article .period-cell,
.t-qual,
.fn-mark {
    font-family: "Trispace", monospace;
}

/* Non-Latin pages use system fonts throughout (see base.css). */
html:lang(bg),
html:lang(bg) body,
html:lang(el),
html:lang(el) body,
html:lang(ja),
html:lang(ja) body,
html:lang(zh),
html:lang(zh) body {
    font-family: serif;
}
html:lang(bg) body :is(h1, h2, h3, h4, h5, h6),
html:lang(el) body :is(h1, h2, h3, h4, h5, h6),
html:lang(ja) body :is(h1, h2, h3, h4, h5, h6),
html:lang(zh) body :is(h1, h2, h3, h4, h5, h6) {
    font-family: sans-serif;
}
html:lang(bg) body :is(code, kbd, article .num, article .period-cell, .t-qual, .fn-mark),
html:lang(el) body :is(code, kbd, article .num, article .period-cell, .t-qual, .fn-mark),
html:lang(ja) body :is(code, kbd, article .num, article .period-cell, .t-qual, .fn-mark),
html:lang(zh) body :is(code, kbd, article .num, article .period-cell, .t-qual, .fn-mark) {
    font-family: monospace;
}

/* ============================================================
   Paginated documents

   Screen prose keeps its 78-character measure and 1rem interface scale.
   On A4, an 11pt base keeps data legible while bringing the serif body
   closer to a printed briefing. The page margins, rather than the screen
   measure, set the print line length.
   ============================================================ */

@media print {
    @page {
        margin: 20mm 16mm;
    }

    :root {
        --text-base: 11pt;
        background: var(--clr-surface);
    }

    /* Letterhead: keep the brand block, drop interactive chrome. */
    .site-header {
        padding: 0;
    }
    .header-nav,
    .lang-switch,
    .skip-link,
    .report-pdf-gate {
        display: none;
    }

    article {
        max-width: none;
        margin: 0;
        padding: 0;
        border: none;
    }

    article p,
    article li,
    article dd,
    article figcaption {
        max-width: none;
    }

    article h1 {
        font-size: var(--text-2xl);
    }

    article h3 {
        margin-top: calc(var(--line) / 2);
    }

    article a {
        color: var(--clr-text);
        text-decoration: underline dashed var(--clr-accent);
        text-underline-offset: 0.15em;
    }

    article h1,
    article h2,
    article h3,
    article tr,
    article blockquote,
    article .web-context,
    .report-disclaimer,
    .report-closing {
        break-inside: avoid;
    }

    article h1,
    article h2,
    article h3 {
        break-after: avoid;
    }

    /* Tables stay in the reading flow at the larger print data size.
       Repeat their header after a page break and never split a row. */
    article table {
        margin: calc(var(--line) / 2) 0;
        font-size: var(--text-base);
        line-height: var(--leading-none);
        break-inside: auto;
    }

    article th,
    article td {
        padding: var(--space-3xs) var(--space-base);
    }

    article thead {
        display: table-header-group;
    }

    /* The provenance notice and the enriched PDF's closing contact are
       interface chrome, not running prose: use the website's compact
       info-note surface and spacing. */
    .report-disclaimer,
    .report-closing {
        max-width: none;
        margin: 0 0 var(--line);
        padding: var(--space-lg) var(--space-xl);
        background: var(--clr-accent-light);
        color: var(--clr-accent);
        font-family: "Trispace", sans-serif;
        font-size: var(--text-sm);
        line-height: var(--leading-text);
    }

    .report-closing {
        margin: var(--line) 0 0;
    }

    .report-disclaimer p,
    .report-closing p {
        margin: 0 0 var(--space-base);
    }

    .report-disclaimer p:last-child,
    .report-closing p:last-child {
        margin-bottom: 0;
    }
}

/* ============================================================
   TODO — for the PNG-export redo: chart-card title blocks.

   When the chart PNG export is rebuilt, give each exported chart card
   a bottom hairline "title block" strip in tiny muted mono — the
   engineering-drawing caption frame: source dataset (Comext/PRODCOM
   code), unit, CIF/FOB convention, period. Deferred on purpose until
   the exporter is reworked; implement the print/PNG version and the
   matching screen version together so exported cards carry the same
   caption the dashboard shows.
   ============================================================ */
