/**
 * MP Leadfunnel – Frontend
 *
 * Alle Werte kommen aus CSS-Custom-Properties, die pro Formular gesetzt werden.
 * Der Reset wirkt bewusst nur innerhalb von .mplf, damit Theme-CSS aussen
 * unangetastet bleibt und wir ohne !important auskommen.
 */

.mplf {
	--mplf-brand: #83b82a;
	--mplf-brand-text: #4d6e18;
	--mplf-on-brand: #ffffff;
	--mplf-ink: #1a1f14;
	--mplf-muted: #5c6452;
	--mplf-hairline: #e6e4dc;
	--mplf-surface: #f5f4f0;
	--mplf-radius: 6px;
	--mplf-max: 520px;
	--mplf-font: inherit;

	max-width: var(--mplf-max);
	margin: 0 auto;
	font-family: var(--mplf-font);
	color: var(--mplf-ink);
	text-align: left;
}

.mplf *,
.mplf *::before,
.mplf *::after {
	box-sizing: border-box;
}

.mplf-box,
.mplf-success-step {
	background: #fff;
	border: 1px solid var(--mplf-hairline);
	border-radius: calc(var(--mplf-radius) + 2px);
	padding: 36px;
	margin: 0;
}

@media (max-width: 480px) {
	.mplf-box,
	.mplf-success-step {
		padding: 22px 18px;
	}
}

/* Nur für Screenreader */
.mplf-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Fortschritt */
.mplf-progress {
	margin: 0 0 26px;
}

.mplf-progress-track {
	height: 6px;
	border-radius: 3px;
	background: var(--mplf-hairline);
	overflow: hidden;
}

.mplf-progress-bar {
	height: 100%;
	width: 0;
	border-radius: 3px;
	background: var(--mplf-brand);
	transition: width 0.3s ease;
}

.mplf-progress-label {
	margin: 8px 0 0;
	font-size: 11px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--mplf-muted);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Schritte */
.mplf-step[hidden] {
	display: none;
}

.mplf-steplabel {
	display: block;
	font-size: 11px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--mplf-muted);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	margin: 0 0 10px;
}

.mplf-question {
	font-size: 20px;
	font-weight: 700;
	line-height: 1.3;
	margin: 0 0 6px;
	color: var(--mplf-ink);
}

.mplf-question:focus {
	outline: none;
}

.mplf-question:focus-visible {
	outline: 2px solid var(--mplf-brand-text);
	outline-offset: 3px;
}

.mplf-stepdesc {
	font-size: 14px;
	color: var(--mplf-muted);
	margin: 0 0 12px;
	line-height: 1.5;
}

.mplf-fields {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin-top: 16px;
}

.mplf-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.mplf-label {
	font-size: 14px;
	font-weight: 600;
	color: var(--mplf-ink);
	line-height: 1.35;
}

.mplf-req {
	color: var(--mplf-brand-text);
}

.mplf-help {
	font-size: 12.5px;
	color: var(--mplf-muted);
	line-height: 1.45;
}

/* Eingabefelder – Reset gegen Theme-Styles, ohne !important */
.mplf input[type="text"],
.mplf input[type="email"],
.mplf input[type="tel"],
.mplf input[type="number"],
.mplf select,
.mplf textarea {
	width: 100%;
	padding: 13px 15px;
	border: 1.5px solid #d0cfc7;
	border-radius: var(--mplf-radius);
	font-size: 16px; /* verhindert Auto-Zoom auf iOS */
	font-family: inherit;
	line-height: 1.4;
	background: #fff;
	color: var(--mplf-ink);
	box-shadow: none;
	margin: 0;
	height: auto;
	min-height: 0;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.mplf select {
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235c6452' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 18px;
	padding-right: 40px;
}

.mplf textarea {
	min-height: 110px;
	resize: vertical;
}

.mplf input:focus,
.mplf select:focus,
.mplf textarea:focus {
	outline: none;
	border-color: var(--mplf-brand-text);
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06), 0 0 0 3px color-mix(in srgb, var(--mplf-brand) 30%, transparent);
}

.mplf input:focus-visible,
.mplf select:focus-visible,
.mplf textarea:focus-visible {
	outline: 2px solid var(--mplf-brand-text);
	outline-offset: 1px;
}

.mplf ::placeholder {
	color: #8b8b83;
	opacity: 1;
}

.mplf [aria-invalid="true"] {
	border-color: #b3261e;
}

/* Kacheln als echte Radiogruppe */
.mplf-tiles-set {
	border: 0;
	padding: 0;
	margin: 0;
	min-width: 0;
}

.mplf-tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
	gap: 10px;
	margin-top: 4px;
}

