/*  ForgeBoard — Print stylesheet (improved)
    --------------------------------------------------------------
    Optimised for paper:
    - Hide all UI chrome (nav, dropdowns, toolbars, theme toggle)
    - Force black-on-white for max readability + ink savings
    - Smart page-break rules so posts don't get split mid-quote
    - Show URL after external links (skips internal anchors)
    - Page number in the bottom margin via @page
    - Print-only header showing site name + URL + print date
    GPL-2.0 (c) 2026 FanFanLaTuFlippe
    -------------------------------------------------------------- */

/* ---------- Page setup ---------- */
@page {
	margin: 1.8cm 1.5cm 2.2cm;
	size: A4;
}

/* ---------- Print-only metadata header (injected via CSS content) ---------- */
@media print {
	body::before {
		content: "Source: " attr(data-print-url, " ") "  •  Printed from " attr(data-print-site, " ");
		display: block;
		border-bottom: 1pt solid #999;
		color: #555;
		font-family: Georgia, "Times New Roman", serif;
		font-size: 9pt;
		font-style: italic;
		margin-bottom: 1em;
		padding-bottom: 0.4em;
	}

	/* ---------- Reset chrome ---------- */
	html, body {
		background: #fff !important;
		color: #000 !important;
		font-family: Georgia, "Times New Roman", serif;
		font-size: 11pt;
		line-height: 1.5;
	}

	/* Hide everything that's not core content */
	.forge-topbar,
	#page-header,
	.forge-nav-card,
	.forge-nav-wrap,
	.forge-toolbar,
	.forge-bottom-row,
	.forge-jumpbox,
	.forge-jumpbox-inline,
	.forge-jumpbox-return,
	.forge-topic-bottom-bar,
	.forge-topic-review-toggle,
	.forge-topic-review-bar .right-box,
	.action-bar,
	.skiplink,
	.responsive-menu,
	.dropdown-trigger,
	.dropdown,
	.dropdown-extended,
	.notification_list,
	.forge-theme-toggle,
	.forge-nav-theme-toggle,
	.forge-mini-pagination,
	.forge-search,
	.forge-inline-search,
	.search-box,
	.forge-forum-hero-actions,
	.forge-hero-action,
	.forge-mark-read,
	.forge-hero-mark-read,
	#nav-footer,
	.forge-footer-nav,
	.forge-footer-meta,
	.copyright,
	#page-footer,
	.post-buttons,
	.forge-mcp-post-actions,
	.back2top,
	.forge-lastpost-jump,
	.forge-first-unread,
	.signature,
	.darkenwrapper,
	.phpbb_alert,
	#phpbb_confirm,
	.cp-menu,
	.cookie-notice,
	.cookie-notice-container {
		display: none !important;
	}

	/* ---------- Layout reset ---------- */
	.wrap, .forge-shell, #wrap, .forge-main, #page-body {
		background: #fff !important;
		border: 0 !important;
		box-shadow: none !important;
		margin: 0 !important;
		max-width: 100% !important;
		padding: 0 !important;
		width: 100% !important;
	}

	/* ---------- Hero blocks ---------- */
	.forge-hero, .forge-forum-hero, .forge-topic-hero {
		background: #fff !important;
		border: 0 !important;
		box-shadow: none !important;
		display: block !important;
		padding: 0 !important;
		page-break-after: avoid;
	}

	.forge-hero h1,
	.forge-forum-hero h1,
	.forge-topic-hero h1 {
		font-size: 18pt;
		margin: 0 0 0.5em;
		page-break-after: avoid;
	}

	.forge-kicker {
		color: #555 !important;
		font-size: 9pt;
		letter-spacing: 0.05em;
		margin: 0 0 0.2em;
		text-transform: uppercase;
	}

	.forge-topic-hero-meta {
		color: #444 !important;
		font-size: 10pt;
		margin: 0 0 1em;
	}

	.forge-topic-hero-meta a { color: #000 !important; text-decoration: none; }

	/* ---------- Headings ---------- */
	h1, h2, h3, h4 {
		color: #000 !important;
		page-break-after: avoid;
	}
	h1 { font-size: 18pt; margin: 0 0 0.5em; }
	h2 { font-size: 16pt; margin: 0.8em 0 0.4em; }
	h3 { font-size: 13pt; margin: 0.6em 0 0.3em; }
	h4 { font-size: 11pt; margin: 0.4em 0 0.2em; }

	p, ul, ol, dl { orphans: 3; widows: 3; }

	/* ---------- Posts ---------- */
	.post,
	.forge-mcp-post {
		background: #fff !important;
		border: 0 !important;
		border-top: 1pt solid #999 !important;
		box-shadow: none !important;
		margin: 1em 0 0 !important;
		padding: 0.6em 0 !important;
		page-break-inside: avoid;
	}

	.post .inner,
	.forge-mcp-post .inner {
		background: transparent !important;
		display: block !important;
		grid-template-columns: none !important;
		padding: 0 !important;
	}

	.postbody,
	.forge-mcp-postbody {
		float: none !important;
		width: 100% !important;
	}

	/* Compact author line — show name and date inline */
	.postprofile {
		background: transparent !important;
		border: 0 !important;
		float: none !important;
		font-size: 10pt;
		margin: 0 0 0.5em !important;
		padding: 0 !important;
		width: 100% !important;
	}

	.postprofile dl, .postprofile dd { display: inline; margin: 0 0.3em 0 0; }
	.postprofile .avatar-container, .avatar { display: none !important; }
	.postprofile .username, .postprofile strong { font-weight: bold; }

	.post .author,
	.forge-mcp-post-author {
		color: #444 !important;
		font-size: 10pt;
		font-style: italic;
		margin: 0 0 0.5em !important;
	}

	.content {
		color: #000 !important;
		font-size: 11pt;
	}

	/* Avoid breaking right after a heading */
	.post h3, .post .author { page-break-after: avoid; }

	/* ---------- Quote blocks ---------- */
	blockquote {
		background: transparent !important;
		border: 0 !important;
		border-left: 3pt solid #888 !important;
		color: #333 !important;
		margin: 0.5em 0 !important;
		padding: 0.2em 0 0.2em 0.8em !important;
		page-break-inside: avoid;
	}

	blockquote cite {
		color: #555 !important;
		font-style: normal;
		font-weight: bold;
	}

	blockquote blockquote {
		border-left-color: #bbb !important;
	}

	/* ---------- Code blocks ---------- */
	.codebox {
		background: #f6f6f6 !important;
		border: 1pt solid #ccc !important;
		page-break-inside: avoid;
	}

	.codebox p {
		background: #eee !important;
		color: #333 !important;
		font-family: Georgia, serif;
		font-size: 9pt;
		font-weight: bold;
		padding: 0.2em 0.5em !important;
	}

	.codebox code,
	.codebox pre {
		background: transparent !important;
		color: #000 !important;
		font-family: "Courier New", Consolas, monospace;
		font-size: 9pt;
		padding: 0.5em !important;
		white-space: pre-wrap !important;
		word-break: break-word;
	}

	/* Inline code */
	code:not(.codebox code) {
		background: #f0f0f0 !important;
		color: #000 !important;
		font-family: "Courier New", Consolas, monospace;
		font-size: 0.92em;
		padding: 1pt 3pt;
	}

	/* ---------- Links ---------- */
	a, a:link, a:visited {
		color: #000 !important;
		text-decoration: underline;
	}

	/* Show URL after external links — skip internal anchors and javascript */
	a[href^="http"]:not(.no-print-url):after,
	a[href^="//"]:not(.no-print-url):after {
		content: " (" attr(href) ")";
		color: #555 !important;
		font-size: 9pt;
		font-style: italic;
		font-weight: normal;
		word-break: break-all;
	}

	/* Don't expand internal phpBB links (./viewtopic.php, etc.) */
	a[href^="./"]:after,
	a[href^="../"]:after,
	a[href^="#"]:after,
	a[href^="javascript:"]:after,
	a.lastsubject:after,
	a.topictitle:after,
	a.username:after,
	a.username-coloured:after,
	.postprofile a:after,
	.forge-topic-hero-meta a:after {
		content: "" !important;
	}

	/* ---------- Topic / forum titles list ---------- */
	.forabg, .forumbg, .panel,
	.forge-category, .forge-topic-card, .forge-forum-card {
		background: #fff !important;
		border: 0 !important;
		box-shadow: none !important;
		padding: 0 !important;
	}

	.forge-category-head { padding: 0; }
	.forge-category-head h2 { margin: 1em 0 0.3em; }

	/* ---------- Tables (UCP, MCP, etc.) ---------- */
	table { border-collapse: collapse; width: 100%; }
	th, td {
		border: 0.5pt solid #ccc;
		padding: 0.3em 0.5em;
		font-size: 10pt;
		text-align: left;
	}
	th { background: #f0f0f0 !important; font-weight: bold; }

	/* ---------- Pagination ---------- */
	.pagination {
		color: #555 !important;
		font-size: 9pt;
		margin: 0.5em 0;
	}
	.pagination .arrow,
	.pagination ul { display: none !important; }

	/* ---------- Attachments ---------- */
	.attachbox {
		background: #f9f9f9 !important;
		border: 1pt solid #ccc !important;
		margin: 0.5em 0;
		padding: 0.4em !important;
	}

	.attachbox dt { font-weight: bold; }

	/* Hide image attachments thumbnails to save ink, keep filenames */
	.attachbox img { display: none !important; }

	/* ---------- Forms hidden — printing a form is meaningless ---------- */
	form .panel:has(textarea),
	#postingbox,
	#postform,
	.posting-buttons,
	.smiley-box,
	#format-buttons,
	#colour_palette,
	#bbpalette {
		display: none !important;
	}

	/* ---------- Misc cleanup ---------- */
	.hidden-print { display: none !important; }

	/* Standalone elements that print authors should call out */
	.notice {
		border: 1pt solid #999 !important;
		font-style: italic;
		padding: 0.4em !important;
	}

	/* Ensure images don't overflow the page */
	img {
		max-width: 100% !important;
		height: auto !important;
		page-break-inside: avoid;
	}

	/* Avoid breaking inside small elements */
	.attachbox, .codebox, blockquote { page-break-inside: avoid; }
}
