/* ==========================================================================
   POLICY, PRINTED OR SAVED AS PDF

   The web page is the controlled document. This stylesheet governs what a
   reader gets when they take a copy away, and its whole job is to make sure
   that copy admits what it is.

   Loaded with media="print", and only on a policy page.

   🔴 Nothing here may hide policy text. A printed copy that quietly drops a
   clause is worse than no printed copy at all. Everything removed below is
   site furniture: navigation, the site header and footer, the download button
   that produced this copy in the first place.
   ========================================================================== */

@media print {

	/* ---- page geometry ------------------------------------------------- */

	@page {
		size: A4 portrait;
		/* Room at the foot for the running line, which is fixed to it. */
		margin: 16mm 16mm 24mm;
	}

	html,
	body {
		background: #fff !important;
		color: #241c1f !important;
		font-size: 10.5pt;
		line-height: 1.45;
	}

	/* ---- site furniture, gone ------------------------------------------ */

	.wp-site-blocks > header,
	.wp-site-blocks > footer,
	.wp-block-template-part,
	.nwp-skip-link,
	.nwp-policy__download {
		display: none !important;
	}

	/*
	 * 🔴 `.nwp-envbanner` is NOT hidden, on purpose.
	 *
	 * It only exists outside production, and it says "STAGING environment,
	 * demonstrator content only, not the live NW Panthers website". A printed
	 * copy taken from staging that looked like the real policy is precisely
	 * the confusion this whole stamp exists to prevent, so the warning travels
	 * with it. On the live site the banner is not rendered at all and nothing
	 * here applies.
	 */
	.nwp-envbanner {
		border: 1pt solid #241c1f;
		padding: 2mm 3mm;
		margin-block-end: 5mm;
		font-family: "IBM Plex Mono", ui-monospace, monospace;
		font-size: 8pt;
		color: #241c1f !important;
		background: transparent !important;
		break-after: avoid;
	}

	main.nwp-policy {
		padding: 0 !important;
		max-inline-size: none !important;
	}

	/* ---- the parts that exist only on paper ---------------------------- */

	.nwp-print-only {
		display: block !important;
	}

	/*
	 * The stamp. First thing on the first page, before the title, because a
	 * reader has to know what they are holding before they read it.
	 */
	.nwp-print-stamp {
		border: 2pt solid #5b0b24;
		padding: 5mm 6mm;
		margin-block-end: 8mm;
		break-inside: avoid;
		break-after: avoid;
	}

	.nwp-print-stamp__flag {
		font-family: "Archivo Black", "Segoe UI", sans-serif;
		font-size: 15pt;
		line-height: 1.1;
		text-transform: uppercase;
		letter-spacing: 0.04em;
		color: #5b0b24;
		margin: 0 0 2mm;
	}

	.nwp-print-stamp__detail,
	.nwp-print-stamp__url {
		font-family: "IBM Plex Mono", ui-monospace, monospace;
		font-size: 8pt;
		line-height: 1.5;
		color: #241c1f;
		margin: 0;
	}

	.nwp-print-stamp__url {
		word-break: break-all;
		margin-block-start: 1mm;
	}

	/*
	 * 🔴 THE WATERMARK IS A TILED BACKGROUND ON THE PAGE ITSELF, not a
	 * positioned element.
	 *
	 * The obvious approach is `position: fixed`, which the CSS paged media
	 * spec says repeats on every sheet. Chromium does not do that: it paints a
	 * fixed element on the FIRST page only. Measured, not assumed — the first
	 * build of this stamped page 1 and left pages 2 and 3 bare, which is the
	 * worst outcome, because a bare page looks controlled.
	 *
	 * A repeating background on `html` does tile across every sheet, so a page
	 * separated from the rest still says what it is.
	 *
	 * Deliberately faint. It has to be unmistakable when you look for it and
	 * invisible while you read. A watermark dark enough to fight the text
	 * would make a safeguarding document harder to read, which is the
	 * opposite of the point.
	 */
	html {
		background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='260'%3E%3Ctext x='210' y='140' fill='%235b0b24' fill-opacity='0.07' font-family='Segoe UI,sans-serif' font-size='34' font-weight='700' letter-spacing='2' text-anchor='middle' transform='rotate(-30 210 130)'%3EUNCONTROLLED COPY%3C/text%3E%3C/svg%3E" ) !important;
		background-repeat: repeat !important;
		/* Without this the browser drops backgrounds when printing. */
		print-color-adjust: exact !important;
		-webkit-print-color-adjust: exact !important;
	}

	/* Body must not paint over the watermark behind it. */
	body {
		background: transparent !important;
	}

	/* The element version is redundant now the background carries it. */
	.nwp-print-watermark,
	.nwp-print-running {
		display: none !important;
	}

	/* ---- the document itself -------------------------------------------- */

	.nwp-policy h1 {
		font-size: 20pt;
		line-height: 1.15;
		margin: 0 0 4mm;
	}

	.nwp-policy h2 {
		font-size: 12pt;
		margin: 6mm 0 2mm;
		break-after: avoid;
	}

	.nwp-policy p,
	.nwp-policy li {
		orphans: 3;
		widows: 3;
	}

	.nwp-policy ul {
		padding-inline-start: 6mm;
	}

	/* Metadata and history are provenance. Keep them, keep them quiet. */
	.nwp-policy__meta {
		border: 0.5pt solid #d8d0cb;
		padding: 4mm;
		font-size: 8pt;
		break-inside: avoid;
	}

	.nwp-policy__history {
		break-inside: avoid;
		margin-block-start: 8mm;
	}

	.nwp-policy__history table {
		font-size: 7.5pt;
	}

	/*
	 * 🔴 The safeguarding contacts must survive onto paper intact and must not
	 * be split across a page break. Somebody may be holding this page because
	 * they are worried about a child.
	 */
	.nwp-policy__safeguarding {
		break-inside: avoid;
		border: 1pt solid #5b0b24;
		padding: 4mm 5mm;
		margin-block-start: 6mm;
	}

	/* A URL is useless on paper unless it is written out. */
	.nwp-policy a[ href ^= "http" ]::after {
		content: " (" attr( href ) ")";
		font-family: "IBM Plex Mono", ui-monospace, monospace;
		font-size: 7.5pt;
		word-break: break-all;
	}
}
