/* =====================================================================
   print.css
   ---------------------------------------------------------------------
   Print-media overrides for the Guildmerge HTML Output System.

   Source of truth:
     - .planning/phases/01-brand-shell-template/01-UI-SPEC.md (Print Contract)
     - /Projects/DotJess website/BRAND-GUIDE.md
   Companion file: guildmerge.css (tokens declared on :root are used here).

   Loaded by the template as:
     <link rel="stylesheet" href="../../_assets/print.css" media="print">

   media="print" gates activation, but contents are also wrapped in
   @media print so the file is safe if the link attribute is dropped.

   INLINING WARNING (read before embedding this file in a <style> block):
   This file is ALREADY wrapped in @media print (see below). When you
   inline it into a portable single-file artefact, paste the contents
   AS-IS. Do NOT wrap it in another @media print, that produces
   @media print { @media print { ... } } which Safari's print engine
   silently ignores, so the topbar never hides and page margins never
   apply (symptom: a large empty band at the top of page 1, no clean
   page wrap). Inline guildmerge.css first, then this file verbatim.

   SAFARI PRINT GOTCHA (not a CSS problem, cannot be fixed in this file):
   Safari's print dialog has a "Print headers and footers" option that
   injects the page title and date into the page-margin band. That reads
   as a large top margin no stylesheet can remove. If a user reports a
   big top gap after this CSS is confirmed applying, tell them to untick
   "Print headers and footers" in the print dialog.

   What hides: topbar, footer band, skip link, top-level nav, button.
     In-card jump-nav is allowed to print.
   What stays: card, headings, body, tables, code blocks, lists,
     callouts, <details> contents (forced open), per-artefact footer
     with the file path.
   What changes: shadow drops out (no card border), type scale shrinks
     about 10 percent, link URLs render inline in parens, .table-scroll
     overflow reset to visible so wide tables aren't clipped.

   Page background is already white, so no background swap is needed.

   Constraints:
     - Vanilla CSS, no @import, no https://, no JavaScript references
     - Australian English in comments, no em dashes
   ===================================================================== */

@media print {

  /* Force light scheme. Page is white already. */
  :root {
    color-scheme: light;
  }

  body {
    background: #ffffff;
    color: #1a1a1a;
  }

  /* Hide chrome: topbar, footer band, skip link, top-level nav, buttons.
     In-card jump-nav (e.g. <nav aria-label="Jump to section"> inside a
     .card) is allowed to print — only chrome-level nav is suppressed. */
  body > header,
  body > footer,
  body > nav,
  .topbar,
  .topbar nav,
  .skip-link,
  .gm-print-btn,
  button {
    display: none;
  }

  /* Card prints with no frame: the shadow drops out and no border
     replaces it. The page margin is the only boundary. A 1px card border
     read as an unnecessary box on paper and fragmented into stray lines
     at page breaks on long artefacts (Jess, 2026-06-02). The card itself
     is still allowed to split across pages; logical groupings inside it
     are individually protected below and in guildmerge.css §20. */
  .card {
    box-shadow: none;
    border: none;
  }

  /* Page-break rules: keep headings with their content, keep tables,
     figures, code blocks, and callouts off page boundaries. */
  h1, h2, h3, h4 {
    page-break-after: avoid;
    break-after: avoid;
  }

  table, figure, pre, .callout {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Card sub-structures: protect headers, footers, and any section
     wrapper from splitting. The card itself can break across pages,
     but a section header should never be orphaned from its body. */
  .card-header,
  .card-footer,
  .card > section,
  .card > .gm-section,
  .card > header {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* .table-scroll uses overflow:auto on screen. On paper, overflow
     clipping silently truncates the right edge of wide tables. Reset
     to visible and shrink table type so wide content has a chance to
     fit. Tables that still overflow will wrap or get hinted landscape
     by the operator. */
  .table-scroll {
    overflow: visible !important;
  }

  .table-scroll table {
    width: 100%;
    font-size: 0.85em;
  }

  /* <details> defaults to printing only the <summary> line, which
     destroys FAQ content in feature-explainer and reference docs.
     Force every <details> open on paper so all answers render. */
  details {
    display: block;
  }

  details > summary {
    list-style: none;
    cursor: default;
  }

  details > summary::-webkit-details-marker {
    display: none;
  }

  details:not([open]) > *:not(summary) {
    display: revert;
  }

  /* Expand link URLs inline so a printed page still shows the target.
     Skip for internal anchors and javascript: pseudo-links. */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #5c5c5c;
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  /* Type scale shifts down about 10 percent on paper. Body stays at
     roughly 16px so the document remains comfortable. */
  h1 { font-size: 1.95rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.2rem; }
  body { font-size: 0.95rem; }
  pre, code { font-size: 0.7rem; }

  /* H2 stays text-green on paper, matches screen brand. */
  h2 { color: #1e7a6a; }

  /* Links print in text-green to match brand. */
  a { color: #1e7a6a; }

  /* Page margin: 1.5cm on every edge. Reduced from 2cm 2026-05-29
     (Jess) — 2cm read as an oversized top band on A4. 1.5cm keeps a
     clean gutter without wasting the first quarter of page 1. */
  @page {
    margin: 1.5cm;
  }

  /* Main container loses the centred cap on paper. @page handles gutter. */
  main,
  body > main {
    width: 100%;
    margin: 0;
    padding: 0;
  }
}
