/* ==========================================================================
 * TSB – Motion layer
 * Everything here is scoped to html.tsb-motion, which is only set on the
 * front end when the visitor has NOT asked for reduced motion.
 * Hidden "before reveal" states are further scoped to html.tsb-io, set by
 * motion.js once the observer is running → content never stays hidden.
 * ======================================================================== */

/* "Arrives fast, brakes hard" easing used everywhere */
:root {
	--tsb-ease: cubic-bezier(0.16, 1, 0.3, 1);
	--tsb-dash: 650ms;
}

/* ---------------------------------------------------------------
 * 1. HERO – entrance + light streaks + slow push-in
 * ------------------------------------------------------------- */
@keyframes tsb-dash-in {
	from { opacity: 0; transform: translateX(-70px) skewX(-12deg); filter: blur(3px); }
	60%  { filter: blur(0); }
	to   { opacity: 1; transform: none; filter: none; }
}
@keyframes tsb-push-in {
	from { transform: scale(1.12) translateX(2%); }
	to   { transform: scale(1) translateX(0); }
}

.tsb-motion .tsb-hero .wp-block-cover__image-background {
	animation: tsb-push-in 14s var(--tsb-ease) both;
}
.tsb-motion .tsb-hero .wp-block-cover__inner-container > .wp-block-group > * {
	animation: tsb-dash-in var(--tsb-dash) var(--tsb-ease) both;
}
.tsb-motion .tsb-hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(1) { animation-delay: 0.10s; }
.tsb-motion .tsb-hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(2) { animation-delay: 0.22s; }
.tsb-motion .tsb-hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(3) { animation-delay: 0.36s; }
.tsb-motion .tsb-hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(4) { animation-delay: 0.48s; }
.tsb-motion .tsb-hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(5) { animation-delay: 0.60s; }

/* Light streaks racing across the road area of the photo */
@property --tsb-p {
	syntax: "<percentage>";
	inherits: false;
	initial-value: 0%;
}
@keyframes tsb-streak { to { --tsb-p: 100%; } }

.tsb-motion .tsb-hero::after {
	content: "";
	position: absolute;
	inset: 55% 0 0 0;
	z-index: 1;
	pointer-events: none;
	mix-blend-mode: screen;
	opacity: 0.4;
	background-image:
		linear-gradient(90deg, transparent, rgba(245, 43, 0, 0.7)),
		linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5)),
		linear-gradient(90deg, transparent, rgba(245, 43, 0, 0.6));
	background-size: 220px 1px, 140px 1px, 300px 2px;
	background-repeat: no-repeat;
	background-position:
		calc(var(--tsb-p) * 2.4 - 140%) 30%,
		calc(var(--tsb-p) * 2.0 - 80%) 62%,
		calc(var(--tsb-p) * 2.8 - 190%) 88%;
	animation: tsb-streak 5s linear infinite;
}
.tsb-motion .tsb-hero .wp-block-cover__inner-container { z-index: 2; }

/* ---------------------------------------------------------------
 * 2. SCROLL REVEAL – blocks "dash in" from the left, staggered
 * ------------------------------------------------------------- */
.tsb-io .tsb-reveal {
	opacity: 0;
	transform: translateX(-48px) skewX(-8deg);
	filter: blur(2px);
}
.tsb-io .tsb-reveal.is-inview {
	opacity: 1;
	transform: none;
	filter: none;
	transition:
		opacity calc(var(--tsb-dash) * 0.7) ease-out,
		transform var(--tsb-dash) var(--tsb-ease),
		filter calc(var(--tsb-dash) * 0.6) ease-out;
	transition-delay: var(--tsb-delay, 0ms);
}
/* Cards keep their own hover transform after the reveal */
.tsb-io .is-style-tsb-card.tsb-reveal.is-inview:hover {
	transform: translateY(-3px);
	transition-delay: 0ms;
}

/* Kicker speed lines draw themselves */
.tsb-io .is-style-tsb-kicker.tsb-reveal::before { transform: skewX(-20deg) scaleX(0); transform-origin: left; }
.tsb-io .is-style-tsb-kicker.tsb-reveal.is-inview::before {
	transform: skewX(-20deg) scaleX(1);
	transition: transform 0.7s var(--tsb-ease) calc(var(--tsb-delay, 0ms) + 0.15s);
}

