/* Plakat popup
   Markup: <dialog id="plakat-popup"> at the end of index.php. Behaviour: assets/js/plakat-popup.js.
   The poster leads. The interface offers one action (open the PDF) and one way out (close). */

.plakat-popup {
	--plakat-scrim: rgba(6, 20, 13, 0.96);		/* the site's green (--primary-color), pushed almost to black */
	--plakat-chip: rgba(6, 20, 13, 0.9);
	--plakat-paper: #ecebe3;					/* lighter take on the poster's warm grey ground */
	--plakat-ink: var(--primary-color, #0a3925);
	--plakat-ratio: 0.7071;						/* poster width / height (A4). Change it for a poster with another format. */
	--plakat-pad: clamp(0.75rem, 3vw, 2rem);

	/* Reset the browser's dialog box: the dialog is a full-screen scrim that holds the poster. */
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: auto;
	height: auto;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #fff;
	line-height: 1.4;
	overflow: auto;
	overscroll-behavior: contain;
	-webkit-tap-highlight-color: transparent;
}

.plakat-popup:not([open]) {
	display: none;
}

.plakat-popup::backdrop {
	background: transparent;
}

/* The animations are !important on purpose: the template switches every animation off (body.is-preload)
   until the page has finished loading, but this popup opens long before that. */
.plakat-popup[open] {
	display: flex;
	padding: var(--plakat-pad);
	background: var(--plakat-scrim);
	animation: plakat-scrim-in 260ms ease-out !important;
}

/* Page behind stays put while the popup is open. */
html.plakat-popup-open {
	overflow: hidden;
}

.plakat-popup ::selection {
	background: var(--plakat-ink);
	color: #fff;
}

/* Panel: as wide as the poster. The poster is as large as fits, so it never needs scrolling. */
.plakat-popup__panel {
	--plakat-chrome: calc(2 * var(--plakat-pad) + 3.75rem);		/* padding + button bar + gap */

	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	width: min(100%, 56rem, calc((100vh - var(--plakat-chrome)) * var(--plakat-ratio)));
	margin: auto;
	outline: none;
}

@supports (height: 100dvh) {
	.plakat-popup__panel {
		width: min(100%, 56rem, calc((100dvh - var(--plakat-chrome)) * var(--plakat-ratio)));
	}
}

/* Very short screens (phone held sideways): size the poster by width and let the popup scroll. */
@media (max-height: 36rem) {
	.plakat-popup__panel {
		width: min(100%, 28rem);
	}
}

.plakat-popup[open] .plakat-popup__panel {
	animation: plakat-panel-in 480ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Button bar: PDF on the left, close on the right. Sticks to the top while the popup scrolls. */
.plakat-popup__bar {
	position: sticky;
	top: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}

/* Both controls beat the template's global a / a:hover / button rules (hence the double class). */
.plakat-popup .plakat-popup__pdf,
.plakat-popup .plakat-popup__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 2.75rem;
	margin: 0;
	border-radius: 0.375rem;
	cursor: pointer;
	line-height: 1;
	text-decoration: none;
	transition: background-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

.plakat-popup .plakat-popup__pdf {
	gap: 0.5rem;
	padding: 0 1.125rem;
	border: 2px solid transparent;			/* stays visible in forced-colors mode */
	background: var(--plakat-paper);
	color: var(--plakat-ink) !important;
	font: 700 0.8125rem/1 "Roboto Slab", serif;
	letter-spacing: 0.075em;
	text-transform: uppercase;
	white-space: nowrap;
}

.plakat-popup .plakat-popup__pdf:hover {
	background: #fff;
	border-color: transparent;
}

.plakat-popup .plakat-popup__pdf:active {
	background: #dcdacf;
}

.plakat-popup .plakat-popup__close {
	flex: none;
	width: 2.75rem;
	padding: 0;
	border: 0;
	background: var(--plakat-chip);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
	color: #fff !important;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
}

.plakat-popup .plakat-popup__close:hover,
.plakat-popup .plakat-popup__close:active {
	background: rgb(6, 20, 13);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.plakat-popup .plakat-popup__pdf:focus-visible,
.plakat-popup .plakat-popup__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.plakat-popup__icon {
	flex: none;
	display: block;
	width: 1.25rem;
	height: 1.25rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

.plakat-popup__img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 0.375rem;
	background: #d4d2c6;
	box-shadow: 0 1.5rem 3.5rem -1rem rgba(0, 0, 0, 0.6), 0 0.125rem 0.5rem rgba(0, 0, 0, 0.35);
}

/* Text for screen readers only: dialog title and a written version of the poster. */
.plakat-popup__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Closing (class set by the script, which then calls dialog.close()). */
.plakat-popup.is-closing {
	animation: plakat-scrim-out 180ms ease-in forwards !important;
}

.plakat-popup.is-closing .plakat-popup__panel {
	animation: plakat-panel-out 180ms ease-in forwards !important;
}

@keyframes plakat-scrim-in {
	from { background-color: rgba(6, 20, 13, 0); }
}

@keyframes plakat-scrim-out {
	to { background-color: rgba(6, 20, 13, 0); }
}

@keyframes plakat-panel-in {
	from { opacity: 0; transform: translateY(1.25rem) scale(0.985); }
}

@keyframes plakat-panel-out {
	to { opacity: 0; transform: translateY(0.5rem) scale(0.99); }
}

@keyframes plakat-fade-in {
	from { opacity: 0; }
}

@keyframes plakat-fade-out {
	to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {

	.plakat-popup[open] .plakat-popup__panel {
		animation: plakat-fade-in 200ms linear !important;
	}

	.plakat-popup.is-closing .plakat-popup__panel {
		animation: plakat-fade-out 120ms linear forwards !important;
	}

	.plakat-popup .plakat-popup__pdf,
	.plakat-popup .plakat-popup__close {
		transition: none;
	}

}

@media print {

	.plakat-popup {
		display: none !important;
	}

}
