/*
 * Fieldsets, text inputs and error text, on the white card.
 *
 * Control borders use --color-border-control, not --color-border. WCAG 1.4.11 wants 3:1 for the
 * boundary that identifies a control, and the hairline divider colour is nowhere near that.
 */

.field {
	margin: 0;
	padding: 0;
	border: 0;
}

/*
 * Covers all four orderings. .field + .field alone missed .field-row + .field, so the pill group on
 * step 5 sat flush against the bottom of the name and email inputs.
 */
:is(.field, .field-row) + :is(.field, .field-row) {
	margin-block-start: var(--space-4);
}

/* Step 5 puts the name and email side by side: the card is wide enough that stacking two short
   inputs down the middle of it looks like a mistake. */
.field-row {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-3);

	/* end, not stretch: if one label wraps to two lines the inputs still share a bottom edge
	   instead of one growing to fill the taller cell. */
	align-items: end;
}

.field-row > .field + .field {
	margin-block-start: 0;
}

@media (max-width: 34rem) {
	.field-row {
		grid-template-columns: minmax(0, 1fr);
	}
}

.field__legend,
.field__label {
	display: block;
	padding: 0;
	color: var(--color-text);
	font-size: var(--font-3);
	font-weight: var(--weight-medium);
	line-height: var(--leading-snug);
}

.field--input .field__label {
	margin-block-end: var(--space-1);
}

.field__input {
	display: block;
	width: 100%;
	min-height: var(--tap-min);
	padding: var(--space-15) var(--space-2);
	background-color: var(--color-bg-quiet);
	border: var(--border-control) solid transparent;
	border-radius: var(--radius-md);
	color: var(--color-text);
	font-size: var(--font-4);
	transition:
		background-color var(--duration) var(--ease),
		border-color var(--duration) var(--ease);
}

/* Vertical resize only: dragging it wider would take the box past the edge of the card. */
.field__textarea {
	min-height: 0;
	padding-block: var(--space-15);
	line-height: var(--leading);
	resize: vertical;
}

.field__input::placeholder {
	color: var(--color-text-muted);
	opacity: 1;
}

.field__input:hover {
	border-color: var(--color-border-control);
}

.field__input:focus-visible {
	background-color: var(--bnk-white);
	border-color: var(--color-accent);
	outline: var(--focus-width) solid var(--focus-color);
	outline-offset: 1px;
}

.field__error {
	display: block;
	margin-block-start: var(--space-05);
	color: var(--bnk-green-deep);
	font-size: var(--font-2);
	font-weight: var(--weight-medium);
}

/*
 * The invalid state is carried on the border and by the message, never by colour alone: a red ring
 * would be the only signal for anyone who cannot see the difference, and red is not on this palette.
 */
.field.is-invalid .field__input {
	border-color: var(--bnk-green-deep);
}

/* Unchecked labels only. Left unscoped this ties with .choice__input:checked + .choice__label at
   equal specificity, and which won would depend on the order the files happen to be globbed in. */
.field.is-invalid .choice__input:not(:checked) + .choice__label {
	border-color: var(--bnk-green-deep);
}
