/* ==========================================================================
   PRINT — paper is a publication, not a screenshot                  [item 22]
   Package Y13b. MUST be linked LAST, after static/mobile.css.
   --------------------------------------------------------------------------
   A PRINTED PAGE THAT LOSES ITS PROVENANCE IS A PRINTED PAGE THAT LIES.

   Everything below serves one sentence: whatever comes out of the printer must
   carry the screen's TITLE, its AS-OF DATE and the SOURCE of every panel on
   it, and it must not carry a single control that cannot be pressed.

   --------------------------------------------------------------------------
   WHY THIS SHEET HAS TO EXIST AT ALL — MEASURED, NOT ASSUMED

   `static/singularity_aesthetics.css:141` sets

       #app-root       { display: flex; height: 100vh; overflow: hidden; }
       #terminal-viewport { height: 100vh; overflow-y: hidden; }
       .workspace      { height: 100%; overflow: auto; }   (styles.css:196)

   Printed as-is that is ONE sheet of paper containing one viewport-height
   crop of a scrolling region, with everything below the fold silently gone.
   Not truncated with an ellipsis — gone, with no mark on the page saying so.
   Section 2 is the whole reason for this file; the chrome removal is the easy
   part.

   --------------------------------------------------------------------------
   LOAD ORDER IS LOAD-BEARING

   Section 1 re-points the theme tokens at the LIGHT set. instrument.css
   declares those same names on `:root[data-theme="light"]` (0,2,0),
   `:root[data-theme="dark"]` (0,2,0) and `:root[data-colorblind="true"]`
   (0,2,0). This sheet repeats every one of those selectors so specificity
   ties, and then wins on source order — which it only does if it is linked
   AFTER instrument.css. Linked before it, section 1 is dead and the terminal
   prints near-white ink on white paper. See `.ag-exhaust/wave4/Y13_wiring.md`.

   --------------------------------------------------------------------------
   CHARTS: WHAT CSS CAN AND CANNOT REACH                             [item 22]

   `frontend/viz/core.js:92` resolves every chart colour through
   `getComputedStyle(document.documentElement)` AT DRAW TIME and then bakes the
   resulting string into a canvas bitmap or an SVG paint attribute. Re-pointing
   a custom property afterwards cannot reach either one: the canvas is pixels,
   and an SVG `fill="#E08EBE"` attribute never consulted a variable.

   So a chart drawn in the dark theme carries LIGHT ink, and section 1 would
   put it on white paper — invisible. Section 6 keeps such a chart on the plate
   it was drawn against (`--y13PrintPlate`, the dark void, with
   `print-color-adjust: exact`), so the ink stays on its own background instead
   of being washed off it. In the light theme the plate is `transparent` and
   nothing changes, because a light-theme chart is already dark ink on light.

   RESIDUAL HAZARD, STATED RATHER THAN HIDDEN: Chromium's "Background graphics"
   checkbox still gates `print-color-adjust: exact`. With it off, a chart drawn
   in the dark theme prints as its light ink on bare paper. The real fix is a
   redraw on `beforeprint`, which needs one listener in `static/app.js` — a file
   this package does not own. It is filed as a recommendation to the
   integration pass, not silently worked around.

   --------------------------------------------------------------------------
   "EVERY PAGE PRINTS WITH ITS TITLE, ITS AS-OF DATE AND ITS SOURCE LIST"

   Read as every APP page, which is what CSS can actually guarantee:

     title      `.viewport-title-block` (terminal) / `.pk-masthead h1` (pages)
                — section 4 keeps both and forbids a break directly after them.
     as-of      `time.sgcAgo` and `.sgkAsOf`. Section 5 prints the ABSOLUTE
                timestamp out of `attr(datetime)`; "updated 3m ago" on paper is
                relative to a moment the reader cannot recover.
     sources    every panel's `.sgkProv` chip stays, and section 5 unfolds the
                `.sgkProvPop` detail rows that are `hidden` on screen, so the
                source, method and URL print beside the panel they belong to.

   NOT read as every SHEET of paper. Repeating a running header on each sheet
   needs `@page` margin boxes, which no shipping browser implements; the
   alternative — `position: fixed` — repeats in Chromium but reserves no space,
   so it overprints the body on sheets 2..n. This build has never composited a
   verification pane, so an unreviewable overprint is not a trade worth making.
   Stated here instead of shipped blind.

   --------------------------------------------------------------------------
   NO VISUAL REVIEW HAS HAPPENED ON THIS SHEET. The verification pane in this
   build has never composited and no print preview was opened. Every claim
   above is a claim about the CSS and about the rules it overrides, both read
   from the files; none of it is a claim about how a page looks.

   Class names are hyphen-free camelCase under `y13`, so the
   `[class*="-tile"]` / `[class$="-header"]` families in obsidian_orchid.css
   cannot reach them. Never a raw hex: every colour here is an instrument.css
   token.
   ========================================================================== */

