/*
 * Intermedia Email Marketing: sign-up forms and pop-up.
 * Every rule is wrapped in :where() (zero specificity) so the theme wins by
 * default; colours and fonts are inherited. The owner's look settings set
 * --iem-accent, --iem-accent-hover, --iem-radius, --iem-button-radius,
 * --iem-input-radius, --iem-gap and --iem-max-width.
 */

/* Form wrapper: the container the layout responds to, wherever it is dropped. */
:where(.iem-form) {
	box-sizing: border-box;
	width: 100%;
	max-width: var(--iem-max-width, 100%);
	margin: 0 0 1.5em;
	container-type: inline-size;
	container-name: iem-form;
}
:where(.iem-form *, .iem-form *::before, .iem-form *::after) { box-sizing: border-box; }
:where(.iem-form p) { margin: 0; }
:where(.iem-form__title) { font-weight: 600; font-size: 1.15em; margin: 0 0 .35em; overflow-wrap: anywhere; }
:where(.iem-form__text) { margin: 0 0 .75em; overflow-wrap: anywhere; }

/* Fields: a wrapping row. Without container queries this already falls back
   to one row when there is room and stacks when there is not. */
:where(.iem-form__fields) {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: var(--iem-gap, .75em);
	margin: 0 0 .75em;
}
:where(.iem-form__field) { flex: 1 1 13em; min-width: 0; max-width: 100%; }
:where(.iem-form__submit) { flex: 0 0 auto; min-width: 0; max-width: 100%; }
:where(.iem-form__label) { display: block; margin: 0 0 .25em; overflow-wrap: anywhere; }
:where(.iem-form__input) {
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	min-height: 44px;
	font: inherit;
	color: inherit;
}
:where(.iem-form__button) {
	min-height: 44px;
	min-width: 44px;
	max-width: 100%;
	white-space: normal;
	cursor: pointer;
}
:where(.iem-form__input:focus-visible, .iem-form__button:focus-visible, .iem-form input[type="checkbox"]:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
:where(.iem-form__consent, .iem-form__privacy) { font-size: .9em; margin: 0 0 .5em; overflow-wrap: anywhere; }
:where(.iem-form__consent label) { display: inline-flex; align-items: flex-start; gap: .5em; min-height: 44px; padding: .5em 0; cursor: pointer; }
:where(.iem-form__consent input) { flex: 0 0 auto; width: 1.15em; height: 1.15em; margin: .15em 0 0; }
:where(.iem-form__message) { margin: .5em 0 0; min-height: 1em; }
/* Links of the consent text: colour and hover colour come from the theme's own
   link rules; the thin underline is what themes give links inside text (a
   bare "a" usually has none). One class, so a theme rule for the area wins. */
.iem-form__link { text-decoration: underline; text-decoration-thickness: .75px; text-underline-offset: .12em; transition: color .2s; }
:where(.iem-form__message.is-success) { color: #1e7e34; }
:where(.iem-form__message.is-error) { color: #b32d2e; }
:where(.iem-form.is-busy .iem-form__button) { opacity: .7; cursor: progress; }

/* Forced layouts. */
:where(.iem-form--stacked .iem-form__field, .iem-form--stacked .iem-form__submit) { flex-basis: 100%; }
:where(.iem-form--stacked .iem-form__button) { width: 100%; }
:where(.iem-form--inline .iem-form__fields) { flex-wrap: nowrap; }
:where(.iem-form--inline .iem-form__field) { flex-basis: 0; flex-grow: 1; }

/* Automatic layout: stack in a narrow container (footer column, sidebar, phone). */
@container iem-form (max-width: 30em) {
	:where(.iem-form--auto .iem-form__field, .iem-form--auto .iem-form__submit) { flex-basis: 100%; }
	:where(.iem-form--auto .iem-form__button) { width: 100%; }
}

/* Touch screens: 16px or more stops iOS from zooming on focus. */
@media (pointer: coarse) {
	:where(.iem-form__input) { font-size: max(16px, 1em); }
}

/* Notices at the bottom right of the screen (same look as the platform's):
   ours, so they do not depend on the theme. Above the pop-up and the page,
   below nothing: a notice must be seen. */
.iem-toasts {
	position: fixed;
	right: 16px;
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 2147483000;
	display: flex;
	flex-direction: column-reverse;
	gap: 6px;
	max-width: calc(100vw - 32px);
	pointer-events: none;
}
.iem-toasts .iem-toast {
	box-sizing: border-box;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	min-width: 220px;
	max-width: 340px;
	margin: 0;
	padding: 10px 14px;
	border: 0;
	border-left: 3px solid #2e7d32;
	border-radius: 4px;
	background: #fff;
	box-shadow: 0 2px 12px rgba(0, 0, 0, .12), 0 0 0 1px rgba(0, 0, 0, .05);
	color: #111;
	font-size: 14px;
	line-height: 1.45;
	text-align: left;
	pointer-events: auto;
	animation: iem-toast-in .2s ease-out;
}
.iem-toasts .iem-toast--error { border-left-color: #d32f2f; }
.iem-toasts .iem-toast.is-leaving { animation: iem-toast-out .2s ease forwards; }
.iem-toasts .iem-toast__icon { flex: 0 0 auto; display: flex; margin-top: 1px; color: #2e7d32; }
.iem-toasts .iem-toast--error .iem-toast__icon { color: #d32f2f; }
.iem-toasts .iem-toast__message { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; color: #111; }
.iem-toasts .iem-toast__close {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	min-width: 0;
	min-height: 0;
	margin: -2px -6px 0 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: #555;
	font: inherit;
	font-size: 18px;
	line-height: 1;
	opacity: .6;
	cursor: pointer;
}
.iem-toasts .iem-toast__close:hover, .iem-toasts .iem-toast__close:focus-visible { opacity: 1; color: #111; background: none; }
@keyframes iem-toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes iem-toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(12px); } }
@media (max-width: 600px) {
	.iem-toasts { left: 16px; right: 16px; }
	.iem-toasts .iem-toast { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
	.iem-toasts .iem-toast, .iem-toasts .iem-toast.is-leaving { animation: none; }
}

/* Honeypot: off screen, not display:none (some bots skip hidden fields). */
.iem-form__hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.iem-visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

/* Placement strips (cart, footer). */
:where(.iem-placement) { box-sizing: border-box; width: 100%; padding: 1.5em 0; clear: both; }
:where(.iem-placement--footer) { padding: 2em 1em; }
:where(.iem-placement__inner) { max-width: var(--iem-max-width, 64em); margin: 0 auto; }
:where(.iem-placement .iem-form) { margin-bottom: 0; }

/* Pop-up: self-contained. Layout defaults are :where() (the theme can win);
   what the owner sets in the Pop-up tab arrives as a variable plus a modifier
   class (iem-popup--has-*), and those rules have real specificity. The panel
   gets the page's own background from the script unless a colour is set. */
:where(.iem-popup) {
	position: fixed;
	inset: 0;
	z-index: var(--iem-popup-z, 99990);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
:where(.iem-popup[hidden]) { display: none; }
:where(.iem-popup *, .iem-popup *::before, .iem-popup *::after) { box-sizing: border-box; }
:where(.iem-popup__backdrop) { position: absolute; inset: 0; background: var(--iem-popup-overlay, rgba(0, 0, 0, .5)); }
:where(.iem-popup__dialog) {
	position: relative;
	display: flex;
	width: 100%;
	max-width: var(--iem-popup-w, 44em);
	max-height: min(90vh, 46em);
	max-height: min(90dvh, 46em);
	animation: iem-popup-in .2s ease-out;
}
:where(.iem-popup__dialog:focus) { outline: none; }
:where(.iem-popup__panel) {
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
	overflow: auto;
	overscroll-behavior: contain;
	background: var(--iem-popup-bg, #fff);
	color: inherit;
	border-radius: var(--iem-radius, 8px);
	box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
:where(.iem-popup__body) { flex: 1 1 auto; min-width: 0; padding: 2em 1.5em 1.5em; }
:where(.iem-popup__title) { margin: 0 0 .5em; font-size: 1.4em; line-height: 1.25; overflow-wrap: anywhere; }
:where(.iem-popup--title-gap-right .iem-popup__title) { margin-right: calc(var(--iem-popup-close-size, 44px) + .25em); }
:where(.iem-popup--title-gap-left .iem-popup__title) { margin-left: calc(var(--iem-popup-close-size, 44px) + .25em); }
:where(.iem-popup__text) { margin: 0 0 1em; overflow-wrap: anywhere; }
:where(.iem-popup .iem-form) { margin: 0; }
/* No empty gap under the form: the message line takes room only when it has text. */
.iem-popup .iem-form__message:empty { min-height: 0; margin: 0; }
.iem-popup .iem-form .iem-form__consent { margin-bottom: 0; }

/* Position on the screen. The corner positions leave the page usable. */
:where(.iem-popup--pos-top) { align-items: flex-start; }
:where(.iem-popup--pos-bottom) { align-items: flex-end; }
.iem-popup--corner { pointer-events: none; align-items: flex-end; }
.iem-popup--pos-bottom-left { justify-content: flex-start; }
.iem-popup--pos-bottom-right { justify-content: flex-end; }
.iem-popup--corner .iem-popup__backdrop { display: none; }
.iem-popup--corner .iem-popup__dialog { pointer-events: auto; max-width: var(--iem-popup-w, 24em); }

/* Image: left (default), right, top or as the panel's background. */
:where(.iem-popup__image) {
	flex: 0 0 var(--iem-popup-img-w, 40%);
	width: var(--iem-popup-img-w, 40%);
	max-width: var(--iem-popup-img-w, 40%);
	height: auto;
	align-self: stretch;
	object-fit: var(--iem-popup-img-fit, cover);
}
:where(.iem-popup--img-right .iem-popup__panel) { flex-direction: row-reverse; }
:where(.iem-popup--img-top .iem-popup__panel) { flex-direction: column; }
.iem-popup--img-top .iem-popup__image { flex: 0 0 auto; width: 100%; max-width: 100%; height: var(--iem-popup-img-h, 200px); }
.iem-popup--img-background .iem-popup__panel {
	background-image: linear-gradient(var(--iem-popup-img-dim, rgba(0, 0, 0, .45)), var(--iem-popup-img-dim, rgba(0, 0, 0, .45))), var(--iem-popup-img);
	background-size: cover;
	background-position: center;
	color: #fff;
}
.iem-popup--img-background .iem-popup__title { color: inherit; }
/* On a picture or a chosen text colour the theme's link colour may not be readable: links take the text colour. */
.iem-popup--img-background .iem-form__link, .iem-popup--has-color .iem-form__link { color: inherit; }

/* Panel options. */
.iem-popup--has-radius .iem-popup__panel { border-radius: var(--iem-popup-radius); }
.iem-popup--has-pad .iem-popup__body { padding: var(--iem-popup-pad); }
.iem-popup--has-color .iem-popup__panel, .iem-popup--has-color .iem-popup__title { color: var(--iem-popup-color); }
.iem-popup--has-title-color .iem-popup__title { color: var(--iem-popup-title-color); }
.iem-popup--has-title-size .iem-popup__title { font-size: var(--iem-popup-title-size); }
.iem-popup--has-text-size .iem-popup__text { font-size: var(--iem-popup-text-size); }
.iem-popup--has-border .iem-popup__panel { border: var(--iem-popup-border-w) solid var(--iem-popup-border-color, currentColor); }
.iem-popup--no-shadow .iem-popup__panel { box-shadow: none; }
.iem-popup--align-center .iem-popup__body { text-align: center; }
.iem-popup--align-center .iem-form__fields { justify-content: center; }
.iem-popup--align-center .iem-form__label { text-align: center; }
.iem-popup--align-center .iem-form__consent label { text-align: left; }

/* Button and fields of the pop-up (only what is set). */
.iem-popup--accent .iem-form__button { background-color: var(--iem-accent); border-color: var(--iem-accent); }
.iem-popup--has-accent-hover .iem-form .iem-form__button:hover,
.iem-popup--has-accent-hover .iem-form .iem-form__button:focus-visible { background-color: var(--iem-popup-accent-hover); border-color: var(--iem-popup-accent-hover); }
.iem-popup--has-btn-color .iem-form .iem-form__button { color: var(--iem-popup-btn-color); }
.iem-popup--has-btn-radius .iem-form .iem-form__button { border-radius: var(--iem-popup-btn-radius); }
.iem-popup--has-input-radius .iem-form .iem-form__input { border-radius: var(--iem-popup-input-radius); }

/* Close button: ours, so it does not take the theme's button look. */
.iem-popup .iem-popup__close {
	position: absolute;
	top: .25em;
	right: .25em;
	left: auto;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--iem-popup-close-size, 44px);
	height: var(--iem-popup-close-size, 44px);
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-size: calc(var(--iem-popup-close-size, 44px) * .62);
	line-height: 1;
	text-transform: none;
	cursor: pointer;
}
/* A small button keeps a finger-sized target. */
.iem-popup .iem-popup__close::after { content: ""; position: absolute; inset: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%); }
.iem-popup .iem-popup__close:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
.iem-popup--img-background .iem-popup__close { color: #fff; }
.iem-popup--close-circle .iem-popup__close { background: var(--iem-popup-close-bg, rgba(0, 0, 0, .65)); color: #fff; border-radius: 50%; }
.iem-popup--close-text .iem-popup__close { width: auto; height: auto; min-height: 44px; padding: 0 .75em; font-size: .9em; text-decoration: underline; }
.iem-popup--close-text .iem-popup__close::after { content: none; }
.iem-popup--closepos-inside-left .iem-popup__close, .iem-popup--closepos-outside-left .iem-popup__close { right: auto; left: .25em; }
.iem-popup--closepos-outside-right .iem-popup__close { top: calc(var(--iem-popup-close-size, 44px) / -2); right: calc(var(--iem-popup-close-size, 44px) / -2); }
.iem-popup--closepos-outside-left .iem-popup__close { top: calc(var(--iem-popup-close-size, 44px) / -2); left: calc(var(--iem-popup-close-size, 44px) / -2); }
.iem-popup--closepos-outside-right .iem-popup__dialog, .iem-popup--closepos-outside-left .iem-popup__dialog { max-width: min(var(--iem-popup-w, 44em), calc(100% - var(--iem-popup-close-size, 44px))); }
/* Half outside the panel the plain × sits on the dark layer. */
.iem-popup--closepos-outside-right.iem-popup--close-x .iem-popup__close, .iem-popup--closepos-outside-left.iem-popup--close-x .iem-popup__close { color: #fff; }
.iem-popup.iem-popup--has-close-color .iem-popup__close { color: var(--iem-popup-close-color); }

/* "No, thanks" link. */
.iem-popup .iem-popup__decline {
	display: inline-block;
	min-height: 44px;
	margin: .5em 0 0;
	padding: .5em 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-size: .9em;
	text-decoration: underline;
	text-transform: none;
	opacity: .8;
	cursor: pointer;
}

/* Entrance. */
:where(.iem-popup--anim-slide .iem-popup__dialog) { animation: iem-popup-slide .3s ease-out; }
:where(.iem-popup--anim-zoom .iem-popup__dialog) { animation: iem-popup-zoom .2s ease-out; }
:where(.iem-popup--anim-none .iem-popup__dialog) { animation: none; }

/* Narrow screens: a sheet at the bottom (at the top for "Top"); the side
   image goes away or moves above the text. */
@media (max-width: 600px) {
	:where(.iem-popup) { align-items: flex-end; padding: 0; }
	:where(.iem-popup--pos-top) { align-items: flex-start; }
	:where(.iem-popup__dialog) { max-width: none; animation-name: iem-sheet-in; }
	.iem-popup--corner .iem-popup__dialog, .iem-popup--closepos-outside-right .iem-popup__dialog, .iem-popup--closepos-outside-left .iem-popup__dialog { max-width: none; }
	:where(.iem-popup--anim-none .iem-popup__dialog) { animation: none; }
	:where(.iem-popup--pos-top .iem-popup__dialog) { animation-name: iem-popup-in; }
	:where(.iem-popup__panel) { flex-direction: column; border-radius: var(--iem-radius, 12px) var(--iem-radius, 12px) 0 0; padding-bottom: env(safe-area-inset-bottom); }
	.iem-popup--has-radius .iem-popup__panel { border-radius: var(--iem-popup-radius) var(--iem-popup-radius) 0 0; }
	.iem-popup--pos-top .iem-popup__panel { border-radius: 0 0 var(--iem-popup-radius, var(--iem-radius, 12px)) var(--iem-popup-radius, var(--iem-radius, 12px)); padding-bottom: 0; }
	.iem-popup .iem-popup__image { display: none; }
	.iem-popup--img-mobile-top .iem-popup__image { display: block; flex: 0 0 auto; width: 100%; max-width: 100%; height: min(var(--iem-popup-img-h, 200px), 30vh); }
	:where(.iem-popup__body) { padding: 1.75em 1em 1.25em; }
	.iem-popup--closepos-outside-right .iem-popup__close { top: .25em; right: .25em; }
	.iem-popup--closepos-outside-left .iem-popup__close { top: .25em; left: .25em; }
	.iem-popup--closepos-outside-right.iem-popup--close-x .iem-popup__close, .iem-popup--closepos-outside-left.iem-popup--close-x .iem-popup__close { color: inherit; }
}

@keyframes iem-popup-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes iem-popup-slide { from { opacity: 0; transform: translateY(48px); } to { opacity: 1; transform: none; } }
@keyframes iem-popup-zoom { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
@keyframes iem-sheet-in { from { transform: translateY(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
	.iem-popup .iem-popup__dialog { animation: none; }
}

/* Body scroll lock while the pop-up is open (padding set by the script). */
html.iem-popup-open, html.iem-popup-open body { overflow: hidden; }
