/* =============================================================================
 * TWE UI — print.css
 * The paper / PDF surface of the TWE / EdaphOS tool fleet.
 *
 *   Version : 2.1.0        Date : 2026-09-11
 *   Requires: tokens.css v2.1.0 — this file only re-points its tokens.
 *
 * WHY THIS FILE EXISTS
 * TWE's product is a stamped geotechnical report. The fleet's dashboards,
 * triage worksheets, gate packets, flow maps and portfolio views all get
 * printed or "Save as PDF"-ed and sent to a client or an approving engineer.
 * The screen system earns its polish from glass, a dual shadow ramp and
 * low-alpha borders — every one of which prints as a black slab, a grey smear,
 * or nothing at all. The prettier the screen guide, the worse the printed
 * artifact, unless this file is loaded.
 *
 * LOAD ORDER: link LAST — after tokens.css, base.css, data.css, motion.css and
 * every component sheet. It wins ties by source order, which section 2 needs.
 *
 * OVERLAP with data.css §15 (which unwinds its own table-wrap/freeze/KPI) is
 * intentional: a component owns its print form, while this file owns the
 * document and the hand-rolled non-kit markup most fleet tools still ship.
 *
 * !important is confined to the section-4 kill-list, visibility and
 * backgrounds: chart libraries emit inline styles and component sheets emit
 * deeper selectors than a stylesheet can politely outrank, and one surviving
 * box-shadow is a grey band across a client deliverable.
 *
 * NO JS. The two behaviours that genuinely need a line of script are documented
 * at their rule (opening <details> below Chromium 131; filling the provenance
 * header). Both degrade to "content missing", never to "layout broken".
 * ========================================================================== */