.mplf-tiles[data-columns="2"] {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mplf-tiles[data-columns="3"] {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mplf-tiles[data-columns="4"] {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 560px) {
	.mplf-tiles[data-columns="3"],
	.mplf-tiles[data-columns="4"] {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.mplf-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 20px 10px;
	background: var(--mplf-surface);
	border: 2px solid var(--mplf-hairline);
	border-radius: var(--mplf-radius);
	font-weight: 600;
	font-size: 14px;
	line-height: 1.2;
	text-align: center;
	color: var(--mplf-ink);
	cursor: pointer;
	transition: border-color 0.16s ease, background 0.16s ease;
}

.mplf-tile:hover {
	border-color: var(--mplf-brand);
	background: color-mix(in srgb, var(--mplf-brand) 10%, #fff);
}

.mplf-tile-input:checked + .mplf-tile {
	border-color: var(--mplf-brand);
	background: color-mix(in srgb, var(--mplf-brand) 14%, #fff);
}

.mplf-tile-input:focus-visible + .mplf-tile {
	outline: 3px solid var(--mplf-brand-text);
	outline-offset: 2px;
}

.mplf-tile-sub {
	font-size: 11.5px;
	font-weight: 400;
	color: var(--mplf-muted);
	line-height: 1.3;
}

.mplf-stars {
	display: flex;
	gap: 2px;
	justify-content: center;
}

.mplf-stars svg {
	width: 18px;
	height: 18px;
	fill: var(--mplf-brand);
	stroke: none;
}

.mplf-icon {
	width: 28px;
	height: 28px;
	stroke: var(--mplf-brand-text);
	fill: none;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	flex: none;
}

/* Eingabefeld mit Icon davor */
.mplf-input-wrap {
	position: relative;
	display: block;
}

.mplf-input-wrap .mplf-icon {
	position: absolute;
	left: 13px;
	top: 50%;
	transform: translateY(-50%);
	width: 20px;
	height: 20px;
	pointer-events: none;
}

.mplf-input-wrap input {
	padding-left: 44px;
}

/* Zähler mit +/− */
.mplf-fields.is-multi {
	gap: 18px;
}

.mplf-stepper {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.mplf-stepper-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mplf-stepper-btn {
	flex: none;
	width: 46px;
	height: 46px;
	border-radius: var(--mplf-radius);
	border: 1.5px solid var(--mplf-hairline);
	background: var(--mplf-surface);
	color: var(--mplf-ink);
	font-size: 22px;
	line-height: 1;
	font-family: inherit;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: border-color 0.16s ease, background 0.16s ease;
}

.mplf-stepper-btn:hover {
	border-color: var(--mplf-brand);
	background: color-mix(in srgb, var(--mplf-brand) 10%, #fff);
}

.mplf-stepper-btn:focus-visible {
	outline: 3px solid var(--mplf-brand-text);
	outline-offset: 2px;
}

.mplf .mplf-stepper-input {
	text-align: center;
	font-weight: 600;
	-moz-appearance: textfield;
}

.mplf .mplf-stepper-input::-webkit-outer-spin-button,
.mplf .mplf-stepper-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.mplf-stepper-unit {
	flex: none;
	font-size: 14px;
	font-weight: 600;
	color: var(--mplf-muted);
	min-width: 44px;
}

/* Ladeanzeige */
.mplf-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	padding: 36px 0;
	text-align: center;
}

.mplf-loading[hidden] {
	display: none;
}

.mplf-spinner {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 3px solid var(--mplf-hairline);
	border-top-color: var(--mplf-brand);
	animation: mplf-spin 0.8s linear infinite;
}

.mplf-loading-text {
	margin: 0;
	font-size: 14px;
	color: var(--mplf-muted);
}

@keyframes mplf-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Fehler */
.mplf-error,
.mplf-fielderror {
	font-size: 13px;
	color: #b3261e;
	line-height: 1.45;
	margin: 0;
}

.mplf-error:empty,
.mplf-fielderror:empty {
	display: none;
}

.mplf-error {
	margin-top: 12px;
}

/* Aktionen */
.mplf-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 22px;
}

.mplf-actions-spacer {
	flex: 1 1 auto;
}

.mplf-actions [hidden] {
	display: none;
}

.mplf-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 13px 22px;
	border-radius: var(--mplf-radius);
	font-size: 15px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1.2;
	cursor: pointer;
	text-decoration: none;
	transition: filter 0.15s ease, transform 0.15s ease;
	min-height: 44px; /* Touch-Ziel */
}

.mplf-btn-primary {
	background: var(--mplf-btn-bg, var(--mplf-brand));
	color: var(--mplf-btn-fg, #fff);
	border: 2px solid var(--mplf-btn-bg, var(--mplf-brand));
}

.mplf-btn-ghost {
	background: transparent;
	color: var(--mplf-ink);
	border: 1.5px solid var(--mplf-hairline);
}

.mplf-btn:hover:not(:disabled) {
	filter: brightness(0.94);
	transform: translateY(-1px);
}

.mplf-btn:focus-visible {
	outline: 3px solid var(--mplf-brand-text);
	outline-offset: 2px;
}

.mplf-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

/* Rechtstext */
.mplf-legal {
	font-size: 12.5px;
	color: var(--mplf-muted);
	line-height: 1.55;
	margin: 16px 0 0;
	background: none;
	padding: 0;
}

.mplf-legal a {
	color: var(--mplf-brand-text);
	text-decoration: underline;
	background: none;
}

/* Erfolg */
.mplf-success {
	text-align: center;
	padding: 20px 0;
}

.mplf-ok {
	width: 54px;
	height: 54px;
	border-radius: 50%;
	background: var(--mplf-btn-bg, var(--mplf-brand));
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 16px;
}

.mplf-ok svg {
	width: 26px;
	height: 26px;
	stroke: var(--mplf-btn-fg, #fff);
	fill: none;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.mplf-success-title {
	font-size: 22px;
	font-weight: 700;
	margin: 0 0 10px;
	color: var(--mplf-ink);
}

.mplf-success-title:focus {
	outline: none;
}

.mplf-success-text {
	font-size: 15px;
	color: var(--mplf-muted);
	line-height: 1.6;
	max-width: 340px;
	margin: 0 auto 20px;
}

/* Honeypot */
.mplf-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 0;
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
}

.mplf-credit {
	font-size: 11px;
	color: var(--mplf-muted);
	text-align: center;
	margin: 10px 0 0;
	opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
	.mplf * {
		transition: none;
	}
}
