/*
 * Promo popup — see includes/functions-promo-popup.php.
 *
 * Hand-authored on purpose, outside assets/build/: it is only enqueued on requests
 * where the popup is printed, so pages without it stay byte-identical. To fold it into
 * the SCSS at the next legitimate bundle rebuild, move it to
 * resources/scss/components/_promo-popup.scss and drop the enqueue.
 *
 * The overlay is position: fixed, so opening it never moves the page underneath.
 * Colours follow the theme palette: dark #1c2e3c, primary #fbb034.
 */

.c-promo-popup {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 500001;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: 24px;
	background-color: rgba(28, 46, 60, 0.6);
	overflow: auto;
	overscroll-behavior: contain;
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.3s ease-out, visibility 0s linear 0.3s;
}

.c-promo-popup[hidden] {
	display: none;
}

.c-promo-popup.is-open {
	visibility: visible;
	opacity: 1;
	transition: opacity 0.3s ease-out, visibility 0s linear 0s;
}

.c-promo-popup__dialog {
	position: relative;
	box-sizing: border-box;
	max-width: min(1100px, 100%);
	margin: auto;
	line-height: 0;
	background-color: #fff;
	border-radius: 8px;
	box-shadow: 0 12px 40px rgba(28, 46, 60, 0.35);
	transform: translateY(12px);
	transition: transform 0.3s ease-out;
}

.c-promo-popup.is-open .c-promo-popup__dialog {
	transform: none;
}

.c-promo-popup__link,
.c-promo-popup__media {
	display: block;
	overflow: hidden;
	border-radius: 8px;
}

.c-promo-popup__link:focus-visible {
	outline: 3px solid #fbb034;
	outline-offset: 3px;
}

.c-promo-popup picture {
	display: block;
}

.c-promo-popup__image {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - 48px);
	margin: 0 auto;
}

@supports (height: 100dvh) {
	.c-promo-popup__image {
		max-height: calc(100dvh - 48px);
	}
}

.c-promo-popup__close {
	position: absolute;
	top: -14px;
	right: -14px;
	z-index: 2;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	background-color: #1c2e3c;
	color: #fff;
	line-height: 0;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	/* Scoped on purpose: a bare `transition` would also animate the inherited visibility,
	   and focus() is a no-op on an element that still computes as hidden. */
	transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

.c-promo-popup__close:hover,
.c-promo-popup__close:focus-visible {
	background-color: #fbb034;
	color: #1c2e3c;
}

.c-promo-popup__close:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.c-promo-popup__close svg {
	pointer-events: none;
}

/* Scroll lock. When the page has a classic scrollbar, the script keeps its gutter
   reserved so the page behind does not jump sideways. */
html.has-promo-popup-open,
html.has-promo-popup-open body {
	overflow: hidden;
}

@media (max-width: 767px) {
	/* 16px all round, plus 52px on top for the close button that sits above the banner. */
	.c-promo-popup {
		padding: 68px 16px 16px;
	}

	/* On phones the close button sits just above the banner's top-right corner, so it
	   never covers the artwork (a landscape banner is only ~150px tall here). The image
	   leaves room for it: 84px = the overlay's top and bottom padding. */
	.c-promo-popup__image {
		max-height: calc(100vh - 84px);
	}

	@supports (height: 100dvh) {
		.c-promo-popup__image {
			max-height: calc(100dvh - 84px);
		}
	}

	.c-promo-popup__close {
		top: -52px;
		right: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.c-promo-popup,
	.c-promo-popup.is-open,
	.c-promo-popup__dialog {
		transition: none;
	}
}
