/**
 * Smarter Guides print stylesheet.
 *
 * Two jobs, in one file because they share every rule about paper.
 *
 * The first is a chapter someone hits Ctrl+P on: navigation, video and controls
 * gone, the term list stacked and ruled, and the reader's identity and the
 * disclaimer repeating at the foot of every page.
 *
 * The second is the personalised sheet at /my-guide/{guide}/print/{block}/,
 * which is the artifact this feature exists for: one or two pages of what the
 * reader chose, with room to write.
 *
 * Assumptions this file is built on:
 *
 *   - Backgrounds do not print. Every browser defaults to dropping them and
 *     plenty of printers drop them anyway, so nothing here may depend on a fill
 *     to carry meaning. The 40% row tint that separates term-list rows on screen
 *     is replaced with a rule, not merely repeated as one.
 *   - Colour does not print. Everything is black on white.
 *   - A page break can land anywhere, so anything that reads as one unit — a
 *     term and its explanation, a checklist row, a list item — says so.
 */

/* -------------------------------------------------------------------------
 * The page box
 *
 * The margin is honoured everywhere. The margin boxes below it are CSS Paged
 * Media: real print engines fill them, browsers ignore them and put their own
 * header and footer, including a page number, at the edge of the paper. The
 * identity a browser prints on every page therefore comes from the fixed
 * elements further down, not from here. Printing\Assets adds a matching @page
 * rule carrying the reader's own line, generated on the server.
 * ---------------------------------------------------------------------- */

/*
 * WHY THE FOOTER IS A TABLE FOOT AND NOT A FIXED BOX
 *
 * Two wrong answers were tried on real paper before this one. Both are worth
 * writing down, because both look correct until a five-page sheet is printed.
 *
 * `position: fixed; bottom: 0` repeats on every page — which is why it was
 * chosen — but fixed means out of flow, so the paginated content has no idea
 * it is there and prints straight through the identity line. @page margin does
 * not help: it reserves paper outside the page area, not space inside it. A
 * padding-bottom on the article only cushions the last page.
 *
 * `position: fixed; bottom: -16mm` inside an enlarged page margin put the box
 * in the reserved band on page 1 and then produced a *second* copy at the top
 * of every continuation page, landing on the first item. A fixed box whose
 * offsets place it outside the page area has no well-defined behaviour once
 * the document fragments: the containing block is the page area, and what an
 * engine does with the part that falls outside it — clip, drop, or push to the
 * next fragment — is its own business. There is no offset that fixes that,
 * because the problem is not the number.
 *
 * The mechanism CSS actually provides for this is @page margin boxes, and no
 * browser implements them. They are emitted below and by Printing\Assets for
 * real paged engines, and they are why the sheet is correct under Prince or
 * Paged.js — but relying on them in a browser would mean no identity line on
 * any printed page at all.
 *
 * So the footer is a <tfoot>. A repeated table section is *in flow*: the
 * engine reserves its height on every fragment before it lays any row into
 * that fragment, so content overlapping it is not something that can happen,
 * at any page count, without any reserved band to keep in sync. It is the one
 * construct that gets this right in a browser.
 *
 * The page margin is therefore back to a plain 20mm on all four sides.
 *
 * THE CHAPTER USES THE SAME MECHANISM NOW. Everything above was written for the
 * sheet, and the chapter kept a fixed foot and a known overlap for three rounds
 * because "a chapter is not a table". It is one now: templates/chapter.php
 * emits a real frame and the overlap is gone in both engines at every page
 * count. See the running-foot section further down for the numbers.
 *
 * FIREFOX DRAWS THE REPEATED FOOT A SECOND TIME, IN THE TOP MARGIN OF EVERY
 * CONTINUATION PAGE.
 *
 * Somebody will print a chapter in Firefox, see the identity line at the top of
 * page two, and think it is new breakage. It is not new and it is not breakage:
 * it is a duplicate of a line that is also, correctly, at the foot of that same
 * page. Redundant provenance, not lost provenance. It sits about 16mm from the
 * paper edge, above the content area, and obscures nothing — which is the whole
 * difference between it and the defect it replaced, where body text printed
 * through the identity line on six of seven pages.
 *
 * It is avoidable in principle, because the sheet does not do it and the sheet
 * is the same construct. Roughly twenty-five bisection experiments did not find
 * the trigger. Ruled out, each measured rather than reasoned about: the Divi
 * ancestor chain, the layout wrapper, the sidebar and rail, the fixed diagonal
 * overlay, the hidden fixed disclaimer and watermark, declaring the display
 * trio explicitly, border-collapse, table-layout, break-inside on the foot,
 * cell padding in every combination, the body class and its margin reset,
 * loading sheet.css, the number of lines in the foot, the foot's element
 * structure, and content length from two to nine pages. Two documents that
 * could not be made to differ in any way that mattered behaved differently.
 *
 * So it is recorded rather than fixed, exactly like the diagonal-marks engine
 * split further down, and for the same reason: an accepted, measured, cosmetic
 * difference between engines is a better place to stand than a speculative
 * change to a mechanism that is otherwise correct. If it is ever worth another
 * look, start from the fact that the sheet is clean and the chapter is not, in
 * the same browser, on the same day.
 *
 * WHAT THE FOOT COSTS. A reserved band on every page is paper: eight pages of
 * chapter become nine, about twelve per cent. That is the right trade and it is
 * not close. The alternative is not "eight pages"; it is eight pages on seven
 * of which the provenance line and the reader's own text are printed on top of
 * each other and neither is legible.
 */