@media print {

/* --------------------------------------------------------------------------
   0 — THE SHEET

   `margin: 14mm` leaves room for the browser's own header/footer (the one the
   user controls in the print dialog) without assuming it is on.
   -------------------------------------------------------------------------- */
@page {
  margin: 14mm;
}

/* --------------------------------------------------------------------------
   1 — INK THAT SURVIVES WHITE PAPER

   The body of this block is `:root[data-theme="light"]` from instrument.css
   section 22, declaration for declaration, so the two cannot disagree about
   what "light" means. tests/test_wave4_y13.py compares the two property sets
   and fails if instrument.css grows a name this block does not carry.

   The selector list repeats every (0,2,0) theme selector instrument.css uses,
   so a user who explicitly chose dark still prints readable.
   -------------------------------------------------------------------------- */
:root,
:root[data-theme],
:root[data-theme="dark"],
:root[data-theme="light"],
:root[data-colorblind="true"] {
  --i-void: var(--lt-void);
  --i-surface-1: var(--lt-surface-1);
  --i-surface-2: var(--lt-surface-2);
  --i-surface-3: var(--lt-surface-3);
  --i-surface-4: var(--lt-surface-4);
  --oo-sidebar: var(--lt-sidebar);
  --i-ink-1: var(--lt-ink-1);
  --i-ink-2: var(--lt-ink-2);
  --i-ink-3: var(--lt-ink-3);
  --i-ink-4: var(--lt-ink-4);
  --oo-muted-rgb: var(--lt-muted-rgb);
  --i-hair: var(--lt-hair);
  --i-hair-strong: var(--lt-hair-strong);
  --i-orchid: var(--lt-orchid);
  --i-orchid-bright: var(--lt-orchid-bright);
  --i-orchid-deep: var(--lt-orchid-deep);
  --oo-orchid: var(--lt-orchid);
  --oo-orchid-rgb: var(--lt-orchid-rgb);
  --i-cyber: var(--lt-cyber);
  --i-amber: var(--lt-amber);
  --i-amber-rgb: var(--lt-amber-rgb);
  --i-orchid-wash: var(--lt-orchid-wash);
  --i-amber-wash: var(--lt-amber-wash);
  --i-bull: var(--lt-bull);
  --i-bear: var(--lt-bear);
  --oo-bullish-rgb: var(--lt-bull-rgb);
  --oo-bearish-rgb: var(--lt-bear-rgb);
  --i-bull-wash: var(--lt-bull-wash);
  --i-bear-wash: var(--lt-bear-wash);
  --i-rim: var(--lt-rim);
  --i-rim-strong: var(--lt-rim-strong);
  --i-underlight: var(--lt-underlight);
  --i-elev-1: var(--lt-elev-1);
  --i-elev-2: var(--lt-elev-2);
  --i-elev-3: var(--lt-elev-3);
  --elev-1: var(--lt-e1);
  --elev-2: var(--lt-e2);
  --elev-3: var(--lt-e3);
  --i-ambient: var(--lt-ambient);
  --i-grain-opacity: var(--lt-grain-opacity);
  --i-control-bg: var(--lt-control-bg);
  --i-control-bg-hover: var(--lt-control-bg-hover);
  --i-accent-edge-soft: var(--lt-accent-edge-soft);
  --i-accent-edge: var(--lt-accent-edge);
  --i-accent-edge-bright: var(--lt-accent-edge-bright);
  --i-accent-wash: var(--lt-accent-wash);
  --i-accent-glow: var(--lt-accent-glow);
  --i-accent-glow-strong: var(--lt-accent-glow-strong);
  --i-btn-primary-shadow: var(--lt-btn-primary-shadow);
  --i-btn-primary-shadow-hover: var(--lt-btn-primary-shadow-hover);
  --i-row-hover: var(--lt-row-hover);
  --i-nav-hover: var(--lt-nav-hover);
  --i-nav-active-wash: var(--lt-nav-active-wash);
  --i-header-bg: var(--lt-header-bg);
  --i-field-bg: var(--lt-field-bg);
  --i-wash-faint: var(--lt-wash-faint);
  --i-scroll-thumb: var(--lt-scroll-thumb);
  --i-scroll-thumb-track: var(--lt-scroll-thumb-track);
  --i-scroll-thumb-hover: var(--lt-scroll-thumb-hover);
  --i-viz-1: var(--lt-viz-1);
  --i-viz-2: var(--lt-viz-2);
  --i-viz-3: var(--lt-viz-3);
  --i-viz-4: var(--lt-viz-4);
  --i-viz-5: var(--lt-viz-5);
  --i-viz-6: var(--lt-viz-6);
  --i-viz-7: var(--lt-viz-7);
  --i-viz-8: var(--lt-viz-8);
  --i-viz-grid: var(--lt-viz-grid);
  --i-viz-grid-axis: var(--lt-viz-grid-axis);
  --i-viz-plot-bg: var(--lt-viz-plot-bg);
  --i-viz-crosshair: var(--lt-viz-crosshair);
  --i-viz-rim: var(--lt-viz-rim);
  --i-seq-1: var(--lt-seq-1);
  --i-seq-2: var(--lt-seq-2);
  --i-seq-3: var(--lt-seq-3);
  --i-seq-4: var(--lt-seq-4);
  --i-seq-5: var(--lt-seq-5);
  --i-seq-6: var(--lt-seq-6);
  --i-seq-7: var(--lt-seq-7);
  --i-heat-n4: var(--lt-heat-n4);
  --i-heat-n3: var(--lt-heat-n3);
  --i-heat-n2: var(--lt-heat-n2);
  --i-heat-n1: var(--lt-heat-n1);
  --i-heat-0: var(--lt-heat-0);
  --i-heat-p1: var(--lt-heat-p1);
  --i-heat-p2: var(--lt-heat-p2);
  --i-heat-p3: var(--lt-heat-p3);
  --i-heat-p4: var(--lt-heat-p4);
  --sig-pos-cb: var(--lt-sig-pos-cb);
  --sig-neg-cb: var(--lt-sig-neg-cb);
  --sig-pos-cb-wash: var(--lt-sig-pos-cb-wash);
  --sig-neg-cb-wash: var(--lt-sig-neg-cb-wash);
}

/* instrument.css section 23 switches these two triplets per theme at (0,3,0).
   Matched here so the colourblind alternate also prints in its light pair. */
:root[data-colorblind="true"]:not([data-theme="light"]),
:root[data-colorblind="true"][data-theme="light"] {
  --oo-bullish-rgb: 13, 102, 172;
  --oo-bearish-rgb: 145, 82, 0;
}

/* The plate a dark-drawn chart keeps under it — see the header. Declared here
   rather than in the block above because it must read the DOCUMENT's theme,
   not the printed one. */
:root { --y13PrintPlate: var(--dk-void); }
:root[data-theme="light"] { --y13PrintPlate: transparent; }

/* --------------------------------------------------------------------------
   2 — THE SHELL UNLOCKS AND FLOWS

   The four rules the header names, undone. Without this section every other
   rule in this file is decoration on a single cropped sheet.
   -------------------------------------------------------------------------- */
html,
body,
#terminal-root,
#app-root,
#app-root.app-root,
#terminal-viewport,
#app-root #terminal-viewport,
#app-root .terminal-viewport,
#app-root .workspace,
#app-root .workspace > * {
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  width: auto !important;
  max-width: none !important;
  overflow: visible !important;
}

