/*
 * MCC Popup - front end styles.
 * Everything is namespaced under .mcc-popup so Bricks / Elementor / theme CSS does not leak in.
 * Customisable per popup through CSS variables: --mcc-width, --mcc-radius, --mcc-bg, --mcc-pad, --mcc-overlay, --mcc-z.
 */

.mcc-popup {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: var(--mcc-z, 999999);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
	pointer-events: none; /* Without an overlay the page behind stays usable. */
	font-size: 16px;
	line-height: 1.5;
	text-align: left;
}

.mcc-popup[hidden] {
	display: none !important;
}

.mcc-popup *,
.mcc-popup *::before,
.mcc-popup *::after {
	box-sizing: border-box;
}

/* ---- Positions ---- */
.mcc-popup--top { align-items: flex-start; }
.mcc-popup--bottom { align-items: flex-end; }
.mcc-popup--bottom-right { align-items: flex-end; justify-content: flex-end; }
.mcc-popup--bottom-left { align-items: flex-end; justify-content: flex-start; }

/* ---- Overlay ---- */
.mcc-popup__overlay {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: var(--mcc-overlay, rgba(0, 0, 0, 0.6));
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: auto;
}

.mcc-popup.is-open .mcc-popup__overlay {
	opacity: 1;
}

/* ---- Dialog ---- */
.mcc-popup__dialog {
	position: relative;
	width: var(--mcc-width, 600px);
	max-width: 100%;
	max-width: min(100%, var(--mcc-max, 100%)); /* Never wider than the screen, nor the optional cap. */
	margin: 0;
	opacity: 0;
	outline: 0;
	pointer-events: auto;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.mcc-popup.is-open .mcc-popup__dialog {
	opacity: 1;
	transform: none;
}

.mcc-anim--slide .mcc-popup__dialog { transform: translateY(32px); }
.mcc-anim--slide.mcc-popup--top .mcc-popup__dialog { transform: translateY(-32px); }
.mcc-anim--zoom .mcc-popup__dialog { transform: scale(0.92); }
.mcc-anim--none .mcc-popup__dialog,
.mcc-anim--none .mcc-popup__overlay { transition: none; }

.mcc-popup__body {
	position: relative;
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	overflow: auto;
	overscroll-behavior: contain;
	background: var(--mcc-bg, #fff);
	border-radius: var(--mcc-radius, 8px);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.mcc-popup--shortcode .mcc-popup__body {
	padding: var(--mcc-pad, 24px);
}

/* ---- Image popups ---- */
.mcc-popup--image .mcc-popup__body {
	background: transparent;
}

.mcc-popup .mcc-popup__link {
	display: block;
	margin: 0;
	padding: 0;
	line-height: 0;
	text-decoration: none;
	border: 0;
	box-shadow: none;
}

.mcc-popup .mcc-popup__picture {
	display: block;
	margin: 0;
	padding: 0;
}

.mcc-popup .mcc-popup__img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

/* ---- Close button (strong selectors: themes love to restyle <button>) ---- */
.mcc-popup button.mcc-popup__close {
	all: unset;
	box-sizing: border-box;
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.mcc-popup button.mcc-popup__close:hover,
.mcc-popup button.mcc-popup__close:focus {
	background: #000;
	color: #fff;
	transform: scale(1.06);
}

.mcc-popup button.mcc-popup__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.7);
}

.mcc-popup button.mcc-popup__close svg {
	display: block;
	width: 18px;
	height: 18px;
	pointer-events: none;
}

.mcc-popup--close-outside button.mcc-popup__close {
	top: -12px;
	right: -12px;
}

/* ---- Phones (under 768px, same breakpoint as the mobile image and the Devices rule) ---- */
@media (max-width: 767px) {
	.mcc-popup {
		padding: 12px;
	}

	.mcc-popup__dialog {
		width: var(--mcc-width-m, 100%);
		max-width: 100%;
	}

	.mcc-popup__overlay {
		background: var(--mcc-overlay-m, var(--mcc-overlay, rgba(0, 0, 0, 0.6)));
	}

	.mcc-popup__body {
		max-height: calc(100vh - 24px);
		max-height: calc(100dvh - 24px);
	}

	.mcc-popup--bottom-right,
	.mcc-popup--bottom-left {
		justify-content: center;
	}
}

/* ---- Locked page scroll while a modal popup is open ---- */
html.mcc-popup-lock {
	overflow: hidden !important;
	padding-right: var(--mcc-sbw, 0);
}

/* ---- Accessibility / print ---- */
@media (prefers-reduced-motion: reduce) {
	.mcc-popup__overlay,
	.mcc-popup__dialog,
	.mcc-popup button.mcc-popup__close {
		transition: none !important;
	}
}

@media print {
	.mcc-popup {
		display: none !important;
	}
}