@page {
	margin: 20mm;
}

@media print {

	/* ---------------------------------------------------------------------
	 * Shared paper rules
	 * ------------------------------------------------------------------ */

	body {
		background: #fff;
		color: #000;
	}

	p,
	li,
	dd,
	dt {
		orphans: 3;
		widows: 3;
	}

	h1,
	h2,
	h3 {
		page-break-after: avoid;
		break-after: avoid;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	/* ---------------------------------------------------------------------
	 * A chapter, printed
	 * ------------------------------------------------------------------ */

	.smartg-skip,
	.smartg-sidebar,
	.smartg-pager,
	.smartg-video,
	.smartg-saved,
	.smartg-hub__actions,
	.smartg-continue,
	.smartg-locked__actions,
	.smartg-chapter__actions,
	.smartg-button,
	.smartg-link-button,
	.smartg-checklist__bar,
	.smartg-checklist__actions,
	.smartg-checklist__disclose,
	.smartg-block__status,
	.smartg-progress,

	/*
	 * The search field and its results are a query, not a chapter. A printed
	 * page carries the reading; nobody wants a screenshot of what they typed
	 * into a box, and the results themselves are already gone by the time the
	 * page they point at is in a printer.
	 */
	.smartg-search,
	.smartg-search-results,

	/*
	 * The band under a free chapter is a sales panel. It is honest on screen
	 * and it is an advertisement on paper, so it does not print. The chapter
	 * itself, its identity line and its disclaimer all still do.
	 */
	.smartg-more,

	.smartg-reader-shell button,
	.smartg-reader-shell nav {
		display: none !important;
	}

	.smartg-reader-shell {
		background: #fff;
		color: #000;
		padding: 0;
		font-size: 11pt;
		line-height: 1.5;
	}

	.smartg-layout {
		display: block;
		max-width: none;
	}

	/*
	 * background: none, not #fff. The page is already white and an opaque fill
	 * here would paint over the diagonal identity marks below, which sit at
	 * z-index -1 behind the text. See "The diagonal marks on a printed chapter".
	 */
	.smartg-content {
		border: 0;
		background: none;
		max-width: none;
		padding: 0 0 26pt;
	}

	.smartg-prose {
		max-width: none;
		font-size: 11pt;
	}

	/*
	 * The watermark tile is meant to survive printing; that is most of its point.
	 * It is decoration over the reading surface, never a row separator, so nothing
	 * below depends on it arriving.
	 */
	.smartg-sensitive {
		background-image: var(--smartg-watermark);
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.smartg-prose a {
		color: #000;
		text-decoration: underline;
	}

	.smartg-prose a::after {
		content: " (" attr(href) ")";
		font-size: 0.85em;
		word-break: break-all;
	}

	/* ---------------------------------------------------------------------
	 * The term list
	 *
	 * Over 400 pairs in the first guide, so this is the chapter. On paper it
	 * stacks: term in semibold, explanation indented beneath it, a rule between
	 * entries. No grid, no boxes, no tints — the screen's alternating wash is
	 * removed outright rather than trusted to print, and the rule does the
	 * separating on its own.
	 * ------------------------------------------------------------------ */

	.smartg-prose .smartg-terms {
		display: block;
		margin: 1.5em 0;
	}

	.smartg-prose .smartg-terms dt,
	.smartg-prose .smartg-terms dd {
		background: none !important;
		border: 0;
		display: block;
	}

	.smartg-prose .smartg-terms dt {
		font-weight: 600;
		padding: 0.55em 0 0.15em;
		border-top: 0.75pt solid #000;
	}

	.smartg-prose .smartg-terms dt:first-of-type {
		border-top: 0;
	}

	.smartg-prose .smartg-terms dd {
		padding: 0 0 0.55em 1.5em;
		margin: 0;
	}

	/*
	 * A pair is one thing, so it does not split. dt and dd are separate boxes, so
	 * the term is also told to keep the line after it, which is what stops a term
	 * printing alone at the foot of a page.
	 */
	.smartg-prose .smartg-terms dt,
	.smartg-prose .smartg-terms dd {
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-prose .smartg-terms dt {
		page-break-after: avoid;
		break-after: avoid;
	}

	.smartg-prose li,
	.smartg-prose tr,
	.smartg-prose blockquote,
	.smartg-prose figure {
		page-break-inside: avoid;
		break-inside: avoid;
	}

	/* ---------------------------------------------------------------------
	 * Everything opens
	 *
	 * Paper has no disclosure triangles. Every collapsed section and every
	 * explanation body is expanded, whatever state the reader left it in.
	 * ------------------------------------------------------------------ */

	details {
		display: block !important;
	}

	details > summary {
		list-style: none;
		font-weight: 600;
		page-break-after: avoid;
		break-after: avoid;
	}

	details:not([open]) > *,
	details > *:not(summary) {
		display: block !important;
	}

	.smartg-checklist__body[hidden],
	.smartg-block [hidden] {
		display: block !important;
	}

	.smartg-block {
		border-left-width: 0.75pt;
		page-break-inside: auto;
		break-inside: auto;
	}

	.smartg-checklist__item,
	.smartg-checklist__row {
		page-break-inside: avoid;
		break-inside: avoid;
	}

	/* ---------------------------------------------------------------------
	 * Everything the styling pass added
	 *
	 * The rule for all of it is the same rule the term list follows: paper has
	 * no fills, so nothing may depend on one. Every chip, badge, panel and
	 * quote states itself with a rule, a border or a word, and each is told not
	 * to split across a page.
	 *
	 * Nothing here is taken out of flow, and the reason survives the fix that
	 * made the running foot a repeating table foot rather than a fixed box. The
	 * foot is now in flow and pagination accounts for it, which is exactly why
	 * it stays clean; a second positioned thing among the content is how that
	 * gets undone one element at a time.
	 * ------------------------------------------------------------------ */

	/* The rail is an aside, so the blanket nav rule above does not catch it. */
	.smartg-rail,
	.smartg-hub__start,
	.smartg-next,
	.smartg-note__form,
	.smartg-note__field,
	.smartg-note__actions,
	.smartg-video__duration,
	.smartg-sidebar__summary,
	.smartg-continue__cta,
	.smartg-pager__number,
	.smartg-saved__link {
		display: none !important;
	}

	.smartg-hub__band-heading::after {
		display: none;
	}

	/*
	 * A filled chip prints as a pale grey rectangle or as nothing at all,
	 * depending on the browser's background setting. Outlined, it is the same
	 * number in the same place either way.
	 */
	.smartg-chip {
		background: none !important;
		color: #000;
		border: 0.75pt solid #000;
		min-width: 1.6em;
		height: auto;
		padding: 0.1em 0.35em;
		font-size: 10pt;
	}

	.smartg-badge,
	.smartg-badge--anchor,
	.smartg-badge--reading,
	.smartg-badge--read,
	.smartg-badge--free,
	.smartg-badge--locked {
		background: none !important;
		color: #000;
		border: 0.75pt solid #000;
	}

	/* ---------------------------------------------------------------------
	 * The four authoring components
	 * ------------------------------------------------------------------ */

	.smartg-prose .smartg-quote {
		margin: 14pt 0;
		padding-top: 8pt;
		border-top: 1.5pt solid #000;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-prose .smartg-quote__text {
		font-size: 12pt;
		font-style: italic;
		color: #000;
	}

	.smartg-prose .smartg-quote__cite {
		font-size: 9pt;
		color: #000;
	}

	.smartg-prose .smartg-takeaway {
		margin: 12pt 0;
		padding: 4pt 0 4pt 8pt;
		border-left: 2pt solid #000;
		font-size: 11pt;
		font-weight: 700;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-prose .smartg-callout {
		margin: 14pt 0;
		border: 0.75pt solid #000;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-prose .smartg-callout__title {
		background: none !important;
		color: #000;
		border-bottom: 0.75pt solid #000;
		padding: 5pt 8pt;
		font-size: 11pt;
		page-break-after: avoid;
		break-after: avoid;
	}

	.smartg-prose .smartg-callout__body {
		background: none !important;
		padding: 4pt 8pt 8pt;
	}

	/*
	 * An editor's warning is printed rather than hidden. A reader never receives
	 * the element at all, so anybody holding this page is the person who needs
	 * to see it.
	 */
	.smartg-authoring-warning {
		background: none !important;
		color: #000;
		border: 0.75pt dashed #000;
		padding: 5pt 8pt;
		font-size: 9pt;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	/* ---------------------------------------------------------------------
	 * The reader's own note
	 *
	 * This is the one thing on the page nobody else has, so it prints — as the
	 * paragraph the template renders for paper, not as the textarea, whose
	 * contents browsers disagree about.
	 * ------------------------------------------------------------------ */

	.smartg-note {
		background: none !important;
		border: 0;
		border-top: 0.75pt solid #000;
		border-radius: 0;
		margin: 16pt 0 0;
		padding: 8pt 0 0;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-note__heading {
		font-size: 11pt;
		color: #000;
		page-break-after: avoid;
		break-after: avoid;
	}

	.smartg-note__intro,
	.smartg-note__status {
		display: none !important;
	}

	.smartg-note__print {
		display: block;
		margin: 0;
		font-size: 10pt;
		line-height: 1.4;
		color: #000;
	}

	/* ---------------------------------------------------------------------
	 * The running foot of a printed chapter
	 *
	 * This was `position: fixed` for three rounds and it was wrong for three
	 * rounds. The comment that used to sit here said so and called it a known
	 * open problem: fixed repeats on every page, which is why it was chosen,
	 * but fixed is out of flow, so the paginated content had no idea it was
	 * there and printed straight through the identity line.
	 *
	 * MEASURED, BEFORE AND AFTER, ON EVERY PAGE RATHER THAN THE FIRST AND LAST:
	 *
	 *                     1 page   2 pages   4 pages   8 pages
	 *   fixed, Chrome       0/1       0/2       1/4       3/8
	 *   fixed, Firefox      0/1       1/2       3/4       6/7
	 *   table foot, both    0/1       0/2       0/4       0/8
	 *
	 * (pages where body text printed over the foot, of the pages printed.)
	 *
	 * The old comment also said the chapter "needs the same treatment and
	 * cannot borrow it, because it renders inside the theme's own document".
	 * That turned out to be a statement about markup that did not exist yet
	 * rather than a limit: the theme owns the document, which does not stop the
	 * chapter owning a table inside it. templates/chapter.php now emits one,
	 * and it fragments correctly inside Divi's own ancestor chain — float,
	 * relative container and all — with chapter content that is itself mostly
	 * tables and term lists.
	 *
	 * IT MUST BE REAL TABLE ELEMENTS. See the note on the frame below; this is
	 * the single most important thing on this path.
	 * ------------------------------------------------------------------ */

	/*
	 * THE FRAME.
	 *
	 * <table> / <tbody> / <tfoot>, and the displays are declared here rather
	 * than left to the user agent so that a theme print stylesheet doing
	 * something wholesale to tables cannot quietly turn the foot into an
	 * ordinary block and put it on the last page only.
	 *
	 * DO NOT REWRITE THIS AS DIVS WITH display: table-footer-group.
	 *
	 * It is the obvious simplification — it looks like the same thing without
	 * the markup — and it is measurably worse than doing nothing at all. With
	 * divs the foot is not repeated: it appears on the LAST PAGE ONLY, so an
	 * eight page chapter prints seven pages with no identity line anywhere on
	 * them. Today's fixed box at least appears on every page, overlap and all.
	 * Only real table elements get the repeating treatment from an engine.
	 * This was measured in both engines before the markup was written this way,
	 * and the result is the reason the markup looks like that.
	 */
	.smartg-chapter-frame {
		display: table;
		width: 100%;
		border-collapse: collapse;
		margin: 0;
	}

	.smartg-chapter-frame__body {
		display: table-row-group;
	}

	.smartg-chapter-frame__foot {
		display: table-footer-group;
	}

	/*
	 * Direct children only. A chapter's own content is table-heavy — the
	 * importer writes real tables — and a descendant selector here would strip
	 * the borders and padding off every one of them.
	 */
	.smartg-chapter-frame > tbody > tr > td,
	.smartg-chapter-frame > tfoot > tr > td {
		padding: 0;
		border: 0;
		vertical-align: top;
	}

	/*
	 * The foot itself. No positioning of any kind: it is a cell in a repeated
	 * table foot, and that is the whole mechanism.
	 *
	 * The !important guards are the sheet's, for the sheet's reason: this is
	 * one of the places the reader's name appears on paper, and a theme print
	 * stylesheet that hides things wholesale should not be able to take it off.
	 */
	.smartg-running-foot {
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
		padding-top: 3pt;
		border-top: 0.25pt solid #000;
		font-size: 8pt;
		line-height: 1.3;
		color: #000;
		background: none;
		text-align: left;
	}

	.smartg-running-foot__disclaimer,
	.smartg-running-foot__identity {
		display: block !important;
		visibility: visible !important;
		margin: 0;
	}

	/*
	 * The screen's two copies, on the framed path only.
	 *
	 * A chapter renders the disclaimer and the identity line where it always
	 * did, so nothing about the screen changes; on paper the running foot
	 * carries both, once per page, and these two would be a second copy at the
	 * end of the last page.
	 *
	 * Scoped to --framed rather than to .smartg-reader-shell, because the hub
	 * and the locked screen use the same shell and have no frame to carry their
	 * foot. Those two now print their disclaimer in flow at the end — which is
	 * one appearance rather than one per page, and is the honest behaviour for
	 * a page with no reserved band, rather than a fixed box that can be printed
	 * over.
	 */
	.smartg-reader-shell--framed .smartg-disclaimer,
	.smartg-reader-shell--framed .smartg-watermark {
		display: none !important;
	}

	/*
	 * Everywhere else the two are ordinary flow content on paper. They were
	 * `position: fixed` here until the frame landed; nothing on the chapter
	 * path is positioned now except the diagonal marks below, and the guard in
	 * tests/print.php asserts exactly that.
	 */
	.smartg-reader-shell .smartg-disclaimer,
	.smartg-reader-shell .smartg-watermark {
		margin: 8pt 0 0;
		padding: 0;
		font-size: 8pt;
		line-height: 1.3;
		color: #000;
		text-align: left;
		background: none;
		border: 0;
	}

	/* ---------------------------------------------------------------------
	 * The diagonal marks on a printed chapter
	 *
	 * The treatment the comment above said this path needed and could not
	 * borrow. The box, the tiling and the rotation are the sheet's rules, added
	 * to by selector rather than copied; what is different is only what has to
	 * be, because a chapter renders inside the theme's document and the sheet
	 * renders inside its own.
	 *
	 * Two things make a z-index of -1 actually visible here, and both were the
	 * bug that hid two earlier versions of the sheet's marks.
	 *
	 * The shell has to establish a stacking context, so the marks are scoped
	 * inside it and paint after its white background rather than being covered
	 * by it. The sheet gets this free: its wrapper is the body, whose background
	 * paints as the canvas and never covers a descendant. A chapter has no body
	 * of its own, so the shell is made a stacking context here. position:
	 * relative with no offsets — it stays in flow, moves nothing, and cannot
	 * overlap anything.
	 *
	 * And the reading surface has to stop painting opaque white over them. On
	 * paper the page is already white, so dropping the fill costs nothing.
	 *
	 * THE SAME ENGINE SPLIT AS THE SHEET, FOR THE SAME REASON. Chromium paints
	 * a fixed box on every page and the marks appear throughout. Firefox paints
	 * it once against the document, so page one carries them and later pages do
	 * not; a mark showing on page four is page one bleeding through, not a
	 * second painting. This is settled — see the long note in the sheet section
	 * below and the class docblock on Printing\Watermark — and it does not need
	 * investigating again. Provenance does not rest on the diagonal: the
	 * identity line at the foot of the page is the record and is no part of
	 * this. Band mode said it was unavailable here because a band is a strip of
	 * a repeating table foot and a chapter had no table. The chapter has one
	 * now, so that obstacle is gone; the mode is still not offered, because a
	 * band costs 30mm of every page on top of the foot's own band and nobody
	 * has asked the chapter to pay twice.
	 *
	 * WHAT IS DELIBERATELY NOT DONE HERE. The sheet also lifts its article to
	 * z-index 1. Nothing on this path needs that: the shell above is the
	 * stacking context, so the marks at z-index -1 already paint behind the
	 * chapter body without the body being lifted at all.
	 *
	 * It was once necessary to say more here, because the running foot was
	 * position: fixed and lifting the content would have printed the chapter
	 * over the identity line. The foot is a repeating table foot now — in flow,
	 * accounted for by pagination, measured clean on 8 of 8 pages in both
	 * engines — so there is no overlap left to arbitrate. Leaving
	 * .smartg-content unpositioned is now simply one less positioned element on
	 * a path whose whole fix was taking things out of position.
	 * ------------------------------------------------------------------ */

	.smartg-reader-shell {
		position: relative;
		z-index: 0;
	}

	/* ---------------------------------------------------------------------
	 * The sheet
	 * ------------------------------------------------------------------ */

	.smartg-sheet-page {
		margin: 0;
		padding: 0;
		font-size: 11pt;
		line-height: 1.4;
		color: #000;
		background: #fff;
	}

	.smartg-sheet {
		max-width: none;
		margin: 0;
		padding: 0 0 26pt;
		border: 0;
		box-shadow: none;
		background: #fff;
		position: relative;
		z-index: 1;
	}

	/* ---------------------------------------------------------------------
	 * The diagonal identity marks
	 *
	 * Two modes; Printing\Watermark::mode() chooses and the class says which.
	 *
	 * OVERLAY, the default. position: fixed, tiled down the page, z-index -1
	 * inside the article. Chromium paints it on every page.
	 *
	 * FIREFOX PAINTS A FIXED ELEMENT ONCE AGAINST THE DOCUMENT RATHER THAN ONCE
	 * PER PAGE FRAGMENT. Page 1 carries the marks in full; anything appearing on
	 * a later page is page 1 bleeding through, not a second painting. Do not
	 * read a stray mark on page 5 as the mechanism half-working — there is no
	 * other half to find. No offset, inset, containing block or stacking context
	 * changes it, and it has been tried more than once. The specified fix is
	 * @page margin boxes, unimplemented in every browser. This is settled; it
	 * does not need investigating again.
	 *
	 * Overlay mode is therefore Chromium-complete and Firefox-partial by design.
	 * The degradation is accepted because provenance rests on the tfoot identity
	 * line, which repeats on every page in both engines and is no part of this.
	 *
	 * BAND. One mark in a 30mm strip of the running foot, in flow, identical in
	 * every engine because a repeated table section is laid out per fragment.
	 * Costs 30mm of every page, and the angle drops to 8 degrees because a
	 * 45-degree mark is as tall as it is wide.
	 *
	 * Neither uses a negative offset. @page margin boxes are what CSS actually
	 * specifies for a per-page overlay and no browser implements them; they are
	 * emitted above for Prince and Paged.js.
	 * ------------------------------------------------------------------ */

	.smartg-sheet__mark-tile,
	.smartg-chapter-watermark__mark {
		display: block !important;
		visibility: visible !important;
		white-space: nowrap;
		font-weight: 600;
		letter-spacing: 0.02em;
		color: var(--smartg-sheet-watermark-colour, #1f2933);
		opacity: var(--smartg-sheet-watermark-opacity, 0.2);
	}

	/* --- Overlay: tiled over the page, costing nothing ----------------- */

	/*
	 * z-index -1 against the article's 1. The article paints an opaque white
	 * background, so a box beside it at z-index 0 is painted over and invisible
	 * — that is what hid two earlier versions of this. A negative z-index
	 * inside the article's stacking context lands between that background and
	 * every word of the content: in front of the paper, behind the text.
	 *
	 * inset: 0 and nothing else. Every edge sits on the page area, so none of
	 * the box falls outside it and there is nothing for an engine to decide
	 * about the part that does — which is what a negative offset caused, and
	 * what smartg_negative_offsets() in tests/print.php still guards.
	 */
	.smartg-sheet__watermark--overlay,
	.smartg-chapter-watermark {
		position: fixed;
		inset: 0;
		z-index: -1;
		display: flex !important;
		visibility: visible !important;
		opacity: 1 !important;
		flex-direction: column;
		justify-content: space-around;
		align-items: center;
		overflow: hidden;
		pointer-events: none;
		user-select: none;
		-webkit-user-select: none;
	}

	/*
	 * rotate(-45deg) rises from lower left to upper right. CSS rotates
	 * clockwise for positive angles because the Y axis points down, so a
	 * negative angle turns anticlockwise: the text direction (1, 0) maps to
	 * (cos-45, sin-45) = (+0.707, -0.707) — x increasing, y decreasing, and y
	 * decreasing is upward.
	 *
	 * 45 degrees is affordable here in a way it is not in a band, because
	 * nothing reserves space for it. A 20pt line reaches 140mm across a 170mm
	 * page area.
	 */
	.smartg-sheet__watermark--overlay .smartg-sheet__mark-tile,
	.smartg-chapter-watermark .smartg-chapter-watermark__mark {
		transform: rotate(-45deg);
		font-size: 20pt;
	}

	/* --- Band: one mark, in flow, identical in every engine ------------ */

	.smartg-sheet-frame__mark td {
		padding: 0;
		border: 0;
	}

	.smartg-sheet__watermark--band {
		display: flex !important;
		visibility: visible !important;
		opacity: 1 !important;
		flex-direction: column;
		justify-content: space-around;
		align-items: center;
		height: 30mm;
		overflow: hidden;
		pointer-events: none;
		user-select: none;
		-webkit-user-select: none;
	}

	/*
	 * Shallow, because the band has to hold it: at 45 degrees a page-width mark
	 * would need a 112mm strip on every page.
	 */
	.smartg-sheet__watermark--band .smartg-sheet__mark-tile {
		transform: rotate(-8deg);
		font-size: 16pt;
	}

	/*
	 * Black, which is what the assumptions at the top of this file already
	 * promise and what the crossing contrast depends on. It was inheriting the
	 * screen stylesheet's muted grey into print, which put an explanation
	 * crossed by a mark at 4.35:1 — under AA. At #000 it is 14.2:1.
	 */
	.smartg-sheet__explanation {
		color: #000;
	}

	/*
	 * The controls are for choosing what to print. They are not part of it.
	 *
	 * Both of them. The letter form is a separate element rather than another
	 * row of the bar — it is a POST and the bar is a GET — so it needs naming
	 * here in its own right. Left out, the doctor's name and email would print
	 * in a pair of input boxes at the top of the sheet being handed over.
	 */
	.smartg-sheet__controls,
	.smartg-sheet__letter-form {
		display: none !important;
	}

	.smartg-sheet__header {
		border-bottom: 1pt solid #000;
		padding-bottom: 6pt;
		margin-bottom: 10pt;
		page-break-after: avoid;
		break-after: avoid;
	}

	.smartg-sheet__eyebrow {
		font-size: 9pt;
		margin: 0 0 2pt;
	}

	.smartg-sheet__title {
		font-size: 16pt;
		line-height: 1.2;
		margin: 0 0 4pt;
	}

	.smartg-sheet__meta {
		font-size: 10pt;
		margin: 0;
	}

	.smartg-sheet__meta .smartg-sheet__date::before {
		content: " · ";
	}

	/*
	 * The physician letter.
	 *
	 * Black on white with no fill, like everything else on this sheet: a tinted
	 * panel would arrive as an unexplained gap on a printer that drops
	 * backgrounds, and this is the part of the page a stranger reads first.
	 *
	 * IN FLOW, AND NOTHING HERE MAY CHANGE THAT. Being in flow is what puts the
	 * letter on page one and only page one without a rule saying so, and what
	 * keeps it clear of the strip the table foot reserves on every page. A fixed
	 * or absolute box is laid out against the page rather than against the
	 * content, which is how it would come to sit on top of the identity line —
	 * the defect the running foot was rebuilt as a table foot to avoid.
	 *
	 * break-inside: avoid so a five-paragraph letter moves to the next page
	 * whole rather than leaving its sign-off stranded on its own.
	 */
	.smartg-sheet__letter {
		color: #000;
		background: none;
		font-size: 10pt;
		line-height: 1.4;
		margin: 0 0 10pt;
		padding: 0 0 8pt;
		border-bottom: 0.5pt solid #000;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-sheet__letter-line {
		margin: 0 0 6pt;
		orphans: 2;
		widows: 2;
	}

	.smartg-sheet__letter-line:last-child {
		margin-bottom: 0;
	}

	.smartg-sheet__standfirst {
		font-size: 10pt;
		margin: 0 0 10pt;
		padding: 0 0 8pt;
		border-bottom: 0.5pt solid #000;
	}

	/*
	 * The ordering code. Quiet on screen, black on paper: the office reading it
	 * is reading a photocopy, and a grey five-character string is the first
	 * thing a photocopier loses.
	 */
	.smartg-sheet__code {
		color: #000;
		font-size: 9pt;
		font-variant-numeric: tabular-nums;
		white-space: nowrap;
	}

	.smartg-sheet__section {
		margin: 0 0 10pt;
	}

	.smartg-sheet__section-title {
		font-size: 11pt;
		margin: 0 0 4pt;
	}

	.smartg-sheet__items {
		list-style: none;
		margin: 0;
		padding: 0;
	}

	/*
	 * One line, one box to tick in the room. The box is a bordered element rather
	 * than a background or a font glyph, so it prints on a printer that drops
	 * fills and on one with no symbol font.
	 */
	.smartg-sheet__item {
		position: relative;
		padding: 3pt 0 3pt 18pt;
		border-bottom: 0.25pt solid #000;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-sheet__box {
		position: absolute;
		left: 0;
		top: 4.5pt;
		width: 9pt;
		height: 9pt;
		border: 0.75pt solid #000;
		background: none;
	}

	.smartg-sheet__label {
		display: block;
	}

	.smartg-sheet__explanation {
		display: block;
		font-size: 9.5pt;
		padding-top: 1pt;
	}

	.smartg-sheet__count {
		font-size: 9pt;
		margin: 0 0 10pt;
	}

	.smartg-sheet__entries {
		margin: 0 0 10pt;
	}

	.smartg-sheet__entry-label {
		font-weight: 600;
		padding: 4pt 0 0;
		border-top: 0.5pt solid #000;
		page-break-after: avoid;
		break-after: avoid;
	}

	.smartg-sheet__entries dt:first-of-type {
		border-top: 0;
	}

	.smartg-sheet__entry-value {
		margin: 0 0 4pt;
		padding: 0 0 0 1.5em;
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.smartg-sheet__entry-list {
		margin: 0;
		padding: 0 0 0 1em;
	}

	/* Roughly a third of the last page, in real ruled lines. */
	.smartg-sheet__notes {
		page-break-inside: avoid;
		break-inside: avoid;
		margin-top: 12pt;
	}

	.smartg-sheet__notes-title {
		font-size: 10pt;
		margin: 0 0 4pt;
	}

	/*
	 * Eight of these at 26pt is about 210pt of writing space, which is close to a
	 * third of the printable height of an A4 page inside 20mm margins.
	 */
	.smartg-sheet__rule {
		display: block;
		height: 26pt;
		border-bottom: 0.25pt solid #000;
	}

	.smartg-sheet__disclaimer {
		font-size: 8.5pt;
		margin: 10pt 0 0;
	}

	/* ---------------------------------------------------------------------
	 * The identity, twice
	 *
	 * The footer element repeats at the foot of every page. The mark inside the
	 * sheet is hidden on screen and revealed here, carrying the same line, so
	 * deleting one of the two still leaves the other on the paper.
	 *
	 * What this is, plainly: a deterrent and a provenance mark. Anyone with
	 * developer tools can delete both before printing. It makes casual forwarding
	 * feel like what it is, and makes a leaked sheet traceable to the account that
	 * printed it. It restricts nothing and it is not a protection mechanism.
	 * ------------------------------------------------------------------ */

	/*
	 * The frame is a real table in print, so its foot repeats on every page and
	 * — the part that matters — the engine reserves the foot's height on every
	 * fragment before laying a single row into it. Content overlapping the
	 * identity line stops being a thing that can happen rather than a thing
	 * kept at bay by a number that has to be maintained in three files.
	 *
	 * width: 100% because a table shrinks to its content otherwise, and this
	 * one is the page.
	 */
	.smartg-sheet-frame {
		display: table;
		width: 100%;
		border-collapse: collapse;
	}

	.smartg-sheet-frame__body {
		display: table-row-group;
	}

	.smartg-sheet-frame__foot {
		display: table-footer-group;
	}

	.smartg-sheet-frame td {
		padding: 0;
		border: 0;
		vertical-align: top;
	}

	/*
	 * No positioning of any kind. It is a cell in a repeated table foot, and
	 * that is the whole mechanism.
	 *
	 * The !important guards stay: this is one of the three places the reader's
	 * name appears, and a theme print stylesheet that hides things wholesale
	 * should not be able to take it off.
	 */
	.smartg-sheet__footer {
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
		font-size: 8pt;
		line-height: 1.3;
		color: #000;
		background: none;
		border-top: 0.25pt solid #000;
		padding-top: 2pt;
		margin-top: 8pt;
	}

	.smartg-sheet__identity,
	.smartg-sheet__footnote {
		display: block !important;
		visibility: visible !important;
		margin: 0;
	}

	.smartg-sheet__mark {
		display: block !important;
		visibility: visible !important;
		font-size: 8pt;
		color: #000;
		margin: 8pt 0 0;
	}
}
