/*
 * Pages: arrival and touch response for Partners, About, Trust, Contact,
 * Thanks, the legal pages, the 404 and the partner form.
 *
 * Everything here is scoped under .js (set before first paint) and wrapped in
 * "no-preference", so with scripts off or reduced motion every page is exactly
 * as main.css draws it. Only transform, opacity and clip-path move; the two
 * exceptions are the form field's border and outline colour on focus
 * (docs/MOTION.md, "answer the hand"), which never change size.
 *
 * Rules that "draw" are borders in main.css. We never remove them: a cover the
 * colour of the section sits over the border and slides away, so once drawn
 * the page is the same pixels as the plain border.
 */

@keyframes htech-pg-fade {
	from { opacity: 0; }
}
@keyframes htech-pg-drop {
	from { opacity: 0; transform: translate3d(0, -6px, 0); }
}
@keyframes htech-pg-rise {
	from { opacity: 0; transform: translate3d(0, 16px, 0); }
}
/* Safety net for the page heroes only: if the reveal script is slow or fails,
   the hero is shown after 2.5s rather than left invisible. */
@keyframes htech-pg-uncover {
	to { opacity: 0; }
}
@keyframes htech-pg-safe {
	to { opacity: 1; transform: none; clip-path: none; }
}

/* Nothing on these pages may stay clipped once revealed: the foundation's
   clip-path would cut focus outlines and the screens that bleed to the page
   edge, and (with reduced motion) shave the top of every rule. */
