/**
 * Lemontec Popup
 *
 * All values come from custom properties. The design settings in the admin
 * override them inline, themes can override them on `.lmt-popup-root`.
 */

.lmt-popup-root {
	--lmt-popup-background: #ffffff;
	--lmt-popup-color: #1a1a1a;
	--lmt-popup-button-background: #1a1a1a;
	--lmt-popup-button-color: #ffffff;
	--lmt-popup-button-background-hover: #444444;
	--lmt-popup-button-color-hover: #ffffff;
	--lmt-popup-radius: 8px;
	--lmt-popup-button-radius: 40px;
	--lmt-popup-offset-mobile: 16px;
	--lmt-popup-offset-desktop: 24px;
	--lmt-popup-offset: var(--lmt-popup-offset-mobile);
	--lmt-popup-gutter: 16px;
	--lmt-popup-max-width: 440px;
	--lmt-popup-padding: 24px;
	--lmt-popup-toggle-size: 56px;
	--lmt-popup-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
	--lmt-popup-backdrop: rgba(0, 0, 0, 0.5);
	--lmt-popup-duration: 300ms;
	--lmt-popup-z-index: 100000;

	/*
	 * `medium` is the browser's default font size (usually 16px), independent of
	 * the root font size. Sites with `html { font-size: 62.5% }` get the same sizes.
	 * All text inside the popup uses `em` relative to this.
	 */
	--lmt-popup-font-size: medium;

	font-size: var(--lmt-popup-font-size);
}

@media (min-width: 768px) {
	.lmt-popup-root {
		--lmt-popup-offset: var(--lmt-popup-offset-desktop);
		--lmt-popup-gutter: 24px;
		--lmt-popup-padding: 32px;
		--lmt-popup-toggle-size: 64px;
	}
}

/* Popup */

.lmt-popup {
	position: fixed;
	z-index: var(--lmt-popup-z-index);
	right: var(--lmt-popup-gutter);
	bottom: var(--lmt-popup-offset);
	left: var(--lmt-popup-gutter);
	box-sizing: border-box;
	max-width: var(--lmt-popup-max-width);
	max-height: calc(100dvh - var(--lmt-popup-offset) - var(--lmt-popup-gutter));
	margin: 0 0 0 auto;
	padding: var(--lmt-popup-padding);
	overflow-y: auto;
	overscroll-behavior: contain;
	font-family: inherit;
	/* Repeated here, themes with a universal `* { font-size }` rule would override the inherited value. */
	font-size: var(--lmt-popup-font-size);
	color: var(--lmt-popup-color);
	background: var(--lmt-popup-background);
	border-radius: var(--lmt-popup-radius);
	box-shadow: var(--lmt-popup-shadow);
	opacity: 1;
	transform: none;
	transform-origin: bottom right;
	transition:
		opacity var(--lmt-popup-duration) ease,
		transform var(--lmt-popup-duration) ease,
		display var(--lmt-popup-duration) allow-discrete;
}

.lmt-popup[hidden] {
	display: none;
	opacity: 0;
	transform: translateY(12px) scale(0.96);
}

@starting-style {
	.lmt-popup {
		opacity: 0;
		transform: translateY(12px) scale(0.96);
	}
}

.lmt-popup:focus {
	outline: none;
}

.lmt-popup-root--has-toggle .lmt-popup {
	bottom: calc(var(--lmt-popup-offset) + var(--lmt-popup-toggle-size) + 12px);
	max-height: calc(100dvh - var(--lmt-popup-offset) - var(--lmt-popup-toggle-size) - 12px - var(--lmt-popup-gutter));
}

.lmt-popup-root--left .lmt-popup {
	margin: 0 auto 0 0;
	transform-origin: bottom left;
}

/* Centered: all insets set and auto margins center the popup on both axes. */
.lmt-popup-root--center .lmt-popup {
	top: var(--lmt-popup-gutter);
	bottom: var(--lmt-popup-gutter);
	height: fit-content;
	max-height: calc(100dvh - 2 * var(--lmt-popup-gutter));
	margin: auto;
	transform-origin: center;
}

.lmt-popup-backdrop {
	position: fixed;
	z-index: calc(var(--lmt-popup-z-index) - 1);
	inset: 0;
	background: var(--lmt-popup-backdrop);
	opacity: 1;
	transition:
		opacity var(--lmt-popup-duration) ease,
		display var(--lmt-popup-duration) allow-discrete;
}

.lmt-popup-backdrop[hidden] {
	display: none;
	opacity: 0;
}

@starting-style {
	.lmt-popup-backdrop {
		opacity: 0;
	}
}

/* Content */

.lmt-popup__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	color: var(--lmt-popup-color);
	background: var(--lmt-popup-background);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.lmt-popup__close:focus-visible,
.lmt-popup__button:focus-visible,
.lmt-popup-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.lmt-popup__media {
	margin: 0 0 20px;
}

