/**
 * Faithworks Headline Test: front-end headline, button and animations.
 *
 * States (set by picker.js / headline.js on .fwht):
 *   .is-armed   an entrance animation is waiting to play (content hidden)
 *   .is-in      entered: content visible
 *   .is-out     scrolled away with an exit animation (content hidden)
 *   .is-reset   applied for one frame to jump back to "waiting" without a transition
 *
 * Custom properties (the Elementor widget, block and shortcode set these):
 *   --fwht-dur, --fwht-delay, --fwht-dist   animation duration, delay and travel distance
 *   --fwht-mark                             highlight colour behind <mark>
 *   --fwht-gap, --fwht-gap-cta              space above the subheadline and the button
 */

.fwht {
	--fwht-dur: 700ms;
	--fwht-delay: 0ms;
	--fwht-dist: 18px;
	--fwht-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	--fwht-stagger: 90ms;
	--fwht-word: 55ms;
	--fwht-ml: 0;
	--fwht-mr: 0;
	--fwht-jc: flex-start;
	position: relative;
}

.fwht--left {
	text-align: left;
	--fwht-ml: 0;
	--fwht-mr: auto;
	--fwht-jc: flex-start;
}

.fwht--center {
	text-align: center;
	--fwht-ml: auto;
	--fwht-mr: auto;
	--fwht-jc: center;
}

.fwht--right {
	text-align: right;
	--fwht-ml: auto;
	--fwht-mr: 0;
	--fwht-jc: flex-end;
}

.fwht .fwht__headline {
	margin: 0 var(--fwht-mr) 0 var(--fwht-ml);
	text-wrap: balance;
}

.fwht .fwht__sub {
	margin: var(--fwht-gap, 0.75em) var(--fwht-mr) 0 var(--fwht-ml);
	text-wrap: pretty;
}

.fwht .fwht__sub[hidden] {
	display: none;
}

.fwht__headline mark,
.fwht__sub mark {
	padding: 0 0.06em;
	background: linear-gradient(180deg, transparent 58%, var(--fwht-mark, rgba(197, 18, 60, 0.24)) 58%);
	color: inherit;
}

/* Button */
.fwht__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: var(--fwht-jc);
	margin-top: var(--fwht-gap-cta, 1.5em);
}

.fwht .fwht__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 0.85em 1.9em;
	border: 1px solid transparent;
	border-radius: 999px;
	background-color: #c5123c;
	box-shadow: 0 12px 26px -14px rgba(143, 13, 44, 0.75);
	color: #fff;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s var(--fwht-ease);
}

.fwht .fwht__cta:hover,
.fwht .fwht__cta:focus {
	background-color: #8f0d2c;
	color: #fff;
	text-decoration: none;
}

.fwht .fwht__cta:hover {
	transform: translateY(-1px);
}

.fwht .fwht__cta:focus-visible {
	outline: 2px solid #c5123c;
	outline-offset: 3px;
}

/* ---------------------------------------------------------------- motion */

.fwht__inner > * {
	transition-property: opacity, transform, filter;
	transition-duration: var(--fwht-dur);
	transition-timing-function: var(--fwht-ease);
	transition-delay: calc(var(--fwht-delay) + var(--fwht-k, 0) * var(--fwht-stagger));
}

/* Subheadline and button follow the headline by a beat. */
.fwht__inner > :nth-child(2) {
	--fwht-k: 1;
}

.fwht__inner > :nth-child(3) {
	--fwht-k: 2;
}

/* Waiting to enter */
.fwht.is-armed:not(.is-in):not(.is-out) .fwht__inner > * {
	opacity: 0;
}

.fwht[data-fwht-in="fade-up"].is-armed:not(.is-in):not(.is-out) .fwht__inner > * {
	transform: translate3d(0, var(--fwht-dist), 0);
}

.fwht[data-fwht-in="fade-down"].is-armed:not(.is-in):not(.is-out) .fwht__inner > * {
	transform: translate3d(0, calc(var(--fwht-dist) * -1), 0);
}

.fwht[data-fwht-in="slide-left"].is-armed:not(.is-in):not(.is-out) .fwht__inner > * {
	transform: translate3d(calc(var(--fwht-dist) * 2.5), 0, 0);
}

.fwht[data-fwht-in="slide-right"].is-armed:not(.is-in):not(.is-out) .fwht__inner > * {
	transform: translate3d(calc(var(--fwht-dist) * -2.5), 0, 0);
}

.fwht[data-fwht-in="zoom"].is-armed:not(.is-in):not(.is-out) .fwht__inner > * {
	transform: scale(0.94);
}

.fwht[data-fwht-in="blur"].is-armed:not(.is-in):not(.is-out) .fwht__inner > * {
	filter: blur(10px);
	transform: scale(1.02);
}

/* Word by word: the headline stays put while its words rise in. */
.fwht[data-fwht-in="words"] .fwht__w {
	display: inline-block;
	transition-property: opacity, transform;
	transition-duration: var(--fwht-dur);
	transition-timing-function: var(--fwht-ease);
	transition-delay: calc(var(--fwht-delay) + var(--fwht-i, 0) * var(--fwht-word));
}

.fwht[data-fwht-in="words"].is-armed:not(.is-in):not(.is-out) .fwht__inner > .fwht__headline[data-fwht-split] {
	opacity: 1;
	transition: none;
}

.fwht[data-fwht-in="words"].is-armed:not(.is-in):not(.is-out) .fwht__w {
	opacity: 0;
	transform: translate3d(0, 0.45em, 0);
}

.fwht[data-fwht-in="words"] .fwht__inner > :not(.fwht__headline) {
	transition-delay: calc(var(--fwht-delay) + var(--fwht-n, 6) * var(--fwht-word) + var(--fwht-k, 0) * var(--fwht-stagger));
}

.fwht[data-fwht-in="words"].is-armed:not(.is-in):not(.is-out) .fwht__inner > :not(.fwht__headline) {
	transform: translate3d(0, var(--fwht-dist), 0);
}

/* Leaving (scrolled away) */
.fwht.is-out .fwht__inner > * {
	opacity: 0;
	transition-duration: calc(var(--fwht-dur) * 0.7);
	transition-delay: 0ms;
}

.fwht[data-fwht-out="fade-up"].is-out .fwht__inner > * {
	transform: translate3d(0, calc(var(--fwht-dist) * -1), 0);
}

.fwht[data-fwht-out="fade-down"].is-out .fwht__inner > * {
	transform: translate3d(0, var(--fwht-dist), 0);
}

.fwht[data-fwht-out="zoom"].is-out .fwht__inner > * {
	transform: scale(0.96);
}

.fwht[data-fwht-out="blur"].is-out .fwht__inner > * {
	filter: blur(8px);
}

.fwht.is-out .fwht__w {
	transition-delay: 0ms;
}

.fwht.is-reset .fwht__inner > *,
.fwht.is-reset .fwht__w {
	transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.fwht .fwht__inner > *,
	.fwht .fwht__w {
		transform: none !important;
		filter: none !important;
		transition-duration: 200ms !important;
		transition-delay: 0ms !important;
	}

	.fwht .fwht__cta:hover {
		transform: none;
	}
}

/* Shown to editors when no test is chosen */
.fwht-notice {
	padding: 16px 18px;
	border: 1px dashed #c5123c;
	border-radius: 10px;
	background: #fbe8ed;
	color: #8f0d2c;
	font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
