/* ALPEG Forms – front end
 * Inherits fonts and colours from the theme and only adds what is needed.
 * Loaded exclusively on pages that contain a form.
 */
.alpeg-form {
	--af-accent: var(--wp--preset--color--primary, #2f6f5e);
	--af-border: color-mix(in srgb, currentColor 22%, transparent);
	--af-border-strong: color-mix(in srgb, currentColor 40%, transparent);
	--af-field-bg: color-mix(in srgb, currentColor 3%, transparent);
	--af-radius: 8px;
	--af-gap: 1.1rem;
	--af-error: #c0352b;
	--af-success: #1f7a4d;
	box-sizing: border-box;
}
.alpeg-form *,
.alpeg-form *::before,
.alpeg-form *::after {
	box-sizing: inherit;
}

.alpeg-form__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--af-gap) 1rem;
}
.alpeg-form__field {
	grid-column: 1 / -1;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	min-width: 0;
}
.alpeg-form__field--half {
	grid-column: auto / span 1;
}
@media (max-width: 600px) {
	.alpeg-form__field--half {
		grid-column: 1 / -1;
	}
}

.alpeg-form__field > label,
.alpeg-form__field legend,
.alpeg-form__legend {
	font-weight: 600;
	font-size: 0.95em;
	line-height: 1.35;
	padding: 0;
}
.alpeg-form__req {
	color: var(--af-error);
	font-weight: 400;
}

.alpeg-form input[type="text"],
.alpeg-form input[type="email"],
.alpeg-form input[type="tel"],
.alpeg-form input[type="url"],
.alpeg-form input[type="number"],
.alpeg-form input[type="date"],
.alpeg-form input[type="file"],
.alpeg-form select,
.alpeg-form textarea {
	width: 100%;
	max-width: 100%;
	font: inherit;
	color: inherit;
	background: var(--af-field-bg);
	border: 1px solid var(--af-border);
	border-radius: var(--af-radius);
	padding: 0.7em 0.85em;
	line-height: 1.4;
	margin: 0;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.alpeg-form textarea {
	min-height: 8em;
	resize: vertical;
}
.alpeg-form input:hover,
.alpeg-form select:hover,
.alpeg-form textarea:hover {
	border-color: var(--af-border-strong);
}
.alpeg-form input:focus-visible,
.alpeg-form select:focus-visible,
.alpeg-form textarea:focus-visible,
.alpeg-form__submit:focus-visible {
	outline: none;
	border-color: var(--af-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--af-accent) 28%, transparent);
}
.alpeg-form [aria-invalid="true"] {
	border-color: var(--af-error);
}

.alpeg-form fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}
.alpeg-form__choice {
	display: flex;
	align-items: flex-start;
	gap: 0.55em;
	font-weight: 400;
	cursor: pointer;
	line-height: 1.45;
}
.alpeg-form__choice input {
	width: 1.15em;
	height: 1.15em;
	margin: 0.15em 0 0;
	flex: none;
	accent-color: var(--af-accent);
}
.alpeg-form__consent {
	font-size: 0.92em;
}
.alpeg-form__consent a {
	color: inherit;
	text-decoration: underline;
}

.alpeg-form__help {
	margin: 0;
	font-size: 0.85em;
	opacity: 0.75;
}
.alpeg-form__field-error {
	margin: 0;
	font-size: 0.875em;
	color: var(--af-error);
}

.alpeg-form__actions {
	margin-top: calc(var(--af-gap) + 0.25rem);
	display: flex;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
}
.alpeg-form__submit {
	display: inline-flex;
	align-items: center;
	gap: 0.6em;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	border: 0;
	border-radius: var(--af-radius);
	padding: 0.85em 1.6em;
	background: var(--af-accent);
	color: #fff;
	transition: filter 0.15s ease, transform 0.05s ease;
}
.alpeg-form__submit:hover {
	filter: brightness(1.08);
}
.alpeg-form__submit:active {
	transform: translateY(1px);
}
.alpeg-form__submit[disabled] {
	cursor: progress;
	opacity: 0.8;
}
.alpeg-form.is-busy .alpeg-form__submit::before,
.alpeg-form__form.is-busy .alpeg-form__submit::before {
	content: "";
	width: 1em;
	height: 1em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: alpeg-form-spin 0.7s linear infinite;
}
@keyframes alpeg-form-spin {
	to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
	.alpeg-form__form.is-busy .alpeg-form__submit::before { animation: none; }
}