.js [data-reveal].is-in {
	clip-path: none;
}

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

	/* ------------------------- Reveal housekeeping ----------------------- */
	/* The foundation's mask is a clip-path on the observed element itself, and
	   Chrome counts an element clipped to nothing as not visible, so the
	   observer never fires for it. Here the wipe is a cover in the section's
	   colour that slides off instead: same look, and the element stays
	   observable. The text itself is never clipped (focus outlines too). */
	.js [data-reveal="mask"],
	.js [data-reveal="mask"].is-in {
		clip-path: none;
		position: relative;
	}
	.js [data-reveal="mask"]::after {
		content: "";
		position: absolute;
		inset: -0.12em 0 -0.3em;
		background: var(--cover, var(--bg));
		transform-origin: 50% 100%;
		transition: transform var(--dur-slow) var(--ease-out);
		transition-delay: inherit;
		pointer-events: none;
	}
	.js [data-reveal="mask"].is-in::after {
		transform: scaleY(0);
	}
	.js .section--soft [data-reveal="mask"] {
		--cover: var(--soft);
	}
	.js .section--ink [data-reveal="mask"] {
		--cover: var(--ink);
	}

	/* ------------------------------ Page heroes -------------------------- */
	.js .page-hero .marker {
		animation: htech-pg-fade 0.5s var(--ease-out) backwards;
	}
	.js .page-hero [data-reveal],
	.js .page-hero [data-reveal]::after {
		transition-duration: 0.6s;
	}
	.js .page-hero h1[data-reveal] {
		transition-delay: 0.08s;
	}
	.js .page-hero .lede[data-reveal] {
		transition-delay: 0.2s;
	}
	.js .page-hero .actions[data-reveal],
	.js .page-hero .link-row[data-reveal],
	.js .page-hero p[data-reveal="mask"] {
		transition-delay: 0.32s;
	}
	.js .page-hero .jump li[data-reveal] {
		transition-delay: calc(0.3s + var(--i, 0) * var(--stagger));
	}
	.js .page-hero [data-reveal]:not(.is-in) {
		animation: htech-pg-safe 0.01s 2.5s forwards;
	}
	.js .page-hero [data-reveal]:not(.is-in)::after {
		animation: htech-pg-uncover 0.01s 2.5s forwards;
	}
	/* A hero link made by htech_link() cannot take an attribute: it arrives by class. */
	.js .pg-rise {
		animation: htech-pg-rise 0.6s var(--ease-out) 0.32s backwards;
	}
	/* Legal text and the default page body can be thousands of pixels tall,
	   too tall for a scroll reveal, so they arrive once on load. */
	.js .page-hero .prose {
		animation: htech-pg-rise 0.7s var(--ease-out) 0.2s backwards;
	}

	/* ------------------------- Partners: jump links ---------------------- */
	.jump a::after {
		transition: transform var(--dur-fast) var(--ease-out);
	}
	.jump a:hover::after,
	.jump a:focus-visible::after {
		transform: translate3d(4px, 0, 0);
	}

	/* ------------------------ Partners: ways to work --------------------- */
	/* The number leads: the card's own words follow a beat later. */
	.js .ways .card .card__title,
	.js .ways .card .card__text {
		opacity: 0;
		transition: opacity var(--dur) var(--ease-out);
		transition-delay: calc(var(--i, 0) * var(--stagger) + 0.22s);
	}
	.js .ways .card.is-in .card__title,
	.js .ways .card.is-in .card__text {
		opacity: 1;
	}

	/* ------------------------------- Ticks ------------------------------- */
	/* The small orange dash draws in from the left. */
	.js .ticks li::before {
		transform: scaleX(0);
		transform-origin: 0 50%;
		transition: transform var(--dur) var(--ease-out);
		transition-delay: calc(var(--i, 0) * var(--stagger) + 0.25s);
	}
	.js .ticks li.is-in::before {
		transform: none;
	}

	/* ---------------------------- Partner chapters ----------------------- */
	.js .chapter__figure[data-reveal],
	.js .chapter__phone[data-reveal] {
		transition-duration: 0.9s;
	}

	/* "Your clients stay yours.": the orange rule draws top to bottom, then the text. */
	.js .aside[data-reveal] {
		position: relative;
		opacity: 1;
		transform: none;
		transition: none;
	}
	.js .aside[data-reveal]::before {
		content: "";
		position: absolute;
		left: -3px;
		top: 0;
		bottom: 0;
		width: 5px;
		background: var(--bg);
		transform-origin: 50% 100%;
		transition: transform 0.6s var(--ease-in-out);
	}
	.js .aside[data-reveal].is-in::before {
		transform: scaleY(0);
	}
	.js .aside[data-reveal] > * {
		opacity: 0;
		transition: opacity var(--dur-slow) var(--ease-out) 0.5s;
	}
	.js .aside[data-reveal].is-in > * {
		opacity: 1;
	}

	/* "What you get / What we ask": the two columns arrive one after the other. */
	.pair > [data-reveal="fade"]:nth-child(2) {
		transition-delay: 0.2s;
	}

	/* --------------------------- Rules that draw ------------------------- */
	/* Facts (Trust), names (About), topics (Contact): the top rule is drawn
	   from the left by a cover, in the section's colour, that slides away. */
	.js .facts__row,
	.js .names li,
	.js .topics li {
		position: relative;
	}
	.js .facts__row::before,
	.js .names li::before,
	.js .topics li::before {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		top: -3px;
		height: 5px;
		background: var(--bg);
		transform-origin: 100% 50%;
		transition: transform 0.7s var(--ease-in-out);
		transition-delay: calc(var(--i, 0) * var(--stagger) + 0.2s);
	}
	.js .facts__row::before,
	.js .topics li::before {
		background: var(--soft);
	}
	.js .facts__row.is-in::before,
	.js .names li.is-in::before,
	.js .topics li.is-in::before {
		transform: scaleX(0);
	}
	.topics a span {
		transition: transform var(--dur-fast) var(--ease-out);
	}
	.topics a:focus-visible span {
		transform: translate3d(4px, 0, 0);
	}

	/* -------------------------- Contact: the email ----------------------- */
	/* The underline is drawn by a copy of the address (data-text) with
	   transparent letters, so it has exactly the same position and gaps as the
	   real one. Only where the browser can hide the copy from screen readers. */
	@supports (content: "x" / "") {
		.js .big-email {
			position: relative;
			text-decoration-color: transparent;
		}
		.js .big-email::after {
			content: attr(data-text) / "";
			position: absolute;
			inset: 6px 0;
			color: transparent;
			text-decoration: underline;
			text-decoration-color: var(--accent);
			text-decoration-thickness: 3px;
			text-underline-offset: 8px;
			clip-path: inset(-20px 100% -20px -20px);
			transition: clip-path 0.55s var(--ease-in-out) 0.7s;
			pointer-events: none;
		}
		.js [data-reveal].is-in > .big-email::after {
			clip-path: inset(-20px -20px -20px -20px);
		}
	}

	/* -------------------------------- Form ------------------------------- */
	/* The form card rises once as it enters. It starts in place (never
	   invisible), only 28px lower, so nothing depends on the script. */
	.js .form-section > div[data-reveal]:not(.is-in) {
		opacity: 1;
		transform: translate3d(0, 28px, 0);
	}

	.form input[type="text"],
	.form input[type="email"],
	.form input[type="tel"],
	.form select,
	.form textarea {
		transition: border-color 0.15s ease;
	}
	.form__error {
		animation: htech-pg-drop 0.25s var(--ease-out) backwards;
	}
	.form-notice {
		animation: htech-pg-fade 0.45s var(--ease-out) backwards;
	}
	.form .btn {
		transition: transform 0.12s ease-out;
	}
	.form .btn:active {
		transform: translate3d(0, 1px, 0) scale(0.98);
	}
}
