/*
 * WM Contact Form: layout only. Colours, borders and type come from the theme; the
 * :where() selectors keep this file's specificity at zero so any theme rule wins.
 */

.wmcf-form {
	container-type: inline-size;
}

:where(.wmcf-fields) {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 20px 24px;
}

@container (min-width: 480px) {
	:where(.wmcf-fields) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	:where(.wmcf-field) {
		grid-column: 1 / -1;
	}

	:where(.wmcf-field--half) {
		grid-column: auto;
	}
}

:where(.wmcf-label) {
	display: block;
	margin-bottom: 6px;
}

/* Help line and character counter between the label and the control: the help line on the
   left, the counter on the right (also alone, or on a line of its own on narrow screens). */
:where(.wmcf-info) {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 6px 16px;
	margin-bottom: 6px;
}

:where(.wmcf-description) {
	flex: 1 1 12em;
	margin: 0;
}

:where(.wmcf-counter) {
	flex: none;
	margin-inline-start: auto;
}

:where(.wmcf-input) {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	font: inherit;
}

:where(textarea.wmcf-input) {
	resize: vertical;
}

:where(.wmcf-check) {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

:where(.wmcf-check input) {
	flex: none;
	margin: 0.2em 0 0;
}

/* A single checkbox has its help line under the box. */
:where(.wmcf-field--checkbox > .wmcf-info) {
	margin: 6px 0 0;
}

/* Radio and checkbox groups: one option per line, or side by side with "inline". */
:where(.wmcf-choices) {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

:where(.wmcf-choices legend) {
	padding: 0;
}

:where(.wmcf-choices:not(.wmcf-choices--inline) .wmcf-check + .wmcf-check) {
	margin-top: 8px;
}

:where(.wmcf-choices--inline) {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
}

/* The help line of a group keeps a row of its own above options side by side. */
:where(.wmcf-choices--inline > .wmcf-info) {
	flex-basis: 100%;
	margin-bottom: 0;
}

/* Options with a description: the description on its own line, under the option. */
:where(.wmcf-check-text, .wmcf-check-description) {
	display: block;
}

:where(.wmcf-check-description) {
	font-size: 0.875em;
	opacity: 0.75;
}

/* Sliders: the value on the label's line, the help line under it, the two ends under the
   slider. */
:where(.wmcf-field--range) {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	column-gap: 12px;
}

:where(.wmcf-field--range > .wmcf-info, .wmcf-field--range > .wmcf-range, .wmcf-field--range > .wmcf-range-ends, .wmcf-field--range > .wmcf-error) {
	flex-basis: 100%;
}

:where(.wmcf-range) {
	margin: 0;
	cursor: pointer;
}

:where(.wmcf-range-ends) {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 6px;
	font-size: 0.875em;
}

:where(.wmcf-error) {
	margin: 6px 0 0;
	font-size: 0.875em;
}

:where(.wmcf-hint) {
	margin: 6px 0 0;
	font-size: 0.875em;
	opacity: 0.75;
}

:where(.wmcf-file) {
	cursor: pointer;
}

:where(.wmcf-file)::file-selector-button {
	margin-right: 12px;
	font: inherit;
	cursor: pointer;
}

:where(.wmcf-message) {
	margin-bottom: 24px;
}

:where(.wmcf-message > :last-child) {
	margin-bottom: 0;
}

:where(.wmcf-actions) {
	margin-top: 24px;
}

/* A note ("We answer within two working days") on the left, the button on the right. */
:where(.wmcf-actions:has(> .wmcf-note)) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px 24px;
}

:where(.wmcf-note) {
	margin: 0;
}

/* Multi-step forms. Without JavaScript the steps follow each other; with it, one shows. */
:where(.wmcf-progress) {
	display: block;
	width: 100%;
	margin-bottom: 24px;
}

:where(.wmcf-step:not([hidden]) ~ .wmcf-step:not([hidden])) {
	margin-top: 40px;
}

:where(.wmcf-step-title) {
	margin: 0;
}

:where(.wmcf-step-description) {
	margin: 8px 0 0;
}

:where(.wmcf-step > .wmcf-fields) {
	margin-top: 24px;
}

/* Back, the step count, then Continue or the submit button at the end of the line. */
:where(.wmcf-step-nav) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 16px;
}

:where(.wmcf-step-count) {
	margin-inline-end: auto;
}

/* The widget is usually invisible (it only appears when Cloudflare needs a click), so the
   space above the button is split around it. */
:where(.wmcf-turnstile) {
	margin-top: 16px;
}

:where(.wmcf-turnstile + .wmcf-actions) {
	margin-top: 8px;
}

.wmcf-form[aria-busy="true"] .wmcf-submit {
	cursor: progress;
	opacity: 0.7;
}

.wmcf-form [hidden] {
	display: none !important;
}

/* Spam trap: out of sight and out of the tab order. */
.wmcf-hp {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}