#app-root,
#app-root.app-root {
  display: block !important;
}

/* Backgrounds off. The paper is the surface; printing the void as a flat tint
   costs a full page of toner and buys nothing. This also neutralises the
   domain wash from static/domain.css, whose 3.5% hue would print as a grey
   cast rather than as a tint. */
html,
body,
#terminal-root,
#app-root,
#app-root #terminal-viewport,
#app-root .terminal-viewport,
#app-root .workspace,
:root[data-y13domain] #app-root {
  background: none !important;
  background-image: none !important;
  box-shadow: none !important;
}

/* Padding that exists to clear a fixed rail is padding that indents every
   printed line by 24mm of nothing. */
#app-root #terminal-viewport,
#app-root .terminal-viewport {
  padding: 0 !important;
}

/* Anything the app pinned to the viewport is pinned to a viewport that does
   not exist on paper: in Chromium it repeats on every sheet, over the body.
   `.sgkProvPop` is exempt — section 5 deliberately unfolds it INTO the flow. */
#app-root [style*="position: fixed"],
#app-root [style*="position:fixed"] {
  position: static !important;
}

/* --------------------------------------------------------------------------
   3 — CHROME OUT

   Four families: the navigation rail, the command palette, the toasts, and
   the controls. Nothing here carries data; every one of them is a thing the
   reader of a sheet of paper cannot press.

   `.sgkProv` is EXPLICITLY excluded from the button sweep. It is a <button>,
   but what it renders is the source line, and dropping it is exactly the
   failure this sheet exists to prevent.
   -------------------------------------------------------------------------- */

