/*
 * Funnelforms runtime. The rules sit in cascade layers: ffx (the form), ffx-strong (the few rules that must
 * win over ffx whatever their selector) and ffx-custom (the form's own CSS, Frontend\Renderer::custom_css()).
 * Theme and page builder CSS (Elementor, Divi, ...) sits outside any layer and would beat every layered rule,
 * so the shield at the end of this file takes it back on the form's own elements (see there).
 * Colours come from the form's tokens (Frontend\StyleTokens); tints mix them with transparency or with
 * the text colour, so they work on light and dark backgrounds alike.
 */
@layer ffx, ffx-strong, ffx-custom;

@layer ffx {
	.ffx-form {
		--ffx-color-primary: #6a30f5;
		--ffx-color-on-primary: #fff;
		--ffx-color-background: #fff;
		--ffx-color-text: #1d1b26;
		--ffx-color-muted: #5f5b6b;
		--ffx-color-border: #d9d6e3;
		--ffx-color-error: #b42318;
		--ffx-color-success: #067647;
		--ffx-font-family: inherit;
		--ffx-radius-card: 12px;
		--ffx-radius-input: 8px;
		--ffx-gap: 12px;
		--ffx-padding: 40px;
		--ffx-font-size: 16px;
		--ffx-shadow: none;
		--ffx-step-animation: none;
		/* Own helpers: accent tint, easing and the resting shadow of answer tiles. */
		--ffx-tint: color-mix(in srgb, var(--ffx-color-primary) 9%, transparent);
		--ffx-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
		/* Outline of fields and answer cards, 3:1 against the background (StyleTokens::field_border()). */
		--ffx-line: var(--ffx-color-field-border, color-mix(in srgb, var(--ffx-color-border) 50%, currentColor));
		--ffx-rest: 0 1px 2px rgb(16 24 40 / 0.06), 0 10px 24px -10px rgb(16 24 40 / 0.18);

		box-sizing: border-box;
		/* Width in the design (token form.width): a number of pixels, or none for the full width. */
		max-width: var(--ffx-max-width, 960px);
		margin: 0 auto;
		padding: var(--ffx-padding);
		/*
		 * Layers: the overlay colour, the background image, then the background colour (a second
		 * colour makes a gradient; without one both ends are the same).
		 */
		background:
			linear-gradient(var(--ffx-color-overlay, transparent), var(--ffx-color-overlay, transparent)),
			var(--ffx-background-image, none) var(--ffx-background-position, center) / var(--ffx-background-size, cover) no-repeat,
			linear-gradient(var(--ffx-background-angle, 160deg), var(--ffx-color-background), var(--ffx-color-background-end, var(--ffx-color-background)));
		color: var(--ffx-color-text);
		font-family: var(--ffx-font-family);
		font-size: var(--ffx-font-size);
		line-height: var(--ffx-line-body, 1.5);
		border: var(--ffx-container-border, 0);
		border-radius: calc(var(--ffx-radius-card) + 6px);
		box-shadow: var(--ffx-shadow);
		scroll-margin-top: 100px;
		-webkit-font-smoothing: antialiased;
		/* Not inherited from a theme's wrapper (capitals and spacing of an Elementor or Divi module). */
		font-style: normal;
		letter-spacing: normal;
		text-indent: 0;
		text-shadow: none;
		text-transform: none;
		word-spacing: normal;
	}

	/* A form with a background of its own is a card that lifts off the page. */
	.ffx-sticky {
		--ffx-shadow: 0 1px 3px rgb(16 24 40 / 0.06), 0 24px 56px -24px rgb(16 24 40 / 0.22);
	}

	/* Native controls (date picker, check boxes) drawn for a dark form (StyleTokens::classes()). */
	.ffx-dark {
		--ffx-rest: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 24px -10px rgb(0 0 0 / 0.6);
		color-scheme: dark;
	}

	/* On a dark form the tiles stand out a little lighter than the card. */
	.ffx-dark .ffx-option {
		background: var(--ffx-color-option, color-mix(in srgb, currentColor 5%, var(--ffx-color-background)));
	}

	.ffx-form *,
	.ffx-form ::before,
	.ffx-form ::after {
		box-sizing: inherit;
	}

	:where(.ffx-form) :is(button, input, select, textarea) {
		margin: 0;
		color: inherit;
		font: inherit;
		letter-spacing: inherit;
	}

	:where(.ffx-form) button {
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}

	/* Over every display rule of the form, e.g. the grid of the bottom bar on wide screens. */
	.ffx-form [hidden] {
		display: none !important;
	}

	.ffx-form :focus-visible {
		outline: 3px solid var(--ffx-color-primary);
		outline-offset: 2px;
	}

	.ffx-required {
		color: var(--ffx-color-error);
	}

	.ffx-required-note {
		margin: -12px 0 0;
		color: var(--ffx-color-muted);
		font-size: 0.75em;
		text-align: center;
	}

	.ffx-sr-only {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
		border: 0;
	}

	/* Layout of the form and its steps */
	.ffx-shell,
	.ffx-step,
	.ffx-contact,
	.ffx-field,
	.ffx-slider,
	.ffx-success,
	.ffx-payment,
	.ffx-loader {
		display: flex;
		flex-direction: column;
	}

	.ffx-shell {
		gap: 20px;
	}

	.ffx-step {
		gap: 36px;
	}

	.ffx-contact {
		gap: 18px;
	}

	/* Steps and the end come in with the form's transition; back, sideways ones come from the other side. */
	.ffx-step,
	.ffx-contact,
	.ffx-success {
		--ffx-dir: 1;
		animation: var(--ffx-step-animation);
	}

	.ffx-back > * {
		--ffx-dir: -1;
	}

	@keyframes ffx-fade {
		from {
			opacity: 0;
		}
	}

	@keyframes ffx-slide {
		from {
			opacity: 0;
			transform: translateX(calc(var(--ffx-dir) * 24px));
		}
	}

	@keyframes ffx-fade-right {
		from {
			opacity: 0;
			transform: translateX(calc(var(--ffx-dir) * -32px));
		}
	}

	@keyframes ffx-back-in-right {
		from {
			opacity: 0.6;
			transform: translateX(calc(var(--ffx-dir) * 80px)) scale(0.85);
		}
	}

	@keyframes ffx-up {
		from {
			opacity: 0;
			transform: translateY(24px);
		}
	}

	@keyframes ffx-zoom {
		from {
			opacity: 0;
			transform: scale(0.94);
		}
	}

	/* Headings: form heading, questions, contact step, thank-you page */
	/* Headings: their size and spacing as variables, which the rules outside the layer apply. */
	.ffx-heading,
	.ffx-question,
	.ffx-contact-title,
	.ffx-success-heading {
		--ffx-hs: var(--ffx-font-size-heading, 1.75em);
		padding: 0;
		text-align: var(--ffx-text-align, center);
		text-wrap: balance;
	}

	.ffx-heading,
	.ffx-success-heading {
		--ffx-hs: calc(var(--ffx-font-size-heading, 1.75em) * 1.15);
	}

	/* Several fields in a step: their questions are labels, a size below the step's. */
	.ffx-step:has(> .ffx-field + .ffx-field) .ffx-question {
		--ffx-hs: calc(var(--ffx-font-size-heading, 1.75em) * 0.64);
		--ffx-hw: 600;
	}

	.ffx-step:has(> .ffx-field + .ffx-field) {
		gap: 24px;
	}

	.ffx-field {
		gap: 10px;
		min-width: 0;
		margin: 0;
		padding: 0;
		border: 0;
	}

	/* 6px more to the answers; a legend takes no part in the field's flex gap. */
	.ffx-question {
		--ffx-hm: 6px;
	}

	legend.ffx-question {
		--ffx-hm: 24px;
	}

	/* At most 40em wide, centred or at the side of the questions (align.text: --ffx-description-inline). */
	.ffx-description {
		max-width: 40em;
		margin: 0 auto 8px;
		margin-inline: var(--ffx-description-inline, auto);
		color: var(--ffx-color-muted);
		text-align: var(--ffx-text-align, center);
		text-wrap: pretty;
	}

	legend + .ffx-description {
		margin-top: -14px;
	}

	.ffx-description:empty {
		display: none;
	}

	.ffx-label {
		padding: 0;
		font-size: 0.9375em;
		font-weight: 600;
	}

	/* Answer tiles: the icon or image above the text, a mark when chosen. */
	.ffx-options {
		--ffx-cols: var(--ffx-auto, 3);
		--ffx-tile: 150px;
		display: grid;
		/* All tiles in one row when each gets 150px, otherwise half as many per row, never under 130px. */
		grid-template-columns: repeat(auto-fit, minmax(max(130px, clamp((100% - (var(--ffx-cols) - 1) * var(--ffx-gap)) / var(--ffx-cols), (var(--ffx-cols) * (var(--ffx-tile) + var(--ffx-gap)) - var(--ffx-gap) - 100%) * 999, (100% - (var(--ffx-half, 2) - 1) * var(--ffx-gap)) / var(--ffx-half, 2))), 1fr));
		gap: var(--ffx-gap);
	}

	.ffx-option {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		/* From the top, so the icons of a row stay level when one label wraps onto two lines. */
		justify-content: flex-start;
		gap: 14px;
		min-width: 0;
		min-height: 64px;
		padding: 26px 16px 22px;
		background: var(--ffx-color-option, var(--ffx-color-background));
		font-family: var(--ffx-font-field, inherit);
		font-size: var(--ffx-font-size-field, 1em);
		font-weight: 600;
		line-height: 1.3;
		text-align: center;
		overflow-wrap: break-word;
		-webkit-hyphens: auto;
		hyphens: auto;
		border: var(--ffx-border-width, 1px) var(--ffx-border-style, solid) var(--ffx-line);
		border-radius: var(--ffx-radius-card);
		box-shadow: var(--ffx-rest);
		cursor: pointer;
		transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s, transform 0.25s var(--ffx-ease);
	}

	@media (hover: hover) {
		.ffx-option:not(.is-disabled, .is-revealed *):hover {
			border-color: color-mix(in srgb, var(--ffx-color-primary) 55%, var(--ffx-line));
			box-shadow: 0 4px 8px -4px rgb(16 24 40 / 0.1), 0 20px 36px -14px rgb(16 24 40 / 0.3);
			transform: translateY(-4px);
		}
	}

	.ffx-option:active {
		transform: scale(0.98);
	}

	.ffx-options .ffx-option[aria-pressed="true"],
	.ffx-options .ffx-option:has(:checked) {
		background: var(--ffx-color-option-selected, color-mix(in srgb, var(--ffx-color-primary) 7%, var(--ffx-color-option, var(--ffx-color-background))));
		border-color: var(--ffx-color-primary);
		box-shadow: 0 0 0 1px var(--ffx-color-primary), 0 12px 28px -14px color-mix(in srgb, var(--ffx-color-primary) 80%, transparent);
	}

	/* Multiple choice: the box is hidden but focusable; the tile shows its state. */
	.ffx-option input {
		position: absolute;
		opacity: 0;
		pointer-events: none;
	}

	.ffx-option:has(:focus-visible) {
		outline: 3px solid var(--ffx-color-primary);
		outline-offset: 2px;
	}

	/* The mark: a tick in a circle once chosen; an empty box where several answers may be ticked. */
	.ffx-option::after {
		position: absolute;
		inset-block-start: 12px;
		inset-inline-end: 12px;
		display: grid;
		place-items: center;
		width: 24px;
		height: 24px;
		color: var(--ffx-color-on-primary);
		background: var(--ffx-color-primary);
		font: 700 13px/1 system-ui, sans-serif;
		border: 2px solid var(--ffx-color-primary);
		border-radius: 50%;
		transform: scale(0);
		transition: transform 0.25s var(--ffx-ease);
		/* Marks drawn by CSS are not read out (alternative text ""); browsers without that syntax keep the first line. */
		content: "✓";
		content: "✓" / "";
	}

	label.ffx-option::after {
		color: inherit;
		background: var(--ffx-color-background);
		border-color: color-mix(in srgb, currentColor 30%, transparent);
		border-radius: 6px;
		transform: none;
		content: "";
	}

	.ffx-option[aria-pressed="true"]::after,
	.ffx-option:has(:checked)::after {
		color: var(--ffx-color-on-primary);
		background: var(--ffx-color-primary);
		border-color: var(--ffx-color-primary);
		transform: none;
		content: "✓";
		content: "✓" / "";
	}

	/* Icons in a soft circle that fills with the accent once chosen. */
	.ffx-option-icon {
		display: inline-grid;
		flex: none;
		place-items: center;
		width: 1.75em;
		height: 1.75em;
		color: var(--ffx-color-icon, var(--ffx-color-primary));
		background: linear-gradient(150deg, color-mix(in srgb, var(--ffx-color-icon, var(--ffx-color-primary)) 20%, transparent), color-mix(in srgb, var(--ffx-color-icon, var(--ffx-color-primary)) 8%, transparent));
		font-size: var(--ffx-icon-size, 48px);
		line-height: 1;
		border-radius: 50%;
		transition: color 0.2s, background-color 0.2s;
	}

	[aria-pressed="true"] > .ffx-option-icon,
	:checked ~ .ffx-option-icon {
		color: var(--ffx-color-on-primary);
		background: var(--ffx-color-icon, var(--ffx-color-primary));
	}

	/* Line icons get a soft fill in their own colour: a duotone look. */
	.ffx-option-svg svg {
		width: 1em;
		height: 1em;
		fill: color-mix(in srgb, currentColor 22%, transparent);
		stroke-width: 1.75;
	}

	.ffx-option-media {
		max-width: 100%;
		max-height: var(--ffx-icon-size, 96px);
		object-fit: contain;
		border-radius: calc(var(--ffx-radius-card) * 0.5);
	}

	.ffx-hide-icons :is(.ffx-option-media, .ffx-option-icon) {
		display: none;
	}

	/* Rows: icon at the side, the mark at the end. */
	.ffx-icon-left .ffx-option,
	.ffx-icon-right .ffx-option {
		flex-direction: row;
		justify-content: flex-start;
		padding-block: 14px;
		padding-inline: 16px 44px;
		text-align: start;
	}

	.ffx-icon-right .ffx-option {
		flex-direction: row-reverse;
		justify-content: flex-end;
	}

	.ffx-icon-right .ffx-option-label {
		flex: 1;
	}

	/* A label stays inside its tile: long words (Mehrfamilienhaus) are hyphenated, or broken where the browser cannot. */
	.ffx-option-label {
		max-width: 100%;
	}

	.ffx-icon-left .ffx-option::after,
	.ffx-icon-right .ffx-option::after {
		inset-block-start: calc(50% - 11px);
	}

	.ffx-icon-left .ffx-option-icon,
	.ffx-icon-right .ffx-option-icon {
		font-size: min(var(--ffx-icon-size, 22px), 32px);
	}

	@media (min-width: 769px) {
		.ffx-desktop-list,
		.ffx-columns.ffx-desktop-list {
			grid-template-columns: 1fr;
		}

		.ffx-desktop-list2 {
			grid-template-columns: repeat(2, minmax(0, 1fr));
		}

		/* Answers per row, chosen in the builder */
		.ffx-desktop-grid.ffx-columns {
			grid-template-columns: repeat(var(--ffx-columns), minmax(0, 1fr));
		}

		:is(.ffx-desktop-list, .ffx-desktop-list2) .ffx-option {
			flex-direction: row;
			justify-content: flex-start;
			padding-block: 14px;
			padding-inline: 16px 44px;
			text-align: start;
		}

		:is(.ffx-desktop-list, .ffx-desktop-list2) .ffx-option::after {
			inset-block-start: calc(50% - 11px);
		}

		:is(.ffx-desktop-list, .ffx-desktop-list2) .ffx-option-icon {
			font-size: min(var(--ffx-icon-size, 22px), 32px);
		}
	}

	.ffx-icon-bottom .ffx-option {
		flex-direction: column-reverse;
	}

	.ffx-size-s .ffx-option {
		min-height: 44px;
		padding-block: 10px;
	}

	.ffx-size-l .ffx-option {
		min-height: 96px;
		padding-block: 30px;
	}

	.ffx-image-full .ffx-option {
		padding: var(--ffx-image-inset, 8px) 12px 16px;
	}

	.ffx-image-full .ffx-option-media {
		width: calc(100% + 24px - 2 * var(--ffx-image-inset, 8px));
		max-width: none;
		max-height: none;
		aspect-ratio: 4 / 3;
		object-fit: cover;
	}

	.ffx-image-square .ffx-option-media {
		aspect-ratio: 1;
	}

	.ffx-image-wide .ffx-option-media {
		aspect-ratio: 16 / 9;
	}

	/* As uploaded: the whole image, never cut. */
	.ffx-image-auto .ffx-option-media {
		aspect-ratio: auto;
		height: auto;
		object-fit: contain;
	}

	.ffx-option.is-disabled {
		cursor: not-allowed;
		opacity: 0.5;
	}

	/* Inputs */
	.ffx-input {
		width: 100%;
		min-height: 52px;
		padding: 12px 16px;
		background: var(--ffx-color-background);
		font-family: var(--ffx-font-field, inherit);
		font-size: var(--ffx-font-size-field, inherit);
		border: var(--ffx-border-width, 1px) var(--ffx-border-style, solid) var(--ffx-line);
		border-radius: var(--ffx-radius-input);
		box-shadow: 0 1px 2px rgb(16 24 40 / 0.05);
		text-overflow: ellipsis;
		transition: border-color 0.15s, box-shadow 0.15s;
	}

	.ffx-input::placeholder {
		color: var(--ffx-color-muted);
		opacity: 0.8;
	}

	.ffx-input:hover {
		border-color: color-mix(in srgb, currentColor 35%, var(--ffx-line));
	}

	/* Fields show focus with the accent border and a soft ring; the transparent outline is for forced colours. */
	.ffx-form .ffx-input:focus {
		border-color: var(--ffx-color-primary);
		outline: 2px solid transparent;
		box-shadow: 0 0 0 4px color-mix(in srgb, var(--ffx-color-primary) 22%, transparent);
	}

	.ffx-invalid .ffx-input,
	.ffx-form .ffx-invalid .ffx-input:focus {
		border-color: var(--ffx-color-error);
		box-shadow: 0 0 0 4px color-mix(in srgb, var(--ffx-color-error) 15%, transparent);
	}

	textarea.ffx-input {
		min-height: 128px;
		resize: vertical;
	}

	/* Lists get their own arrow, a small triangle. */
	select.ffx-input,
	.ffx-pick-toggle {
		padding-inline-end: 44px;
		background:
			linear-gradient(45deg, transparent 50%, currentColor 50%) calc(100% - 21px) 55% / 5px 5px no-repeat,
			linear-gradient(-45deg, transparent 50%, currentColor 50%) calc(100% - 16px) 55% / 5px 5px no-repeat,
			var(--ffx-color-background);
		appearance: none;
	}

	[dir="rtl"] :is(select.ffx-input, .ffx-pick-toggle) {
		background-position: 21px 55%, 16px 55%, 0 0;
	}

	/* A list with nothing chosen looks like an empty input. */
	.ffx-select:has(option[value=""]:checked) {
		color: var(--ffx-color-muted);
	}

	.ffx-contact :is(input, select).ffx-input {
		min-height: var(--ffx-input-height, 52px);
	}

	.ffx-input-wrap {
		position: relative;
	}

	.ffx-has-icon .ffx-input {
		padding-inline-start: 46px;
	}

	.ffx-input-icon {
		position: absolute;
		inset-block: 0;
		inset-inline-start: 16px;
		display: flex;
		align-items: center;
		color: var(--ffx-color-muted);
		pointer-events: none;
	}

	.ffx-input-wrap:focus-within .ffx-input-icon {
		color: var(--ffx-color-primary);
	}

	.ffx-input-svg svg {
		width: 18px;
		height: 18px;
	}

	/* Number with unit */
	.ffx-number {
		display: flex;
		align-items: center;
		gap: 10px;
	}

	.ffx-unit {
		color: var(--ffx-color-muted);
		font-weight: 600;
		white-space: nowrap;
	}

	/* Native boxes in the accent colour */
	.ffx-form :is([type="checkbox"], [type="radio"]) {
		flex: none;
		width: 20px;
		height: 20px;
		accent-color: var(--ffx-color-primary);
	}

	/*
	 * Consent and checkbox fields of the contact step: the box beside its text, centred on the first
	 * line (half a line of the text minus half the box), also when the text runs over several lines.
	 * Every contact step may have one, so this sits here and not in runtime-more.css: until 5.0.7 the
	 * box stood right at the text and too high in forms that do not load that sheet (forms from 3.x).
	 */
	.ffx-consent {
		display: flex;
		align-items: flex-start;
		gap: 12px;
		font-size: 0.9375em;
	}

	.ffx-consent input {
		margin: calc(var(--ffx-line-body, 1.5) * 0.5em - 10px) 0 0;
		font-size: inherit;
	}

	/*
	 * Links in texts (consent, content steps, descriptions, HTML fields) in the form's colour. The
	 * shield sets links back to the browser's blue where no rule of the layers names a colour; :where()
	 * keeps this below every rule of a link with a class of its own (downloads, buttons, language links).
	 */
	:where(.ffx-form) a {
		color: var(--ffx-color-primary);
	}

	/* Content steps */
	.ffx-content {
		overflow-wrap: anywhere;
	}

	.ffx-content > :first-child {
		margin-top: 0;
	}

	.ffx-content > :last-child {
		margin-bottom: 0;
	}

	.ffx-content img,
	.ffx-content iframe {
		max-width: 100%;
	}

	.ffx-summary {
		margin: 12px 0;
		padding: 4px 16px;
		list-style: none;
		border: 1px solid var(--ffx-color-border);
		border-radius: var(--ffx-radius-card);
	}

	.ffx-summary li {
		display: flex;
		justify-content: space-between;
		gap: 16px;
		padding: 10px 0;
	}

	.ffx-summary li + li {
		border-top: 1px solid color-mix(in srgb, currentColor 10%, transparent);
	}

	.ffx-summary span {
		color: var(--ffx-color-muted);
	}

	.ffx-summary strong {
		text-align: end;
	}

	/* Buttons */
	.ffx-button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: 10px;
		min-height: 48px;
		padding: var(--ffx-button-padding, 12px) calc(var(--ffx-button-padding, 12px) * 2);
		background: transparent;
		font-weight: 600;
		line-height: 1.2;
		text-decoration: none;
		border: 1px solid var(--ffx-line);
		border-radius: var(--ffx-radius-button, var(--ffx-radius-input));
		transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s var(--ffx-ease), filter 0.2s;
	}

	.ffx-button-primary {
		color: var(--ffx-color-on-button, var(--ffx-color-on-primary));
		background: var(--ffx-color-button, var(--ffx-color-primary));
		border-color: var(--ffx-color-button, var(--ffx-color-primary));
		box-shadow: 0 1px 2px rgb(16 24 40 / 0.1), 0 6px 16px -6px color-mix(in srgb, var(--ffx-color-button, var(--ffx-color-primary)) 70%, transparent);
	}

	@media (hover: hover) {
		.ffx-button-primary:not(:disabled):hover {
			filter: brightness(0.93);
			box-shadow: 0 1px 2px rgb(16 24 40 / 0.1), 0 10px 22px -8px color-mix(in srgb, var(--ffx-color-button, var(--ffx-color-primary)) 80%, transparent);
			transform: translateY(-1px);
		}

		.ffx-button:not(.ffx-button-primary):not(:disabled):hover {
			background: color-mix(in srgb, currentColor 6%, var(--ffx-color-back, transparent));
		}
	}

	.ffx-button:not(:disabled):active {
		transform: scale(0.98);
	}

	.ffx-button-back {
		color: var(--ffx-color-on-back, var(--ffx-color-muted));
		background: var(--ffx-color-back, transparent);
		border-color: transparent;
	}

	/* Back and Next as pills, like the arrows of Funnelforms 3; Next filled with the accent. */
	.ffx-nav > .ffx-button,
	.ffx-button-submit {
		min-height: 52px;
		padding-inline: 28px;
		border-radius: var(--ffx-radius-button, 999px);
	}

	.ffx-nav > .ffx-button-back {
		padding-inline: 18px 22px;
		background: var(--ffx-color-back, color-mix(in srgb, currentColor 7%, transparent));
	}

	.ffx-button:disabled {
		opacity: 0.6;
		cursor: wait;
	}

	/* Arrows drawn with borders, mirrored right to left. */
	.ffx-button-next::after,
	.ffx-content-button::after,
	.ffx-button-back::before {
		flex: none;
		width: 8px;
		height: 8px;
		border: solid currentColor;
		border-width: 2px 2px 0 0;
		transform: rotate(45deg);
		content: "";
	}

	.ffx-button-back::before,
	[dir="rtl"] .ffx-button-next::after,
	[dir="rtl"] .ffx-content-button::after {
		transform: rotate(-135deg);
	}

	[dir="rtl"] .ffx-button-back::before {
		transform: rotate(45deg);
	}

	.ffx-content-button,
	.ffx-button-submit {
		align-self: center;
		min-width: min(100%, 240px);
	}

	.ffx-button-submit {
		min-height: 54px;
		margin-top: 6px;
		font-size: 1.0625em;
	}

	/* Busy: a small spinner in the button that sends. */
	[aria-busy="true"] .ffx-button-submit::before {
		width: 16px;
		height: 16px;
		border: 2px solid;
		border-right-color: transparent;
		border-radius: 50%;
		animation: ffx-spin 0.7s linear infinite;
		content: "";
	}

	.ffx-contact > * {
		grid-column: 1 / -1;
	}

	.ffx-contact > :is(.ffx-contact-name, .ffx-contact-email, .ffx-contact-phone, .ffx-contact-text, .ffx-contact-select) {
		grid-column: auto;
	}

	.ffx-contact-title + .ffx-description {
		margin-top: -10px;
	}

	.ffx-submit-left > .ffx-button-submit {
		align-self: flex-start;
		justify-self: start;
	}

	.ffx-submit-center > .ffx-button-submit {
		justify-self: center;
	}

	.ffx-submit-right > .ffx-button-submit {
		align-self: flex-end;
		justify-self: end;
	}

	.ffx-submit-full > .ffx-button-submit {
		align-self: stretch;
	}

	.ffx-submit-s > .ffx-button-submit {
		min-height: 40px;
		padding: 6px 16px;
		font-size: 0.875em;
	}

	.ffx-submit-l > .ffx-button-submit {
		min-height: 60px;
		padding: 14px 40px;
		font-size: 1.125em;
	}

	/* Contact step in two columns: short fields side by side, everything else across. */
	@media (min-width: 769px) {
		.ffx-contact.ffx-contact-columns {
			display: grid;
			grid-template-columns: repeat(2, minmax(0, 1fr));
		}
	}

	/*
	 * The bottom bar: Back, the progress with "Step 2 of 5", Next. On wide screens in one row, the
	 * progress in the middle whether or not the buttons show; stacked with the progress on top where
	 * the buttons sit together (button.align) or the screen is narrow.
	 */
	.ffx-nav {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: var(--ffx-button-align, space-between);
		gap: 14px var(--ffx-gap);
		padding-top: 20px;
		border-top: 1px solid color-mix(in srgb, currentColor 10%, transparent);
	}

	.ffx-nav > .ffx-button {
		flex: var(--ffx-button-flex, 0 1 auto);
	}

	.ffx-button-next {
		margin-inline-start: var(--ffx-next-margin, auto);
	}

	.ffx-progress-row {
		display: flex;
		flex: 1 0 100%;
		flex-direction: column;
		gap: 8px;
		order: -1;
		min-width: 0;
	}

	.ffx-progress-meta {
		display: flex;
		justify-content: space-between;
		gap: 12px;
		color: var(--ffx-color-muted);
		font-size: 0.8125em;
		font-weight: 600;
		font-variant-numeric: tabular-nums;
	}

	.ffx-progress-step {
		color: var(--ffx-color-text);
	}

	.ffx-progress {
		height: 8px;
		overflow: hidden;
		background: var(--ffx-color-progress-track, color-mix(in srgb, currentColor 11%, transparent));
		border-radius: 99px;
	}

	.ffx-progress-bar {
		width: 0;
		min-width: 8px;
		height: 100%;
		background: var(--ffx-color-progress, var(--ffx-color-primary)) linear-gradient(90deg, transparent 30%, rgb(255 255 255 / 0.35));
		border-radius: inherit;
		transition: width 0.6s var(--ffx-ease);
	}

	@media (min-width: 769px) {
		.ffx-form:not(.ffx-stack) .ffx-nav {
			display: grid;
			grid-template-columns: auto minmax(0, 1fr) auto;
			gap: 12px 28px;
		}

		.ffx-form:not(.ffx-stack) .ffx-button-back {
			grid-area: 1 / 1;
			justify-self: start;
		}

		.ffx-form:not(.ffx-stack) .ffx-progress-row {
			grid-area: 1 / 2;
		}

		/* Without Back or Next the bar takes their place. */
		.ffx-form:not(.ffx-stack) [hidden] + .ffx-progress-row {
			grid-column-start: 1;
		}

		.ffx-form:not(.ffx-stack) .ffx-progress-row:has(+ [hidden]) {
			grid-column-end: 4;
		}

		.ffx-form:not(.ffx-stack) .ffx-button-next {
			grid-area: 1 / 3;
			justify-self: end;
		}
	}

	/* Errors: next to the field with a mark, and for the whole form as a notice. */
	.ffx-error {
		display: flex;
		align-items: center;
		gap: 8px;
		margin: 0;
		color: var(--ffx-color-error);
		font-size: 0.875em;
		font-weight: 600;
	}

	.ffx-error::before {
		display: grid;
		flex: none;
		place-items: center;
		width: 18px;
		height: 18px;
		color: #fff;
		background: var(--ffx-color-error);
		font: 700 12px/1 system-ui, sans-serif;
		border-radius: 50%;
		content: "!";
		content: "!" / "";
	}

	.ffx-form-error {
		justify-content: center;
		padding: 12px 16px;
		background: color-mix(in srgb, var(--ffx-color-error) 9%, transparent);
		border-radius: var(--ffx-radius-input);
	}

	/* Thank-you page */
	.ffx-success,
	.ffx-payment {
		position: relative;
		align-items: center;
		gap: 16px;
		padding: 16px 0 8px;
		text-align: center;
	}

	.ffx-success-image {
		max-width: 100%;
		height: auto;
		border-radius: var(--ffx-radius-card);
	}

	.ffx-success-heading {
		text-align: center;
	}

	.ffx-success-text {
		max-width: 36em;
		color: var(--ffx-color-muted);
	}

	/* Lists ("What happens now") stay a centred block with their numbers next to the lines. */
	.ffx-success-text :is(ol, ul) {
		display: inline-block;
		text-align: start;
	}

	.ffx-success-check {
		width: 80px;
		height: 80px;
		padding: 10px;
		background: var(--ffx-tint);
		border-radius: 50%;
		stroke: var(--ffx-color-primary);
		stroke-width: 3;
		stroke-linecap: round;
		stroke-linejoin: round;
	}

	.ffx-success-check circle {
		stroke-dasharray: 151;
		stroke-dashoffset: 151;
		animation: ffx-draw 0.6s ease-out forwards;
	}

	.ffx-success-check path {
		stroke-dasharray: 36;
		stroke-dashoffset: 36;
		animation: ffx-draw 0.35s 0.5s ease-out forwards;
	}

	@keyframes ffx-draw {
		to {
			stroke-dashoffset: 0;
		}
	}

	.ffx-success-answers {
		width: 100%;
		max-width: 520px;
		text-align: start;
	}

	.ffx-success-answers dl {
		display: grid;
		grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
		gap: 8px 16px;
		margin: 0;
		padding: 14px 18px;
		border: 1px solid var(--ffx-color-border);
		border-radius: var(--ffx-radius-card);
	}

	.ffx-success-answers dt {
		color: var(--ffx-color-muted);
	}

	.ffx-success-answers dd {
		margin: 0;
		font-weight: 600;
		overflow-wrap: anywhere;
	}

	.ffx-redirect-note,
	.ffx-preview-note {
		margin: 16px 0 0;
		color: var(--ffx-color-muted);
		font-size: 0.9em;
		text-align: center;
		overflow-wrap: anywhere;
	}

	.ffx-redirect-now {
		color: var(--ffx-color-primary);
	}

	@keyframes ffx-spin {
		to {
			transform: rotate(360deg);
		}
	}

	/* Image or video of a content step */
	.ffx-media {
		width: var(--ffx-media-width, 100%);
		max-width: 100%;
		margin: 0 auto;
	}

	.ffx-media-image,
	.ffx-media-video {
		display: block;
		width: 100%;
		height: auto;
		border: 0;
		border-radius: var(--ffx-radius-card);
	}

	.ffx-media-caption {
		margin-top: 8px;
		color: var(--ffx-color-muted);
		font-size: 0.875em;
		text-align: center;
	}

	.ffx-loading .ffx-card {
		opacity: 0.6;
		transition: opacity 0.2s;
	}

	/* Honeypot: off screen, not display:none, so simple bots still fill it. */
	.ffx-hp {
		position: absolute;
		left: -10000px;
		width: 1px;
		height: 1px;
		overflow: hidden;
	}

	.ffx-closed-message {
		text-align: center;
	}

	/* Phones */
	@media (max-width: 768px) {
		.ffx-form {
			padding: min(var(--ffx-padding), 24px) min(var(--ffx-padding), 16px);
			font-size: var(--ffx-font-size-mobile, var(--ffx-font-size));
		}

		.ffx-step {
			gap: 28px;
		}

		.ffx-question,
		.ffx-contact-title {
			--ffx-hs: var(--ffx-font-size-heading-mobile, var(--ffx-font-size-heading, 1.375em));
		}

		.ffx-option,
		.ffx-input {
			font-size: var(--ffx-font-size-field-mobile, var(--ffx-font-size-field, inherit));
		}

		.ffx-option {
			padding: 18px 12px;
		}

		.ffx-option-media {
			max-height: var(--ffx-icon-size-mobile, var(--ffx-icon-size, 96px));
		}

		.ffx-option-icon {
			font-size: var(--ffx-icon-size-mobile, var(--ffx-icon-size, 36px));
		}

		.ffx-mobile-grid {
			grid-template-columns: repeat(2, minmax(0, 1fr));
		}

		.ffx-mobile-grid.ffx-columns-mobile {
			grid-template-columns: repeat(var(--ffx-columns-mobile), minmax(0, 1fr));
		}

		.ffx-mobile-list {
			grid-template-columns: 1fr;
		}

		.ffx-mobile-list .ffx-option {
			flex-direction: row;
			justify-content: flex-start;
			min-height: 60px;
			padding-block: 12px;
			padding-inline: 14px 44px;
			text-align: start;
		}

		.ffx-mobile-list .ffx-option::after {
			inset-block-start: calc(50% - 11px);
		}

		.ffx-mobile-list .ffx-option-icon {
			font-size: min(var(--ffx-icon-size-mobile, 28px), 32px);
		}

		.ffx-contact.ffx-contact-columns-mobile {
			display: grid;
			grid-template-columns: repeat(2, minmax(0, 1fr));
		}

		.ffx-nav .ffx-button-next,
		.ffx-button-submit {
			flex: var(--ffx-button-flex, 1 1 auto);
			align-self: stretch;
		}

		/*
		 * The bar stays at the bottom of the screen while the form is in view, as long as it holds the
		 * step's Next button. Without it (a choice that moves on by itself, a step with a button of its
		 * own like the contact step) it would only cover the step: the consent and the submit button.
		 */
		.ffx-sticky .ffx-nav:has(> .ffx-button-next:not([hidden])) {
			position: sticky;
			bottom: 0;
			z-index: 3;
			margin-inline: calc(-1 * min(var(--ffx-padding), 16px));
			padding: 12px min(var(--ffx-padding), 16px) max(12px, env(safe-area-inset-bottom));
			background: var(--ffx-color-background-end, var(--ffx-color-background));
			box-shadow: 0 -10px 24px -16px rgb(16 24 40 / 0.3);
		}
	}

	@media (prefers-reduced-motion: reduce) {
		.ffx-form *,
		.ffx-form ::after {
			transition: none;
		}

		.ffx-form :is(.ffx-option, .ffx-button, .ffx-rating-option) {
			transform: none !important;
		}

		.ffx-step,
		.ffx-contact,
		.ffx-success {
			animation: none;
		}

		.ffx-success-check :is(circle, path) {
			animation: none;
			stroke-dashoffset: 0;
		}
	}
}

