/**
 * Paged print view with Paged.js (see print-pagedjs.php)
 *
 * The theme's print rules are copied in before this file (pagedjs-init.js), so
 * this only holds what differs in the paged view: the page box with a header
 * and footer on every page, and the on-screen preview of the pages.
 */

@page {
	size: A4;
	margin: 30mm 20mm 40mm;

	/* Header and footer sit 8 mm from the text, away from the paper edge */
	@top-left {
		content: element(pageHeader);
		vertical-align: bottom;
		padding-bottom: 8mm;
		width: 120mm;
	}

	/* Flag with "Co-funded by" and the funding statement below it on three lines
	   (needs at least 137 mm), leaving room for the page number */
	@bottom-left {
		content: element(pageFooter);
		vertical-align: top;
		padding-top: 8mm;
		width: 155mm;
	}

	/* Line height = height of the EU flag (12 mm wide, 3:2), so the number sits
	   on the flag's center line */
	@bottom-right {
		content: counter(page) " / " counter(pages);
		vertical-align: top;
		padding-top: 8mm;
		color: #000;
		font-family: "Source Sans 3", sans-serif;
		font-size: 8pt;
		line-height: 8mm;
	}
}

/* Header and footer are repeated on every page by Paged.js instead of being
   fixed, as in the normal print (body::before and body::after) */
.ohamr-pagedjs-header {
	position: running(pageHeader);
}

.ohamr-pagedjs-footer {
	position: running(pageFooter);
}

/* The copies in the page margins. Paged.js does not keep the other declarations
   of the running rules above, so the layout is set here.

   Header: logo with the description beside it, as in the site header at mobile
   width (header.scss: logo rem-calc(113px), description rem-calc(9px), max
   rem-calc(129px), line before it). In rem, so it follows the root size.

   Text in the header and footer is pure black, not the site's grey or dark
   blue: many printers render grey as a raster, which makes small text blurry. */
.pagedjs_margin .ohamr-pagedjs-header {
	display: flex !important;
	align-items: center;
	gap: 1rem;
}

.pagedjs_margin .ohamr-pagedjs-header img {
	display: block;
	flex-shrink: 0;
	width: 7.0625rem;
	height: auto;
}

.pagedjs_margin .ohamr-pagedjs-header__description {
	position: relative;
	max-width: 8.0625rem;
	color: #000;
	font-family: "Source Sans 3", sans-serif;
	font-size: 0.5625rem;
	line-height: 1.4;
}

.pagedjs_margin .ohamr-pagedjs-header__description::before {
	content: "";
	position: absolute;
	top: 3px;
	bottom: 3px;
	left: -0.5rem;
	border-left: 1px solid #000;
}

/* Footer: the flag with "Co-funded by the European Union" on the same line as the
   page number, and the funding statement below */
.pagedjs_margin .ohamr-pagedjs-footer {
	display: flex !important;
	flex-direction: column;
	gap: 3mm;
	color: #000;
	font-family: "Source Sans 3", sans-serif;
	font-size: 2.8mm;
	font-weight: 300;
	line-height: 3.3mm;
}

.pagedjs_margin .ohamr-pagedjs-footer__cofunded {
	display: flex;
	align-items: center;
	gap: 2mm;
	white-space: nowrap;
}

.pagedjs_margin .ohamr-pagedjs-footer__cofunded img {
	flex-shrink: 0;
	width: 12mm;
	height: auto;
}

.pagedjs_margin .ohamr-pagedjs-footer__statement {
	margin: 0;
}

/* White pages also when printing; otherwise the theme's light grey body
   background shows through */
.pagedjs_page {
	background-color: #fff;
}

/* About 90 % of the normal print. There the browser shrinks the whole page to
   fit the paper; Paged.js lays out at full size in the page area. Overrides the
   copied rules from base/print.scss (root 80 %, column 500 px + 150 px). The
   header logo is sized in rem, so it follows the root size like the text. */
html {
	font-size: 72%;
}

.ohamr-table-of-contents,
.ohamr-long-page__content,
.ohamr-pagedjs-title {
	width: 450px;
	margin-left: 135px;
}

/* Title and excerpt, moved above the table of contents (pagedjs-init.js). The
   featured image stays in the content, where it would stand alone, so hide it. */
.ohamr-pagedjs-title .ohamr-single-call__title {
	margin-top: 16mm !important;
	font-weight: 700;
}

.entry-content > .ohamr-single-report__content--image {
	display: none;
}

/* Title page: title, excerpt and table of contents on page 1, the content
   always starts on page 2 */
.ohamr-long-page__toc--mobile {
	break-after: page;
}

/* Page numbers in the table of contents, right aligned. target-counter() is
   resolved by Paged.js from the link's #id to the page of that heading. */
.ohamr-long-page__toc--mobile .ohamr-table-of-contents__link {
	display: flex;
	justify-content: space-between;
	gap: 4mm;
	width: 100%;
}

.ohamr-long-page__toc--mobile .ohamr-table-of-contents__link::after {
	content: target-counter(attr(href), page);
	flex-shrink: 0;
}

/* The added country section: white instead of grey. Its fact boxes are white
   on the grey section on screen, so give them the same grey as elsewhere. */
.ohamr-country-content {
	background-color: #fff;
}

.ohamr-country-content .ohamr-fact-box {
	background-color: #eee;
}

/* The colored band with the section name at the top of the first page */
.ohamr-subheader {
	display: none !important;
}

/* Replaced by the header and footer above */
body::before,
body::after {
	display: none !important;
}

/* WordPress admin bar when logged in */
#wpadminbar {
	display: none !important;
}

html {
	margin-top: 0 !important;
}
