/* ============================================================
   print.css — book-typography view for paper.
   Loaded only via <link media="print">.
   ============================================================ */

@page {
	size: A4;
	margin: 22mm 20mm 26mm;

	@bottom-center {
		content: 'Õiguskantsleri aastaülevaade 2025 / 2026  ·  ' counter(page);
		font-family: 'Fraunces', Georgia, serif;
		font-size: 8.5pt;
		font-style: italic;
		color: #666;
	}
}

@page :first {
	margin: 30mm 20mm 30mm;
	@bottom-center { content: ''; }
}

/* Reset to plain paper, no theme tints */
:root,
:root[data-theme='dark'] {
	--paper: #ffffff;
	--ink: #000000;
	--ink-soft: #1a1a1a;
	--ink-muted: #555555;
	--rule: #cccccc;
	--blue: #000000;
	color-scheme: light !important;
}

html, body {
	background: #ffffff !important;
	background-image: none !important;
	color: #111 !important;
	font-family: 'Fraunces', Georgia, 'Times New Roman', serif !important;
	font-size: 11pt;
	line-height: 1.65;
	-webkit-print-color-adjust: economy;
	print-color-adjust: economy;
	font-variation-settings: 'opsz' 11;
	hyphens: none;
}

/* Kill all UI chrome */
aside,
.actions,
#navToggle,
#themeToggle,
#printBtn,
#pdfBtn,
#publicationPdfBtn,
.article-media-controls,
.article-audio-player,
form[role='search'],
nav[aria-label='Sisukord'],
body::before,
body::after,
.atmosphere {
	display: none !important;
}

/* Layout: single column, flow naturally */
body,
.shell {
	display: block !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	gap: 0 !important;
}

main {
	display: block !important;
	padding: 0 !important;
	min-height: auto !important;
	width: 100% !important;
	max-width: none !important;
	align-content: normal !important;
	grid-template-columns: none !important;
	isolation: auto !important;
}

main::before,
main::after {
	display: none !important;
	content: none !important;
}

article {
	display: block !important;
	width: 100% !important;
	max-width: none !important;
	padding: 0 !important;
	margin: 0 !important;
	isolation: auto !important;
	page-break-before: always;
	break-before: page;
}

/* First article doesn't break — it's the first thing printed */
body > main > article:first-child {
	page-break-before: avoid;
	break-before: avoid;
}

/* ---------- Typography hierarchy ---------- */

h1, h2, h3, h4 {
	font-family: 'Inter', Helvetica, Arial, sans-serif !important;
	color: #000 !important;
	font-weight: 700;
	letter-spacing: -0.01em;
	page-break-after: avoid;
	break-after: avoid;
	page-break-inside: avoid;
	break-inside: avoid;
}

article :is(h1, h2, h3, h4) strong {
	font-weight: inherit;
}

body[data-page='lihtne-keel'] article,
body[data-page='lihtne-keel'] article * {
	font-family: Arial, sans-serif !important;
}

body[data-page='lihtne-keel'] article > p:first-of-type::first-letter {
	font-size: inherit;
	line-height: inherit;
	float: none;
	padding: 0;
	font-weight: inherit;
	color: inherit;
}

/* Chapter title — top of new page, dramatic */
article > header {
	margin-bottom: 14mm;
	page-break-after: avoid;
	break-after: avoid;
}

article > header > p {
	font-family: 'Inter', Helvetica, sans-serif !important;
	font-size: 8.5pt;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: #777;
	margin: 0 0 6mm;
}

article > header > h1 {
	font-size: 32pt;
	line-height: 1.04;
	margin: 0;
	font-variation-settings: 'opsz' 144;
}

/* Section heading */
article > h2,
.prose h2 {
	font-size: 18pt;
	line-height: 1.2;
	margin: 14mm 0 4mm;
	font-variation-settings: 'opsz' 36;
	page-break-before: auto;
	break-before: auto;
}

/* First H2 in a chapter doesn't need a huge top gap (header already separates) */
article > header + h2,
article > header + p + h2,
article > h2:first-of-type {
	margin-top: 0;
}

/* Subsection */
article > h3,
.prose h3 {
	font-size: 13pt;
	line-height: 1.3;
	margin: 9mm 0 2.5mm;
	font-variation-settings: 'opsz' 18;
	font-style: italic;
	font-weight: 500;
}

article > h4 {
	font-size: 11pt;
	margin: 6mm 0 1.5mm;
	font-style: italic;
}

/* ---------- Body text ---------- */

article > p,
article p {
	margin: 0 !important;
	max-width: none !important;
	font-size: 11pt !important;
	line-height: 1.65 !important;
	text-align: justify;
	hyphens: none;
	word-break: normal;
	overflow-wrap: normal;
	orphans: 3;
	widows: 3;
	font-variation-settings: 'opsz' 11;
}

/* First paragraph after heading: no indent */
article > h1 + p,
article > h2 + p,
article > h3 + p,
article > h4 + p,
article > header + p,
.prose h1 + p,
.prose h2 + p,
.prose h3 + p {
	text-indent: 0;
	margin-top: 0 !important;
}

/* Subsequent paragraphs: classic indent, no extra spacing */
article > p + p,
.prose p + p {
	text-indent: 1.5em;
	margin-top: 0 !important;
}

