/*
 * THE SITE ON PAPER (chrome, pane %48; TanElk dispatch 78, item 3). A section page or a lesson
 * prints as a page of a book: no header, navigation, toggles or drawers; the reading text across
 * the page's full width at a book size; equations whole; and every colour dark enough to read when
 * the printer has no colour.
 *
 * WHERE IT LOADS. The root layout links this file with media="print", served as /print.css by
 * src/app/print.css/route.ts. A screen never needs these rules, so they stay off the render path
 * and out of every route's first-load stylesheets: bundled into globals.css or reader.css, they
 * would be downloaded, parsed and counted against the route budget on every visit, to be used only
 * on the rare visit that prints. The browser fetches a print stylesheet at low priority and never
 * waits for it before painting.
 *
 * WHAT IS LEFT ALONE. Per-component print rules (equations.css, foundations.css, reader.css and
 * others) stay where they are. This file holds the rules that cross surfaces: the site's chrome,
 * the drawers, and the reading layout's grid.
 *
 * WHY EVERY SELECTOR STARTS AT :root. This sheet's place among the bundled stylesheets is not
 * something the layout controls, so a rule here cannot count on coming last. One extra class of
 * specificity wins over the screen rule it overrides wherever the two land, without !important.
 */

@page {
  margin: 20mm 37mm 22mm;
}

/* --- The site's chrome belongs to a screen ------------------------------------------------ */
/* .no-print had a rule only in platform/print/print.css, which the offline chapters use and the
   site never loads, so on the site it hid nothing: "Embed this laboratory on another page"
   printed under every laboratory that has an embed (measured on live under print emulation). */
:root .no-print,
:root .site-header,
:root .site-footer,
:root .skip-link,
:root .offline-chapters,
:root .guided-tour-guide,
:root .guided-tour-loading,
:root .foundation-page-exit,
:root .foundation-page-text > p:has(+ .foundation-page-exit),
:root a.button,
:root select {
  display: none;
}
/* The paper colour is a screen's; the sheet is the paper. */
:root,
:root body {
  background: white;
}
/* A heading printed as the last line of a page belongs to the next. */
h2,
h3,
h4 {
  break-after: avoid;
}

/* --- Drawers -------------------------------------------------------------------------------
   A closed drawer prints as its summary alone: a line saying there is more, on a page that cannot
   open it. So a closed drawer prints nothing, and an open one prints what the reader opened, with
   its summary as a plain label rather than a disclosure triangle. The one exception is the status
   note ("Draft explanation, not yet reviewed"), whose summary is the status and always prints. */
:root main details:not([open]):not(.callout-note) {
  display: none;
}
summary {
  list-style: none;
}
summary::-webkit-details-marker {
  display: none;
}
summary::marker {
  content: "";
}
.callout-note > summary {
  padding-left: 0;
  font-weight: 600;
}
/* The step drawers print open (am-plat-print-3orn). "Show every step here" and "Explore the
   equations in this step" hold the derivations themselves, and so do the drawers that hold the
   missing-step explorer's transitions (details:has(.missing-step-math)): closed, BM section 4 printed 50 of the 233 equations a reader brings on screen by
   opening them (measured on live under print emulation). ::details-content is what a closed
   drawer's content lives in, hidden; made visible, the content prints under its summary, which
   prints as a label. The other drawers still print nothing: they hold a control, a term-by-term
   gloss or a question, not the argument. */
:root main details.local-steps:not([open]):not(.callout-note),
:root main details:has(.missing-step-math):not([open]):not(.callout-note) {
  display: block;
}
:root main details.local-steps::details-content,
:root main details:has(.missing-step-math)::details-content {
  content-visibility: visible;
  display: block;
  block-size: auto;
}

/* --- The reading layout: one column across the page ---------------------------------------- */
:root .reader-anatomy {
  display: block;
}
/* The text fills the page's text block, and the margins make that block a book's: 136mm across
   an A4 sheet, at the scale's small step (about 12pt on paper), holds 71-75 characters a line,
   inside the 45-75 band the screen columns keep. A full-width line across a 160mm block measured
   88-90 characters, too long to follow back to the next line. */
:root .reader-main,
:root article.foundation-page {
  max-width: none;
  margin-inline: 0;
  font-size: var(--type-small);
}
/* The companion column sits beside the text on a screen; on paper it would take a third of every
   page from the text it accompanies. Its symbol key does not need it: every formula in the text
   carries its own legend beneath it, in the same quantity colours. */
:root .reader-companion-column,
:root .reader-inline-lab,
:root .reader-root > .page-intro > a {
  display: none;
}
/* On a screen the laboratory is a window that scrolls inside itself; printed that way it would be
   cut to the window's height. Here its static worked case prints whole, in the flow. */
:root .reader-sticky-lab {
  position: static;
  max-height: none;
  overflow: visible;
}

/* --- The first encounter's drag strip -------------------------------------------------------
   Its markers are white numerals on filled discs, and a printer without "background graphics"
   drops the fills, leaving white on white. The four readouts in the same box carry the same
   positions in words and numbers, so they print and the strip and its keyboard hint do not. A box
   whose only content is a button would print as an empty bar, so it goes with its button. */
:root .encounter .notice:has(kbd) > :not(.input-grid),
:root .encounter > .notice:has(> button:only-child) {
  display: none;
}

/* --- Where a link goes, on paper -------------------------------------------------------------
   A printed link is text with nowhere to click, so an external link prints its address after it,
   as the offline chapters already do (print.css). Links within the site are named by their text,
   and a lesson or section on paper is found by that name; printing 241 relative paths on one
   section page would bury the prose. An internal link that carries a locator ("§4, p. 556")
   prints the locator instead. */
:root main a[href^="http"]:not([data-no-print-url])::after,
:root main a[href^="//"]:not([data-no-print-url])::after {
  content: " (" attr(href) ")";
  font-family: var(--font-mono);
  font-size: var(--type-fine);
  font-weight: 400;
  overflow-wrap: anywhere;
}
:root main a[data-print-locator]::after {
  content: " (" attr(data-print-locator) ")";
  font-size: var(--type-fine);
  font-weight: 400;
}
