/* PDF Page Downloader — print stylesheet.
   Loaded with media="print" so it has zero effect on the normal screen view.
   Combined with pdf-download.js, which tags row/column wrappers with
   .nspdf-row/.nspdf-cols-N/.nspdf-col before calling window.print(). */

@page {
	size: A4;
	margin: 15mm 12mm;
}

@media print {

	/* ---------- Base ---------- */

	html, body {
		width: auto !important;
		height: auto !important;
		background: #fff !important;
		overflow: visible !important;
	}

	* {
		-webkit-print-color-adjust: exact !important;
		print-color-adjust: exact !important;
		color-adjust: exact !important;
	}

	/* Chrome/Firefox print margin-box headers/footers already carry the URL
	   and date; nothing extra needed here. */

	.nspdf-download-wrap,
	.nspdf-bg-tip {
		display: none !important;
	}

	/* ---------- Never clip content that would otherwise be lost ---------- */

	body, #page, #main-content, article, .entry-content,
	.et_pb_section, .et_pb_row, .et_pb_column, .et_pb_module {
		overflow: visible !important;
		max-height: none !important;
	}

	/* Divi accordion/toggle modules: expand every panel so collapsed
	   content isn't silently missing from the PDF. */
	.et_pb_toggle .et_pb_toggle_content,
	.et_pb_accordion .et_pb_toggle_content {
		display: block !important;
		max-height: none !important;
		height: auto !important;
		overflow: visible !important;
	}

	/* Divi tabs: show every tab's content stacked, since only one pane is
	   normally in the DOM as visible. */
	.et_pb_tabs .et_pb_all_tabs .et_pb_tab_content,
	.et_pb_tabs .et_pb_tab {
		display: block !important;
		height: auto !important;
	}
	.et_pb_tabs_controls {
		display: none !important;
	}

	/* Divi slider/carousel: print every slide, stacked, instead of only the
	   active one; hide the now-meaningless nav controls. */
	.et_pb_slider .et_pb_slide {
		display: block !important;
		position: static !important;
		opacity: 1 !important;
		transform: none !important;
	}
	.et-pb-slider-arrows,
	.et-pb-controllers,
	.et_pb_controllers {
		display: none !important;
	}

	/* Scroll/entrance animation libraries (Divi's own + AOS-style) often
	   leave elements at opacity:0 until a scroll event fires, which never
	   happens during print — force everything visible. */
	[data-animation],
	.et_pb_module[class*="et-animated"],
	.et-animated,
	.aos-init,
	[class*="et_pb_animation_"] {
		opacity: 1 !important;
		transform: none !important;
		visibility: visible !important;
	}

	/* Truncated headings/text (ellipsis, fixed line-clamp) should show in full. */
	h1, h2, h3, h4, h5, h6,
	p, li,
	.et_pb_blurb_title, .et_pb_blurb_description,
	.et_pb_module_content {
		overflow: visible !important;
		text-overflow: clip !important;
		white-space: normal !important;
		-webkit-line-clamp: unset !important;
		display: block;
	}

	/* ---------- Responsive column stacking ----------
	   pdf-download.js tags each detected multi-column row with .nspdf-row
	   and a .nspdf-cols-N modifier (N = number of direct column children).
	   Every detected row — 2 columns or more — stacks to a single full-width
	   column for print, like a narrow tablet/portrait breakpoint (A4 width
	   is close to a tablet's, and this is simpler and far more print-safe
	   than trying to keep multiple columns side by side on a narrow page:
	   no per-column width math, and no risk of the float/grid pagination
	   issues that come with keeping columns side by side). */

	.nspdf-row.nspdf-cols-2,
	.nspdf-row.nspdf-cols-3,
	.nspdf-row.nspdf-cols-4,
	.nspdf-row.nspdf-cols-5,
	.nspdf-row.nspdf-cols-6 {
		display: block !important;
	}
	.nspdf-row.nspdf-cols-2 > .nspdf-col,
	.nspdf-row.nspdf-cols-3 > .nspdf-col,
	.nspdf-row.nspdf-cols-4 > .nspdf-col,
	.nspdf-row.nspdf-cols-5 > .nspdf-col,
	.nspdf-row.nspdf-cols-6 > .nspdf-col {
		display: block !important;
		width: 100% !important;
		max-width: 100% !important;
		flex: none !important;
		float: none !important;
		margin: 0 0 6mm 0 !important;
	}
	.nspdf-row.nspdf-cols-2 > .nspdf-col:last-child,
	.nspdf-row.nspdf-cols-3 > .nspdf-col:last-child,
	.nspdf-row.nspdf-cols-4 > .nspdf-col:last-child,
	.nspdf-row.nspdf-cols-5 > .nspdf-col:last-child,
	.nspdf-row.nspdf-cols-6 > .nspdf-col:last-child {
		margin-bottom: 0 !important;
	}

	/* Old float:left/float:right column techniques (still common outside
	   Divi) rely on a clearfix-driven height on the row that no longer
	   makes sense once columns stack — release it so the row sizes from
	   its (now vertically stacked) content instead. */
	.nspdf-row-was-float {
		height: auto !important;
		min-height: 0 !important;
	}

	/* ---------- Page-break control ---------- */

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

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

	/* Atomic, self-contained modules should never split across a page. */
	img, svg, figure,
	.et_pb_image, .et_pb_blurb, .et_pb_testimonial, .et_pb_cta,
	.et_pb_pricing_table, .et_pb_button_module_wrapper, .et_pb_counters,
	.et_pb_circle_counter, .et_pb_number_counter, .et_pb_team_member,
	.nspdf-col {
		break-inside: avoid;
		page-break-inside: avoid;
	}

	/* A column taller than roughly one print page (flagged by JS, since
	   CSS alone can't measure rendered height) must be allowed to break —
	   forcing an oversized block to stay whole is what causes it to get
	   shoved onto its own mostly-blank page when it can't fit the
	   remaining space either. */
	.nspdf-col-tall {
		break-inside: auto !important;
		page-break-inside: auto !important;
	}

	table {
		break-inside: auto;
	}
	tr, td, th {
		break-inside: avoid;
		page-break-inside: avoid;
	}
	thead {
		display: table-header-group;
	}
	tfoot {
		display: table-row-group;
	}

	/* ---------- Document title (inserted by JS when enabled) ---------- */

	.nspdf-doc-title {
		display: block !important;
		font-size: 20pt;
		font-weight: 700;
		margin: 0 0 6mm 0;
		padding-bottom: 4mm;
		border-bottom: 1pt solid #999;
		break-after: avoid;
	}
}
