.nffat-contact-form__form {
	--field-pad: 60px;
}

/* Progress: fills as the required fields become valid, the heart beats once it's full. */
.nffat-contact-form__progress {
	position: relative;
	height: 6px;
	margin: 4px 28px 32px 0;
	border-radius: 999px;
	background: var(--wp--preset--color--magenta-50);
}

.nffat-contact-form__progress-bar {
	position: absolute;
	inset: 0 auto 0 0;
	width: calc(var(--progress, 0) * 100%);
	border-radius: inherit;
	background: linear-gradient(90deg, var(--wp--preset--color--magenta-100), var(--wp--preset--color--magenta));
	transition: width 600ms var(--wp--custom--ease--out);
}

.nffat-contact-form__progress-heart {
	position: absolute;
	top: 50%;
	left: calc(var(--progress, 0) * 100%);
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--wp--preset--color--white);
	box-shadow: 0 4px 12px rgb(238 61 150 / 0.3);
	color: var(--wp--preset--color--magenta);
	translate: -50% -50%;
	transition: left 600ms var(--wp--custom--ease--out), background-color 300ms, color 300ms;
}

.nffat-contact-form__progress-heart .nffat-icon {
	width: 16px;
	height: 16px;
}

.is-complete .nffat-contact-form__progress-heart {
	background: var(--wp--preset--color--magenta);
	color: var(--wp--preset--color--white);
	animation: nffat-form-beat 1.4s ease-in-out infinite;
}

@keyframes nffat-form-beat {
	0%, 40%, 100% { scale: 1; }
	12% { scale: 1.25; }
	24% { scale: 1.05; }
	32% { scale: 1.18; }
}

/* Fields */
.nffat-contact-form .nffat-form__fields {
	gap: 22px 20px;
}

.nffat-contact-form .nffat-form__field label {
	width: fit-content;
	transition: color 200ms var(--nffat-ease-out), translate 300ms var(--wp--custom--ease--back);
}

.nffat-contact-form .nffat-form__field:focus-within label {
	color: var(--wp--preset--color--magenta-700);
	translate: 6px 0;
}

.nffat-form__control {
	position: relative;
}

.nffat-contact-form .nffat-form__control :is(input, textarea) {
	min-height: 58px;
	padding: 16px 18px 16px var(--field-pad);
	border: 1.5px solid transparent;
	border-radius: 18px;
	background: var(--wp--preset--color--cream);
	transition: background-color 220ms var(--nffat-ease-out), border-color 220ms var(--nffat-ease-out), box-shadow 300ms var(--nffat-ease-out), translate 300ms var(--wp--custom--ease--out);
}

.nffat-contact-form .nffat-form__control textarea {
	min-height: 168px;
	field-sizing: content;
	max-height: 420px;
	resize: none;
}

.nffat-contact-form .nffat-form__control :is(input, textarea):focus {
	outline: none;
	border-color: var(--wp--preset--color--magenta);
	background: var(--wp--preset--color--white);
	box-shadow: 0 0 0 5px var(--wp--preset--color--magenta-50), 0 14px 30px -18px rgb(238 61 150 / 0.6);
	translate: 0 -2px;
}

@media (hover: hover) and (pointer: fine) {
	.nffat-contact-form .nffat-form__control :is(input, textarea):hover:not(:focus) {
		border-color: var(--wp--preset--color--magenta-100);
	}
}

/* Icon tile: wiggles on focus, flips to a teal tick once the field is valid. */
.nffat-form__icon {
	position: absolute;
	top: 11px;
	left: 11px;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 12px;
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--ink-muted);
	pointer-events: none;
	transition: background-color 250ms var(--nffat-ease-out), color 250ms var(--nffat-ease-out), translate 300ms var(--wp--custom--ease--out);
}

.nffat-form__icon .nffat-icon {
	grid-area: 1 / 1;
	width: 18px;
	height: 18px;
	transition: opacity 200ms, scale 400ms var(--wp--custom--ease--back), rotate 400ms var(--wp--custom--ease--back);
}

.nffat-form__icon-done {
	opacity: 0;
	scale: 0.4;
	rotate: -90deg;
}

.nffat-form__control:focus-within .nffat-form__icon {
	background: var(--wp--preset--color--magenta);
	color: var(--wp--preset--color--white);
	translate: 0 -2px;
	animation: nffat-form-wiggle 500ms var(--nffat-ease-out);
}

.nffat-form__control.is-valid .nffat-form__icon {
	background: var(--wp--preset--color--teal-50);
	color: var(--wp--preset--color--teal);
}

.nffat-form__control.is-valid:focus-within .nffat-form__icon {
	background: var(--wp--preset--color--teal);
	color: var(--wp--preset--color--white);
}

