/*
 * Home page motion (docs/MOTION.md, Home owner).
 *
 * Every start state sits under `.js` and `prefers-reduced-motion: no-preference`,
 * so with scripts off or reduced motion the page is exactly as main.css draws it.
 * Only transform, opacity and clip-path move. Settled, nothing differs from main.css.
 */

/* The headline's two sentences, one line box each (as main.css already lays them out). */
.hero__line {
	display: block;
}

/* A heading that wipes up: the element with data-reveal="trigger" is what the
   foundation watches (it never hides), and its .home-mask child is what is clipped.
   (A clipped element cannot be watched itself: a fully clipped box never intersects.) */
.home-mask {
	display: block;
}
.js [data-reveal="trigger"],
.js [data-reveal="trigger"].is-in {
	opacity: 1;
	transform: none;
	clip-path: none;
}

/* The foundation leaves `clip-path: inset(0 0 -20% 0)` on every revealed element,
   which would cut off focus outlines at the sides and top and change how thin
   rules are drawn. Nothing here needs it once arrived. */
.js .card--link[data-reveal].is-in,
.js .tile[data-reveal].is-in,
.js .tiles__more[data-reveal].is-in,
.js .steps__item[data-reveal].is-in,
.js .in-use__visual[data-reveal].is-in,
.js .lede[data-reveal].is-in {
	clip-path: none;
}

/* Answer the hand: hover and focus (also for reduced motion, but instant there). */
a.card--link:focus-visible .link > span {
	border-bottom-width: 4px;
	padding-bottom: 2px;
}

