@property --motion-duration { syntax: "<time>"; inherits: false; initial-value: 700ms; }
@property --motion-delay { syntax: "<time>"; inherits: false; initial-value: 0ms; }
@property --motion-step { syntax: "<time>"; inherits: false; initial-value: 80ms; }
@property --motion-i { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --motion-dir { syntax: "<number>"; inherits: false; initial-value: 1; }

:root {
	--nffat-speed: var(--wp--custom--motion--speed, 1.7);
	--nffat-hover-speed: var(--wp--custom--motion--hover-speed, 1.4);
	--nffat-motion-ease: var(--wp--custom--ease--out, cubic-bezier(0.23, 1, 0.32, 1));
	--nffat-motion-ease-in-out: var(--wp--custom--ease--in-out, cubic-bezier(0.77, 0, 0.175, 1));
	--nffat-motion-ease-drawer: var(--wp--custom--ease--drawer, cubic-bezier(0.32, 0.72, 0, 1));
	--nffat-motion-ease-back: var(--wp--custom--ease--back, cubic-bezier(0.34, 1.56, 0.64, 1));
}

.nffat-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.nffat-delay-1 { --motion-delay: 120ms; }
.nffat-delay-2 { --motion-delay: 240ms; }
.nffat-delay-3 { --motion-delay: 360ms; }
.nffat-delay-4 { --motion-delay: 480ms; }
.nffat-delay-5 { --motion-delay: 600ms; }
.nffat-delay-6 { --motion-delay: 720ms; }

/* --motion-delay doesn't inherit, so a delay on a staggered parent has to be passed down explicitly. */
[class*="nffat-each-"] > * { --motion-delay: inherit; }

.nffat-replay[data-from="above"] { --motion-dir: -1; }

.nffat-in-marker {
	background: linear-gradient(var(--motion-marker, var(--wp--preset--color--magenta-100)) 0 0) no-repeat 0 90% / 100% 0.85em;
	border-radius: 0.2em;
	padding-inline: 0.12em;
	margin-inline: -0.12em;
}

@media (prefers-reduced-motion: no-preference) {
	.nffat-motion [class*="nffat-in-"]:not(.is-in, .nffat-in-marker),
	.nffat-motion [class*="nffat-each-"]:not(.is-in) > * {
		opacity: 0;
	}

	.nffat-motion .nffat-in-marker:not(.is-in) {
		background-size: 0% 0.85em;
	}

	[class*="nffat-in-"].is-in,
	[class*="nffat-each-"].is-in > *,
	.is-in .nffat-line__in,
	.is-in .nffat-char {
		animation-duration: calc(var(--motion-duration) * var(--nffat-speed));
		animation-timing-function: var(--motion-ease, var(--nffat-motion-ease));
		animation-delay: calc((var(--motion-delay) + var(--motion-i) * var(--motion-step)) * var(--nffat-speed));
		animation-fill-mode: backwards;
	}

	.nffat-in-rise.is-in, .nffat-each-rise.is-in > * { animation-name: nffat-rise; }
	.nffat-in-rise-far.is-in { animation-name: nffat-rise-far; --motion-duration: 800ms; }
	.nffat-in-focus.is-in { animation-name: nffat-focus; --motion-duration: 850ms; }
	.nffat-in-unfold.is-in { animation-name: nffat-unfold; --motion-duration: 850ms; }
	.nffat-in-settle.is-in { animation-name: nffat-settle; --motion-duration: 1100ms; }
	.nffat-in-drop.is-in { animation-name: nffat-drop; --motion-duration: 650ms; --motion-ease: var(--nffat-motion-ease-back); }
	.nffat-in-pop.is-in, .nffat-each-pop.is-in > * { animation-name: nffat-pop; --motion-duration: 380ms; --motion-ease: var(--nffat-motion-ease-back); }
	.nffat-each-pop.is-in > * { --motion-step: 50ms; }
	.nffat-in-from-left.is-in { animation-name: nffat-from-left; }
	.nffat-in-from-right.is-in { animation-name: nffat-from-right; }
	.nffat-in-land.is-in { animation-name: nffat-land; --motion-duration: 650ms; --motion-ease: var(--nffat-motion-ease-back); }
	.nffat-in-stamp.is-in { animation-name: nffat-stamp; --motion-duration: 260ms; }
	.nffat-in-wipe-up.is-in { animation-name: nffat-wipe-up; --motion-duration: 900ms; }
	.nffat-in-wipe-right.is-in { animation-name: nffat-wipe-right; --motion-duration: 900ms; }
	.nffat-in-wipe-down.is-in { animation-name: nffat-wipe-down; --motion-duration: 900ms; }
	.nffat-in-grow.is-in { animation-name: nffat-grow; --motion-duration: 1100ms; }
	.nffat-in-fill.is-in { animation-name: nffat-fill; --motion-duration: 1000ms; }
	.nffat-in-marker.is-in { animation-name: nffat-marker; --motion-duration: 800ms; }
	.nffat-in-drop-down.is-in { animation-name: nffat-drop-down; --motion-duration: 650ms; }
	.nffat-each-grow.is-in > * { animation-name: nffat-each-grow; --motion-step: 70ms; }
	.nffat-each-fan.is-in > * { animation-name: nffat-each-fan; --motion-step: 60ms; }
	.nffat-each-deal.is-in > * { animation-name: nffat-each-deal; --motion-step: 90ms; }
	.nffat-each-light.is-in > * { animation-name: nffat-each-light; --motion-duration: 350ms; --motion-step: 100ms; }

	/* Flex stops the lines' negative margins collapsing, so split text keeps the original height. */
	.nffat-lines {
		display: flex;
		flex-direction: column;
	}

	.nffat-line {
		display: block;
		overflow: hidden;
		white-space: nowrap;
		/* Room for ascenders and descenders that overflow: hidden would otherwise cut off. */
		padding: 0.12em 0.04em 0.16em;
		margin: -0.12em -0.04em -0.16em;
	}

	.nffat-line__in { display: block; --motion-step: 90ms; }
	.nffat-char { display: inline-block; --motion-step: 35ms; }

	.is-in .nffat-line__in,
	.is-in .nffat-char {
		animation-name: nffat-mask-rise;
		--motion-duration: 750ms;
	}
}

@keyframes nffat-rise { from { opacity: 0; translate: 0 calc(24px * var(--motion-dir)); } }
@keyframes nffat-rise-far { from { opacity: 0; translate: 0 calc(40% * var(--motion-dir)); } }
@keyframes nffat-focus { from { opacity: 0; filter: blur(10px); translate: 0 12px; } }
@keyframes nffat-unfold { from { opacity: 0; clip-path: inset(32% 24% round 24px); } to { clip-path: inset(0 round 24px); } }
@keyframes nffat-settle { from { opacity: 0; scale: 1.12; } }
@keyframes nffat-drop { from { opacity: 0; translate: 0 -70px; rotate: 16deg; } }
@keyframes nffat-pop { from { opacity: 0; scale: 0.7; } }
@keyframes nffat-from-left { from { opacity: 0; translate: -36px 0; } }
@keyframes nffat-from-right { from { opacity: 0; translate: 36px 0; } }
@keyframes nffat-land { from { opacity: 0; scale: 0.3; rotate: -60deg; } }
@keyframes nffat-stamp { from { opacity: 0; scale: 1.5; rotate: -12deg; } }
@keyframes nffat-wipe-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
@keyframes nffat-wipe-right { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes nffat-wipe-down { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
@keyframes nffat-grow { from { opacity: 0; scale: 0.45; transform-origin: 50% 100%; } to { transform-origin: 50% 100%; } }
@keyframes nffat-fill { from { scale: 0 1; transform-origin: 0 50%; } to { transform-origin: 0 50%; } }
@keyframes nffat-marker { from { background-size: 0% 0.85em; } }
@keyframes nffat-drop-down { from { translate: 0 -160%; } }
@keyframes nffat-mask-rise { from { translate: 0 115%; } }
@keyframes nffat-each-grow { from { opacity: 0; translate: 0 12px; scale: 0.9; } }
@keyframes nffat-each-fan { from { opacity: 0; translate: calc(var(--motion-i) * -22px) 0; scale: 0.7; } }
@keyframes nffat-each-deal { from { opacity: 0; translate: calc(var(--motion-i) * -70px - 30px) 0; rotate: -7deg; } }
@keyframes nffat-each-light { from { opacity: 0.2; scale: 0.8; } }

.nffat-scroll-depth { overflow: hidden; }

/* Rotating phrases. Without JS or with reduced motion only the current phrase shows. motion.js adds .is-rotating:
   then every phrase shares one grid cell, the current one fades in, and the box resizes to fit it. */
.nffat-rotate {
	display: inline-flex;
	box-sizing: border-box;
	vertical-align: bottom;
}

.nffat-rotate > :not(.is-current) {
	display: none;
}

.nffat-rotate > * {
	display: inline-flex;
	align-items: center;
	white-space: nowrap;
}

.nffat-rotate.is-rotating {
	display: inline-grid;
	overflow: hidden;
	transition: width calc(560ms * var(--nffat-speed)) var(--nffat-motion-ease-back);
}

.nffat-rotate.is-rotating > * {
	display: inline-flex;
	grid-area: 1 / 1;
	justify-self: start;
	opacity: 0;
	scale: 0.92;
	transition: opacity calc(200ms * var(--nffat-speed)) var(--nffat-motion-ease), scale calc(200ms * var(--nffat-speed)) var(--nffat-motion-ease);
}

.nffat-rotate.is-rotating > .is-current {
	opacity: 1;
	scale: 1;
	transition-duration: calc(380ms * var(--nffat-speed));
	transition-delay: calc(120ms * var(--nffat-speed));
}

.nffat-rotate.is-rotating > .is-current .nffat-icon {
	animation: nffat-rotate-icon calc(480ms * var(--nffat-speed)) var(--nffat-motion-ease-back) calc(140ms * var(--nffat-speed)) backwards;
}

@keyframes nffat-rotate-icon { from { scale: 0.4; rotate: -25deg; } }

.nffat-header-hides,
.nffat-header-shrinks {
	position: sticky;
	top: var(--wp--style--root--padding-top, 24px);
	z-index: 20;
	transition: translate calc(400ms * var(--nffat-hover-speed)) var(--nffat-motion-ease), scale calc(400ms * var(--nffat-hover-speed)) var(--nffat-motion-ease);
}

.nffat-header-hides.is-hidden { translate: 0 -170%; }
.nffat-header-shrinks.is-compact { scale: 0.92; }

[class*="nffat-hover-"],
.nffat-hover-focus > *,
.nffat-hover-spread > * {
	--motion-hover: calc(var(--motion-duration-hover, 220ms) * var(--nffat-hover-speed));
	transition:
		translate var(--motion-hover) var(--nffat-motion-ease),
		scale var(--motion-hover) var(--nffat-motion-ease),
		rotate var(--motion-hover) var(--nffat-motion-ease),
		opacity var(--motion-hover) var(--nffat-motion-ease),
		clip-path var(--motion-hover) var(--nffat-motion-ease),
		background-color var(--motion-hover) var(--nffat-motion-ease),
		color var(--motion-hover) var(--nffat-motion-ease),
		/* Press feedback uses transform and must stay fast whatever the hover speed is. */
		transform 160ms var(--nffat-motion-ease);
}

.nffat-hover-zoom, .nffat-hover-spin { --motion-duration-hover: 500ms; }
.nffat-hover-swell, .nffat-hover-peek, .nffat-hover-reveal, .nffat-hover-open, .nffat-hover-straighten { --motion-duration-hover: 320ms; }

:where(.nffat-hover-raise, .nffat-hover-sweep, .nffat-hover-follow) { position: relative; isolation: isolate; }
:where(a.nffat-hover-underline, .nffat-hover-underline a) { position: relative; }

.nffat-roll { position: relative; display: block; overflow: hidden; }
.nffat-roll > span { display: block; }
.nffat-roll::after { content: attr(data-label); position: absolute; left: 0; top: 100%; }
.nffat-roll > span, .nffat-roll::after { transition: translate calc(320ms * var(--nffat-hover-speed)) var(--nffat-motion-ease); }

.nffat-follow-pill {
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: inherit;
	background: var(--motion-follow, var(--wp--preset--color--teal-50));
	opacity: 0;
	pointer-events: none;
	transition: clip-path calc(260ms * var(--nffat-hover-speed)) var(--nffat-motion-ease), opacity calc(160ms * var(--nffat-hover-speed)) var(--nffat-motion-ease);
}

@media (hover: hover) and (pointer: fine) {
	.nffat-hover:hover .nffat-hover-nudge, .nffat-hover-nudge:not(.nffat-hover *):hover { translate: 4px 0; }
	.nffat-hover:hover .nffat-hover-turn, .nffat-hover-turn:not(.nffat-hover *):hover { rotate: -45deg; }
	.nffat-hover:hover .nffat-hover-swell, .nffat-hover-swell:not(.nffat-hover *):hover { scale: 1.14; rotate: -8deg; }
	.nffat-hover:hover .nffat-hover-peek, .nffat-hover-peek:not(.nffat-hover *):hover { translate: 0 -16%; }
	.nffat-hover:hover .nffat-hover-lift, .nffat-hover-lift:not(.nffat-hover *):hover { translate: 0 -5px; }
	.nffat-hover:hover .nffat-hover-zoom, .nffat-hover-zoom:not(.nffat-hover *):hover { scale: 1.07; }
	.nffat-hover:hover .nffat-hover-tilt, .nffat-hover-tilt:not(.nffat-hover *):hover { rotate: -12deg; scale: 1.12; }
	.nffat-hover:hover .nffat-hover-wake, .nffat-hover-wake:not(.nffat-hover *):hover { background-color: var(--motion-wake, var(--wp--preset--color--magenta-600)); color: var(--wp--preset--color--white); }
	.nffat-hover:hover .nffat-hover-straighten, .nffat-hover-straighten:not(.nffat-hover *):hover { rotate: 0deg; scale: 1.06; translate: 0 -4px; }
	.nffat-hover:hover .nffat-hover-spin, .nffat-hover-spin:not(.nffat-hover *):hover { rotate: 72deg; }
	.nffat-hover:hover .nffat-hover-tint, .nffat-hover-tint:not(.nffat-hover *):hover { background-color: var(--motion-tint, var(--wp--preset--color--magenta)); color: var(--wp--preset--color--white); translate: 0 -2px; }
	.nffat-hover:hover .nffat-hover-pop, .nffat-hover-pop:not(.nffat-hover *):hover { translate: 0 -3px; scale: 1.08; }
	.nffat-hover:hover .nffat-hover-slide, .nffat-hover-slide:not(.nffat-hover *):hover { translate: 6px 0; }

	.nffat-hover-appear { opacity: 0; translate: -6px 0; }
	.nffat-hover:hover .nffat-hover-appear, .nffat-hover-appear:not(.nffat-hover *):hover { opacity: 1; translate: 0 0; }

	.nffat-hover-reveal { translate: 0 calc(100% + 12px); }
	.nffat-hover:hover .nffat-hover-reveal, .nffat-hover-reveal:not(.nffat-hover *):hover { translate: 0 0; }

	.nffat-hover-raise::after {
		content: "";
		position: absolute;
		inset: 0;
		z-index: -1;
		border-radius: inherit;
		box-shadow: var(--motion-shadow, 0 18px 30px rgb(4 41 39 / 0.16));
		opacity: 0;
		pointer-events: none;
		transition: opacity calc(250ms * var(--nffat-hover-speed)) var(--nffat-motion-ease);
	}
	.nffat-hover:hover .nffat-hover-raise, .nffat-hover-raise:not(.nffat-hover *):hover { translate: 0 -6px; }
	.nffat-hover:hover .nffat-hover-raise::after, .nffat-hover-raise:not(.nffat-hover *):hover::after { opacity: 1; }

	.nffat-hover-sweep { overflow: hidden; }
	.nffat-hover-sweep::before {
		content: "";
		position: absolute;
		inset: -2px;
		z-index: -1;
		background: var(--motion-sweep, var(--wp--preset--color--ink));
		translate: -101% 0;
		transition: translate calc(380ms * var(--nffat-hover-speed)) var(--nffat-motion-ease);
	}
	.nffat-hover:hover .nffat-hover-sweep, .nffat-hover-sweep:not(.nffat-hover *):hover { background-color: transparent; color: var(--motion-sweep-text, var(--wp--preset--color--white)); }
	.nffat-hover:hover .nffat-hover-sweep::before, .nffat-hover-sweep:not(.nffat-hover *):hover::before { translate: 0 0; }

	.nffat-hover:hover .nffat-hover-roll .nffat-roll > span, .nffat-hover-roll:not(.nffat-hover *):hover .nffat-roll > span,
	.nffat-hover:hover .nffat-hover-roll .nffat-roll::after, .nffat-hover-roll:not(.nffat-hover *):hover .nffat-roll::after { translate: 0 -100%; }

	a.nffat-hover-underline::after,
	.nffat-hover-underline a::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		height: 2px;
		border-radius: 1px;
		background: var(--motion-underline, var(--wp--preset--color--magenta-600));
		scale: 0 1;
		transform-origin: 100% 50%;
		transition: scale calc(320ms * var(--nffat-hover-speed)) var(--nffat-motion-ease);
	}
	a.nffat-hover-underline:hover::after,
	.nffat-hover-underline a:hover::after { scale: 1 1; transform-origin: 0 50%; }

	.nffat-hover-focus:hover > :not(:hover) { opacity: 0.5; scale: 0.96; }

	.nffat-hover-spread:hover > * { translate: calc(var(--motion-i) * 10px) 0; }
	.nffat-hover-spread:hover > :hover { translate: calc(var(--motion-i) * 10px) -4px; scale: 1.12; }

	.nffat-hover-open[data-label] {
		--motion-open-size: 48px;
		width: auto;
		gap: 8px;
		padding-inline: 16px 14px;
		border-radius: 999px;
		white-space: nowrap;
		clip-path: inset(0 0 0 calc(100% - var(--motion-open-size)) round 999px);
		translate: calc(-100% + var(--motion-open-size)) 0;
	}
	.nffat-hover-open[data-label]::before { content: attr(data-label); font-size: 13px; font-weight: 700; }
	.nffat-hover:hover .nffat-hover-open[data-label], .nffat-hover-open[data-label]:not(.nffat-hover *):hover { clip-path: inset(0 round 999px); translate: 0 0; }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
	.nffat-hover:hover .nffat-hover-beat, .nffat-hover-beat:not(.nffat-hover *):hover { animation: nffat-beat calc(650ms * var(--nffat-hover-speed)) var(--nffat-motion-ease); }
	.nffat-hover:hover .nffat-hover-ring, .nffat-hover-ring:not(.nffat-hover *):hover { animation: nffat-ring calc(550ms * var(--nffat-hover-speed)) var(--nffat-motion-ease); }
	.nffat-hover:hover .nffat-hover-sway, .nffat-hover-sway:not(.nffat-hover *):hover { animation: nffat-sway calc(900ms * var(--nffat-hover-speed)) var(--nffat-motion-ease); }

	.nffat-hover:hover .nffat-hover-arrow-swap .nffat-icon, .nffat-hover-arrow-swap:not(.nffat-hover *):hover .nffat-icon,
	.nffat-hover:hover .nffat-hover-arrow-swap > .wp-block-button__link::after, .nffat-hover-arrow-swap:not(.nffat-hover *):hover > .wp-block-button__link::after { animation: nffat-arrow-swap calc(420ms * var(--nffat-hover-speed)) var(--nffat-motion-ease); }
	.nffat-hover:hover .nffat-hover-arrow-fly .nffat-icon, .nffat-hover-arrow-fly:not(.nffat-hover *):hover .nffat-icon { animation: nffat-arrow-fly calc(420ms * var(--nffat-hover-speed)) var(--nffat-motion-ease); }
}

@keyframes nffat-beat { 15% { scale: 1.25; } 30% { scale: 0.95; } 45% { scale: 1.18; } }
@keyframes nffat-ring { 15% { rotate: -16deg; } 35% { rotate: 14deg; } 55% { rotate: -10deg; } 75% { rotate: 6deg; } }
@keyframes nffat-sway { 0%, 100% { transform-origin: 50% 100%; } 25% { rotate: 14deg; transform-origin: 50% 100%; } 55% { rotate: -9deg; transform-origin: 50% 100%; } 80% { rotate: 4deg; transform-origin: 50% 100%; } }
@keyframes nffat-arrow-swap { 45% { translate: 130% 0; opacity: 0; } 46% { translate: -130% 0; opacity: 0; } }
@keyframes nffat-arrow-fly { 45% { translate: 130% -130%; opacity: 0; } 46% { translate: -130% 130%; opacity: 0; } }
