/**
 * AW Forms front-end styles. Minimal and theme-friendly.
 *
 * Brand hooks: a theme can set these custom properties (globally or on the
 * form wrap) to tie the form into the site's brand. Sensible generic
 * fallbacks apply when they are not defined.
 *
 *   --aw-form-accent   primary button / focus colour
 *   --aw-form-error    invalid field + error message colour
 *   --aw-form-border   input border colour
 *   --aw-form-radius   corner radius
 */

.aw-form-wrap {
	--aw-form-accent: var( --aw-brand-primary, #1c5d4c );
	--aw-form-error: var( --aw-brand-danger, #b32d2e );
	--aw-form-border: var( --aw-brand-border, #c3c4c7 );
	--aw-form-radius: var( --aw-brand-radius, 4px );
}

.aw-form__field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 1rem;
}

/* A condition-hidden field sets [hidden], but the flex display above overrides the browser's [hidden]{display:none} (leaving it visible but disabled), so restore the hide. */
.aw-form__field[hidden] {
	display: none;
}

.aw-form__field label {
	font-weight: 600;
}

.aw-form__field input,
.aw-form__field textarea,
.aw-form__field select {
	box-sizing: border-box;
	width: 100%;
	min-height: 2.75rem;
	padding: 0.5rem 0.75rem;
	border: 1px solid var( --aw-form-border );
	border-radius: var( --aw-form-radius );

	/* Explicit metrics (not `font: inherit`): the body line-height inflates text inputs while selects cap height, so a shared size, line-height and min-height keep the controls aligned. */
	font-family: inherit;
	font-size: 1rem;
	line-height: 1.4;
}

.aw-form__field input:focus,
.aw-form__field textarea:focus,
.aw-form__field select:focus {
	outline: 2px solid var( --aw-form-accent );
	outline-offset: 1px;
	border-color: var( --aw-form-accent );
}

.aw-form__field textarea {
	min-height: 6rem;
	resize: vertical;
}

/* Safari renders a native select at ~23px and ignores author padding/min-height, so selects came out shorter than inputs; appearance:none lets them honour the shared sizing, and the chevron replaces the native arrow it removes. */
.aw-form__field select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%235c5c5c' stroke-width='1.5' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 0.7rem;
	padding-right: 2rem;
}

.aw-form__required {
	color: var( --aw-form-error );
}

/* Inline per-field validation (replaces the browser's native bubble). */
.aw-form__field--invalid input,
.aw-form__field--invalid textarea {
	border-color: var( --aw-form-error );
	box-shadow: 0 0 0 1px var( --aw-form-error );
}

.aw-form__error {
	color: var( --aw-form-error );
	font-size: 0.85em;
	font-weight: 500;
	line-height: 1.4;
}

.aw-form__submit {
	padding: 0.6rem 1.5rem;
	border: none;
	border-radius: var( --aw-form-radius );
	background: var( --aw-form-accent );
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.aw-form__submit:hover {
	opacity: 0.92;
}

.aw-form__submit:disabled {
	opacity: 0.6;
	cursor: default;
}

/* Loading state: a spinner shows while the submission is in flight so a slow send reads as "working"; transparent text hides the label under it without changing the button width. */
.aw-form__submit.is-loading {
	position: relative;
	color: transparent;
	opacity: 1;
}

.aw-form__submit.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 1.1em;
	height: 1.1em;
	margin: -0.55em 0 0 -0.55em;
	border: 2px solid rgba( 255, 255, 255, 0.5 );
	border-top-color: #fff;
	border-radius: 50%;
	animation: aw-form-spin 0.6s linear infinite;
}

@keyframes aw-form-spin {

	to {
		transform: rotate( 360deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {

	.aw-form__submit.is-loading::after {
		animation-duration: 1.6s;
	}
}

.aw-form__notice {
	padding: 0.75rem 1rem;
	margin-bottom: 1rem;
	border-radius: var( --aw-form-radius );
}

.aw-form__notice--success {
	background: #edfaef;
	border: 1px solid var( --aw-form-accent );
}

.aw-form__notice--error {
	background: #fcf0f1;
	border: 1px solid var( --aw-form-error );
}

/* Multi-step wizard: steps, progress indicator, and navigation. */
.aw-form__step {
	border: 0;
	padding: 0;
	margin: 0;
	min-width: 0;
}

.aw-form__step-title {
	padding: 0;
	margin-bottom: 0.75rem;
	font-size: 1.1em;
	font-weight: 700;
}

.aw-form__progress {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.25rem;
	counter-reset: aw-step;
	list-style: none;
	padding: 0;
	margin: 0 0 1.25rem;
}

.aw-form__progress-item {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	counter-increment: aw-step;
	font-size: 0.9em;
	font-weight: 600;
	opacity: 0.55;
}

.aw-form__progress-item::before {
	content: counter( aw-step );
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.7em;
	height: 1.7em;
	border: 2px solid currentColor;
	border-radius: 50%;
	font-size: 0.85em;
}

.aw-form__progress-item.is-active,
.aw-form__progress-item.is-done {
	color: var( --aw-form-accent );
	opacity: 1;
}

.aw-form__progress-item.is-done::before {
	content: "\2713";
	background: var( --aw-form-accent );
	border-color: var( --aw-form-accent );
	color: #fff;
}

/* Radio groups: each option on its own row, labels at normal weight. */
.aw-form__field--radio {
	border: 0;
	padding: 0;
	margin: 0 0 1rem;
	min-width: 0;
}

.aw-form__field--radio legend {
	padding: 0;
	margin-bottom: 0.4rem;
	font-weight: 600;
}

.aw-form__radio {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin-bottom: 0.25rem;
}

.aw-form__radio input {
	width: auto;
	min-height: 0;
	padding: 0;
}

.aw-form__radio label {
	font-weight: 400;
}

.aw-form__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.aw-form__prev,
.aw-form__next {
	padding: 0.6rem 1.25rem;
	border: 1px solid var( --aw-form-accent );
	border-radius: var( --aw-form-radius );
	background: transparent;
	color: var( --aw-form-accent );
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.aw-form__next {
	background: var( --aw-form-accent );
	color: #fff;
}

.aw-form__prev:hover,
.aw-form__next:hover {
	opacity: 0.92;
}