/* Section speed-line decoration slides in from the right */
.tsb-io .is-style-tsb-speed.tsb-watch::before {
	transform: skewX(-20deg) translateX(40%);
	opacity: 0;
}
.tsb-io .is-style-tsb-speed.tsb-watch.is-inview::before {
	transform: skewX(-20deg) translateX(0);
	opacity: 0.08;
	transition: transform 1.1s var(--tsb-ease), opacity 0.8s ease-out;
}

/* ---------------------------------------------------------------
 * 3. BUTTONS – shine sweep + ringing phone
 * ------------------------------------------------------------- */
.tsb-motion .wp-block-button__link {
	position: relative;
	overflow: hidden;
	isolation: isolate;
}
.tsb-motion .wp-block-button__link::after {
	content: "";
	position: absolute;
	inset: 0 auto 0 -60%;
	width: 45%;
	z-index: -1;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
	transform: skewX(-20deg) translateX(0);
	pointer-events: none;
}
.tsb-motion .wp-block-button__link:hover::after,
.tsb-motion .wp-block-button__link:focus-visible::after {
	transform: skewX(-20deg) translateX(420%);
	transition: transform 0.55s var(--tsb-ease);
}

@keyframes tsb-ring {
	0%, 82%, 100% { transform: rotate(0); }
	85% { transform: rotate(-16deg); }
	88% { transform: rotate(14deg); }
	91% { transform: rotate(-10deg); }
	94% { transform: rotate(8deg); }
	97% { transform: rotate(-4deg); }
}
.tsb-motion .tsb-btn-phone .wp-block-button__link::before {
	animation: tsb-ring 4.5s ease-in-out infinite;
	transform-origin: 50% 60%;
}

/* ---------------------------------------------------------------
 * 4. CARDS – icon dashes forward leaving a trail
 * ------------------------------------------------------------- */
.tsb-motion .tsb-icon { position: relative; }
.tsb-motion .tsb-icon img { transition: transform 0.45s var(--tsb-ease); }
.tsb-motion .tsb-icon::before {
	content: "";
	position: absolute;
	left: -6px;
	top: 50%;
	width: 34px;
	height: 16px;
	translate: 0 -50%;
	background:
		linear-gradient(var(--wp--preset--color--primary), var(--wp--preset--color--primary)) 100% 0 / 100% 2px no-repeat,
		linear-gradient(var(--wp--preset--color--primary), var(--wp--preset--color--primary)) 100% 50% / 70% 2px no-repeat,
		linear-gradient(var(--wp--preset--color--primary), var(--wp--preset--color--primary)) 100% 100% / 45% 2px no-repeat;
	transform: skewX(-20deg) scaleX(0);
	transform-origin: right;
	opacity: 0;
	transition: transform 0.45s var(--tsb-ease), opacity 0.3s ease;
}
.tsb-motion .is-style-tsb-card:hover .tsb-icon img { transform: translateX(22px); }
.tsb-motion .is-style-tsb-card:hover .tsb-icon::before { transform: skewX(-20deg) scaleX(1) translateX(14px); opacity: 0.9; }

/* Mission links: arrow nudges forward */
.tsb-motion .tsb-spec a { display: inline-block; transition: transform 0.3s var(--tsb-ease); }
.tsb-motion .tsb-spec a:hover { transform: translateX(6px); }

/* ---------------------------------------------------------------
 * 5. HEADER – compacts on scroll + red scroll-progress "speedometer"
 * ------------------------------------------------------------- */
.tsb-motion .tsb-topbar,
.tsb-motion .tsb-header__logo img,
.tsb-motion .tsb-header__bar {
	transition: all 0.35s var(--tsb-ease);
}
.tsb-motion .tsb-topbar { max-height: 4rem; overflow: hidden; }
.tsb-motion.is-scrolled .tsb-topbar { max-height: 0; padding-top: 0 !important; padding-bottom: 0 !important; }
.tsb-motion.is-scrolled .tsb-header__bar { padding-top: 0.4rem !important; padding-bottom: 0.4rem !important; }
.tsb-motion.is-scrolled .tsb-header__logo img { max-height: 44px; }

.tsb-header__bar { position: relative; }
@supports (animation-timeline: scroll()) {
	@keyframes tsb-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
	.tsb-motion .tsb-header__bar::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		height: 3px;
		background: var(--wp--preset--color--primary);
		transform-origin: left;
		animation: tsb-progress linear both;
		animation-timeline: scroll(root);
	}
}