/* No page scrolling behind an open popup. */
html:has(.ffx-popup[open]) {
	overflow: hidden;
}

/*
 * Rules that win over the layer ffx whatever its selectors, and still lose to the form's own CSS
 * (ffx-custom). Until 5.0.4 they sat outside the layers to beat theme CSS; the shield below does that now.
 */
@layer ffx-strong {
	/* Headings look the same on every theme. Sizes come from the layer ffx (--ffx-hs). */
	.ffx-form :is(.ffx-heading, .ffx-question, .ffx-contact-title, .ffx-success-heading) {
		margin: 0 0 var(--ffx-hm, 0);
		color: var(--ffx-color-heading, inherit);
		font-family: var(--ffx-font-heading, inherit);
		font-size: var(--ffx-hs);
		font-style: normal;
		font-weight: var(--ffx-hw, var(--ffx-font-weight-heading, 700));
		line-height: var(--ffx-line-heading, 1.25);
		letter-spacing: -0.01em;
		text-transform: none;
	}

	/* The heading above every step (settings.heading) may have a colour of its own, as in 3.x. */
	.ffx-form .ffx-heading {
		color: var(--ffx-color-form-heading, var(--ffx-color-heading, inherit));
	}

	.ffx-form .ffx-success-answers h3 {
		margin: 0 0 8px;
		font-size: 1em;
		font-weight: 700;
		letter-spacing: normal;
	}

	/*
	 * Headings, steps and the success text get focus from the script (tabindex -1), never from the
	 * keyboard: no ring, also not the one of :focus-visible in the layer ffx.
	 */
	.ffx-form [tabindex="-1"]:focus {
		outline: none;
	}

	/* Links drawn as buttons (login, success button) keep the button's colours. */
	.ffx-form a.ffx-button-primary,
	.ffx-form a.ffx-button-primary:is(:visited, :hover, :focus) {
		color: var(--ffx-color-on-button, var(--ffx-color-on-primary));
		text-decoration: none;
	}
}