.lmt-popup__image {
	display: block;
	width: 100%;
	height: auto;
	max-height: 200px;
	object-fit: cover;
	border-radius: calc(var(--lmt-popup-radius) / 2);
}

/* Keep the first line of text clear of the close button, unless an image comes first. */
.lmt-popup__close + :not(.lmt-popup__media) {
	padding-right: 40px;
}

/* Centered text: pad both sides, so the text stays optically centered next to the close button. */
.lmt-popup-root--text-center .lmt-popup {
	text-align: center;
}

.lmt-popup-root--text-center .lmt-popup__close + :not(.lmt-popup__media) {
	padding-left: 40px;
}

.lmt-popup-root--text-center .lmt-popup__text :is(ul, ol) {
	padding-left: 0;
	list-style-position: inside;
}

.lmt-popup__eyebrow {
	margin: 0 0 6px;
	font-size: 1.125em;
	font-family: var(--lmt-popup-headline-font-family, var(--font-headline, var(--font-heading, inherit)));
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/*
 * Uses the theme's headline font when it exposes one as a custom property
 * (`--font-headline` in the Lemontec framework, `--font-heading` as common alternative),
 * otherwise the text font. Set `--lmt-popup-headline-font-family` to choose a font explicitly.
 */
.lmt-popup__headline {
	margin: 0 0 12px;
	font-family: var(--lmt-popup-headline-font-family, var(--font-headline, var(--font-heading, inherit)));
	font-size: 2.5em;
	font-weight: 700;
	line-height: 1.2;
	color: inherit;
}

.lmt-popup__subline {
	margin: -4px 0 16px;
	font-family: var(--lmt-popup-headline-font-family, var(--font-headline, var(--font-heading, inherit)));
	font-size: 1.25em;
	font-weight: 500;
	line-height: 1.35;
}

.lmt-popup__text {
	font-size: 1em;
	line-height: 1.5;
}

.lmt-popup__text > * {
	margin: 0 0 0.75em;
}

/*
 * Theme styles for p/li (or a universal `*` rule) often set rem sizes and weights
 * directly on every element, so nested elements would not follow the popup's text.
 */
.lmt-popup__text * {
	font-size: inherit;
	line-height: inherit;
}

.lmt-popup__text :is(strong, b) {
	font-weight: 700;
}

.lmt-popup__text > :last-child {
	margin-bottom: 0;
}

.lmt-popup__text a {
	color: inherit;
	text-decoration: underline;
}

/* Sizes from the "Formats" dropdown of the text editor, keep in sync with editor-content.css. */
.lmt-popup__text .lmt-popup-small {
	font-size: 0.875em;
}

.lmt-popup__text .lmt-popup-large {
	font-size: 1.25em;
}

.lmt-popup__button {
	display: inline-block;
	margin-top: 20px;
	padding: 0.75em 1.5em;
	font-family: inherit;
	font-size: 1em;
	font-weight: 600;
	line-height: 1.2;
	color: var(--lmt-popup-button-color);
	text-decoration: none;
	background: var(--lmt-popup-button-background);
	border-radius: var(--lmt-popup-button-radius);
	transition:
		color var(--lmt-popup-duration) ease,
		background-color var(--lmt-popup-duration) ease;
}

.lmt-popup__button:hover,
.lmt-popup__button:focus-visible {
	color: var(--lmt-popup-button-color-hover);
	background: var(--lmt-popup-button-background-hover);
}

/* Button font "Like headline", same lookup as the headline. */
.lmt-popup-root--button-font-headline .lmt-popup__button {
	font-family: var(--lmt-popup-headline-font-family, var(--font-headline, var(--font-heading, inherit)));
}

/* Floating button */

.lmt-popup-toggle {
	position: fixed;
	z-index: var(--lmt-popup-z-index);
	right: var(--lmt-popup-gutter);
	bottom: var(--lmt-popup-offset);
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--lmt-popup-toggle-size);
	height: var(--lmt-popup-toggle-size);
	margin: 0;
	padding: 0;
	color: var(--lmt-popup-button-color);
	background: var(--lmt-popup-button-background);
	border: 0;
	border-radius: 50%;
	box-shadow: var(--lmt-popup-shadow);
	cursor: pointer;
	transition:
		color var(--lmt-popup-duration) ease,
		background-color var(--lmt-popup-duration) ease,
		transform var(--lmt-popup-duration) ease;
}

.lmt-popup-toggle[hidden] {
	display: none;
}

.lmt-popup-toggle:hover,
.lmt-popup-toggle:focus-visible {
	color: var(--lmt-popup-button-color-hover);
	background: var(--lmt-popup-button-background-hover);
	transform: scale(1.05);
}

.lmt-popup-root--left .lmt-popup-toggle {
	right: auto;
	left: var(--lmt-popup-gutter);
}

.lmt-popup-toggle__icon {
	display: block;
	width: 50%;
	height: 50%;
	object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
	.lmt-popup,
	.lmt-popup-backdrop,
	.lmt-popup__button,
	.lmt-popup-toggle {
		transition: none;
	}
}
