/* ============================================================
   EGP EU Widerrufsbutton – Frontend Styles
   All rules scoped to .egp-euwb-* | No global styles
   ============================================================ */

/* ---------- Trigger button ---------- */

.egp-euwb-trigger {
	appearance: none;
	background: #6a4ddc;
	border: 1.5px solid #6a4ddc;
	border-radius: 200px;
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	font-family: var(--mu-font-family-serif, Georgia, serif);
	font-size: var(--mu-font-size-p-m, 1.0625rem);
	font-weight: 400;
	letter-spacing: 0;
	line-height: var(--mu-line-height-text-md, 1.2);
	min-height: 52px;
	padding: 0.7em 1.6em;
	text-align: center;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s;
}

.egp-euwb-trigger:hover,
.egp-euwb-trigger:focus-visible {
	background: #5a3dc6;
	border-color: #5a3dc6;
}

.egp-euwb-trigger-link {
	color: #111;
	cursor: pointer;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.egp-euwb-trigger-link:hover {
	color: #333;
}

.egp-euwb-noscript {
	color: #71717a;
	display: block;
	font-size: 0.875em;
	margin-top: 0.5rem;
}

/* ---------- Scroll lock ---------- */

body.egp-euwb-modal-open {
	overflow: hidden;
}

/* ---------- Overlay ---------- */

.egp-euwb-modal[hidden] {
	display: none !important;
}

.egp-euwb-modal {
	align-items: center;
	background: rgba(9, 9, 11, 0.52);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	box-sizing: border-box;
	display: flex;
	inset: 0;
	justify-content: center;
	overflow-y: auto;
	padding: 24px 16px;
	position: fixed;
	z-index: 999999;
}

.egp-euwb-modal *,
.egp-euwb-modal *::before,
.egp-euwb-modal *::after {
	box-sizing: border-box;
}

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

.egp-euwb-modal__panel {
	background: #fff;
	border-radius: 16px;
	box-shadow:
		0 0 0 1px rgba(0, 0, 0, 0.05),
		0 8px 24px rgba(0, 0, 0, 0.1),
		0 24px 64px rgba(0, 0, 0, 0.12);
	color: #18181b;
	font: inherit;
	max-height: min(780px, calc(100vh - 48px));
	max-width: 480px;
	overflow-y: auto;
	padding: 32px;
	position: relative;
	width: 100%;
}

/* ---------- Close button ---------- */

.egp-euwb-modal__close {
	align-items: center;
	appearance: none;
	background: transparent;
	border: 0;
	border-radius: 50%;
	color: #a1a1aa;
	cursor: pointer;
	display: flex;
	font-size: 22px;
	height: 36px;
	justify-content: center;
	line-height: 1;
	padding: 0;
	position: absolute;
	right: 14px;
	top: 14px;
	transition: background 0.15s, color 0.15s;
	width: 36px;
}

.egp-euwb-modal__close > span {
	display: block;
	line-height: 1;
	margin-top: -4px;
}

.egp-euwb-modal__close:hover {
	background: #f4f4f5;
	color: #18181b;
}

/* ---------- Focus rings (keyboard nav) ---------- */

.egp-euwb-trigger:focus-visible {
	outline: none; /* focus indicated by background-color change (same as hover) */
}

.egp-euwb-modal button:focus-visible {
	outline: 3px solid #72aee6;
	outline-offset: 2px;
}

.egp-euwb-modal input:focus-visible {
	outline: 3px solid #72aee6;
	outline-offset: 0;
}

/* Mouse focus on inputs: suppress outline (border-color is visual cue) */
.egp-euwb-modal input:focus:not(:focus-visible) {
	outline: none;
}

/* ---------- Title & intro ---------- */

.egp-euwb-modal__title,
.egp-euwb-success__title {
	-webkit-font-smoothing: auto;
	font-family: var(--mu-font-family-sansSerif, inherit);
	font-size: var(--mu-font-size-h2, 1.375rem);
	font-weight: 400;
	letter-spacing: -0.015em;
	line-height: var(--mu-line-height-sm, 1.2);
	margin: 0 44px 8px 0;
	text-align: left !important;
}

.egp-euwb-modal__intro {
	color: #52525b;
	font-family: var(--mu-font-family-serif);
	font-size: var(--mu-font-size-p-m, 0.9rem);
	line-height: 26px;
	margin: 0 0 1.6em;
	text-align: left;
}

/* ---------- Honeypot ---------- */

.egp-euwb-honeypot {
	height: 1px;
	left: -9999px;
	overflow: hidden;
	position: absolute;
	top: auto;
	width: 1px;
}

/* ---------- Form layout ---------- */

.egp-euwb-form {
	margin-top: 4px;
}

/* ---------- Name row (Vorname + Nachname side by side) ---------- */

.egp-euwb-field-row {
	align-items: flex-start;
	display: flex;
	margin: 0 0 -1px;
}

/* ---------- Field container ---------- */

.egp-euwb-field {
	margin: 0 0 -1px;
	position: relative;
}

/* Half fields inside row: no individual margin, row wrapper handles vertical spacing */
.egp-euwb-field.egp-euwb-field--half {
	flex: 1;
	margin: 0;
	min-width: 0;
}

/* Checkbox field needs its own spacing (not part of the connected-border group) */
.egp-euwb-field.egp-euwb-field--checkbox {
	margin-bottom: 2em !important;
	margin-top: 2em;
}

/* ---------- Text / email inputs (checkout style) ---------- */

.egp-euwb-field > input[type="text"],
.egp-euwb-field > input[type="email"] {
	appearance: none;
	background: transparent;
	border: 1px solid #808080;
	border-radius: 0;
	color: #18181b;
	display: block;
	font: inherit;
	font-size: 1rem;
	min-height: 56px;
	padding: 22px 14px 6px;
	transition: border-color 0.15s;
	width: 100%;
}

/* Remove left border on the second half field (shared border from first) */
.egp-euwb-field--half + .egp-euwb-field--half > input[type="text"] {
	border-left: 0;
}

/* Focus: bring input to front, accent border */
.egp-euwb-field > input[type="text"]:focus,
.egp-euwb-field > input[type="email"]:focus {
	border-color: #111;
	position: relative;
	z-index: 1;
}

/* Error border */
.egp-euwb-field > input[type="text"][aria-invalid="true"],
.egp-euwb-field > input[type="email"][aria-invalid="true"] {
	border-color: #b32d2e;
}

/* Chrome autofill: suppress yellow/blue background */
.egp-euwb-field > input:-webkit-autofill,
.egp-euwb-field > input:-webkit-autofill:focus {
	-webkit-box-shadow: 0 0 0 1000px #fff inset;
	-webkit-text-fill-color: #18181b;
	transition: background-color 5000s ease;
}

/* ---------- Floating labels (text/email only — NOT checkbox) ---------- */
/*
 * Using input-type-specific adjacency selectors so the checkbox label
 * (which follows input[type="checkbox"]) is never matched here.
 */

.egp-euwb-field > input[type="text"] + label,
.egp-euwb-field > input[type="email"] + label {
	color: #999;
	font-size: 1rem;
	font-weight: 400;
	left: 14px;
	pointer-events: none;
	position: absolute;
	top: 28px; /* fixed: half of 56px input height — avoids wrong 50% when error span adds height */
	transform: translateY(-50%);
	transition:
		top 0.18s ease,
		font-size 0.18s ease,
		color 0.18s ease,
		transform 0.18s ease;
}

/* Floated: focused or has value */
.egp-euwb-field > input[type="text"]:focus + label,
.egp-euwb-field > input[type="email"]:focus + label,
.egp-euwb-field > input[type="text"]:not(:placeholder-shown) + label,
.egp-euwb-field > input[type="email"]:not(:placeholder-shown) + label,
.egp-euwb-field > input:-webkit-autofill + label {
	color: #808080;
	font-size: 0.75rem;
	top: 9px;
	transform: none;
	z-index: 2; /* above focused input's z-index:1 so label stays visible */
}

/* Error label color (rest + floated) */
.egp-euwb-field > input[type="text"][aria-invalid="true"] + label,
.egp-euwb-field > input[type="email"][aria-invalid="true"] + label,
.egp-euwb-field > input[type="text"][aria-invalid="true"]:focus + label,
.egp-euwb-field > input[type="email"][aria-invalid="true"]:focus + label,
.egp-euwb-field > input[type="text"][aria-invalid="true"]:not(:placeholder-shown) + label,
.egp-euwb-field > input[type="email"][aria-invalid="true"]:not(:placeholder-shown) + label {
	color: #b32d2e;
}

/* ---------- Error message ---------- */

.egp-euwb-field__error {
	color: #b32d2e;
	display: block;
	font-size: 0.8125rem;
	line-height: 1.4;
	margin-top: 0;
	min-height: 0; /* collapses to 0 when empty → fields share borders cleanly */
}

/* Only reserve space when an error message is actually shown */
.egp-euwb-field__error:not(:empty) {
	margin-top: 4px;
	min-height: 1.1em;
}

/* ---------- Checkbox field ---------- */

.egp-euwb-field--checkbox {
	align-items: start;
	display: grid;
	gap: 0 10px;
	grid-template-columns: 18px 1fr;
}

.egp-euwb-field--checkbox > input[type="checkbox"] {
	accent-color: #111;
	cursor: pointer;
	height: 18px;
	margin-top: 6px;
	width: 18px;
}

/* Checkbox label: static, NOT absolute */
.egp-euwb-field--checkbox > label {
	color: #3f3f46;
	cursor: pointer;
	font-family: var(--mu-font-family-serif);
	font-size: var(--mu-font-size-p-m, 0.875rem);
	font-weight: 400;
	line-height: 1.55;
	text-align: left !important;
}

.egp-euwb-field--checkbox .egp-euwb-field__error {
	grid-column: 2;
}

/* ---------- Form status ---------- */

.egp-euwb-form__status {
	font-size: 0.875rem;
	line-height: 1.5;
	margin: 12px 0 8px;
	min-height: 1.35em;
}

.egp-euwb-form__status:empty {
	display: none;
}

.egp-euwb-form__status.is-error {
	color: #b32d2e;
}

/* ---------- Submit button ---------- */

.egp-euwb-submit {
	appearance: none;
	background: #6a4ddc;
	border: 1.5px solid #6a4ddc;
	border-radius: 200px;
	color: #fff;
	cursor: pointer;
	display: flex;
	font-family: var(--mu-font-family-serif, Georgia, serif);
	font-size: 1.0625rem;
	font-weight: 400;
	justify-content: center;
	letter-spacing: 0;
	margin-top: 20px;
	min-height: 52px;
	padding: 0.75em 1.5em;
	text-align: center;
	transition: background 0.15s, border-color 0.15s;
	width: 100%;
}

.egp-euwb-submit:hover,
.egp-euwb-submit:focus-visible {
	background: #5a3dc6;
	border-color: #5a3dc6;
}

.egp-euwb-submit:disabled {
	cursor: wait;
	opacity: 0.58;
}

/* ---------- Success state ---------- */

.egp-euwb-success {
	padding: 4px 0 0;
	text-align: center;
}

.egp-euwb-success p {
	color: #52525b;
	font-family: var(--mu-font-family-serif);
	font-size: var(--mu-font-size-p-m, 0.875rem);
	line-height: 26px;
	margin-bottom: 2em;
	margin-top: 1.4em;
	text-align: left;
}

.egp-euwb-success__icon {
	display: block;
	height: 60px;
	margin: 0 auto 22px;
	width: 60px;
}

.egp-euwb-success__circle {
	stroke: #16833a;
	stroke-width: 3;
	stroke-dasharray: 151;
	stroke-dashoffset: 151;
	animation: egp-euwb-draw 0.52s ease forwards;
}

.egp-euwb-success__check {
	stroke: #16833a;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 4;
	stroke-dasharray: 40;
	stroke-dashoffset: 40;
	animation: egp-euwb-draw 0.36s ease 0.42s forwards;
}

.egp-euwb-success__title {
	margin: 0 0 16px;
}

.egp-euwb-success__warning {
	background: #fefce8;
	border: 1px solid #ca8a04;
	border-radius: 4px;
	color: #713f12;
	font-size: 0.875rem;
	line-height: 1.6;
	margin: 0 0 16px;
	padding: 12px 14px;
	text-align: left;
}

@keyframes egp-euwb-draw {
	to {
		stroke-dashoffset: 0;
	}
}

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
	.egp-euwb-modal {
		align-items: flex-start;
		padding: 10px;
	}

	.egp-euwb-modal__panel {
		border-radius: 12px;
		max-height: calc(100svh - 20px);
		max-height: calc(100vh - 20px); /* fallback */
		padding: 24px 20px;
	}

	.egp-euwb-modal__title,
	.egp-euwb-success__title {
		font-size: 1.2rem;
		text-align: left;
	}

	.egp-euwb-modal__intro {
		text-align: left;
	}

	.egp-euwb-field--checkbox > label {
		text-align: left;
	}

	/* Name row: stack vertically on small screens */
	.egp-euwb-field-row {
		align-items: stretch; /* allow children to fill full width */
		flex-direction: column;
		margin: 0 0 -1px;
	}

	.egp-euwb-field--half {
		width: 100%;
	}

	/* Restore full border on stacked Nachname field */
	.egp-euwb-field--half + .egp-euwb-field--half > input[type="text"] {
		border-left: 1px solid #808080;
		border-top: 0; /* avoid double border when stacked */
	}

	.egp-euwb-field--half + .egp-euwb-field--half > input[type="text"][aria-invalid="true"] {
		border-left: 1px solid #b32d2e;
	}

	.egp-euwb-submit,
	.egp-euwb-trigger {
		width: 100%;
	}
}