@media (prefers-reduced-motion: no-preference) {

	/* ------------------------------ Hero arrival ---------------------------- */
	/* About 1.2s: square, label, line one, line two, paragraph, buttons, dash;
	   the screen rises alongside and the plate lands last. Runs from first paint
	   (no waiting on a script); `backwards` fill means nothing lingers once done. */
	@keyframes htech-square {
		from { transform: scale(0); }
		to { transform: none; }
	}
	@keyframes htech-fade {
		from { opacity: 0; }
		to { opacity: 1; }
	}
	@keyframes htech-rise {
		from { opacity: 0; transform: translate3d(0, 18px, 0); }
		to { opacity: 1; transform: none; }
	}
	@keyframes htech-wipe {
		from { transform: translate3d(0, 0.4em, 0); clip-path: inset(0 -5% 100% -5%); }
		to { transform: none; clip-path: inset(-10% -5% -25% -5%); }
	}
	@keyframes htech-screen {
		from { opacity: 0.01; transform: translate3d(0, 36px, 0); }
		to { opacity: 1; transform: none; }
	}

	.js .hero .marker::before {
		animation: htech-square 0.45s var(--ease-out) backwards;
	}
	.js .hero .marker {
		animation: htech-fade 0.5s var(--ease-out) 0.1s backwards;
	}
	.js .hero__line {
		animation: htech-wipe 0.75s var(--ease-out) 0.15s backwards;
	}
	.js .hero__line + .hero__line {
		animation-delay: 0.3s;
	}
	.js .hero .lede {
		animation: htech-rise 0.6s var(--ease-out) 0.45s backwards;
	}
	.js .hero .actions {
		animation: htech-rise 0.6s var(--ease-out) 0.55s backwards;
	}
	.js .hero .dash {
		animation: htech-rise 0.55s var(--ease-out) 0.65s backwards;
	}
	.js .hero__visual .screen {
		animation: htech-screen 0.9s var(--ease-out) 0.2s backwards;
	}
	.js .hero__caption {
		animation: htech-rise 0.45s var(--ease-out) 0.75s backwards;
	}
	/* Restored from the back/forward cache: show the hero as it is, at once. */
	.hero-settled .hero *,
	.hero-settled .hero *::before {
		animation: none !important;
	}

	/* Masked headings below the fold. */
	.js [data-reveal="trigger"] .home-mask {
		transform: translate3d(0, 0.35em, 0);
		clip-path: inset(0 -5% 100% -5%);
		transition:
			transform var(--dur-slow) var(--ease-out),
			clip-path var(--dur-slow) var(--ease-out);
	}
	.js [data-reveal="trigger"].is-in .home-mask {
		transform: none;
		clip-path: inset(-10% -5% -25% -5%);
	}

	/* --------------------------- Hero drift (desktop) ----------------------- */
	@media (min-width: 1000px) {
		.js .hero__visual.is-drifting {
			transform: translate3d(0, var(--hero-drift, 0px), 0);
			will-change: transform;
		}
	}

	/* ---------------------------- Who we work with -------------------------- */
	/* The lift uses `translate`, so it never fights the reveal's `transform`. */
	.js .card--link[data-reveal] {
		transition:
			opacity var(--dur-slow) var(--ease-out) calc(var(--i, 0) * 90ms),
			transform var(--dur-slow) var(--ease-out) calc(var(--i, 0) * 90ms),
			translate var(--dur-fast) var(--ease-out),
			border-color var(--dur-fast) var(--ease-out);
	}
	.card--link:hover,
	.card--link:focus-visible {
		translate: 0 -3px;
	}

	/* ------------------------------ How it works ---------------------------- */
	/* The top rule draws left to right; the number wipes up after it. */
	.js .steps__item[data-reveal] {
		position: relative;
		border-top-color: transparent;
		transition-delay: calc(var(--i, 0) * 180ms);
	}
	.js .steps__item[data-reveal]::before {
		content: "";
		position: absolute;
		top: -1.5px;
		left: 0;
		right: 0;
		height: 1.5px;
		background: var(--ink);
		transform: scaleX(0);
		transform-origin: 0 50%;
		transition: transform 0.9s var(--ease-in-out) calc(var(--i, 0) * 180ms);
	}
	.js .steps__item[data-reveal] .steps__num {
		transform: translate3d(0, 0.5em, 0);
		clip-path: inset(0 0 100% 0);
		transition:
			transform var(--dur-slow) var(--ease-out) calc(var(--i, 0) * 180ms + 250ms),
			clip-path var(--dur-slow) var(--ease-out) calc(var(--i, 0) * 180ms + 250ms);
	}
	.js .steps__item.is-in::before {
		transform: none;
	}
	.js .steps__item.is-in .steps__num {
		transform: none;
		clip-path: inset(-20% -10% -20% -10%);
	}

	/* --------------------------- Software in use ---------------------------- */
	/* The figure is only the trigger; its children move. */
	.js .in-use__visual[data-reveal] {
		opacity: 1;
		transform: none;
	}
	.js .in-use__visual[data-reveal] > * {
		opacity: 0;
		transform: translate3d(0, 28px, 0);
		transition:
			opacity var(--dur-slow) var(--ease-out),
			transform var(--dur-slow) var(--ease-out);
	}
	.js .in-use__visual[data-reveal] .phone {
		transition-delay: 0.25s;
	}
	.js .in-use__visual[data-reveal] .caption {
		transition-delay: 0.45s;
	}
	.js .in-use__visual.is-in > * {
		opacity: 1;
		transform: none;
	}
	@media (min-width: 1000px) {
		.js .in-use__visual[data-reveal] .phone {
			transform: translate3d(56px, 0, 0);
			transition-duration: 0.9s;
			transition-delay: 0.3s;
		}
		.js .in-use__visual.is-in .phone {
			transform: none;
		}
	}

	/* ------------------------------ Our products ---------------------------- */
	/* Pointer on a tile: its thumbnail pans slowly across the real screen,
	   and comes back quickly when the pointer leaves. */
	@media (hover: hover) and (min-width: 1000px) {
		.tile__thumb .screen__img {
			transition: transform 1.2s var(--ease-in-out);
		}
		.tile:hover .tile__thumb .screen__img,
		.tile:focus-visible .tile__thumb .screen__img {
			transform: translate3d(-150px, -70px, 0);
			transition-duration: 12s;
			will-change: transform;
		}
	}
}

/* Phone: one column, so no stagger (see motion.css). */
@media (max-width: 999px) {
	.js .card--link[data-reveal],
	.js .tile[data-reveal],
	.js .steps__item[data-reveal],
	.js .steps__item[data-reveal]::before {
		transition-delay: 0s;
	}
	.js .steps__item[data-reveal] .steps__num {
		transition-delay: 0.15s;
	}
}