.alpeg-form__notice {
	border-radius: var(--af-radius);
	padding: 0.9em 1.1em;
	margin: 0 0 var(--af-gap);
	line-height: 1.5;
}
.alpeg-form__notice p {
	margin: 0;
}
.alpeg-form__notice p + p {
	margin-top: 0.35em;
}
.alpeg-form__notice--error {
	background: color-mix(in srgb, var(--af-error) 10%, transparent);
	border-left: 4px solid var(--af-error);
}
.alpeg-form__notice--success {
	background: color-mix(in srgb, var(--af-success) 10%, transparent);
	border-left: 4px solid var(--af-success);
	margin: 0;
	white-space: pre-line;
}
.alpeg-form__notice:focus {
	outline: none;
}

/* Honeypot: invisible for humans, hidden from screen readers. */
.alpeg-form__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

[hidden].alpeg-form__notice,
.alpeg-form [hidden] {
	display: none !important;
}

/* File upload */
.alpeg-form input[type="file"] {
	padding: 0.55em 0.7em;
	cursor: pointer;
}
.alpeg-form input[type="file"]::file-selector-button {
	font: inherit;
	font-size: 0.9em;
	margin-right: 0.8em;
	padding: 0.35em 0.9em;
	border: 1px solid var(--af-border-strong);
	border-radius: calc(var(--af-radius) - 2px);
	background: transparent;
	color: inherit;
	cursor: pointer;
}

/* Multi-step forms */
.alpeg-form__step {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}
.alpeg-form__step + .alpeg-form__step {
	margin-top: calc(var(--af-gap) * 1.6);
}
.alpeg-form__step-title {
	font-weight: 700;
	font-size: 1.1em;
	padding: 0;
	margin: 0 0 var(--af-gap);
}
.alpeg-form__progress {
	margin: 0 0 calc(var(--af-gap) + 0.2rem);
}
.alpeg-form__progress-bar {
	height: 6px;
	border-radius: 99px;
	background: color-mix(in srgb, currentColor 12%, transparent);
	overflow: hidden;
}
.alpeg-form__progress-bar span {
	display: block;
	height: 100%;
	width: 0;
	background: var(--af-accent);
	border-radius: inherit;
	transition: width 0.25s ease;
}
.alpeg-form__progress-label {
	margin: 0.5em 0 0;
	font-size: 0.9em;
	font-weight: 600;
}
.alpeg-form__back {
	font: inherit;
	background: transparent;
	color: inherit;
	border: 1px solid var(--af-border-strong);
	border-radius: var(--af-radius);
	padding: 0.85em 1.4em;
	cursor: pointer;
}
.alpeg-form__back:hover {
	border-color: currentColor;
}
.alpeg-form__next {
	font: inherit;
	font-weight: 600;
	border: 0;
	border-radius: var(--af-radius);
	padding: 0.85em 1.6em;
	background: var(--af-accent);
	color: #fff;
	cursor: pointer;
}
.alpeg-form__next:focus-visible,
.alpeg-form__back:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--af-accent) 28%, transparent);
}
.alpeg-form__actions [hidden] {
	display: none !important;
}
@media (prefers-reduced-motion: reduce) {
	.alpeg-form__progress-bar span { transition: none; }
}

.alpeg-form .screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute !important;
	width: 1px;
	word-wrap: normal !important;
}
.alpeg-form__field[hidden],
.alpeg-form__step[hidden] {
	display: none !important;
}
