.fpw-animated-text {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: var( --fpw-at-justify, center );
	gap: 0.35em;
	text-decoration: none;
	color: inherit;
	max-width: 100%;
	line-height: inherit;
}

a.fpw-animated-text {
	cursor: pointer;
}

.fpw-animated-text__before,
.fpw-animated-text__after {
	display: inline-block;
	line-height: inherit;
	vertical-align: baseline;
}

/*
 * Alignment strategy:
 * - `.measure` is in-flow, visibility:hidden text → real typographic baseline + width.
 * - `.rotator-clip` is absolutely painted on top with overflow:hidden for animations.
 * Flex items must NOT use overflow:hidden themselves, or browsers align to the
 * margin-box bottom instead of the text baseline.
 */
.fpw-animated-text__rotator {
	position: relative;
	display: inline-block;
	max-width: 100%;
	line-height: inherit;
	vertical-align: baseline;
	overflow: visible;
}

.fpw-animated-text__measure {
	display: inline-block;
	visibility: hidden;
	pointer-events: none;
	white-space: nowrap;
	line-height: inherit;
	vertical-align: baseline;
}

.fpw-animated-text__rotator-clip {
	position: absolute;
	inset: 0;
	overflow: hidden;
	line-height: inherit;
}

.fpw-animated-text__item {
	position: absolute;
	top: 0;
	left: 0;
	display: inline-block;
	white-space: nowrap;
	visibility: hidden;
	pointer-events: none;
	line-height: inherit;
}

.fpw-animated-text__item.is-active {
	visibility: visible;
	pointer-events: auto;
}

.fpw-animated-text__item.is-out {
	visibility: visible;
}

.fpw-animated-text__unit {
	display: inline-block;
	vertical-align: baseline;
}

/* ---------- fade ---------- */
.fpw-animated-text--effect-fade .fpw-animated-text__item {
	transition: opacity 0.5s ease;
	opacity: 0;
}
.fpw-animated-text--effect-fade .fpw-animated-text__item.is-visible {
	opacity: 1;
}

/* ---------- slide-up / slide-down (letter or word units) ---------- */
.fpw-animated-text--effect-slide-up .fpw-animated-text__unit,
.fpw-animated-text--effect-slide-down .fpw-animated-text__unit {
	opacity: 0;
	transition: transform 0.45s cubic-bezier( 0.2, 0.8, 0.2, 1 ), opacity 0.35s ease;
	transition-delay: calc( var( --i, 0 ) * 35ms );
}
.fpw-animated-text--effect-slide-up .fpw-animated-text__unit {
	transform: translateY( 60% );
}
.fpw-animated-text--effect-slide-down .fpw-animated-text__unit {
	transform: translateY( -60% );
}
.fpw-animated-text--effect-slide-up .fpw-animated-text__item.is-visible .fpw-animated-text__unit,
.fpw-animated-text--effect-slide-down .fpw-animated-text__item.is-visible .fpw-animated-text__unit {
	opacity: 1;
	transform: translateY( 0 );
}

/* ---------- flip-3d (word units) ---------- */
.fpw-animated-text--effect-flip-3d .fpw-animated-text__rotator-clip {
	perspective: 800px;
}
.fpw-animated-text--effect-flip-3d .fpw-animated-text__unit {
	opacity: 0;
	transform: rotateX( 65deg );
	transform-origin: 50% 100%;
	transition: transform 0.4s ease, opacity 0.3s ease;
	transition-delay: calc( var( --i, 0 ) * 60ms );
}
.fpw-animated-text--effect-flip-3d .fpw-animated-text__item.is-visible .fpw-animated-text__unit {
	opacity: 1;
	transform: rotateX( 0deg );
}

/* ---------- zoom ---------- */
.fpw-animated-text--effect-zoom .fpw-animated-text__item {
	transition: transform 0.4s ease, opacity 0.4s ease;
	opacity: 0;
	transform: scale( 0.5 );
}
.fpw-animated-text--effect-zoom .fpw-animated-text__item.is-visible {
	opacity: 1;
	transform: scale( 1 );
}

