/*
 * listmonk-Anmeldung: ALTCHA-Prüfung im Look der jeweiligen Seite.
 * Die Werte (--lma-*) übernimmt das Skript vom E-Mail-Feld und vom Absende-Knopf.
 */

.lma-pruefung {
	--lma-radius: 10px;
	--lma-bg: #fff;
	--lma-border: #8a8a8a;
	--lma-kasten: var(--lma-border);
	--lma-border-w: 1px;
	--lma-height: 48px;
	--lma-text: #222;
	--lma-akzent: #1d4ed8;
	--lma-font-size: 16px;
	--lma-pad: 14px;
	--lma-font: inherit;
	--lma-ok: #1e7a3c;
	--lma-fehler: #b3261e;
	box-sizing: border-box;
	grid-column: 1 / -1; /* in Rastern über die ganze Breite */
	flex: 1 1 100%;
	width: 100%;
	min-height: var(--lma-height); /* Platz halten, bis das Widget geladen ist */
	margin: 1rem 0;
	font-family: var(--lma-font);
	container-type: inline-size;
}

.lma-pruefung altcha-widget {
	display: block;
	--altcha-max-width: 100%;
}

/* Rahmen wie ein Eingabefeld */
.lma-pruefung .altcha {
	max-width: none;
	border: var(--lma-border-w) solid var(--lma-border);
	border-radius: var(--lma-radius);
	background: var(--lma-bg);
	color: var(--lma-text);
	transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.lma-pruefung .altcha:hover {
	border-color: color-mix(in srgb, var(--lma-akzent) 55%, var(--lma-kasten));
}

.lma-pruefung .altcha:focus-within {
	border-color: var(--lma-akzent);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--lma-akzent) 18%, transparent);
}

.lma-pruefung .altcha .altcha-main {
	box-sizing: border-box;
	min-height: calc(var(--lma-height) - 2 * var(--lma-border-w));
	padding: 0.4em var(--lma-pad);
	gap: 0.7em;
	font-size: var(--lma-font-size);
	line-height: 1.3;
}

/* Schild-Symbol rechts (rein dekorativ) */
.lma-pruefung .altcha .altcha-main::after {
	content: "";
	flex: none;
	width: 1.25em;
	height: 1.25em;
	background: currentColor;
	opacity: 0.35;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.6 8 11 4.6-1.4 8-6 8-11V5l-8-3Zm-1.2 14.2-3.5-3.5 1.4-1.4 2.1 2.1 4.9-4.9 1.4 1.4-6.3 6.3Z'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.6 8 11 4.6-1.4 8-6 8-11V5l-8-3Zm-1.2 14.2-3.5-3.5 1.4-1.4 2.1 2.1 4.9-4.9 1.4 1.4-6.3 6.3Z'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: opacity 0.2s ease, color 0.2s ease;
}

.lma-pruefung .altcha .altcha-label {
	display: block;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	line-height: 1.3;
	color: inherit;
	margin: 0;
	padding: 0;
	user-select: none;
}

/* Eigenes Kästchen */
.lma-pruefung .altcha .altcha-checkbox {
	flex: none;
	width: 1.5em;
	height: 1.5em;
	color: var(--lma-akzent);
}

.lma-pruefung .altcha .altcha-checkbox input {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	display: grid;
	place-content: center;
	width: 1.5em;
	height: 1.5em;
	margin: 0;
	border: 2px solid var(--lma-kasten);
	border-radius: min(var(--lma-radius), 0.45em);
	background: #fff;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.lma-pruefung .altcha .altcha-checkbox input::after {
	content: "";
	width: 0.36em;
	height: 0.68em;
	margin-top: -0.14em;
	border: solid #fff;
	border-width: 0 0.17em 0.17em 0;
	transform: rotate(45deg) scale(0);
	transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.lma-pruefung .altcha .altcha-checkbox input:hover {
	border-color: var(--lma-akzent);
}

.lma-pruefung .altcha .altcha-checkbox input:active {
	transform: scale(0.92);
}

.lma-pruefung .altcha .altcha-checkbox input:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--lma-akzent) 40%, transparent);
	outline-offset: 2px;
}

.lma-pruefung .altcha .altcha-checkbox input:checked {
	border-color: var(--lma-ok);
	background: var(--lma-ok);
}

.lma-pruefung .altcha .altcha-checkbox input:checked::after {
	transform: rotate(45deg) scale(1);
}

/* Schmale Formulare: Text in einer Zeile halten */
@container (max-width: 250px) {
	.lma-pruefung .altcha .altcha-main {
		gap: 0.5em;
		padding-left: 0.75em;
		padding-right: 0.75em;
	}

	.lma-pruefung .altcha .altcha-main::after {
		display: none;
	}

	.lma-pruefung .altcha .altcha-label {
		font-size: 0.92em;
		white-space: nowrap;
	}
}

/* Lade-Kreisel */
.lma-pruefung .altcha .altcha-checkbox .altcha-spinner {
	color: var(--lma-akzent);
}

/* Zustand: wird geprüft */
.lma-pruefung .altcha[data-state="verifying"] .altcha-label {
	opacity: 0.75;
}

/* Zustand: geprüft */
.lma-pruefung .altcha[data-state="verified"] {
	border-color: color-mix(in srgb, var(--lma-ok) 60%, var(--lma-border));
	background: color-mix(in srgb, var(--lma-ok) 7%, var(--lma-bg));
}

.lma-pruefung .altcha[data-state="verified"] .altcha-main::after {
	color: var(--lma-ok);
	opacity: 0.9;
}

/* Zustand: Fehler / abgelaufen */
.lma-pruefung .altcha[data-state="error"],
.lma-pruefung .altcha[data-state="expired"] {
	border-color: var(--lma-fehler);
}

.lma-pruefung .altcha .altcha-error {
	padding: 0 var(--lma-pad) 0.6em;
	font-size: 0.85em;
	font-weight: 600;
	color: var(--lma-fehler);
}

@media (prefers-reduced-motion: reduce) {
	.lma-pruefung .altcha,
	.lma-pruefung .altcha .altcha-checkbox input,
	.lma-pruefung .altcha .altcha-checkbox input::after {
		transition: none;
	}
}

/* Meldungen */
.listmonk-form .lma-meldung {
	grid-column: 1 / -1;
	margin: 0.75rem 0 0;
}

.listmonk-form .lma-meldung:empty {
	display: none;
}

.listmonk-form .lma-meldung--fehler {
	color: #b3261e;
	font-weight: 700;
}

.listmonk-form input[aria-invalid="true"] {
	border-color: #b3261e !important;
}

.listmonk-form [type="submit"]:disabled {
	opacity: 0.7;
	cursor: progress;
}

/* Erfolg */
.listmonk-form .lma-fertig {
	display: flex;
	gap: 1rem;
	align-items: flex-start;
	animation: lma-rein 0.35s ease both;
}

.listmonk-form .lma-fertig:focus {
	outline: none;
}

.listmonk-form .lma-fertig::before {
	content: "";
	flex: none;
	width: 2.6rem;
	height: 2.6rem;
	margin-top: 0.1rem;
	border-radius: 50%;
	background: var(--lma-ok, #1e7a3c) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 60% no-repeat;
}

.listmonk-form .lma-fertig > div > * {
	margin: 0 0 0.4rem;
}

@keyframes lma-rein {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.listmonk-form .lma-fertig { animation: none; }
}
