/* =============================================================================
   Fernando Kylas Brand System: print.css
   -----------------------------------------------------------------------------
   medium: paper and PDF. Loaded second, only by a document that prints

   GENERATED. Do not edit this file.

   Source:    lab/publication-engine/platform/design-system/css/{print}.css
   Producer:  assets/css/build-css.py
   Authority: docs/foundations/*.md, which wins over both.

   Load order is part of the contract: core.css first and always; print.css only
   where a document will be printed; report.css only where it is a Fernando Kylas
   report. See docs/architecture.md §7.
   ============================================================================= */

/* =============================================================================
   Fernando Kylas Report Engine: Print / PDF
   -----------------------------------------------------------------------------
   The printed A4 PDF is a PRIMARY output, not an afterthought. This sheet:
     • sets A4 geometry and margins;
     • forces the light (paper) render, a near-black A4 wastes ink and reads
       worse on paper, so dark theme is a SCREEN affordance only (documented);
     • sizes reading type in POINTS against the accessible-print floor
       (typography.md §8: 10pt floor, 10pt+ for decision documents);
     • controls page breaks: cover and each section own their pages, headings
       never orphan, atomic components never split, long tables break with
       repeating headers;
     • expands every <details> so nothing collapses out of the PDF;
     • prints destination URLs after external links;
     • removes all screen-only chrome.
   ============================================================================= */

@page {
  size: A4;
  margin: 20mm 20mm 18mm 20mm;
}
/* First page (cover) gets a little more breathing room at the top. */
@page :first {
  margin-top: 24mm;
}