@media print {

/* ------------------------------------------------------------ 1. the page --
 * US Letter: every TWE deliverable, transmittal and boring log is Letter.
 * 0.6in clears a duplex/staple edge without stealing table width. Custom
 * properties do NOT cascade into the page context, so the literals here are
 * correct here and nowhere else in the kit. The @bottom-center block is inert
 * in Chromium (see section 10) and is kept so server-side PDF rendering gets
 * page numbering for free. */
@page {
  size: 8.5in 11in;
  margin: 0.6in;
  @bottom-center { content: "Page " counter(page) " of " counter(pages); font-size: 9pt; }
}
/* A cover page carries the title block: more headroom, no running footer. */
@page :first {
  margin: 1in 0.6in 0.6in;
  @bottom-center { content: ""; }
}
/* A 20-column boring-log summary does not fit portrait. Named pages are
 * supported at the Chromium 120 floor; where they are not this degrades to
 * portrait rather than to a clipped table. */
@page landscape { size: 11in 8.5in; margin: 0.6in; }
.twe-print-landscape { page: landscape; break-before: page; }

/* --------------------------------------------- 2. force the light palette --
 * Someone printing at 21:00 is in dark theme. Printing #0d1117 surfaces costs
 * a toner cartridge and puts white-on-black text on paper. Because every rule
 * in every TWE sheet reads a var(), re-pointing the tokens here converts the
 * whole fleet to a print palette without touching one component rule — that
 * is the entire strategy of this file. Selectors are :root-qualified (0,2,0)
 * to outrank tokens.css's [data-twe-theme='dark'|'light'|'field'] blocks and
 * its :root:not([data-twe-theme]) prefers-color-scheme block, load order aside. */
:root,
:root:not([data-twe-theme]),
:root[data-twe-theme] {
  color-scheme: light only;

  /* Paper is the background. No ink is spent describing it. */
  --twe-bg: #ffffff;            --twe-bg-surface: #ffffff;
  --twe-bg-raised: #ffffff;     --twe-bg-card: #ffffff;
  --twe-bg-card-hover: #ffffff; --twe-bg-input: #ffffff;
  --twe-bg-inset: #ffffff;      --twe-bg-overlay: transparent;

  --twe-text:           var(--twe-navy-950);
  --twe-text-secondary: var(--twe-navy-700);
  --twe-text-muted:     var(--twe-navy-600);  /* the screen muted greys are
                                               * AA on a backlit panel and drop
                                               * out entirely at 300dpi */
  --twe-text-inverse:   #ffffff;

  /* Solid, never alpha: an 8%-alpha border is invisible on white, and those
   * borders separate every card, cell and field in this system. Integral and
   * >=1px — 125%/150% Windows DPI plus the printer's own scaling makes any
   * sub-pixel hairline vanish on one page and double on the next. */
  --twe-border:        var(--twe-navy-300);
  --twe-border-strong: var(--twe-navy-500);
  --twe-border-light:  var(--twe-navy-200);
  --twe-border-width:  1px;

  /* Depth is not printable. Re-pointing the elevation ramp at its source is
   * the actual fix; the section-4 kill-list is only the safety net. */
  --twe-elev-0: none; --twe-elev-1: none; --twe-elev-2: none;
  --twe-elev-3: none; --twe-elev-4: none; --twe-elev-5: none;
  --twe-elev-glow: none; --twe-highlight: none; --twe-shadow-alpha: 0;

  --twe-glass-bg: #ffffff;  --twe-glass-blur: 0px;  --twe-glass-sat: 1;
  --twe-glass-border: var(--twe-navy-300);

  /* The four status tints print as four indistinguishable greys on the mono
   * lasers most TWE offices run. Section 11 restores hue only where it is
   * load-bearing, and never without a glyph beside it. */
  --twe-ok-bg: transparent;     --twe-warn-bg: transparent;
  --twe-danger-bg: transparent; --twe-info-bg: transparent;

  /* A transition still running when the print snapshot is taken is captured
   * mid-flight, i.e. at a half-drawn state. */
  --twe-dur-instant: 0.01ms; --twe-dur-fast: 0.01ms; --twe-dur: 0.01ms;
  --twe-dur-slow: 0.01ms;    --twe-dur-enter: 0.01ms;
}

/* ------------------------------------------------------- 3. document base --
 * "economy" is the default everywhere; "exact" is opted into per component
 * (section 11) so a colour costs toner only when it carries information. */
html, body {
  background: #ffffff !important;
  color: var(--twe-text) !important;
  font-family: var(--twe-font-sans);
  font-size: var(--twe-text-base);
  line-height: var(--twe-leading-body);
  -webkit-print-color-adjust: economy;
  print-color-adjust: economy;
  margin: 0; padding: 0;
  width: auto; height: auto; max-height: none; overflow: visible;
}
/* App shells are viewport-locked scroll containers. Left alone they clip the
 * document to one screenful and print page 1 of 40. */
#app, #root, main, .twe-app, .twe-shell, .twe-main, .twe-content, .twe-layout,
.twe-vt-main, .twe-scroll, .twe-scroll--thin, .twe-scroll--none {
  display: block !important;
  position: static !important;
  overflow: visible !important;
  height: auto !important; max-height: none !important;
  width: auto !important;  max-width: none !important;
  grid-template-columns: none !important;
}

/* --------------------------------------------------- 4. what cannot print --
 * Each of these is a screen-only device: backdrop-filter prints as a black
 * slab, box-shadow as a grey band, a decorative gradient as a solid bar of
 * toner. The universal selector is deliberate — a chart library's inline
 * filter is not reachable any other way.
 *
 * THE CONSEQUENCE IS A KIT-WIDE DESIGN RULE: no TWE component may encode
 * separation or meaning in a shadow, a blur, a glow or a hue alone — none of
 * those exist on paper, and none exist for a screen reader either. Whatever a
 * shadow said on screen is re-stated here as a real 1px border (section 5);
 * whatever a colour said is re-stated as text, glyph or shape (section 11). */
*, *::before, *::after {
  box-shadow: none !important;
  text-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  filter: none !important;      /* also drops dark-theme invert() on diagrams */
  animation: none !important;
  transition: none !important;
}
/* Custom scrollbars are meaningless on paper; the thumb/track tokens go unused. */
::-webkit-scrollbar { display: none !important; }
/* Reveal-on-scroll is the worst print bug in the kit: motion.css §3 drives
 * .twe-reveal from a view() timeline, so anything below the fold sits at
 * opacity 0 and PRINTS BLANK. `animation: none` above already releases the
 * `both` fill; this states the end state explicitly so no later rule can
 * re-blank a page of a client deliverable. */
.twe-reveal, .twe-stagger > * { opacity: 1 !important; transform: none !important; }
/* Glass becomes an opaque bordered panel — translucency over white is a smear. */
.twe-glass, .twe-glass-panel, [class*="glass"] {
  background: #ffffff !important;
  border: var(--twe-border-width) solid var(--twe-border) !important;
}
/* Ornament is removed, not flattened: it never carried information. */
.twe-glow, .twe-aurora, .twe-noise, .twe-grain, .twe-decor, .twe-spotlight,
.twe-gradient-bg { display: none !important; }

/* -------------------------- 5. give back what the shadows were carrying --- */
.twe-card, .twe-panel, .twe-tile, .twe-kpi, .twe-metric, .twe-well,
.twe-callout, .twe-section, fieldset, figure, pre {
  background: #ffffff !important;
  border: var(--twe-border-width) solid var(--twe-border) !important;
  border-radius: var(--twe-radius-sm);
  padding: var(--twe-space-3);
  margin: 0 0 var(--twe-space-3);
  break-inside: avoid;
}
hr { border: 0; border-top: var(--twe-border-width) solid var(--twe-border); }

/* ------------------------------------------- 6. tables: the whole point ----
 * A geotechnical deliverable is mostly tables. A header that does not repeat
 * makes page 2 of a boring-log summary unreadable — and unusable as evidence.
 * break-* is native at the Chromium 120 floor, so no legacy page-break-*
 * aliases are needed. */
table, .twe-table { width: 100% !important; border-collapse: collapse !important;
                    font-size: var(--twe-text-sm); }
thead { display: table-header-group; }   /* repeats the header on every page */
tfoot { display: table-footer-group; }   /* totals land at the foot of each */
tr, td, th { break-inside: avoid; }
th, td {
  background: #ffffff !important;   /* kills zebra striping and hover tints */
  border: var(--twe-border-width) solid var(--twe-border) !important;
  padding: var(--twe-space-1) var(--twe-space-2);
  vertical-align: top;
}
/* A sticky header inside a print flow either repeats wrongly or overlaps rows.
 * data.css handles its own; this covers the fleet's hand-rolled tables. */
thead th, tfoot td, .twe-table--freeze th, .twe-table--freeze td { position: static !important; }
/* th is distinguished by CASE, TRACKING and a heavier rule — NOT by weight:
 * only font weight 400 is a real vendored face (tokens.css §0) and base.css
 * sets font-synthesis:none, so `font-weight: 600` alone would render pixel-
 * identical to the body rows. Invisible emphasis is a WCAG 1.3.1 failure. */
th {
  text-align: left;
  font-size: var(--twe-text-2xs);
  text-transform: uppercase;
  letter-spacing: var(--twe-tracking-eyebrow);
  border-bottom: 2px solid var(--twe-border-strong) !important;
}
/* Numbers keep the mono face and tabular figures. A decimal column that does
 * not align is a QA finding on a stamped report, and Outfit has no true
 * tabular figures — which is why tokens.css forbids setting numerics in it. */
.num, .twe-num, .twe-td--num, td[data-twe-num] {
  font-family: var(--twe-font-mono);
  font-variant-numeric: var(--twe-nums);
  text-align: right;
}
/* An ellipsised cell on screen is a click away from its full value. On paper
 * it is data loss, so truncation is unwound. */
.twe-td--trunc { max-width: none !important; overflow: visible !important;
                 text-overflow: clip !important; white-space: normal !important; }
caption, .twe-chart-caption {
  caption-side: top; text-align: left; padding-bottom: var(--twe-space-1);
  font-size: var(--twe-text-xs); color: var(--twe-text-secondary);
}

/* ----------------------------------------------- 7. pagination discipline -- */
h1, h2, h3, h4 { break-after: avoid; break-inside: avoid;
                 line-height: var(--twe-leading-tight); }
h1 { font-size: var(--twe-text-2xl); }
h2 { font-size: var(--twe-text-xl); }
h3 { font-size: var(--twe-text-lg); }
h4 { font-size: var(--twe-text-md); }
p, li, blockquote, dd { widows: 3; orphans: 3; }
.twe-page-break { break-before: page; }
.twe-keep, .twe-keep-together, .twe-definition-list, .twe-list-row { break-inside: avoid; }

/* ------------------------------------- 8. chrome that means nothing here --
 * Buttons above all: a printed "Export" pill is dead UI, and on a client-
 * facing page it reads as a defect. */
nav, aside, dialog, video, audio, iframe, [popover],
.twe-rail, .twe-vt-rail, .twe-sidebar, .twe-nav, .twe-topbar, .twe-tabs,
.twe-toast, .twe-toaster, .twe-tooltip, .twe-popover, .twe-dropdown,
.twe-menu, .twe-cmdk, .twe-skeleton, .twe-spinner, .twe-spin, .twe-resizer,
.twe-btn, .twe-icon-btn, .twe-fab, .twe-theme-toggle, .twe-search,
.twe-pagination, .twe-switch, .twe-toggle,
.twe-modal, .twe-sheet, .twe-backdrop, .twe-overlay,
[role="navigation"], [role="tooltip"], [role="menu"], [role="menubar"],
[role="tablist"], [role="dialog"], [role="alertdialog"],
.twe-no-print, [data-twe-print="hide"] {
  display: none !important;
}
/* Escape hatch: sometimes the artifact IS the modal — a gate packet rendered
 * in a dialog. Mark that subtree; it lays out as a block on paper. */
.twe-print-keep, dialog.twe-print-keep { display: block !important; }
/* Sticky and fixed boxes either repeat on every page or clip their content. A
 * tool's bespoke sticky element must carry .twe-sticky or .twe-no-print. */
header, .twe-header, .twe-vt-header, .twe-appbar, .twe-toolbar, .twe-sticky,
[data-twe-sticky] { position: static !important; top: auto !important; }

/* ---------------------------------------------- 9. what only paper shows --
 * `revert`, not `display: block`: a .twe-print-only <table> must come back as
 * a table. (It reverts to the UA display, so a print-only flex row lays out
 * as a block — set the layout on an inner wrapper if that matters.) */
.twe-print-only, [data-twe-print="only"] { display: revert !important; }

/* Collapsed disclosure content must be revealed — a reader cannot click paper.
 * At the Chromium 120 floor a closed <details> is hidden inside the UA shadow
 * tree and CANNOT be opened from CSS, so a tool that prints disclosures must
 * set the attribute itself:
 *   addEventListener('beforeprint', () =>
 *     document.querySelectorAll('details').forEach(d => d.open = true));
 * Without that line the printout silently loses content, which is why it is
 * documented here instead of left to be discovered on a client's desk. */
details { break-inside: avoid; }
details > summary { list-style: none; font-weight: 600; font-synthesis: weight; }
@supports selector(::details-content) {
  /* Chromium 131+: no script needed. */
  details::details-content { content-visibility: visible !important; }
}
/* Paper has no hover, so an external link's target has to be printed. In-app
 * relative hrefs never match [href^="http"], and the scoping keeps LAN tool
 * URLs out of chrome and buttons. Opt a subtree out with
 * data-twe-print-url="off". */
.twe-prose a[href^="http"]::after, .twe-print-urls a[href^="http"]::after,
p a[href^="http"]::after, li a[href^="http"]::after, td a[href^="http"]::after {
  content: " (" attr(href) ")";
  font-family: var(--twe-font-mono);
  font-size: var(--twe-text-2xs);
  color: var(--twe-text-secondary);
  word-break: break-all;
}
[data-twe-print-url="off"] a[href^="http"]::after { content: none; }
a { color: var(--twe-text) !important; text-decoration: underline; }

/* ------------------------------------ 10. provenance: header and footer ---
 * A client-facing printout MUST carry the project number and the generation
 * date. A printed page with no provenance is a liability in an engineering
 * deliverable: it cannot be tied to a project, a revision, or a responsible
 * engineer — and it will still be in someone's file five years from now when
 * that question is asked. Populate from the app; never hand-typed.
 *   <div class="twe-print-header twe-print-only">
 *     <span class="twe-print-title">Panoptes — Portfolio View</span>
 *     <span class="twe-print-meta">Proj 26.23 · 2026-09-04 · M. Sumpter</span>
 *   </div>
 * PAGE NUMBER: Chromium 120-152 implements no @page margin boxes and exposes
 * counter(page) nowhere in flow, so a live "Page 2 of 7" is impossible
 * in-browser. Routes: the browser's own headers-and-footers print option, or
 * server-side rendering (WeasyPrint/Prince honour section 1's @page block).
 * .twe-print-pageno is the slot for whichever route a tool takes. */
.twe-print-header, .twe-print-footer {
  display: flex !important;
  justify-content: space-between; align-items: baseline;
  gap: var(--twe-space-4);
  font-size: var(--twe-text-2xs);
  color: var(--twe-text-secondary);
}
.twe-print-header { border-bottom: var(--twe-border-width) solid var(--twe-border-strong);
                    padding-bottom: var(--twe-space-1); margin-bottom: var(--twe-space-4); }
/* Chromium repeats a position:fixed element on every printed page — that is
 * how the footer travels without a running-header implementation. */
.twe-print-footer { position: fixed; bottom: 0; left: 0; right: 0;
                    border-top: var(--twe-border-width) solid var(--twe-border);
                    padding-top: var(--twe-space-1); }
.twe-print-title { font-size: var(--twe-text-sm); color: var(--twe-text);
                   font-weight: 600; font-synthesis: weight; }
.twe-print-eyebrow { text-transform: uppercase;
                                   letter-spacing: var(--twe-tracking-eyebrow); }
.twe-print-pageno, .twe-print-meta { font-family: var(--twe-font-mono);
                                     font-variant-numeric: var(--twe-nums); }
/* The screen mark is usually light-on-dark or a CSS-gradient wordmark; both
 * disappear on white. Ship an ink variant and let this swap them. */
.twe-logo--dark, .twe-logo-glow { display: none !important; }
.twe-logo, .twe-logo--print { display: inline-block !important; max-height: 0.4in; }

/* ---------------------------- 11. status: the only colour worth the toner --
 * print-color-adjust:exact appears ONLY here. A danger chip on a triage
 * worksheet is load-bearing — it is usually why the page was printed at all.
 * Colour is never the sole carrier: the label stays near-black (var(--twe-ok)
 * on white is ~1.9:1 and would fail AA as text), the hue moves to the border,
 * and a glyph plus a distinct border style carry the state through a mono
 * printer, a fax and a third-generation photocopy. Section 508 exposure on
 * public-sector work is real. A badge that already renders its own icon opts
 * out of the glyph with data-twe-print-glyph="off". */
.twe-badge, .twe-status, .twe-chip, .twe-pill, [data-twe-status] {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  display: inline-block !important;
  background: #ffffff !important;
  color: var(--twe-text) !important;
  border: var(--twe-border-width) solid var(--twe-border-strong);
  border-radius: var(--twe-radius-pill);
  padding: 0 var(--twe-space-2);
  font-size: var(--twe-text-2xs);
}
.twe-badge--ok,      .twe-status--ok,      [data-twe-status="ok"]      { border-color: var(--twe-ok) !important; }
.twe-badge--warn,    .twe-status--warn,    [data-twe-status="warn"]    { border-color: var(--twe-warn) !important; border-width: 2px; }
.twe-badge--danger,  .twe-status--danger,  [data-twe-status="danger"]  { border-color: var(--twe-danger) !important; border-style: double; border-width: 3px; }
.twe-badge--info,    .twe-status--info,    [data-twe-status="info"]    { border-color: var(--twe-info) !important; border-style: dashed; }
.twe-badge--neutral, .twe-status--neutral, [data-twe-status="neutral"] { border-color: var(--twe-neutral) !important; }
.twe-badge--accent,  .twe-status--accent   { border-color: var(--twe-accent) !important; }
.twe-badge--ok:not([data-twe-print-glyph="off"])::before      { content: "\2713\00A0"; }
.twe-badge--warn:not([data-twe-print-glyph="off"])::before    { content: "\0021\00A0"; }
.twe-badge--danger:not([data-twe-print-glyph="off"])::before  { content: "\00D7\00A0"; }
.twe-badge--info:not([data-twe-print-glyph="off"])::before    { content: "i\00A0"; }
.twe-badge--neutral:not([data-twe-print-glyph="off"])::before { content: "\2013\00A0"; }

/* ------------------------------------------ 12. images, charts and forms -- */
img, svg, canvas, .twe-chart, .twe-chart-host, .twe-map, .twe-flowmap {
  max-width: 100% !important;
  height: auto;
  break-inside: avoid;   /* a chart split across a fold is unreadable evidence */
}
.twe-chart-host { border: var(--twe-border-width) solid var(--twe-border);
                  border-radius: var(--twe-radius-sm); padding: var(--twe-space-2); }
/* Charts label axes in secondary grey at 11px: fine backlit, marginal at
 * 300dpi. `fill` is forced too, because a dark-theme chart draws light text
 * that would print as nothing. */
.twe-chart text, .twe-chart-host text {
  font-size: var(--twe-text-xs) !important;
  fill: var(--twe-navy-950) !important;
}
/* A meter/progress fill is a hue on a track — both flattened by economy mode,
 * so the bar must print as an outline and the paired numeric value (data.css
 * §10 requires one) carries the reading. */
.twe-meter, .twe-progress, .twe-phasebar {
  border: var(--twe-border-width) solid var(--twe-border-strong) !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
/* Worksheets are printed to be filled in or checked, so field boxes must be
 * visible — and a checked box must survive, because its state is data. */
input, select, textarea {
  background: #ffffff !important;
  color: var(--twe-text) !important;
  border: var(--twe-border-width) solid var(--twe-border-strong) !important;
  border-radius: var(--twe-radius-xs);
}
input[type="checkbox"], input[type="radio"] {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

}  /* end @media print */