/* Chapter-opener artwork plate */
article > figure.opener {
	margin: 0 0 8mm;
	page-break-inside: avoid;
	break-inside: avoid;
}
article > figure.opener > img {
	width: 100%;
	max-height: 90mm;
	object-fit: cover;
}
article > figure.opener > figcaption {
	margin-top: 2mm;
	font-family: 'Inter', Helvetica, Arial, sans-serif;
	font-size: 8.5pt;
	color: #555;
}

/* Lede paragraph gets a small drop cap (where browser supports) */
body:not([data-page='lihtne-keel']) article > p:first-of-type::first-letter {
	font-family: 'Inter', Helvetica, Arial, sans-serif;
	font-size: 3.2em;
	line-height: 0.85;
	float: left;
	padding: 0.05em 0.1em 0 0;
	font-weight: 700;
	color: #000;
}

/* ---------- Links ---------- */
a {
	color: inherit !important;
	text-decoration: underline;
	text-decoration-color: #888;
	text-underline-offset: 1.5pt;
	text-decoration-thickness: 0.4pt;
	hyphens: none;
	word-break: normal;
	overflow-wrap: normal;
}

/* Show external URL after link */
article a[href^='http']::after {
	content: ' ⟨' attr(href) '⟩';
	font-size: 8.5pt;
	font-style: italic;
	color: #777;
	word-break: break-all;
	text-decoration: none;
}

/* Don't expand internal/app links */
article a[href^='#']::after,
article a[href^='index.php']::after,
article a[href^='/']::after,
article a[href^='?']::after {
	content: '' !important;
}

/* ---------- Lists ---------- */
article ul,
article ol {
	margin: 4mm 0 4mm 8mm;
	padding-left: 4mm;
}
article li {
	margin-bottom: 1.5mm;
	page-break-inside: avoid;
	break-inside: avoid;
}

/* ---------- Blockquotes ---------- */
article blockquote {
	margin: 5mm 8mm;
	font-style: italic;
	color: #222;
	border-left: 0.6pt solid #999;
	padding-left: 4mm;
}

/* ---------- Search results — strip highlights ---------- */
mark {
	background: transparent !important;
	color: inherit !important;
	font-weight: 600;
	padding: 0;
}

/* ---------- Tables ---------- */
article table {
	border-collapse: collapse;
	width: 100%;
	margin: 4mm 0;
	page-break-inside: avoid;
}
article th,
article td {
	border-bottom: 0.4pt solid #999;
	padding: 1.5mm 2.5mm;
	text-align: left;
	font-size: 10pt;
	vertical-align: top;
	line-height: 1.4;
}
article th {
	font-weight: 600;
	border-bottom: 0.8pt solid #333;
}

/* ---------- Images ---------- */
article img {
	max-width: 100%;
	page-break-inside: avoid;
	break-inside: avoid;
	margin: 4mm 0;
}

article figure {
	margin: 6mm 0;
	page-break-inside: avoid;
}
article figcaption {
	font-size: 9pt;
	font-style: italic;
	color: #555;
	margin-top: 1.5mm;
	text-align: center;
}

/* ---------- CSV-backed charts ---------- */
article > figure.article-chart {
	margin: 7mm 0;
	padding: 4mm;
	border: 0.4pt solid #aaa;
	box-shadow: none;
	page-break-inside: avoid;
	break-inside: avoid;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}
article > figure.article-chart > figcaption {
	margin: 0 0 3mm;
	font-family: 'Inter', Helvetica, Arial, sans-serif;
	font-size: 10pt;
	font-style: normal;
	font-weight: 700;
	color: #000;
	text-align: left;
}
.article-chart .chart-canvas-wrap {
	position: relative;
	width: 100%;
	height: 110mm;
}
.article-chart .chart-data {
	display: none;
}

/* ---------- Cover page ---------- */
body[data-page='cover'] {
	& article {
		page-break-after: always;
		break-after: page;
		page-break-before: avoid;
		break-before: avoid;
		padding: 0 !important;
	}

	& article > figure {
		display: none !important;
	}

	& article > h1 {
		font-size: 38pt;
		line-height: 1.02;
		margin: 60mm 0 12mm;
		font-variation-settings: 'opsz' 144;
		text-align: left;
	}

	& article > p {
		font-size: 12pt !important;
		font-style: italic;
		color: #333;
		max-width: 100mm !important;
		margin-bottom: 16mm !important;
	}

	& article .mark {
		width: 55mm !important;
		aspect-ratio: 149 / 57;
		margin: 8mm 0 0;
		display: block;
		background: #000 !important;
		mask: var(--mark) no-repeat center / contain;
		-webkit-mask: var(--mark) no-repeat center / contain;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}
}

/* ---------- Search results page ---------- */
article[data-search] {
	& > header > h1 {
		font-size: 22pt;
		margin-bottom: 4mm;
	}
	& > section {
		page-break-inside: avoid;
		break-inside: avoid;
		margin: 6mm 0;
		padding-top: 3mm;
		border-top: 0.4pt solid #ccc;
	}
	& > section > h2 {
		font-size: 13pt;
		margin: 0 0 2mm;
	}
	& > section > p {
		font-size: 10pt !important;
		line-height: 1.5 !important;
		text-indent: 0 !important;
		margin: 0 0 2mm !important;
	}
}

/* Avoid breaking the first few lines of a paragraph onto a new page alone */
article > p,
article > h2 + p,
article > h3 + p {
	orphans: 3;
	widows: 3;
}
