/**
 * Blocklane — print styles.
 *
 * Loaded with media="print", so the browser only parses and applies these
 * rules when the user prints. Goal: readable, ink-efficient output of page
 * content with context preserved (link URLs, breadcrumbs, headings).
 *
 * @package blocklane
 * @since   0.1.0
 */

@media print {

	/* -------------------------------------------------------------------------
	 * Page setup.
	 * -----------------------------------------------------------------------*/
	@page {
		margin: 0.75in;
	}

	/* -------------------------------------------------------------------------
	 * Baseline: drop every screen background / shadow / gradient to save ink
	 * and normalize everything to black-on-white. Georgia serif for long-form reading (0.7.0: web fonts are optional presets, so print no longer assumes them)
	 * on paper; core blocks keep their structural type choices (headings,
	 * code).
	 * -----------------------------------------------------------------------*/
	html,
	body {
		background: #fff !important;
		color: #000 !important;
	}

	body {
		font-family: Georgia, "Times New Roman", serif;
		font-size: 11pt;
		line-height: 1.5;
	}

	*,
	*::before,
	*::after {
		background: transparent !important;
		box-shadow: none !important;
		text-shadow: none !important;
		color: #000 !important;
	}

	/* Preserve the monospace stack for code — just ink it black. */
	code,
	kbd,
	pre,
	samp,
	.wp-block-code,
	.wp-block-preformatted {
		font-family: ui-monospace, Menlo, Consolas, monospace;
		border: 1pt solid #999;
		padding: 0.25em 0.5em;
	}

	/* -------------------------------------------------------------------------
	 * Hide non-content chrome. User interactions have no meaning on paper.
	 * Kept: breadcrumbs, post titles, bylines, featured media, body copy.
	 * -----------------------------------------------------------------------*/
	.wp-block-navigation,
	.wp-block-search,
	.wp-block-social-links,
	.wp-block-post-comments-form,
	.wp-block-comments-pagination,
	.wp-block-query-pagination,
	.wp-block-post-navigation-link,
	.wp-block-read-more,
	.wp-block-login-out,
	.skip-link,
	.screen-reader-text,
	[aria-hidden="true"],
	button,
	input[type="button"],
	input[type="submit"],
	input[type="reset"],
	form {
		display: none !important;
	}

	/* -------------------------------------------------------------------------
	 * Links: keep them readable, and append the URL for external links so the
	 * printed copy preserves context. Internal, mail, and tel links stay
	 * clean because appended hrefs would be noise or duplicate info.
	 * -----------------------------------------------------------------------*/
	a,
	a:visited {
		text-decoration: underline;
	}

	a[href^="http"]::after,
	a[href^="https"]::after {
		content: " (" attr(href) ")";
		font-size: 90%;
		font-family: ui-monospace, Menlo, Consolas, monospace;
		word-break: break-all;
	}

	/* Suppress URL expansion on navigational and structural contexts where the
	 * appended href would be noise (post titles, breadcrumbs, site identity,
	 * post meta). Prose links in paragraphs, lists, and quotes keep it. */
	:where(h1, h2, h3, h4, h5, h6) a::after,
	.wp-block-site-title a::after,
	.wp-block-site-logo a::after,
	.wp-block-post-title a::after,
	.wp-block-navigation a::after,
	.wp-block-post-author a::after,
	.wp-block-post-author-name a::after,
	.wp-block-post-date a::after,
	.wp-block-post-terms a::after,
	.wp-block-categories a::after,
	.wp-block-tag-cloud a::after,
	.wp-block-latest-posts a::after,
	.blocklane-breadcrumbs a::after {
		content: none;
	}

	/* -------------------------------------------------------------------------
	 * Typography: absolute pt sizes so printer drivers don't rescale oddly,
	 * and a heading rhythm that reads well on A4/Letter.
	 * -----------------------------------------------------------------------*/
	h1 { font-size: 22pt; line-height: 1.2; }
	h2 { font-size: 18pt; line-height: 1.25; }
	h3 { font-size: 14pt; line-height: 1.3; }
	h4 { font-size: 12pt; line-height: 1.35; }
	h5,
	h6 { font-size: 11pt; line-height: 1.4; }

	p,
	li,
	blockquote,
	dl {
		orphans: 3;
		widows: 3;
	}

	/* -------------------------------------------------------------------------
	 * Page-break discipline: never split figures, tables, or pull-quotes
	 * mid-element; never leave a heading orphaned at the bottom of a page.
	 * -----------------------------------------------------------------------*/
	h1, h2, h3, h4, h5, h6 {
		break-after: avoid;
		page-break-after: avoid;
	}

	figure,
	.wp-block-image,
	.wp-block-table,
	.wp-block-pullquote,
	.wp-block-quote,
	.wp-block-code,
	.wp-block-preformatted {
		break-inside: avoid;
		page-break-inside: avoid;
	}

	/* -------------------------------------------------------------------------
	 * Media: constrain to the printable width and force <details> open so
	 * nothing is hidden by virtue of being collapsed.
	 * -----------------------------------------------------------------------*/
	img,
	.wp-block-image img,
	.wp-block-cover,
	video,
	iframe {
		max-width: 100% !important;
		height: auto !important;
	}

	/* Drop cover-block overlay chrome — keep the text, ditch the tint. */
	.wp-block-cover__background,
	.wp-block-cover__image-background {
		display: none !important;
	}

	.wp-block-cover,
	.wp-block-cover.has-background-dim {
		min-height: 0 !important;
		padding: 0 !important;
	}

	details {
		display: block;
	}
	details > summary {
		display: none;
	}

	/* -------------------------------------------------------------------------
	 * Tables: give them structural borders so rows and columns survive the
	 * transition to paper.
	 * -----------------------------------------------------------------------*/
	.wp-block-table table,
	table {
		border-collapse: collapse;
		width: 100%;
	}

	.wp-block-table th,
	.wp-block-table td,
	th,
	td {
		border: 1pt solid #999;
		padding: 0.4em 0.6em;
	}

	thead {
		display: table-header-group;
	}

	tr,
	img {
		break-inside: avoid;
		page-break-inside: avoid;
	}

	/* -------------------------------------------------------------------------
	 * Blockquote: remove the colored rail, keep the indent so the quote is
	 * still structurally distinct on paper.
	 * -----------------------------------------------------------------------*/
	blockquote,
	.wp-block-quote,
	.wp-block-pullquote {
		border: none !important;
		padding-inline-start: 1em;
		margin-inline-start: 0;
		font-style: italic;
	}
}