/* the rail */
#app-root #singularity-sidebar,
#app-root .singularity-sidebar,
#app-root .sidebar-nav,
#app-root .oo-nav-filter,
#app-root .sgcRecents,
#app-root .pk-nav,
#app-root .pk-skip,
#app-root .skip-link,
/* the palette */
.sgkit,
[data-sgkit="palette"],
.sgkit__scrim,
/* the toasts */
.sgkToastHost,
.sgkToast,
/* per-screen chrome that is pure affordance */
#app-root .sgcWatch,
#app-root .sgcCopy,
#app-root .mobPullCue,
#app-root .mobPullLabel,
#app-root .iv-ctl,
#app-root .iv-ctlend,
#app-root .iv-optset,
#app-root .iv-dl,
#app-root .iv-hoverbox,
#app-root .iv-cvs-over,
#app-root .iv-shim {
  display: none !important;
}

/* the controls. `:not()` chain rather than a blanket rule, so the provenance
   chip, the derived-figure chip and the as-of stay.

   `.sgkFig` is item 47's per-FIGURE provenance button (panel.js:928). A panel
   chip answers "where did this SCREEN come from"; a figure chip answers "where
   did THIS NUMBER come from", and on a WACC panel those are three different
   answers. Sweeping it would print a page whose panel citation is present and
   whose per-figure citations are gone — which reads as complete. */
#app-root button:not(.sgkProv):not(.sgkFig):not(.sgkProvKind),
#app-root .icon-command,
#app-root .amber-button,
#app-root [class*="-button"]:not([class*="-buttonless"]),
#app-root .sgkCtl,
#app-root input,
#app-root select,
#app-root textarea,
#app-root .ticker-shell,
#app-root .command-shell,
#app-root .sidebar-field {
  display: none !important;
}

/* A screen whose only content is a control is still a screen, and hiding all
   of it would print a blank sheet with no explanation. This is the honest
   remainder: the form's own explanatory copy survives the sweep above,
   because it is prose, not a control. */

/* --------------------------------------------------------------------------
   4 — TITLE, AND THE THINGS THAT MUST NOT BE SEPARATED FROM IT
   -------------------------------------------------------------------------- */
