/*
 * Gravity Forms adapters (parent integration module).
 *
 * Gravity Forms' Orbital theme owns form presentation. These rules only cover
 * states and provider markup that the form block settings cannot express.
 * Colours map to the theme.json palette slugs every Beanstalk child keeps.
 * Override the custom properties in the child, never the selectors.
 */

/* Visible focus, disabled and checked states mapped to theme presets. */
.gform-theme.gform-theme--framework.gform_wrapper {
	--gf-ctrl-outline-color-focus: var(--beanstalk-gf-focus-color, var(--wp--preset--color--primary, currentcolor));
	--gf-ctrl-outline-width-focus: 2px;
	--gf-ctrl-outline-offset: 0;
	--gf-ctrl-shadow: none;
	--gf-ctrl-btn-shadow: none;
	--gf-ctrl-btn-shadow-hover: none;
	--gf-ctrl-btn-shadow-focus: none;
}

.gform-theme.gform-theme--framework.gform_wrapper .gform_footer .gform_button[type="submit"]:is(:disabled, [aria-disabled="true"]) {
	cursor: not-allowed;
}

/*
 * The provider prints a "* indicates required fields" legend when the asterisk
 * indicator is selected. Keep it for assistive technology without adding a
 * visible row; every required field still carries native required semantics.
 */
.gform-theme.gform-theme--framework.gform_wrapper .gform_required_legend {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/*
 * GF Cache Buster fetches each form after load and prints a generic grey
 * `.loader` (left-aligned dots with a large bottom margin) until it arrives.
 * Replace it with a centred ring inside an in-flow box, so nothing overlaps
 * the spinner. Set `--beanstalk-gf-loader-min-height` on the form's container
 * in the child to the loaded form's measured height so the page does not
 * jump when the form lands.
 */
.gf-cache-buster-form-container:has(> .loader) {
	display: grid;
	place-items: center;
	min-height: var(--beanstalk-gf-loader-min-height, 160px);
}

.gf-cache-buster-form-container > .loader {
	position: static;
	width: var(--beanstalk-gf-loader-size, 36px);
	height: var(--beanstalk-gf-loader-size, 36px);
	margin: 0;
	font-size: 0;
	border: 2px solid var(--beanstalk-gf-loader-track, color-mix(in srgb, currentcolor 20%, transparent));
	border-top-color: var(--beanstalk-gf-loader-color, var(--wp--preset--color--primary, currentcolor));
	border-radius: 50%;
	box-shadow: none;

	/* The provider's translateZ(0) base would turn a 0 -> 360deg tween into an identity matrix. */
	transform: none;
	animation: beanstalk-gf-spin 0.9s linear infinite;
}

.gf-cache-buster-form-container > .loader::before,
.gf-cache-buster-form-container > .loader::after {
	content: none;
}

@keyframes beanstalk-gf-spin {

	from {
		transform: rotate(0deg);
	}

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

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

	.gf-cache-buster-form-container > .loader {
		animation-duration: 2.4s;
	}
}
