/* Custom Popups — frontend styles. Colors and sizes come from CSS variables set per popup. */

.cpop[hidden] { display: none !important; }

.cpop {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
	pointer-events: none;
}

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

.cpop-overlay {
	position: absolute;
	inset: 0;
	background: var(--cpop-overlay, #000);
	opacity: 0;
	transition: opacity .3s ease;
	pointer-events: auto;
}

.cpop.is-open .cpop-overlay { opacity: var(--cpop-overlay-opacity, .6); }

.cpop-box {
	position: relative;
	width: 100%;
	max-width: var(--cpop-width, 520px);
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	padding: var(--cpop-padding, 32px);
	border-radius: var(--cpop-radius, 12px);
	background: var(--cpop-bg, #fff);
	color: var(--cpop-text, #1d2327);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .25), 0 2px 8px rgba(0, 0, 0, .1);
	pointer-events: auto;
	outline: none;
	opacity: 0;
	transition: opacity .3s ease, transform .3s cubic-bezier(.2, .8, .2, 1);
}


/* Content */
.cpop-content > :first-child { margin-top: 0; }
.cpop-content > :last-child { margin-bottom: 0; }
.cpop-content h1, .cpop-content h2, .cpop-content h3, .cpop-content h4 { color: inherit; }
.cpop-content img { max-width: 100%; height: auto; }

/* Close button */
.cpop-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--cpop-close, #1d2327);
	font: 400 28px/36px Arial, sans-serif;
	text-align: center;
	cursor: pointer;
	opacity: .7;
	transition: opacity .15s, background-color .15s;
}
.cpop-close:hover,
.cpop-close:focus-visible { opacity: 1; background: rgba(127, 127, 127, .15); }
.cpop-close:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.cpop-close-link {
	margin-top: 12px;
	padding: 4px 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	opacity: .75;
	cursor: pointer;
}
.cpop-close-link:hover { opacity: 1; }

/* Animations (starting states) */
.cpop--anim-slide-up .cpop-box { transform: translateY(40px); }
.cpop--anim-zoom .cpop-box { transform: scale(.9); }
.cpop--anim-none .cpop-box,
.cpop--anim-none .cpop-overlay { transition: none; }

/* Positions */
.cpop--fullscreen { padding: 0; }
.cpop--fullscreen .cpop-box {
	max-width: none;
	width: 100%;
	height: 100%;
	max-height: none;
	border-radius: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
}

.cpop--top-bar,
.cpop--bottom-bar { padding: 0; }
.cpop--top-bar { align-items: flex-start; }
.cpop--bottom-bar { align-items: flex-end; }
.cpop--top-bar .cpop-box,
.cpop--bottom-bar .cpop-box {
	max-width: none;
	border-radius: 0;
	padding-right: 56px;
	box-shadow: 0 0 20px rgba(0, 0, 0, .15);
}
.cpop--top-bar .cpop-close,
.cpop--bottom-bar .cpop-close { top: 50%; margin-top: -18px; }
.cpop--top-bar.cpop--anim-slide-up .cpop-box { transform: translateY(-100%); }
.cpop--bottom-bar.cpop--anim-slide-up .cpop-box { transform: translateY(100%); }

.cpop--bottom-right { align-items: flex-end; justify-content: flex-end; }
.cpop--bottom-left { align-items: flex-end; justify-content: flex-start; }
.cpop--bottom-right .cpop-box,
.cpop--bottom-left .cpop-box { max-width: min(var(--cpop-width, 380px), 100%); }

/* Non-modal positions shouldn't block the page unless an overlay is used */
.cpop--top-bar.cpop--no-overlay,
.cpop--bottom-bar.cpop--no-overlay,
.cpop--bottom-right.cpop--no-overlay,
.cpop--bottom-left.cpop--no-overlay { inset: auto 0 0 0; }
.cpop--top-bar.cpop--no-overlay { inset: 0 0 auto 0; }

/* Open state — higher specificity so it beats every position/animation starting state */
.cpop.is-open[data-cpop] .cpop-box { opacity: 1; transform: none; }

/* Lock page scroll behind modals */
html.cpop-lock,
html.cpop-lock body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.cpop-box, .cpop-overlay { transition: opacity .01s; transform: none !important; }
}

@media (max-width: 600px) {
	.cpop--center .cpop-box { padding: min(var(--cpop-padding, 32px), 24px); }
}
