/*
 * P4F Newsletter-Popup - nur das Geruest: Position, Ebene, Animation.
 * Alle Regeln stehen in :where() und haben damit Spezifitaet 0.
 * Jede Regel im Global CSS gewinnt, auch ein einfaches .p4f-nl__box { ... }.
 *
 * Stellschrauben fuer das Global CSS:
 *   .p4f-nl { --p4f-nl-bg: ...; --p4f-nl-width: ...; --p4f-nl-radius: ...; }
 */

:where(.p4f-nl) {
	--p4f-nl-width: 26rem;
	--p4f-nl-gap: 1.5rem;
	--p4f-nl-bg: #fff;
	--p4f-nl-radius: var(--radius-lg, 1.25rem);
	--p4f-nl-shadow: 0 1.25rem 3rem rgba(0, 0, 0, .18);
	--p4f-nl-backdrop: rgba(0, 0, 0, .5);
	--p4f-nl-speed: .3s;
	position: fixed;
	z-index: 99990;
	box-sizing: border-box;
}

:where(.p4f-nl[hidden]) {
	display: none;
}

/* ---------- Positionen ---------- */

:where(.p4f-nl--center) {
	--p4f-nl-width: 34rem;
	inset: 0;
	display: grid;
	place-items: center;
	padding: var(--p4f-nl-gap);
}

:where(.p4f-nl--bottom-right, .p4f-nl--bottom-left, .p4f-nl--bottom-center) {
	bottom: var(--p4f-nl-gap);
	width: calc(100vw - 2 * var(--p4f-nl-gap));
	max-width: var(--p4f-nl-width);
}

:where(.p4f-nl--bottom-right) { right: var(--p4f-nl-gap); }
:where(.p4f-nl--bottom-left) { left: var(--p4f-nl-gap); }
:where(.p4f-nl--bottom-center) { left: 0; right: 0; margin-inline: auto; }

/* ---------- Hintergrund (nur Mitte) ---------- */

:where(.p4f-nl__backdrop) {
	position: absolute;
	inset: 0;
	background: var(--p4f-nl-backdrop);
	opacity: 0;
	transition: opacity var(--p4f-nl-speed) ease;
}

:where(.p4f-nl.is-open .p4f-nl__backdrop) {
	opacity: 1;
}

/* ---------- Box ---------- */

:where(.p4f-nl__box) {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: var(--p4f-nl-width);
	max-height: calc(100vh - 2 * var(--p4f-nl-gap));
	max-height: calc(100dvh - 2 * var(--p4f-nl-gap));
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: clamp(1.25rem, 4vw, 2rem);
	background: var(--p4f-nl-bg);
	border-radius: var(--p4f-nl-radius);
	box-shadow: var(--p4f-nl-shadow);
	opacity: 0;
	transform: translateY(1rem);
	transition: opacity var(--p4f-nl-speed) ease, transform var(--p4f-nl-speed) ease;
}

:where(.p4f-nl.is-open .p4f-nl__box) {
	opacity: 1;
	transform: none;
}

:where(.p4f-nl__box:focus) {
	outline: none;
}

:where(.p4f-nl__box > *) {
	margin-top: 0;
	margin-bottom: 0;
}

:where(.p4f-nl__box > * + *) {
	margin-top: .75rem;
}

:where(.p4f-nl__box > .p4f-nl__form) {
	margin-top: 1.25rem;
}

/* Platz fuer das X rechts oben */
:where(.p4f-nl__eyebrow, .p4f-nl__title) {
	padding-right: 2.25rem;
}

:where(.p4f-nl__text > :first-child, .p4f-nl__note > :first-child) { margin-top: 0; }
:where(.p4f-nl__text > :last-child, .p4f-nl__note > :last-child) { margin-bottom: 0; }

/* ---------- Schliessen ---------- */

:where(.p4f-nl__close) {
	position: absolute;
	top: .75rem;
	right: .75rem;
	display: grid;
	place-items: center;
	width: 2.5rem;
	height: 2.5rem;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

:where(.p4f-nl__close:hover) {
	background: rgba(0, 0, 0, .06);
}

:where(.p4f-nl__close:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ---------- Scrollsperre beim Modal ---------- */

:where(html.p4f-nl-lock) {
	overflow: hidden;
}

/* ---------- Handy ---------- */

@media (max-width: 599px) {
	:where(.p4f-nl) {
		--p4f-nl-gap: .75rem;
	}

	:where(.p4f-nl--bottom-right, .p4f-nl--bottom-left, .p4f-nl--bottom-center) {
		left: var(--p4f-nl-gap);
		right: var(--p4f-nl-gap);
		width: auto;
		max-width: none;
		margin-inline: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	:where(.p4f-nl__box, .p4f-nl__backdrop) {
		transition: none;
	}

	:where(.p4f-nl__box) {
		transform: none;
	}
}

/* ---------- Nur fuer Screenreader (Live-Region) ---------- */

.p4f-nl-sr {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}
