/**
 * MX Popup — scoped modal styles.
 * Default stacking: 999999 (overridable via --mx-popup-z on #mx-popup-app and #mx-popup-app-{id}).
 * Motion: overlay + content use opacity/transform only (GLightbox-style).
 */

.mx_popup {
	--mx-popup-ease: cubic-bezier(0.16, 1, 0.3, 1);
	--mx-popup-duration: 0.38s;
	position: fixed;
	inset: 0;
	z-index: var(--mx-popup-z, 999999);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	box-sizing: border-box;
	pointer-events: none;
	visibility: hidden;
}

.mx_popup.mx_popup--open {
	pointer-events: auto;
	visibility: visible;
}

.mx_popup__overlay {
	position: absolute;
	inset: 0;
	pointer-events: auto;
	cursor: pointer;
	opacity: 0;
	transition: opacity var(--mx-popup-duration) var(--mx-popup-ease);
}

.mx_popup.mx_popup--open:not(.mx_popup--closing) .mx_popup__overlay {
	opacity: 1;
}

.mx_popup.mx_popup--closing .mx_popup__overlay {
	opacity: 0;
}

.mx_popup__dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-height: min(90vh, 100%);
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	box-sizing: border-box;
}

.mx_popup.mx_popup--open .mx_popup__dialog {
	pointer-events: auto;
}

.mx_popup__content {
	max-width: 100%;
	opacity: 0;
	transform: translateY(1rem) scale(0.98);
	transition:
		opacity var(--mx-popup-duration) var(--mx-popup-ease),
		transform var(--mx-popup-duration) var(--mx-popup-ease);
	will-change: opacity, transform;
}

.mx_popup.mx_popup--open:not(.mx_popup--closing) .mx_popup__content {
	opacity: 1;
	transform: none;
}

.mx_popup.mx_popup--closing .mx_popup__content {
	opacity: 0;
	transform: translateY(1rem) scale(0.98);
}

.mx_popup__close {
	position: absolute;
	top: calc(1rem + env(safe-area-inset-top, 0px));
	right: calc(1rem + env(safe-area-inset-right, 0px));
	z-index: 2;
	width: 2.5rem;
	height: 2.5rem;
	min-width: 2.5rem;
	min-height: 2.5rem;
	padding: 0;
	border: none;
	border-radius: 0.35rem;
	font-size: 0;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
	pointer-events: auto;
	opacity: 0;
	transition: opacity var(--mx-popup-duration) var(--mx-popup-ease);
}

.mx_popup.mx_popup--open:not(.mx_popup--closing) .mx_popup__close {
	opacity: 1;
}

.mx_popup.mx_popup--closing .mx_popup__close {
	opacity: 0;
	pointer-events: none;
}

.mx_popup__close:focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 1px;
}

.mx_popup__close:focus:not(:focus-visible) {
	outline: none;
}

.mx_popup__close-x {
	display: block;
	font-size: 1.5rem;
	font-weight: 300;
	line-height: 1;
	margin-top: -0.08em;
}

/*
 * WordPress admin bar (logged-in frontend): match core bar heights so the
 * close control sits below the toolbar (32px desktop, 46px ≤782px).
 */
body.admin-bar .mx_popup .mx_popup__close {
	top: calc(32px + 1rem + env(safe-area-inset-top, 0px));
}

@media screen and (max-width: 782px) {
	body.admin-bar .mx_popup .mx_popup__close {
		top: calc(46px + 1rem + env(safe-area-inset-top, 0px));
	}
}

.mx_popup__body {
	max-width: 100%;
	max-height: 85vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.mx_popup__link {
	display: block;
	max-width: 100%;
	line-height: 0;
}

.mx_popup__image {
	display: block;
	max-width: 100%;
	width: auto;
	height: auto;
	max-height: 85vh;
	object-fit: contain;
	vertical-align: middle;
}

@media (max-width: 600px) {
	.mx_popup__close {
		top: calc(0.65rem + env(safe-area-inset-top, 0px));
		right: calc(0.65rem + env(safe-area-inset-right, 0px));
		width: 2.35rem;
		height: 2.35rem;
		min-width: 2.35rem;
		min-height: 2.35rem;
	}

	body.admin-bar .mx_popup .mx_popup__close {
		top: calc(46px + 0.65rem + env(safe-area-inset-top, 0px));
	}

	.mx_popup__close-x {
		font-size: 1.35rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mx_popup__overlay,
	.mx_popup__content,
	.mx_popup__close {
		transition-duration: 0.01ms;
	}

	.mx_popup__content {
		transform: none;
	}

	.mx_popup.mx_popup--open:not(.mx_popup--closing) .mx_popup__content {
		transform: none;
	}

	.mx_popup.mx_popup--closing .mx_popup__content {
		transform: none;
	}
}

html.mx-popup--locked,
body.mx-popup--locked {
	overflow: hidden;
}

.mx_popup__html {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.mx_popup--type-html .mx_popup__content {
	width: 100%;
}

.mx_popup--type-html .mx_popup__body {
	width: 100%;
	max-height: 85vh;
	overflow: auto;
}

.mx_popup__html img {
	max-width: 100%;
	height: auto;
}
