/**
 * Frontend styles for locally-built popups.
 *
 * Everything is scoped under .engagepop-* and driven by the custom properties
 * the renderer sets inline, so a theme's own CSS can't leak in and the admin
 * preview can reuse this exact file.
 */

.engagepop-root {
	position: fixed;
	inset: 0;
	z-index: 999990;
	pointer-events: none;
}

.engagepop-root[hidden] {
	display: none;
}

.engagepop-overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	opacity: 0;
	transition: opacity 0.25s ease;
	pointer-events: auto;
}

.engagepop-root.is-open .engagepop-overlay {
	opacity: 1;
}

.engagepop-popup {
	position: absolute;
	box-sizing: border-box;
	width: var(--ep-width, 440px);
	max-width: calc(100vw - 32px);
	padding: 28px;
	background: var(--ep-bg, #fff);
	color: var(--ep-text, #0f172a);
	border-radius: var(--ep-radius, 16px);
	box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22), 0 2px 8px rgba(15, 23, 42, 0.08);
	font-family: inherit;
	line-height: 1.5;
	pointer-events: auto;
	opacity: 0;
	transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.engagepop-root.is-open .engagepop-popup {
	opacity: 1;
}

/* Layouts */

.engagepop-layout-modal {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -46%) scale(0.97);
}

.engagepop-root.is-open .engagepop-layout-modal {
	transform: translate(-50%, -50%) scale(1);
}

.engagepop-layout-slidein {
	bottom: 24px;
	padding: 22px;
	transform: translateY(16px);
}

/* Corner offsets belong to the slide-in only: a modal carries whatever
   position value was last saved, and an unscoped `right` would fight its
   left/transform centring. */
.engagepop-layout-slidein.engagepop-pos-bottom-right {
	right: 24px;
}

.engagepop-layout-slidein.engagepop-pos-bottom-left {
	left: 24px;
}

.engagepop-root.is-open .engagepop-layout-slidein {
	transform: translateY(0);
}

.engagepop-layout-bar {
	left: 0;
	right: 0;
	width: 100%;
	max-width: none;
	padding: 14px 56px 14px 24px;
	border-radius: 0;
	box-shadow: 0 2px 16px rgba(15, 23, 42, 0.16);
}

.engagepop-layout-bar.engagepop-pos-top {
	top: 0;
	transform: translateY(-100%);
}

.engagepop-layout-bar.engagepop-pos-bottom {
	bottom: 0;
	transform: translateY(100%);
}

.engagepop-root.is-open .engagepop-layout-bar {
	transform: translateY(0);
}

.engagepop-layout-bar .engagepop-content {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px 18px;
	text-align: center;
}

.engagepop-layout-bar .engagepop-heading,
.engagepop-layout-bar .engagepop-body {
	margin: 0;
	font-size: 15px;
}

.engagepop-layout-bar .engagepop-heading {
	font-weight: 600;
}

.engagepop-layout-bar .engagepop-form {
	margin: 0;
	min-width: 320px;
}

/* Content */

.engagepop-content > *:first-child {
	margin-top: 0;
}

.engagepop-image {
	display: block;
	width: 100%;
	height: auto;
	margin: -28px -28px 20px;
	width: calc(100% + 56px);
	max-width: none;
	border-radius: var(--ep-radius, 16px) var(--ep-radius, 16px) 0 0;
	object-fit: cover;
}

.engagepop-emoji {
	font-size: 34px;
	line-height: 1;
	margin-bottom: 12px;
}

.engagepop-heading {
	margin: 0 0 8px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.25;
	color: inherit;
}

.engagepop-body {
	margin: 0 0 18px;
	font-size: 15px;
	opacity: 0.85;
	color: inherit;
}

.engagepop-close {
	position: absolute;
	top: 10px;
	right: 12px;
	width: 30px;
	height: 30px;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	line-height: 1;
	color: inherit;
	background: transparent;
	border: 0;
	border-radius: 50%;
	opacity: 0.45;
	cursor: pointer;
	transition: opacity 0.15s ease, background 0.15s ease;
}

.engagepop-close:hover,
.engagepop-close:focus-visible {
	opacity: 1;
	background: rgba(127, 127, 127, 0.16);
}

.engagepop-layout-bar .engagepop-close {
	top: 50%;
	right: 14px;
	transform: translateY(-50%);
}

/* Buttons and form */

.engagepop-button {
	display: inline-block;
	box-sizing: border-box;
	padding: 12px 22px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	white-space: nowrap;
	color: var(--ep-accent-text, #fff);
	background: var(--ep-accent, #059669);
	border: 0;
	border-radius: calc(var(--ep-radius, 16px) * 0.55);
	cursor: pointer;
	transition: filter 0.15s ease, transform 0.1s ease;
}

.engagepop-button:hover {
	filter: brightness(1.08);
	color: var(--ep-accent-text, #fff);
}

.engagepop-button:active {
	transform: translateY(1px);
}

.engagepop-cta {
	width: 100%;
}

.engagepop-layout-bar .engagepop-cta {
	width: auto;
	padding: 9px 18px;
	font-size: 14px;
}

.engagepop-form {
	margin: 0;
}

.engagepop-field {
	display: flex;
	gap: 8px;
}

.engagepop-input {
	flex: 1 1 auto;
	box-sizing: border-box;
	width: 100%;
	min-width: 0;
	margin: 0 0 8px;
	padding: 12px 14px;
	font-size: 15px;
	font-family: inherit;
	color: var(--ep-text, #0f172a);
	background: rgba(127, 127, 127, 0.08);
	border: 1px solid rgba(127, 127, 127, 0.28);
	border-radius: calc(var(--ep-radius, 16px) * 0.55);
	box-shadow: none;
}

.engagepop-field .engagepop-input {
	margin-bottom: 0;
}

.engagepop-input:focus {
	outline: 2px solid var(--ep-accent, #059669);
	outline-offset: 1px;
}

.engagepop-consent {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	margin-top: 12px;
	font-size: 13px;
	opacity: 0.8;
	cursor: pointer;
}

.engagepop-consent input {
	margin: 2px 0 0;
	flex: 0 0 auto;
}

.engagepop-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.engagepop-message {
	margin: 10px 0 0;
	font-size: 13px;
	min-height: 1em;
	color: #dc2626;
}

.engagepop-message:empty {
	margin: 0;
	min-height: 0;
}

.engagepop-success {
	text-align: center;
}

.engagepop-success .engagepop-heading {
	margin-bottom: 0;
	font-size: 19px;
}

/* Small screens */

@media (max-width: 600px) {
	.engagepop-layout-modal,
	.engagepop-layout-slidein {
		left: 12px;
		right: 12px;
		width: auto;
		max-width: none;
	}

	.engagepop-layout-slidein {
		bottom: 12px;
	}

	.engagepop-layout-modal {
		top: auto;
		bottom: 12px;
		transform: translateY(16px);
	}

	.engagepop-root.is-open .engagepop-layout-modal {
		transform: translateY(0);
	}

	.engagepop-field {
		flex-direction: column;
	}

	.engagepop-field .engagepop-button {
		width: 100%;
	}

	.engagepop-layout-bar {
		padding: 12px 44px 12px 16px;
	}

	.engagepop-layout-bar .engagepop-form {
		min-width: 0;
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.engagepop-popup,
	.engagepop-overlay {
		transition: opacity 0.01ms;
	}

	.engagepop-root.is-open .engagepop-layout-modal {
		transform: translate(-50%, -50%);
	}
}
