/**
 * The PDF.
 *
 * Authority: `04-calculator-spec.md` §8 and §8.1.
 *
 * This IS the PDF generator. There is no library and no server: the browser
 * prints the result region, which produces selectable text, works offline, and
 * — the point — cannot transmit anything, because nothing is ever sent.
 *
 * §8.1 lists what the PDF must contain. Everything on that list is already in
 * the result region for §5.2's reasons, so printing it is sufficient; the work
 * here is removing the surrounding page and adding the labels the screen does
 * not need.
 */

@media print {

	/* Everything except the result is furniture. */
	body > *:not(.pem-calc-page),
	.pem-calc__form,
	.pem-calc__print,
	.pem-header,
	.pem-header__rule,
	footer,
	nav,
	.pem-cta-panel {
		display: none !important;
	}

	body,
	.pem-calc-page,
	.pem-calc,
	.pem-calc__output {
		display: block !important;
		margin: 0;
		padding: 0;
		background: #fff;
		color: #000;
	}

	.pem-calc__result {
		border: 0;
		padding: 0;
		display: block;
	}

	.pem-calc__result > * { margin-bottom: 10pt; }

	@page {
		margin: 16mm;
	}

	/* The inputs are gone with the form, so the PDF has to restate them. They
	   are written into data attributes by calculator.js at print time. */
	.pem-calc__output::before {
		content: "Pemspring — Estimating Card\A" attr(data-print-header);
		white-space: pre-wrap;
		display: block;
		font-size: 10pt;
		border-bottom: 1pt solid #000;
		padding-bottom: 6pt;
		margin-bottom: 10pt;
	}

	.pem-calc__output::after {
		content: attr(data-print-footer);
		white-space: pre-wrap;
		display: block;
		font-size: 8pt;
		border-top: 1pt solid #999;
		padding-top: 6pt;
		margin-top: 12pt;
	}

	/* A warning that appeared on screen must appear in the PDF — §4.2 is
	   explicit that the decade warning travels with the number, and the PDF is
	   what circulates. */
	.pem-calc__warning {
		border: 1pt solid #000 !important;
		background: none !important;
		color: #000 !important;
		font-weight: 700;
	}

	.pem-calc__notice,
	.pem-calc__conversion {
		background: none !important;
		border: 0 !important;
		border-left: 2pt solid #999 !important;
		padding-left: 6pt !important;
	}

	.pem-calc__p50 { font-size: 22pt; }

	.pem-calc__params { page-break-inside: avoid; }
	.pem-calc__params :is(th, td) { border-bottom: 0.5pt solid #999; }

	.pem-calc__disclaimer {
		border: 1pt solid #000;
		padding: 6pt;
		font-weight: 700;
		page-break-inside: avoid;
	}

	.pem-tag {
		border: 0.5pt solid #000 !important;
		background: none !important;
		color: #000 !important;
	}

	/* The display controls are inputs and the print sheet hides the form, so
	   the unit system and currency travel in the print furniture instead. */
	.pem-calc__display { display: none !important; }

	/* The cost-basis label is required IN the PDF, verbatim - the artefact
	   that circulates is read by someone who never saw the screen. */
	.pem-calc__cost-basis {
		border: 1pt solid #000;
		border-left-width: 3pt;
		background: none;
		padding: 6pt;
		font-size: 9pt;
		page-break-inside: avoid;
	}

	a[href]::after { content: " (" attr(href) ")"; font-size: 8pt; }
}