#app-root .viewport-header,
#app-root .pk-masthead {
  position: static !important;
  background: none !important;
  border: 0 !important;
  border-bottom: 1px solid var(--i-hair-strong) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  padding: 0 0 6px !important;
  margin: 0 0 10px !important;
  break-after: avoid;
  break-inside: avoid;
}

#app-root .viewport-title-block,
#app-root .pk-masthead h1,
#app-root .viewport-command,
#app-root .viewport-command-code {
  break-after: avoid;
  break-inside: avoid;
  color: var(--i-ink-1) !important;
}

/* The CACHED chip and the stale banner are the two elements on the screen
   whose whole job is to stop a figure being read as live. They print. Listed
   explicitly so a future blanket rule cannot sweep them by accident. */
#app-root .degraded-indicator,
#app-root .stale-banner,
#app-root [class*="stale-banner"],
#app-root .sgkProvKind {
  display: revert !important;
  break-inside: avoid;
}

/* --------------------------------------------------------------------------
   5 — AS-OF, AND THE SOURCE LIST                                    [item 22]

   `time.sgcAgo` renders "updated 3m ago" and keeps the absolute instant in
   `datetime` (frontend/kit/chrome.js:1512). Three minutes ago from WHEN is
   unanswerable once the sheet leaves the printer, so the absolute stamp is
   appended. `[datetime]` guards the case chrome.js documents: when no
   timestamp was supplied the attribute is REMOVED and the element says so —
   appending an empty parenthesis there would invent a stamp.
   -------------------------------------------------------------------------- */
#app-root time.sgcAgo,
#app-root .sgcAgo,
#app-root .sgkAsOf,
#app-root .sgkProvWhen {
  display: inline !important;
  color: var(--i-ink-2) !important;
}

#app-root time.sgcAgo[datetime]::after {
  content: " (" attr(datetime) ")";
}

/* The chip stops looking pressable and starts reading as a citation. */
#app-root .sgkProv,
#app-root .sgkFig,
#app-root button.sgkProv,
#app-root button.sgkFig {
  display: inline-flex !important;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: var(--i-ink-2) !important;
  break-inside: avoid;
}

/* The detail rows are `hidden` on screen and are unfolded here: source,
   as-of, method and URL, printed beside the panel they describe. This is the
   source list. */
#app-root .sgkProvPop,
#app-root .sgkProvPop[hidden] {
  display: block !important;
  position: static !important;
  visibility: visible !important;
  opacity: 1 !important;
  max-height: none !important;
  overflow: visible !important;
  background: none !important;
  border: 0 !important;
  border-left: 2px solid var(--i-hair-strong) !important;
  box-shadow: none !important;
  padding: 2px 0 2px 8px !important;
  margin: 4px 0 0 !important;
  font-size: var(--i-t-xs);
  break-inside: avoid;
}

#app-root .sgkProvList {
  display: grid !important;
  grid-template-columns: max-content 1fr;
  gap: 1px 8px;
  margin: 0;
}

/* The raw response fragment is a debugging affordance, not provenance. It can
   run to hundreds of lines and it would push the panel it belongs to off the
   sheet. The SOURCE rows above it are what the citation needs. */
#app-root .sgkProvFrag {
  display: none !important;
}

/* A URL that only exists as an href is a citation the reader cannot follow.
   Scoped to the provenance block and the chart footnote — a blanket
   `a::after` would append a URL to every ticker link in a table. */
#app-root .sgkProvPop a[href]::after,
#app-root .iv-foot a[href]::after,
#app-root .sgkProvVal a[href]::after {
  content: " <" attr(href) ">";
  font-size: var(--i-t-xs);
  color: var(--i-ink-3);
}

/* --------------------------------------------------------------------------
   6 — PANELS FLOW, CHARTS KEEP THEIR INK
   -------------------------------------------------------------------------- */