/* ---------- rotate-loop ---------- */
.fpw-animated-text--effect-rotate-loop .fpw-animated-text__rotator-clip {
	perspective: 1200px;
}
.fpw-animated-text--effect-rotate-loop .fpw-animated-text__item {
	transition: transform 0.45s ease, opacity 0.3s ease;
	opacity: 0;
	transform: rotateX( -90deg );
	transform-origin: 50% 50%;
}
.fpw-animated-text--effect-rotate-loop .fpw-animated-text__item.is-visible {
	opacity: 1;
	transform: rotateX( 0deg );
}

/* ---------- clip-reveal ---------- */
.fpw-animated-text--effect-clip-reveal .fpw-animated-text__item {
	transition: clip-path 0.5s ease, opacity 0.01s ease 0.4s;
	clip-path: inset( 0 100% 0 0 );
	opacity: 0;
}
.fpw-animated-text--effect-clip-reveal .fpw-animated-text__item.is-visible {
	clip-path: inset( 0 0 0 0 );
	opacity: 1;
	transition: clip-path 0.5s ease, opacity 0.01s ease;
}

/* ---------- typing ----------
 * Inline-flex + baseline (no overflow:hidden on flex items).
 * Spacing via gap only — no extra margins.
 * Caret on the unit, absolutely, so it cannot shift the line box.
 */
.fpw-animated-text--effect-typing {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: var( --fpw-at-justify, center );
	gap: 0.2em;
	text-align: var( --fpw-at-text-align, center );
	line-height: inherit;
}

.fpw-animated-text--effect-typing .fpw-animated-text__before,
.fpw-animated-text--effect-typing .fpw-animated-text__after {
	display: inline;
	margin: 0;
	padding-top: 0;
	padding-bottom: 0;
	line-height: inherit;
	vertical-align: baseline;
}

.fpw-animated-text--effect-typing .fpw-animated-text__measure {
	display: none !important;
}

.fpw-animated-text--effect-typing .fpw-animated-text__rotator,
.fpw-animated-text--effect-typing .fpw-animated-text__rotator-clip {
	display: inline;
	position: static;
	overflow: visible;
	max-width: none;
	line-height: inherit;
	vertical-align: baseline;
}

.fpw-animated-text--effect-typing .fpw-animated-text__item {
	display: none;
	position: static;
	visibility: visible;
	pointer-events: auto;
	white-space: normal;
	margin: 0;
	padding-top: 0;
	padding-bottom: 0;
	line-height: inherit;
	vertical-align: baseline;
}

.fpw-animated-text--effect-typing .fpw-animated-text__item.is-active {
	display: inline;
	position: static;
}

.fpw-animated-text--effect-typing .fpw-animated-text__unit {
	display: inline;
	position: relative;
	vertical-align: baseline;
	white-space: pre;
	line-height: inherit;
}

.fpw-animated-text--effect-typing .fpw-animated-text__item.is-active .fpw-animated-text__unit::after {
	content: "";
	position: absolute;
	left: 100%;
	top: 50%;
	width: 2px;
	height: 0.85em;
	margin-left: 0.08em;
	transform: translateY( -50% );
	background-color: var( --fpw-at-cursor-color, currentColor );
	animation: fpw-at-blink 1s step-end infinite;
	pointer-events: none;
}

@keyframes fpw-at-blink {
	50% {
		opacity: 0;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.fpw-animated-text__unit,
	.fpw-animated-text__item {
		transition-duration: 0.01ms !important;
		transition-delay: 0ms !important;
		animation: none !important;
	}
}

.fpw-animated-text .screen-reader-text {
	border: 0;
	clip: rect( 1px, 1px, 1px, 1px );
	clip-path: inset( 50% );
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}
