body.bey-exit-intent-popup-open {
	overflow: hidden;
}

/*
|------------------------------------------------------------------------------
| Dialog shell
|------------------------------------------------------------------------------
*/

.bey-exit-intent-popup {
	position: fixed;
	inset: 0;
	margin: auto;
	padding: 0;
	border: 0;
	background: transparent;
	max-width: none;
	max-height: none;
	overflow: visible;
}

.bey-exit-intent-popup::backdrop {
	background-color: rgba(0, 0, 0, 0.5);
}

/* Fallback for browsers without native <dialog> support: [open] alone
   doesn't get us a backdrop, so this class does the same job manually. */
.bey-exit-intent-popup:not([open]) {
	display: none;
}

.bey-exit-intent-popup--open {
	display: flex !important;
	z-index: 10000;
	/* The UA stylesheet sizes <dialog> with width/height: fit-content, so
	   without this the stand-in backdrop would only cover the panel. */
	width: 100%;
	height: 100%;
	align-items: center;
	justify-content: center;
	background-color: rgba(0, 0, 0, 0.5);
}

/*
|------------------------------------------------------------------------------
| Panel
|------------------------------------------------------------------------------
*/

.bey-exit-intent-popup-form {
	display: flex;
	flex-direction: column;
	gap: calc(var(--wp--preset--spacing--40) * 0.75);

	position: relative;
	/* A definite width is what makes max-width bind — the UA stylesheet sizes
	   <dialog> with width: fit-content, so a percentage here would collapse to
	   the panel's shrink-to-fit content width instead. */
	width: calc(100vw - var(--wp--preset--spacing--40) * 2);
	max-width: 480px;
	max-height: calc(100vh - var(--wp--preset--spacing--40) * 2);
	margin: auto;
	padding: 1.25em;
	overflow-y: auto;
	box-sizing: border-box;

	background-color: var(--wp--preset--color--copper-light);
	color: var(--wp--preset--color--black);
	border-radius: 26px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

@media not (prefers-reduced-motion: reduce) {
	.bey-exit-intent-popup[open] .bey-exit-intent-popup-form,
	.bey-exit-intent-popup--open .bey-exit-intent-popup-form {
		animation: bey-exit-intent-popup-in 0.2s ease-out;
	}
}

@keyframes bey-exit-intent-popup-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/*
|------------------------------------------------------------------------------
| Heading
|------------------------------------------------------------------------------
*/

.bey-exit-intent-popup-heading {
	display: flex;
	flex-direction: row-reverse;
	align-items: center;
}

/* theme.json styles h2 as `:root :where(h2)` with font-weight: 400 — same
   specificity as a single class, so this is scoped to beat it on order too. */
.bey-exit-intent-popup .bey-exit-intent-popup-title {
	margin: 0;
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.2;
	font-weight: 700;
}

.bey-exit-intent-popup-close {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;

	/* Auto margin does the separating here, so the title lands hard left and
	   the icon button overhangs the panel padding by 10px. */
	margin: 0 -10px 0 auto;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--wp--preset--color--black);
	cursor: pointer;
}

.bey-exit-intent-popup-close-icon {
	display: block;
	width: 18px;
	height: 18px;
	fill: currentColor;
}

.bey-exit-intent-popup-close:hover,
.bey-exit-intent-popup-close:focus-visible {
	background-color: var(--wp--preset--color--grey-light);
	color: var(--wp--preset--color--black);
}

.bey-exit-intent-popup-close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/*
|------------------------------------------------------------------------------
| Body
|------------------------------------------------------------------------------
*/

.bey-exit-intent-popup-intro {
	margin: 0 0 var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.3;
}

/* Memira sets 600 here, but the title right above it is the only bold text
   we want in the panel, so the label stays at body weight. */
.bey-exit-intent-popup-form .bey-form-label {
	display: block;
	margin-bottom: 0.25em;
	font-size: 14px;
	font-weight: 400;
}

.bey-exit-intent-popup-form .bey-exit-intent-popup-field {
	width: 100%;
	/* The counter sits directly below and carries the gap to the next block. */
	margin-bottom: 0.25em;
	padding: 12px;
	border: 1px solid var(--wp--preset--color--grey);
	border-radius: 8px;
	font: inherit;
	/* 16px keeps iOS from zooming the viewport on focus. */
	font-size: 16px;
	box-sizing: border-box;
}

.bey-exit-intent-popup-form .bey-exit-intent-popup-field:focus {
	outline: 2px solid var(--wp--preset--color--copper);
	outline-offset: -1px;
	border-color: transparent;
}

.bey-exit-intent-popup-textarea {
	min-height: 120px;
	resize: vertical;
}

.bey-exit-intent-popup-counter {
	margin: 0 0 var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--tiny);
	line-height: 1.3;
	/* Deliberately lighter than the disclaimer — it's a supporting hint, and
	   aria-live carries it to screen readers regardless. */
	color: #777;
	white-space: nowrap;
}

/* Empty until the script fills it in, and the popup needs JS to open at all. */
.bey-exit-intent-popup-counter:empty {
	display: none;
}

.bey-exit-intent-popup-disclaimer {
	/* Bey has no mid-grey preset — grey (#b8b8b8) is too light to read on
	   copper-light, so this keeps Memira's neutral. */
	margin: 0 0 var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.3;
	color: #555;
}

/*
|------------------------------------------------------------------------------
| Actions
|------------------------------------------------------------------------------
*/

.bey-exit-intent-popup-actions {
	display: flex;
	justify-content: flex-end;
}

/* bey-form.js renders the success message as an h2, but here it sits under
   the popup title and reads as body copy — so it drops the Prata heading font.
   The popup title itself is untouched. */
.bey-exit-intent-popup-form .bey-form-message :is(h2, p) {
	font-family: var(--wp--preset--font-family--montserrat);
	font-size: var(--wp--preset--font-size--large);
}

/* bey-form.js always adds a "reset form" button next to the thank-you
   message — pointless here since the popup auto-closes a few seconds later. */
.bey-exit-intent-popup-form .bey-form-message button {
	display: none;
}