#app-root .terminal-panel,
#app-root .sgkPanel,
#app-root [class*="-panel"],
#app-root .iv-fig,
#app-root section,
#app-root article,
#app-root figure {
  break-inside: avoid;
  page-break-inside: avoid;
  max-height: none !important;
  overflow: visible !important;
  box-shadow: none !important;
  background: none !important;
  border: 1px solid var(--i-hair) !important;
  margin: 0 0 8px !important;
}

/* A grid that was sized for a 1440px viewport prints as a column of slivers.
   One column on paper, in DOM order. Restricted to the workspace's own
   children so a table's internal grid is untouched. */
#app-root .workspace {
  display: block !important;
  columns: auto !important;
}

/* Tables repeat their head on every sheet they span, and no row is split. */
#app-root thead { display: table-header-group; }
#app-root tfoot { display: table-footer-group; }
#app-root tr,
#app-root .sgtRow { break-inside: avoid; }

/* Charts. See the header for why the plate exists and what it cannot do.
   `print-color-adjust: exact` is the only way to ask a browser to print a
   background at all; the user's "Background graphics" checkbox still gates it.

   NOTE, deliberately: there is NO `svg text` or `svg line` rule in this file.
   Two such unscoped rules once painted an entire chart at 8% white. Chart
   paint is set by frontend/viz/* at draw time and this sheet does not
   second-guess it. */
#app-root .iv-cvs,
#app-root .iv-surf,
#app-root canvas {
  background: var(--y13PrintPlate) !important;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
  max-width: 100% !important;
  break-inside: avoid;
}

#app-root .iv-fig,
#app-root .iv-cap,
#app-root .iv-foot {
  break-inside: avoid;
}

/* The chart's own footnote carries its source. It is the chart's half of the
   provenance contract and it prints. */
#app-root .iv-foot {
  display: block !important;
  color: var(--i-ink-2) !important;
  font-size: var(--i-t-xs);
}

/* --------------------------------------------------------------------------
   7 — SCREENSHOT MODE SURVIVES THE PRINTER                          [item 23]

   Redaction that holds on screen and dissolves on paper is worse than no
   redaction, because the person who turned it on believes they are covered.
   `frontend/kit/screenshot.js` sets `data-y13shot` on <html>; the redaction
   rules live in static/domain.css and are NOT `@media screen`, so they already
   apply here. This block only re-asserts the two properties this file's own
   sweeps could otherwise have undone.
   -------------------------------------------------------------------------- */
:root[data-y13shot] #app-root .y13Redacted,
:root[data-y13shot] #app-root [data-y13private],
:root[data-y13shot] #app-root .y13PrivateHidden {
  color: transparent !important;
  text-shadow: none !important;
}

:root[data-y13shot] #app-root .y13PrivateHidden {
  visibility: hidden !important;
}

/* The banner naming what was hidden prints WITH the redaction. A redacted
   sheet that does not say it is redacted is a sheet with a hole in it. */
:root[data-y13shot] .y13ShotBanner {
  display: block !important;
  position: static !important;
  border: 1px solid var(--i-hair-strong) !important;
  background: none !important;
  color: var(--i-ink-1) !important;
  padding: 6px 8px !important;
  margin: 0 0 10px !important;
  break-inside: avoid;
  break-after: avoid;
}

/* --------------------------------------------------------------------------
   8 — MOTION AND EFFECTS

   A backdrop blur, a grain overlay and an animation all cost rendering time in
   the print pipeline and none of them reaches paper. Turned off rather than
   left to be rasterised.
   -------------------------------------------------------------------------- */
#app-root *,
#app-root *::before,
#app-root *::after {
  animation: none !important;
  transition: none !important;
  backdrop-filter: none !important;
  text-shadow: none !important;
}

#app-root [class*="-grain"],
#app-root [class*="-ambient"],
#app-root [class*="-glow"] {
  display: none !important;
}

/* Orphans and widows: a single line of a paragraph stranded on its own sheet
   is the classic print defect and costs nothing to prevent. */
#app-root p,
#app-root li,
#app-root dd {
  orphans: 3;
  widows: 3;
}

}