/*
 * Icon font glyphs (3.x forms, settings.iconFont): Font Awesome sets display: inline-block outside a layer,
 * which beat every display of the layer. Answer icons were not centred in their circle and showed although
 * the question hides its icons; icons in contact inputs sat in the top corner of the input. They take the
 * layer's display again: centred, hidden with "hide icons", hidden beside a country picker.
 */
.ffx-form i:is(.ffx-option-icon, .ffx-input-icon) {
	display: revert-layer;
}

/*
 * Shield against theme and page builder CSS. Their rules sit outside any layer, so each of them beat
 * every rule above, however specific: Elementor's kit (post-<id>.css) gave answer tiles and buttons
 * its button colours, paddings and capitals, Divi gave lists of the form bullets, indents and 23px
 * below. On the form's own elements this rule sets every property back to what the layers say
 * (revert-layer: the layer ffx, ffx-strong and the form's own CSS in ffx-custom); where they say
 * nothing, the browser's default applies as on a page without theme CSS. :not() with two IDs makes
 * it more specific than theme selectors (Divi's #page-container, #et-boc .et-l). Theme rules with
 * !important still win, and so do inline styles of the script.
 * Left out: icon font glyphs (<i>, styled by Font Awesome outside a layer) and the parts of SVG icons.
 *
 * The form's own box: themes with a CSS reset on div (OceanWP: div { padding: 0; font: inherit;
 * font-size: 100% }) took its inner spacing, its font and its font size (14px of the theme instead of
 * the form's 16px). Here the look goes back to the layers, while where the box sits stays the theme's
 * and the page builder's (margins, width, display and position of the content column).
 */
:is(.ffx-form, .ffx-popup):not(#ffx-shield#ffx-shield) {
	padding: revert-layer;
	border: revert-layer;
	border-radius: revert-layer;
	background: revert-layer;
	box-shadow: revert-layer;
	box-sizing: revert-layer;
	color: revert-layer;
	font: revert-layer;
	letter-spacing: revert-layer;
	word-spacing: revert-layer;
	text-align: revert-layer;
	text-indent: revert-layer;
	text-transform: revert-layer;
	text-decoration: revert-layer;
	text-shadow: revert-layer;
	vertical-align: revert-layer;
}

:is(.ffx-form, .ffx-popup):not(#ffx-shield#ffx-shield) :not(i, svg, svg *),
:is(.ffx-form, .ffx-popup):not(#ffx-shield#ffx-shield) :not(i, svg, svg *)::before,
:is(.ffx-form, .ffx-popup):not(#ffx-shield#ffx-shield) :not(i, svg, svg *)::after,
:is(.ffx-form, .ffx-popup):not(#ffx-shield#ffx-shield) :is(input, textarea)::placeholder,
.ffx-widget:not(#ffx-shield#ffx-shield) {
	all: revert-layer;
}