.nffat-form__control.is-valid .nffat-form__icon-idle {
	opacity: 0;
	scale: 0.4;
	rotate: 90deg;
}

.nffat-form__control.is-valid .nffat-form__icon-done {
	opacity: 1;
	scale: 1;
	rotate: 0deg;
}

@keyframes nffat-form-wiggle {
	30% { rotate: -12deg; }
	60% { rotate: 8deg; }
}

/* Gentle shake when a field is left wrong. */
.nffat-form__control.is-invalid :is(input, textarea) {
	border-color: var(--wp--preset--color--magenta-700);
	background: var(--wp--preset--color--magenta-50);
}

.nffat-form__control.is-invalid .nffat-form__icon {
	background: var(--wp--preset--color--magenta-700);
	color: var(--wp--preset--color--white);
}

.nffat-form__control.is-shaking {
	animation: nffat-form-shake 420ms var(--nffat-ease-out);
}

@keyframes nffat-form-shake {
	20% { translate: -6px 0; }
	40% { translate: 5px 0; }
	60% { translate: -3px 0; }
	80% { translate: 2px 0; }
}

.nffat-form__count {
	align-self: flex-end;
	margin: 0;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	color: var(--wp--preset--color--ink-muted);
	opacity: 0;
	transition: opacity 300ms;
}

.nffat-form__field--message:focus-within .nffat-form__count,
.nffat-form__count.is-near {
	opacity: 1;
}

.nffat-form__count.is-near {
	color: var(--wp--preset--color--magenta-700);
}

/* Sending: the arrow becomes a heartbeat line while the page posts. */
.nffat-contact-form__send.is-sending {
	pointer-events: none;
}

.nffat-contact-form__send.is-sending .nffat-icon {
	animation: nffat-form-send 700ms var(--nffat-ease-out) both;
}

.nffat-contact-form__send.is-sending .nffat-contact-form__send-label::after {
	content: "";
	display: inline-block;
	width: 1.2em;
	text-align: left;
	animation: nffat-form-dots 1.2s steps(4) infinite;
}

@keyframes nffat-form-send {
	40% { translate: -4px 0; }
	100% { translate: 40px 0; opacity: 0; }
}

@keyframes nffat-form-dots {
	0% { content: ""; }
	25% { content: "."; }
	50% { content: ".."; }
	75% { content: "..."; }
}

/* Sent */
.nffat-contact-form__sent {
	position: relative;
	display: grid;
	justify-items: start;
	gap: 8px;
}

.nffat-contact-form__sent-mark {
	display: grid;
	place-items: center;
	width: 72px;
	height: 72px;
	margin-bottom: 12px;
	border-radius: 50%;
	background: var(--wp--preset--color--teal-50);
	animation: nffat-form-pop 600ms var(--wp--custom--ease--back) both;
}

.nffat-contact-form__sent-mark svg {
	width: 44px;
	height: 44px;
	fill: none;
	stroke: var(--wp--preset--color--teal);
	stroke-width: 3.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.nffat-contact-form__sent-mark circle {
	stroke-dasharray: 151;
	stroke-dashoffset: 151;
	animation: nffat-form-draw 700ms var(--nffat-ease-out) 200ms forwards;
}

.nffat-contact-form__sent-mark path {
	stroke-dasharray: 40;
	stroke-dashoffset: 40;
	animation: nffat-form-draw 400ms var(--nffat-ease-out) 750ms forwards;
}

.nffat-contact-form__sent > :is(h2, p) {
	animation: nffat-form-rise 600ms var(--wp--custom--ease--out) both;
}

.nffat-contact-form__sent > p {
	animation-delay: 120ms;
}

.nffat-contact-form__burst {
	position: absolute;
	top: 36px;
	left: 36px;
	width: 14px;
	height: 14px;
	color: var(--wp--preset--color--magenta);
	pointer-events: none;
	animation: nffat-form-float 1600ms var(--nffat-ease-out) var(--d, 0ms) both;
}

@keyframes nffat-form-pop {
	from { scale: 0.3; opacity: 0; }
}

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

@keyframes nffat-form-rise {
	from { opacity: 0; translate: 0 14px; }
}

@keyframes nffat-form-float {
	from { opacity: 1; translate: 0 0; scale: 0.4; }
	to { opacity: 0; translate: var(--x) var(--y); scale: 1; rotate: var(--r); }
}

@media (prefers-reduced-motion: reduce) {
	.nffat-contact-form *,
	.nffat-contact-form *::after {
		animation: none !important;
		transition-duration: 0ms !important;
	}

	.nffat-contact-form__sent-mark :is(circle, path) {
		stroke-dashoffset: 0;
	}

	.nffat-contact-form__burst {
		display: none;
	}
}
