/* FY Kit - Animation. Themes restyle through the --fyek-motion-* variables:
 *   --fyek-motion-rise       distance a block rises from (28px)
 *   --fyek-motion-time       how long a rise or fade takes (.8s)
 *   --fyek-motion-ease       the easing
 *   --fyek-motion-step       time between items one after another (90ms)
 *   --fyek-motion-stroke-color, --fyek-motion-stroke-opacity, --fyek-motion-stroke-height,
 *   --fyek-motion-stroke-offset (how far under the text), --fyek-stroke-mask (the shape)
 *   --fyek-motion-star-color (stars that fill in)
 * Nothing is hidden here: motion.js arms only what is below the first screen
 * (class is-armed) and shows it as it comes into view (class is-in). */
:root {
	--fyek-stroke-brush: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M4 12c30-5 62-7 96-6 34 1 62 2 96-1 3 0 4 3 1 4-30 5-62 6-96 6-33 0-64-1-95 2-4 0-6-4-2-5z'/%3E%3C/svg%3E");
	--fyek-stroke-crayon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M4 14c20-8 40-9 60-6s40 6 60 3 40-8 72-6c4 0 4 4 0 5-30 0-50 6-70 8-22 2-40-3-60-5S28 12 8 18c-5 1-8-2-4-4z'/%3E%3C/svg%3E");
	--fyek-stroke-sauce: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M3 13c22-6 46-8 70-7 18 1 30 3 52 2 22-1 44-5 72-4-14 3-30 7-52 9-24 2-40-1-62 0-26 1-50 5-74 4-6 0-9-2-6-4z'/%3E%3C/svg%3E");
	--fyek-stroke-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M2 11c40-3 80-5 120-4 26 1 50 2 76 1v3c-26 2-52 2-78 1-40-1-78 0-117 3z'/%3E%3C/svg%3E");
	--fyek-stroke-marker: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M2 4h196v13H2z'/%3E%3C/svg%3E");
	--fyek-stroke-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M2 11c8-6 16-6 24 0s16 6 24 0 16-6 24 0 16 6 24 0 16-6 24 0 16 6 24 0 16-6 24 0 16 6 24 0l2 3c-8 6-16 6-24 0s-16-6-24 0-16 6-24 0-16-6-24 0-16 6-24 0-16-6-24 0-16 6-24 0-16-6-24 0z'/%3E%3C/svg%3E");
	--fyek-stroke-mask: var(--fyek-stroke-brush);
	--fyek-motion-rise: 28px;
	--fyek-motion-time: .8s;
	--fyek-motion-ease: cubic-bezier(.2, .7, .2, 1);
	--fyek-motion-step: 90ms;
	--fyek-motion-stroke-color: var(--fyek-accent, var(--wp--preset--color--accent, currentColor));
	--fyek-motion-stroke-opacity: .32;
	--fyek-motion-stroke-height: .3em;
	--fyek-motion-stroke-offset: -.02em;
	--fyek-motion-star-color: var(--fyek-accent, var(--wp--preset--color--accent, #e3a008));
}
[data-fyek-stroke="brush"] { --fyek-stroke-mask: var(--fyek-stroke-brush); }
[data-fyek-stroke="crayon"] { --fyek-stroke-mask: var(--fyek-stroke-crayon); }
[data-fyek-stroke="sauce"] { --fyek-stroke-mask: var(--fyek-stroke-sauce); }
[data-fyek-stroke="ink"] { --fyek-stroke-mask: var(--fyek-stroke-ink); --fyek-motion-stroke-opacity: .7; --fyek-motion-stroke-height: .14em; --fyek-motion-stroke-offset: -.06em; }
[data-fyek-stroke="marker"] { --fyek-stroke-mask: var(--fyek-stroke-marker); --fyek-motion-stroke-opacity: .22; --fyek-motion-stroke-height: .42em; --fyek-motion-stroke-offset: .04em; }
[data-fyek-stroke="wave"] { --fyek-stroke-mask: var(--fyek-stroke-wave); --fyek-motion-stroke-opacity: .6; --fyek-motion-stroke-height: .2em; --fyek-motion-stroke-offset: -.1em; }

/* Rise in, fade in */
[data-fyek-motion].is-armed:is([data-fyek-motion="rise"], [data-fyek-motion="fade"]),
.fyek-motion-item.is-armed {
	opacity: 0;
	transition: opacity var(--fyek-motion-time) ease var(--fyek-motion-delay, 0ms), transform calc(var(--fyek-motion-time) * 1.15) var(--fyek-motion-ease) var(--fyek-motion-delay, 0ms);
}
[data-fyek-motion="rise"].is-armed, .fyek-motion-item.is-armed { transform: translateY(var(--fyek-motion-rise)); }
[data-fyek-motion].is-armed.is-in, .fyek-motion-item.is-armed.is-in { opacity: 1; transform: none; }

/* Items one after another: each item waits its turn */
.fyek-motion-item { --fyek-motion-delay: calc(var(--fyek-motion-base, 0ms) + var(--fyek-i, 0) * var(--fyek-motion-step)); }
ol.fyek-motion-items > li.is-armed::marker, ul.fyek-motion-items > li.is-armed::marker { color: transparent; }

/* Count up: digits keep their width while they count */
[data-fyek-motion="count"] .fyek-count-num { display: inline-block; font-variant-numeric: tabular-nums; text-align: end; }

/* Underline the slanted words */
[data-fyek-motion="underline"] em,
.fyek-motion-headings :is(h1, h2) em,
.editor-styles-wrapper.fyek-motion-headings :is(h1, h2) em { position: relative; z-index: 0; white-space: nowrap; }
[data-fyek-motion="underline"] em::after,
.fyek-motion-headings :is(h1, h2) em::after,
.editor-styles-wrapper.fyek-motion-headings :is(h1, h2) em::after {
	content: "";
	position: absolute;
	z-index: -1;
	left: -.06em;
	right: -.08em;
	bottom: var(--fyek-motion-stroke-offset);
	height: var(--fyek-motion-stroke-height);
	background: var(--fyek-motion-stroke-color);
	opacity: var(--fyek-motion-stroke-opacity);
	-webkit-mask: var(--fyek-stroke-mask) center / 100% 100% no-repeat;
	mask: var(--fyek-stroke-mask) center / 100% 100% no-repeat;
	pointer-events: none;
	transition: clip-path .9s cubic-bezier(.6, .1, .2, 1) calc(var(--fyek-motion-delay, 0ms) + .15s);
}
em.is-armed::after { clip-path: inset(0 100% 0 0); }
em.is-armed.is-in::after { clip-path: inset(0 0 0 0); }

/* Stars fill from the left */
.fyek-stars { display: inline-block; width: max-content; color: var(--fyek-motion-star-color); }
.fyek-stars.is-armed {
	background: linear-gradient(90deg, var(--fyek-motion-star-color) 50%, color-mix(in srgb, var(--fyek-motion-star-color) 22%, transparent) 50%) 100% 0 / 200% 100% no-repeat;
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	transition: background-position 1.1s ease calc(var(--fyek-motion-delay, 0ms) + .1s);
}
.fyek-stars.is-armed.is-in { background-position: 0 0; }

@media (prefers-reduced-motion: reduce) {
	[data-fyek-motion].is-armed, .fyek-motion-item.is-armed, .fyek-stars.is-armed { opacity: 1 !important; transform: none !important; transition: none !important; }
	em.is-armed::after { clip-path: none !important; transition: none !important; }
	.fyek-stars.is-armed { background: none; color: var(--fyek-motion-star-color); }
}