@media print {

  /* ── Force the paper render regardless of the on-screen theme ───────────── */
  :root,
  :root[data-theme="dark"],
  [data-theme="dark"] {
    --fk-surface:        #ffffff;   /* physical paper is the ground; save ink   */
    --fk-surface-raised: #fbfbfa;
    --fk-surface-accent: #eef2ec;
    --fk-text-primary:   #0A0A0A;
    --fk-text-secondary: #3d3d3d;   /* a touch darker for toner legibility      */
    --fk-text-tertiary:  #565656;
    --fk-border:         #d7d6db;
    --fk-border-strong:  #4A4A4A;
    --fk-accent:         #869F75;    /* green marks still print (become grey ok) */
    --fk-accent-ink:     #0A0A0A;

    /* Reading roles in points (unitless line-heights carry over). */
    --fk-body-size:        10.5pt;
    --fk-body-l-size:      11.5pt;
    --fk-lead-size:        13pt;
    --fk-body-s-size:      9.5pt;
    --fk-caption-size:     8.5pt;
    --fk-footnote-size:    8pt;
    --fk-label-size:       8pt;
    /* Display roles trimmed to fit A4. */
    --fk-display-size:        34pt;
    --fk-report-title-size:   28pt;
    --fk-section-title-size:  20pt;
    --fk-subsection-size:     13pt;
    --fk-card-title-size:     12pt;
    --fk-quote-size:          16pt;
    --fk-metric-size:         26pt;
    --fk-metric-lg-size:      34pt;
  }

  html { font-size: 12pt; }              /* anchor rem to the print point model */

  body {
    background: #ffffff;
    color: var(--fk-text-primary);
  }

  *, *::before, *::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;           /* rails, chips and rules must print   */
    box-shadow: none !important;          /* reports never lean on shadow in print */
  }

  /* ── Remove screen chrome ──────────────────────────────────────────────── */
  .fk-topbar,
  .fk-skip-link,
  .fk-no-print,
  .fk-btn,
  .fk-themetoggle,
  [data-back-top] { display: none !important; }
  .fk-print-only { display: revert !important; }

  /* ═════════════════════════════════════════════════════════════════════════
     THE PAGE-NUMBER COLUMN: restored here, and ONLY here.
     -------------------------------------------------------------------------
     This is the medium rule made mechanical (DESIGN.md §Medium; README §Medium).
     A page number is a print coordinate: it is meaningful on A4 and meaningless on
     screen, where the reader clicks a title and arrives. So the contents component
     ships WITHOUT the column, and print adds it back, rather than the component
     shipping WITH it and screen hiding it.

     The direction of the default is the whole decision. Web-first means the online
     form is what the component is; the printed form is the variation. Inverting that
     is how a website ends up reproducing a PDF's furniture. */
  .fk-toc__item { grid-template-columns: 2.5rem minmax(0, 1fr) auto; }
  .fk-toc__page { display: block; text-align: right; }

  /* The publication footer is screen furniture: on paper the running footer carries
     the same facts on every page, so repeating them once more at the end is noise.
     The colophon is content and prints. It is the provenance of the document. */
  .fk-pubfooter { display: none; }
  .fk-colophon { break-before: auto; max-width: none; }

  /* ── Document shell → full bleed within page margins ───────────────────── */
  .fk-report {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  /* ── Reading measure: hold ~66–70 characters with a font-relative ch cap ──
     Print re-declares the measure in `ch` rather than px, because on paper the
     character count is what matters and the type is re-declared in points.

     `dd` and `figcaption` are included since 2026-07-25: both are prose-bearing
     and both escaped the per-element binding on screen AND in print (`PLAT-07`).
     A `dd` running the full text column on A4 was the same defect, unnoticed
     because nothing measured it.

     This is a deliberate `ch`-based override of the context model rather than a
     use of it: print is a fixed canvas, so the measure is a property of the page
     rather than of a container. A consumer that sets `--fk-measure-context` for
     screen still prints at 68ch, which is correct. */
  p, li, dd, figcaption,
  .fk-body, .fk-body-l, .fk-lead,
  .fk-prose, .fk-flow, .fk-callout, .fk-note {
    max-width: 68ch;
  }
  /* Structural containers span the full text column. */
  .fk-section, .fk-cover, .fk-contents, .fk-part,
  .fk-split, .fk-duo, .fk-grid, .fk-table-wrap, .fk-summary { max-width: none; }

  /* A CONTENTS ROW IS NOT PROSE, and neither is a reference or a footnote. They are
     scanned, not read. The 68ch cap above is bound to `li`, so it was capping them too:
     measured 2026-07-27, a contents row printed 505px wide inside a 643px text column,
     with the page number stranded a third of the way across the page. Same reasoning as
     `--fk-measure-structural` on screen (tokens.css), applied to the fixed canvas. */
  .fk-toc__item, .fk-references > li, .fk-footnotes > li,
  .fk-pubfooter__nav li { max-width: none; }

  /* Two-column blocks collapse to a single column on A4: narrow print columns
     read worse on paper and can force wide content (threshold heads, tables) to
     overflow. Single column is intentional and more legible (see CHECKLIST). */
  .fk-split, .fk-duo { grid-template-columns: 1fr; }
  .fk-split__aside { padding-left: 0; border-left: 0; padding-top: var(--fk-space-5); border-top: var(--fk-hairline); }

  /* ── Page-break architecture ───────────────────────────────────────────── */
  .fk-cover { break-after: page; min-height: 0; }
  .fk-contents,
  .fk-section,
  .fk-part,
  .fk-closing { break-before: page; }
  /* Don't force a break before the very first flowed block after the cover. */
  .fk-cover + * { break-before: auto; }
  /* A part divider owns the break; the section that follows must not add another. */
  .fk-part + .fk-section { break-before: auto; }

  /* Headings stay with the content beneath them. */
  h1, h2, h3, h4,
  .fk-section-title, .fk-subsection-title, .fk-card-title,
  .fk-section__head { break-after: avoid; }

  /* Atomic blocks never split across pages. */
  .fk-finding, .fk-blocker, .fk-callout, .fk-insight, .fk-summary,
  .fk-kpi, .fk-score, .fk-rec, .fk-evidence, .fk-pullquote,
  .fk-phase__head, figure, .fk-figure, blockquote, .fk-compare,
  .fk-bars__row, .fk-meter, .fk-def > div,
  /* Digital Visibility Diagnostic extensions */
  .fk-scoreline, .fk-threshold, .fk-check, .fk-estimate,
  .fk-perspective, .fk-signal, .fk-masthead {
    break-inside: avoid;
  }
  /* These MAY exceed a page: let them break rather than strand blank space. */
  .fk-phase, .fk-timeline, .fk-table-wrap { break-inside: auto; }

  p { orphans: 3; widows: 3; }

  /* ── Tables: repeat headers, allow long registers to break, compress ──── */
  /* A scroll area cannot scroll on paper: the content must be allowed out of the
     box or the part past the fold is simply lost. `.fk-scroll-x` joins the
     wrapper that already had this reset, same decision, same reason. */
  .fk-table-wrap,
  .fk-scroll-x { overflow: visible; padding-block-end: 0; }
  .fk-table thead { display: table-header-group; }
  .fk-table tfoot { display: table-footer-group; }
  .fk-table tr, tr { break-inside: avoid; }
  .fk-table :is(th, td) { padding: 4pt 6pt; }
  .fk-table--wide { font-size: 8.5pt; }

  /* ── Expand every <details> so nothing collapses out of the PDF ─────────── */
  details { display: block; }
  details::details-content { content-visibility: visible !important; block-size: auto !important; }
  details > *:not(summary) { display: block !important; }
  summary { list-style: none; }
  summary::-webkit-details-marker { display: none; }

  /* ── Print destination URLs after external links ───────────────────────── */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: var(--fk-text-tertiary);
    word-break: break-all;
  }
  a[href^="#"]::after,
  a[href^="mailto"]::after { content: none; }

  /* ── Print running footer (Chrome headless emits no margin-box counters, so
        a print-only metadata footer substitutes; page numbers are added by the
        PDF toolchain: see IMPLEMENTATION.md) ────────────────────────────── */
  .fk-report-footer { display: none; }
  .fk-running-footer {
    display: block;
    margin-top: var(--fk-space-6);
    padding-top: var(--fk-space-3);
    border-top: 1px solid var(--fk-border);
    font-size: 8pt;
    color: var(--fk-text-tertiary);
  }

  /* Engines that DO support margin boxes (Firefox, Prince, Paged.js) get real
     page numbers; Chrome simply ignores this block. */
  @page {
    @bottom-right {
      content: counter(page) " / " counter(pages);
      font-family: "Geomanist", sans-serif;
      font-size: 8pt;
      color: #565656;
    }
  }
}
