/* Pop-ups (template-parts/popup.php, popups.js). Loaded only on pages with a live pop-up. */

.popup {
	width: calc(100% - 2 * var(--mo-layout-padding));
	max-width: 37.5rem;                /* 600px without an image */
	max-height: calc(100dvh - 2 * var(--mo-layout-padding));
	margin: auto;
	padding: 0;
	border: 0;
	background: none;
	color: var(--mo-color-text);
	overflow: visible;
}

.popup--has-image {
	max-width: 75rem;                  /* 1200px: 700px image + 500px text */
}

.popup::backdrop {
	background: rgb(50 47 44 / 0.7);
}

.popup[open] {
	animation: popup-in 0.4s ease;
}

@keyframes popup-in {
	from { opacity: 0; transform: translateY(1.25rem); }
}

@media (prefers-reduced-motion: reduce) {
	.popup[open] {
		animation: none;
	}
}

.popup-panel {
	position: relative;
	display: grid;
	max-height: inherit;
	overflow: auto;
	overscroll-behavior: contain;
}

.popup-panel:focus {
	outline: none;
}

.popup--has-image .popup-panel {
	grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
}

/* Images are 700 x 630 (price tables): the area keeps that shape, or grows taller with a long text */
.popup-media {
	position: relative;
}

.popup-media::before {
	content: "";
	display: block;
	aspect-ratio: 700 / 630;
}

.popup-media picture,
.popup-image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.popup-content {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: center;
	padding: 3.125rem;                 /* 50px */
}

.popup-title {
	margin-bottom: 1.25rem;            /* 20px */
	padding-right: 1.875rem;           /* clear of the close button */
}

.popup-text > :first-child {
	margin-top: 0;
}

.popup-text > :last-child {
	margin-bottom: 0;
}

.popup-btn {
	margin-top: 1.875rem;              /* 30px */
}

.popup-close {
	position: absolute;
	top: 0.9375rem;
	right: 0.9375rem;
	z-index: 1;
	display: flex;
	padding: 0.5rem;
	border: 0;
	background: none;
	color: var(--mo-color-dark);
	cursor: pointer;
	transition: color var(--mo-transition);
}

.popup-close:hover {
	color: var(--mo-color-primary);
}

.popup-close:focus-visible {
	outline: 0.125rem solid var(--mo-color-primary);
}

.popup-close svg {
	width: 1.25rem;
	height: auto;
}

/* Below 1024px: image on top, so a table is never cropped */
@media only screen and (max-width: 1023px) {
	.popup--has-image {
		max-width: 37.5rem;            /* 600px */
	}

	.popup--has-image .popup-panel {
		grid-template-columns: minmax(0, 1fr);
	}

	.popup--has-image .popup-close {
		background: var(--mo-color-subtle);
	}

	.popup--has-image .popup-title {
		padding-right: 0;
	}
}

/* Phones */
@media only screen and (max-width: 767px) {
	.popup-content {
		padding: 1.875rem 1.5625rem;   /* 30px 25px */
	}
}
