/**
 * FluentForm styling mapped onto the theme's tokens; enqueued only when the "consistent styling" toggle is on.
 * Button rules prefer the theme's --amrf-button-* variables over generic preset colors.
 */
:root {
	--fluentform-primary: var(--amrf-form-primary);
	--fluentform-secondary: var(--amrf-form-secondary);
	--fluentform-danger: var(--amrf-danger-color);
	--fluentform-border-color: var(--amrf-input-border-color);
	--fluentform-hover-surface: var(--amrf-button-hover-background);
	--fluentform-border-radius: var(--amrf-button-border-radius);
}

/**
 * FluentForm hardcodes a system font on its controls and sets no font-size, so both inherit explicitly.
 */
.fluentform .ff-el-form-control {
	background: var(--amrf-input-background);
	font-family: inherit;
	font-size: inherit;
}

/** Fallback for the block editor preview, where FluentForm's own inline reset on this <fieldset> gets stripped. */
.fluentform fieldset {
	--focus-ring-color: var(--amrf-focus-ring-color);
	margin: 0;
	border: none;
	padding: 0;
}

/** Same editor-preview fallback, for this screen-reader-only <legend>'s inline height:0 reset. */
.ff_screen_reader_title {
	height: 0;
	overflow: hidden;
}

/**
 * Only Firefox honors :hover on <option> — Chromium/WebKit render the
 * dropdown's own native popup and ignore page CSS for its row highlight.
 */
select.ff-el-form-control option:hover {
	background-color: var(--fluentform-hover-surface);
}

/** Bottom margin only: a top margin wouldn't collapse with the one above inside .ff-t-container's flex cells. */
.fluentform .ff-el-group {
	margin-block: 0 2rem;
}

.fluentform .ff-el-group.ff_submit_btn_wrapper {
	margin-block: 0;
}

/**
 * FluentForm hardcodes .ff_btn_style's radius, font-size, padding, line-height and border, and controls don't inherit font-family; applies to every button.
 */
.ff-default .ff_btn_style {
	border-width: var(--amrf-button-border-width, 1px);
	border-radius: var(--fluentform-border-radius);
	line-height: inherit;
	font-family: var(--amrf-button-font-family, inherit);
	font-weight: var(--amrf-button-font-weight, inherit);
	font-size: var(--amrf-button-font-size, inherit);
	padding: var(--amrf-button-padding, 8px 20px);
	min-height: var(--amrf-button-min-height, auto);
}

/**
 * FluentForm hardcodes its submit color, and its default submit button has .ff-btn-submit, not .ff-btn-primary.
 */
.ff-default .ff-btn-primary:not(.ff_btn_no_style),
.ff-default .ff-btn-submit:not(.ff_btn_no_style) {
	background: var(--amrf-button-background);
	border-color: var(--amrf-button-border-color);
	color: var(--amrf-button-text, #fff);
	box-shadow: var(--amrf-button-shadow, none);
}

.ff-default .ff-btn-primary:not(.ff_btn_no_style):focus,
.ff-default .ff-btn-primary:not(.ff_btn_no_style):hover,
.ff-default .ff-btn-submit:not(.ff_btn_no_style):focus,
.ff-default .ff-btn-submit:not(.ff_btn_no_style):hover {
	background-color: var(
		--amrf-button-hover-background,
		var(--fluentform-primary)
	);
	border-color: var(--amrf-button-border-color);
	opacity: 1;
}

.fluentform .ff_t_c {
	padding: 1rem;
}

/**
 * Strips fluent-forms-public.css's card look so the success message sits flush with the modal.
 */
.ff-message-success {
	border: none;
	box-shadow: none;
	margin: 0;
	padding: 0;
	border-radius: 0;
}

.ff-message-success h3,
.ff-message-success p {
	margin: 0;
}

.fluentform input[type="radio"] {
	appearance: none;
	-webkit-appearance: none;
	border: 1px solid var(--fluentform-border-color);
	border-radius: 4px;
}

.fluentform .ff-el-form-check-label:has(> input[type="checkbox"]) {
	display: flex;
	align-items: flex-start;
	gap: 0.5em;
}

.fluentform .ff-el-form-check-label:has(> input[type="checkbox"]) > span {
	margin: 0;
}

/* font: inherit makes 1lh resolve against the label text, not the browser's form-control font. */
.fluentform input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	font: inherit;
	flex-shrink: 0;
	width: 1lh;
	height: 1lh;
	display: grid;
	place-content: center;
	background: var(--amrf-input-background);
	border: 1px solid var(--fluentform-border-color);
	border-radius: var(--fluentform-border-radius);
	cursor: pointer;
}

.fluentform .ff-el-form-check-label > input[type="checkbox"] {
	top: 0;
}

.fluentform input[type="checkbox"]::before {
	content: "";
	width: 0.65em;
	height: 0.65em;
	clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
	box-shadow: inset 1em 1em var(--amrf-input-color, currentColor);
	transform: scale(0);
	transition: transform 0.12s ease-in-out;
}

.fluentform input[type="checkbox"]:checked::before {
	transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
	.fluentform input[type="checkbox"]::before {
		transition: none;
	}
}

@media (forced-colors: active) {
	.fluentform input[type="checkbox"]::before {
		background-color: CanvasText;
	}
}

.fluentform textarea.ff-el-form-control {
	line-height: 1.4;
	resize: vertical;
}

/* field-sizing ignores rows, so multi-row fields are grown by amrf-contact-form-styling.js instead. */
.fluentform textarea.ff-el-form-control[rows="1"] {
	min-height: 48px;
	field-sizing: content;
	transition: min-height 0.25s ease-in-out;
}

.fluentform textarea.ff-el-form-control[rows="1"].is-expanded {
	min-height: 90px;
}

@media (prefers-reduced-motion: reduce) {
	.fluentform textarea.ff-el-form-control[rows="1"] {
		transition: none;
	}
}

.ff-default .ff-el-input--label label,
.fluentform .ff_t_c {
	font-size: 0.875em;
	font-weight: 700;
}

span.ff_tc_checkbox:has(input.ff_gdpr_field) + .ff_t_c::after {
	color: var(--fluentform-danger);
	content: " *";
	margin-left: 3px;
}

input.ff_gdpr_field:focus {
	border-color: var(--fluentform-primary) !important;
}

.fluentform .ff-el-is-error .text-danger {
	font-size: 1rem;
	font-weight: bold;
}

@media (min-width: 768px) {
	.frm-fluent-form .ff-name-field-wrapper .ff-t-cell {
		justify-content: flex-start;
	}
}

.ff-errors-in-stack .error-clear {
	display: none;
}
