/*
 * VA Pop-ups. Colours and fonts come from the theme's theme.json presets where
 * they exist, with plain fallbacks for classic themes. Override any of the
 * --va-popup-* properties in the theme to restyle.
 */
.va-popup {
	--va-popup-bg: var(--wp--preset--color--white, #fff);
	--va-popup-text: var(--wp--preset--color--black, #1e1e1e);
	--va-popup-backdrop: rgb(0 0 0 / 0.6);
	--va-popup-radius: 0;
	--va-popup-pad: clamp(1.25rem, 4vw, 2.25rem);
	--va-popup-width: 40rem;

	width: min(var(--va-popup-width), calc(100vw - 2rem));
	max-width: none;
	max-height: calc(100dvh - 2rem);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: var(--va-popup-radius);
	background: var(--va-popup-bg);
	color: var(--va-popup-text);
	box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 0.35);
	overflow: hidden;
}
.va-popup--small { --va-popup-width: 28rem; }
.va-popup--large { --va-popup-width: 56rem; }

.va-popup::backdrop {
	background: var(--va-popup-backdrop);
}

html:has(.va-popup[open]) {
	overflow: hidden;
}

.va-popup__panel {
	position: relative;
	max-height: calc(100dvh - 2rem);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.va-popup__content {
	padding: var(--va-popup-pad);
}
/* Even spacing between blocks, whatever the theme does in post content. */
.va-popup__content > * {
	margin-block: 0;
}
.va-popup__content > * + * {
	margin-block-start: var(--va-popup-gap, 1rem);
}
/* Headings sized for a pop-up rather than a page. Block font-size settings still win. */
.va-popup__content :is(h1, h2) {
	font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
	line-height: 1.15;
}
.va-popup__content h3 {
	font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem);
	line-height: 1.2;
}
.va-popup__content > :is(h1, h2, h3) + * {
	--va-popup-gap: 0.75rem;
}

/* A full-width image or cover as the first block runs to the edges. */
.va-popup__content > .wp-block-image:first-child,
.va-popup__content > .wp-block-cover:first-child,
.va-popup__content > .wp-block-media-text:first-child {
	margin: calc(var(--va-popup-pad) * -1) calc(var(--va-popup-pad) * -1) var(--va-popup-pad);
}
.va-popup__content > :is(.wp-block-image, .wp-block-cover, .wp-block-media-text):first-child + * {
	margin-block-start: 0;
}
.va-popup__content img {
	display: block;
	max-width: 100%;
	height: auto;
}
.va-popup__content > .wp-block-image:first-child img {
	width: 100%;
	max-height: 50dvh;
	object-fit: cover;
}

.va-popup__close-form {
	position: sticky;
	top: 0;
	z-index: 2;
	height: 0;
	margin: 0;
}
.va-popup__close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--va-popup-bg);
	color: var(--va-popup-text);
	box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 0.25);
	cursor: pointer;
}
.va-popup__close:hover {
	background: var(--va-popup-text);
	color: var(--va-popup-bg);
}
.va-popup__close:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
	.va-popup[open] {
		animation: va-popup-in 0.25s ease-out;
	}
	.va-popup[open]::backdrop {
		animation: va-popup-fade 0.25s ease-out;
	}
}
@keyframes va-popup-in {
	from { opacity: 0; transform: translateY(1rem); }
	to { opacity: 1; transform: none; }
}
@keyframes va-popup-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}
