/*
 * Hero title: "gooey" grow-in from the left when the page opens.
 * Based on Amit Sheen's Gooey Marquee (two text layers), but the text never
 * slides.
 *
 * How it works
 * - .hero__goo    : thickened, blurred copy of the title on black, then
 *                   contrast(15) — this turns soft edges into liquid blobs.
 * - .hero__goo::after : a black "curtain" with a soft left edge that slides
 *                   off to the right. Where its soft edge passes over the
 *                   letters, the contrast makes them drip and stretch.
 * - Then a second soft-edged sweep runs left → right: it hides the goo
 *   (.hero__goo::before) and uncovers the sharp title (.hero__clear) at the
 *   same spot, so the text turns crisp from left to right.
 *   The sharp title is uncovered with the "two opposite slides" trick: the
 *   frame slides right while the text inside slides left by the same amount,
 *   so the text itself never moves.
 * - The whole h1 uses mix-blend-mode: screen, so black becomes see-through
 *   over the video and only the white letters show.
 *
 * Smoothness: only transform and opacity are animated. The graphics card can
 * move/fade those layers without redrawing the text every frame.
 *
 * Things you can tweak
 * - --goo-duration : how long the grow-in takes
 * - --goo-delay    : wait after the page opens
 * - --goo-blur     : bigger = gooier, softer drips
 * - --goo-weight   : thickens the goo letters (Marcellus is thin; without
 *                    this the blur eats the strokes)
 * - --goo-edge     : width of the soft front (bigger = longer drips)
 * - --goo-settle   : how long the left → right "turn crisp" sweep takes
 * - --goo-settle-ease : the curve of that sweep (now a soft ease-out)
 * - --goo-settle-start: when that sweep starts (it overlaps the grow-in a bit)
 * - --goo-soft     : width of the sweep's soft edge
 */

.hero__title {
	--goo-duration: 2.4s;
	--goo-delay: 0.3s;
	--goo-blur: 0.08em;
	--goo-weight: 0.06em;
	--goo-edge: 15%;
	--goo-settle: 3.6s;
	--goo-settle-ease: cubic-bezier(0.22, 1, 0.36, 1); /* fast start, long slow finish */
	--goo-settle-start: calc(var(--goo-delay) + var(--goo-duration) - 0.6s);
	--goo-soft: 1em;
	mix-blend-mode: screen;
}

/* Gooey layer, with room for the blur to spill out. */
.hero__goo {
	position: absolute;
	inset: -0.15em;
	padding: 0.15em;
	overflow: hidden;
	background: #000;
	filter: contrast(15);
	pointer-events: none;
}

.hero__goo-text {
	display: block;
	-webkit-text-stroke: var(--goo-weight) #fff;
	filter: blur(var(--goo-blur));
}

/* Grow-in curtain: 150% wide so its soft edge can start off to the left. */
.hero__goo::after {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 150%;
	background: linear-gradient(to right, transparent, #000 var(--goo-edge));
	transform: translateX(100%);
}

/* "Turn crisp" curtain: black with a soft right edge, slides in from the left
   and hides the goo behind it. Same width as the sharp-title frame below so
   both edges travel together. */
.hero__goo::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	z-index: 1;
	width: calc(100% + var(--goo-soft));
	background: linear-gradient(to right, #000 calc(100% - var(--goo-soft)), transparent);
	transform: translateX(-100%);
}

/* Sharp title: the frame has extra room on the right for its soft edge. */
.hero__clear {
	display: block;
	position: relative;
	overflow: hidden;
	margin: -0.15em calc(-0.15em - var(--goo-soft)) -0.15em -0.15em;
	-webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--goo-soft)), transparent);
	mask-image: linear-gradient(to right, #000 calc(100% - var(--goo-soft)), transparent);
}

.hero__clear-text {
	display: block;
	padding: 0.15em calc(0.15em + var(--goo-soft)) 0.15em 0.15em;
}

@media (prefers-reduced-motion: no-preference) {
	.hero__goo::after {
		will-change: transform;
		animation: goo-curtain var(--goo-duration) cubic-bezier(0.3, 0.6, 0.3, 1) var(--goo-delay) both;
	}

	.hero__goo::before {
		will-change: transform;
		animation: goo-wipe-in var(--goo-settle) var(--goo-settle-ease) var(--goo-settle-start) both;
	}

	.hero__clear {
		will-change: transform;
		animation: goo-wipe-in var(--goo-settle) var(--goo-settle-ease) var(--goo-settle-start) both;
	}

	.hero__clear-text {
		will-change: transform;
		animation: goo-wipe-hold var(--goo-settle) var(--goo-settle-ease) var(--goo-settle-start) both;
	}
}

/* Visitors who prefer less motion just see the plain title. */
@media (prefers-reduced-motion: reduce) {
	.hero__goo {
		display: none;
	}

	.hero__clear {
		-webkit-mask-image: none;
		mask-image: none;
	}
}

@keyframes goo-curtain {
	/* -15%: soft edge just left of the text (all hidden) → 67%: curtain gone */
	from { transform: translateX(calc(var(--goo-edge) * -1)); }
	to   { transform: translateX(67%); }
}

/* Frame slides in from the left… */
@keyframes goo-wipe-in {
	from { transform: translateX(-100%); }
	to   { transform: translateX(0); }
}

/* …while its contents slide the opposite way, so the letters stay put. */
@keyframes goo-wipe-hold {
	from { transform: translateX(100%); }
	to   { transform: translateX(0); }
}
