/**
 * EMF OSCE Stations — print.css
 *
 * Loaded with `media="print"` (see EMF_OSCE_Assets), so every rule in
 * this file applies only when the page is rendered for printing. The
 * outer `@media print` is therefore belt-and-braces.
 *
 * Per BUILD_SPEC §17:
 *   - Hide chrome that doesn't belong on paper (header, footer, nav,
 *     role toggle, timer, reveal gate, print-button row, filter form,
 *     paywall, comments, sidebar).
 *   - The print-on-load JS (§18.4) adds `.print-{role}` to the
 *     `.emf-station` wrapper, which we use to pick exactly one role's
 *     section set to print. `data-role` is the fallback when the JS
 *     hasn't run (rare — but means somebody opened the print dialog
 *     manually).
 *   - Page-break helpers on the mark scheme so domains aren't split
 *     awkwardly across pages.
 *
 * @package EMF_OSCE
 * @since   1.0.0
 */

@media print {

	/* ----------------------------------------------------------------------
	 * 1. Hide chrome.
	 *
	 * Theme header/footer + the plugin's own interactive controls. The
	 * `!important` is necessary because some themes set inline styles on
	 * the page chrome that would otherwise win the cascade.
	 * ---------------------------------------------------------------------- */

	body > header,
	body > footer,
	header.site-header,
	footer.site-footer,
	nav.main-navigation,
	nav.site-navigation,
	.site-header,
	.site-footer,
	.main-navigation,
	#wpadminbar,
	#comments,
	.comments-area,
	.sidebar,
	#sidebar,
	.widget-area,
	.emf-role-toggle,
	.emf-timer,
	.emf-timer-assertive,
	.emf-reveal-gate,
	.emf-print-buttons,
	.emf-paywall__cta-wrap,
	.emf-archive__filters,
	.emf-archive__pagination {
		display: none !important;
	}

	/* ----------------------------------------------------------------------
	 * 2. Role-specific printing.
	 *
	 * `.print-{role}` is set on `.emf-station` by station.js when a URL
	 * carries `?role={role}&print=1` — that's the auto-print flow from
	 * the in-template print buttons. Without it we fall back to
	 * `data-role` so a manual Cmd-P from the screen still prints
	 * something coherent.
	 * ---------------------------------------------------------------------- */

	.emf-station.print-candidate .emf-section.emf-show-candidate,
	.emf-station.print-actor     .emf-section.emf-show-actor,
	.emf-station.print-examiner  .emf-section.emf-show-examiner,
	.emf-station[data-role="candidate"]:not(.print-actor):not(.print-examiner) .emf-section.emf-show-candidate,
	.emf-station[data-role="actor"]:not(.print-candidate):not(.print-examiner) .emf-section.emf-show-actor,
	.emf-station[data-role="examiner"]:not(.print-candidate):not(.print-actor) .emf-section.emf-show-examiner {
		display: block !important;
	}

	.emf-station.print-candidate .emf-section:not(.emf-show-candidate),
	.emf-station.print-actor     .emf-section:not(.emf-show-actor),
	.emf-station.print-examiner  .emf-section:not(.emf-show-examiner) {
		display: none !important;
	}

	/* For the candidate print view, the reveal-gated sections (tasks +
	 * progression, mark scheme, pearls, examiner notes, pitfalls) must
	 * NOT be hidden — printing implies the candidate is past the attempt
	 * and wants the full sheet on paper. */
	.emf-station.print-candidate .emf-reveal-gated {
		display: block !important;
	}

	/* ----------------------------------------------------------------------
	 * 3. Page-break helpers for the mark scheme.
	 *
	 * Prefer the modern `break-inside` property, with the legacy
	 * `page-break-*` alongside for older print engines. (§17)
	 * ---------------------------------------------------------------------- */

	.emf-mark-scheme__domain {
		page-break-inside: avoid;
		break-inside: avoid;
	}

	.emf-mark-scheme__domain-name,
	.emf-mark-scheme h3 {
		page-break-after: avoid;
		break-after: avoid;
	}

	.emf-band,
	.emf-progression__row,
	.emf-mark-scheme li {
		page-break-inside: avoid;
		break-inside: avoid;
	}

	/* ----------------------------------------------------------------------
	 * 4. Print typography + colour.
	 *
	 * Force black ink on white paper for body copy; keep the brand
	 * purple for headings only. Saves toner and prints predictably on
	 * monochrome printers.
	 * ---------------------------------------------------------------------- */

	.emf-station {
		max-width: none;
		margin: 0;
		padding: 0;
		color: #000;
		background: #fff;
	}

	.emf-station-title,
	.emf-mark-scheme__domain-name,
	.emf-mark-scheme h2,
	.emf-mark-scheme h3 {
		color: #000;
	}

	/* Strip decorative chrome that doesn't read well on paper. */
	.emf-actor-opening {
		background: transparent !important;
		border-left: 2px solid #000 !important;
	}

	.emf-score-panel {
		background: transparent !important;
		border: 1px solid #000;
		position: static !important;   /* not sticky on paper */
		box-shadow: none !important;
	}

	/* Flatten the hard-shadow / heavy-border "exam paper" treatment for
	 * print — solid offset shadows waste toner and read poorly on paper. */
	.emf-candidate-instructions,
	.emf-actor-brief,
	.emf-how-to-tackle,
	.emf-mark-scheme,
	.emf-pearls,
	.emf-examiner-notes,
	.emf-pitfalls,
	.emf-qa-grid__chart,
	.emf-mark-scheme__domain,
	.emf-tasklist li {
		box-shadow: none !important;
		border: 1px solid #999 !important;
	}

	/* Keep the candidate-facing donut compact on paper. */
	.emf-qa-grid { grid-template-columns: 1fr 200px; }

	/* Page margins. */
	@page { margin: 1.5cm; }
}
