Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

26.7 KB
Raw Blame
<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<title data-i18n="demos_pricing.meta_title">three.ws — pricing demo</title>
		<meta name="robots" content="noindex" />
		<link rel="stylesheet" href="/fonts/fonts.css" />
		<style>
			:root { color-scheme: dark; }
			*, *::before, *::after { box-sizing: border-box; }
			html, body { height: 100%; margin: 0; background: #050505; color: #eee; font: 15px/1.5 'Inter', -apple-system, system-ui, sans-serif; }

			#avatar-canvas {
				position: fixed; inset: 0;
				width: 100vw; height: 100vh;
				pointer-events: none; z-index: 999;
			}

			.nav {
				position: fixed; top: 0; left: 0; right: 0; z-index: 20;
				display: flex; align-items: center; gap: 16px; padding: 14px 28px;
				background: rgba(4,5,13,0.55); backdrop-filter: blur(14px);
				border-bottom: 1px solid rgba(255,255,255,0.04);
			}
			.nav .brand { font: 700 15px/1 'Space Grotesk','Inter',sans-serif; color:#fff; text-decoration:none; display:flex; align-items:center; gap:7px; }
			.brand-dot { width:8px; height:8px; border-radius:50%; background:linear-gradient(135deg,#3dc1ff,#aacc00); box-shadow:0 0 10px rgba(61, 193, 255,0.6); }
			.nav a.link { color:#555870; text-decoration:none; font-size:13px; margin-left:auto; }
			.nav a.link:hover { color:#3dc1ff; }

			.page {
				min-height: 100vh;
				padding: 130px 24px 80px;
				max-width: 1100px;
				margin: 0 auto;
			}
			.eyebrow {
				display: inline-flex; align-items: center; gap: 9px;
				font-size: 11px; font-weight: 600;
				letter-spacing: 0.17em; text-transform: uppercase;
				color: #3dc1ff; margin-bottom: 14px;
				font-family: 'Space Grotesk', 'Inter', sans-serif;
			}
			.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: #3dc1ff; box-shadow: 0 0 8px rgba(61, 193, 255,0.7); }
			h1 {
				font-family: 'Space Grotesk','Inter',sans-serif;
				font-size: clamp(34px, 4.4vw, 54px); font-weight: 800; letter-spacing: -0.025em;
				line-height: 1.05; margin: 0 0 14px; color: #fff; max-width: 18ch;
			}
			h1 em { color: #3dc1ff; font-style: normal; }
			.lead { color: #6b6e88; font-size: 16px; max-width: 56ch; margin: 0 0 48px; line-height: 1.6; }

			.tiers {
				display: grid;
				grid-template-columns: 1fr 1fr 1fr;
				gap: 18px;
				align-items: end;
				/* Perspective container — slabs tilt back so the top face is visible.
				   Origin pulled up above the grid so we look DOWN at the ledges. */
				perspective: 1600px;
				perspective-origin: 50% -40%;
				transform-style: preserve-3d;
			}
			@media (max-width: 820px) {
				.tiers { grid-template-columns: 1fr; }
			}

			.tier {
				position: relative;
				border-radius: 16px;
				/* Slab top face — bright specular at the very top, then quickly
				   dropping into the body, gives the eye a sense of a thick slab
				   being lit from above. The first ~3px is the lit lip the avatar
				   stands on. */
				background:
					linear-gradient(180deg,
						rgba(70,82,118,0.98) 0%,
						rgba(48,56,84,0.96) 3px,
						rgba(32,38,60,0.94) 10px,
						rgba(20,24,42,0.90) 22px,
						rgba(13,15,28,0.86) 38px,
						rgba(13,15,28,0.86) 100%);
				border: 1px solid rgba(255,255,255,0.06);
				padding: 28px 26px 24px;
				box-shadow:
					/* Top lip bevel — bright hairline + a softer secondary glaze */
					inset 0 1.5px 0 rgba(255,255,255,0.55),
					inset 0 4px 6px -3px rgba(255,255,255,0.28),
					/* Left + right side bevels carve the slab's vertical walls */
					inset 2px 0 0 rgba(255,255,255,0.05),
					inset -2px 0 0 rgba(0,0,0,0.35),
					/* Bottom inner shadow — the underside of the slab */
					inset 0 -3px 0 rgba(0,0,0,0.55),
					/* Stacked side wall — every 4px is one "stone" layer.
					   Six layers reads as a chunky slab, not a thin card. */
					0  4px 0 rgba(14,16,28,0.95),
					0  8px 0 rgba(11,13,24,0.95),
					0 12px 0 rgba(8,10,20,0.96),
					0 16px 0 rgba(6,8,16,0.96),
					0 20px 0 rgba(4,5,12,0.97),
					0 24px 0 rgba(2,3,8,0.98),
					/* Soft ambient occlusion on the ground beneath the slab */
					0 30px 24px -4px rgba(0,0,0,0.55),
					0 44px 60px -8px rgba(0,0,0,0.7);
				/* Tilt back ~10° around the bottom edge so we see the top face of
				   the slab — that's where she stands. */
				transform: rotateX(10deg);
				transform-origin: 50% 100%;
				transition: transform 200ms cubic-bezier(0.3, 0.8, 0.4, 1.05),
				            border-color 200ms ease,
				            box-shadow 200ms ease,
				            background 200ms ease;
				will-change: transform;
			}
			/* Top-face shimmer — a soft glaze across the lip that catches the
			   avatar's feet shadow nicely. Sits just inside the rounded corners
			   so it follows the slab profile. */
			.tier::after {
				content: '';
				position: absolute;
				inset: 1px 1px auto 1px;
				height: 14px;
				border-radius: 15px 15px 0 0;
				background: linear-gradient(180deg,
					rgba(255,255,255,0.10) 0%,
					rgba(255,255,255,0.02) 60%,
					transparent 100%);
				pointer-events: none;
			}
			.tier .pad-top {
				/* Reserved headroom so the avatar standing on top doesn't crowd the title */
				height: 70px;
			}
			.tier h2 {
				font-family: 'Space Grotesk','Inter',sans-serif;
				font-size: 18px; font-weight: 700; margin: 0 0 4px; color: #fff; letter-spacing: -0.005em;
			}
			.tier .blurb { color: #6b6e88; font-size: 13px; margin: 0 0 18px; line-height: 1.5; min-height: 34px; }
			.tier .num { display: flex; align-items: baseline; gap: 6px; margin: 0 0 16px; }
			.tier .num .price { font: 800 36px/1 'Space Grotesk','Inter',sans-serif; color: #fff; }
			.tier .num .per { color: #6b6e88; font-size: 13px; }
			.tier ul { list-style: none; padding: 0; margin: 0 0 22px; }
			.tier li {
				color: #b6b8c8; font-size: 13.5px; padding: 7px 0;
				display: flex; align-items: flex-start; gap: 8px;
				border-top: 1px solid rgba(255,255,255,0.04);
			}
			.tier li:first-child { border-top: 0; }
			.tier li::before {
				content: '';
				flex: 0 0 6px; height: 6px; border-radius: 50%;
				background: #3dc1ff; margin-top: 8px; box-shadow: 0 0 6px rgba(61, 193, 255,0.55);
			}
			.tier .cta {
				display: inline-flex; align-items: center; justify-content: center;
				gap: 8px; width: 100%;
				padding: 13px 18px; border: none; border-radius: 11px;
				font: 700 14px/1 'Inter', inherit; cursor: pointer; text-decoration: none;
				background: rgba(255,255,255,0.06);
				color: #fff;
				border: 1.5px solid rgba(255,255,255,0.08);
				transition: background 140ms, border-color 140ms, transform 140ms;
			}
			.tier .cta:hover { background: rgba(61, 193, 255,0.1); border-color: rgba(61, 193, 255,0.45); }

			/* Hover / "she's on this one" state — cyan-lit version of the slab.
			   Same stacked depth so the volume doesn't pop/change on hover. */
			.tier:hover,
			.tier.is-active {
				border-color: rgba(61, 193, 255,0.55);
				background:
					linear-gradient(180deg,
						rgba(70,138,180,0.98) 0%,
						rgba(46,96,138,0.96) 3px,
						rgba(28,62,98,0.94) 10px,
						rgba(18,42,74,0.90) 22px,
						rgba(12,28,52,0.86) 38px,
						rgba(12,28,52,0.86) 100%);
				box-shadow:
					inset 0 1.5px 0 rgba(180,235,255,0.7),
					inset 0 4px 6px -3px rgba(140,210,255,0.45),
					inset 2px 0 0 rgba(140,210,255,0.10),
					inset -2px 0 0 rgba(0,0,0,0.40),
					inset 0 -3px 0 rgba(0,0,0,0.55),
					0  4px 0 rgba(14,38,64,0.95),
					0  8px 0 rgba(10,30,54,0.95),
					0 12px 0 rgba(8,24,46,0.96),
					0 16px 0 rgba(6,18,38,0.96),
					0 20px 0 rgba(4,12,28,0.97),
					0 24px 0 rgba(2,8,22,0.98),
					0 30px 24px -4px rgba(0,0,0,0.55),
					0 44px 60px -8px rgba(61, 193, 255,0.28);
			}
			.tier:hover { transform: rotateX(10deg) translateY(-6px); }
			.tier.is-active .cta {
				background: linear-gradient(160deg, #5ad1ff, #2cb0ef);
				color: #0b0b0b; border-color: transparent;
				box-shadow: 0 4px 0 0 #005a8a;
			}

			/* "Most popular" ribbon on Pro */
			.tier.pro {
				/* Visually elevated even when no hover */
				background: rgba(18,24,12,0.85);
				border-color: rgba(61, 193, 255,0.4);
			}
			.tier.pro::before {
				content: 'Most popular';
				position: absolute; top: -11px; left: 50%;
				/* Counter-rotate so the ribbon faces the camera instead of tilting with the slab */
				transform: translateX(-50%) rotateX(-10deg);
				transform-origin: 50% 100%;
				background: linear-gradient(160deg, #5ad1ff, #2cb0ef);
				color: #0b0b0b;
				font: 700 10.5px/1 'Space Grotesk','Inter',sans-serif;
				letter-spacing: 0.12em; text-transform: uppercase;
				padding: 6px 12px; border-radius: 999px;
				box-shadow: 0 6px 16px rgba(61, 193, 255,0.3);
			}

			.hint {
				margin-top: 28px;
				color: #4a4d63; font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase;
			}
		</style>
	</head>
	<body>
		<div class="nav">
			<a href="/" class="brand">
				<img src="/three.svg" width="20" height="20" alt="" />
				<span class="brand-dot"></span>
				three.ws
			</a>
			<a href="/demos/" class="link" data-i18n="demos_pricing.lab">← lab</a>
		</div>

		<div class="page">
			<div class="eyebrow"><span class="eyebrow-dot"></span><span data-i18n="demos_pricing.pick_your_tier">Pick your tier</span></div>
			<h1 data-i18n-html="demos_pricing.hover_a_plan_she_ll_show_you">Hover a plan — <em>she'll show you which one to pick.</em></h1>
			<p class="lead" data-i18n="demos_pricing.she_lives_on_the_page_move_your">She lives on the page. Move your cursor across the tiers and she'll climb onto whichever one you're looking at, then point at the button.</p>

			<div class="tiers" id="tiers">
				<div class="tier" id="tier-basic" data-tier="basic">
					<div class="pad-top"></div>
					<h2 data-i18n="demos_pricing.basic">Basic</h2>
					<p class="blurb" data-i18n="demos_pricing.for_solo_builders_shipping_their_first_agent">For solo builders shipping their first agent.</p>
					<div class="num"><span class="price">$0</span><span class="per" data-i18n="demos_pricing.forever">/forever</span></div>
					<ul>
						<li data-i18n="demos_pricing.1_agent">1 agent</li>
						<li data-i18n="demos_pricing.default_rig_animations">Default rig + animations</li>
						<li data-i18n="demos_pricing.public_deploy_at_three_ws">Public deploy at three.ws/&lt;name&gt;</li>
					</ul>
					<button type="button" class="cta" data-tier-cta="basic" data-i18n="demos_pricing.start_free">Start free</button>
				</div>

				<div class="tier pro" id="tier-pro" data-tier="pro">
					<div class="pad-top"></div>
					<h2 data-i18n="demos_pricing.pro">Pro</h2>
					<p class="blurb" data-i18n="demos_pricing.for_studios_and_teams_shipping_multiple_agen">For studios and teams shipping multiple agents.</p>
					<div class="num"><span class="price">$29</span><span class="per" data-i18n="demos_pricing.mo">/mo</span></div>
					<ul>
						<li data-i18n="demos_pricing.unlimited_agents">Unlimited agents</li>
						<li data-i18n="demos_pricing.custom_avatars_lipsync">Custom avatars + lipsync</li>
						<li data-i18n="demos_pricing.animation_studio_memory_seeds">Animation studio + memory seeds</li>
						<li data-i18n="demos_pricing.custom_subdomain">Custom subdomain</li>
					</ul>
					<button type="button" class="cta" data-tier-cta="pro" data-i18n="demos_pricing.choose_pro">Choose Pro</button>
				</div>

				<div class="tier" id="tier-enterprise" data-tier="enterprise">
					<div class="pad-top"></div>
					<h2 data-i18n="demos_pricing.enterprise">Enterprise</h2>
					<p class="blurb" data-i18n="demos_pricing.for_platforms_embedding_agents_at_scale">For platforms embedding agents at scale.</p>
					<div class="num"><span class="price" data-i18n="demos_pricing.talk">Talk</span><span class="per" data-i18n="demos_pricing.to_us">to us</span></div>
					<ul>
						<li data-i18n="demos_pricing.self_hosted_runtime">Self-hosted runtime</li>
						<li data-i18n="demos_pricing.on_chain_identity_erc_8004">On-chain identity (ERC-8004)</li>
						<li data-i18n="demos_pricing.custom_rigs_licensing">Custom rigs &amp; licensing</li>
						<li data-i18n="demos_pricing.sla_dedicated_infra">SLA + dedicated infra</li>
					</ul>
					<button type="button" class="cta" data-tier-cta="enterprise" data-i18n="demos_pricing.contact_sales">Contact sales</button>
				</div>
			</div>

			<p class="hint" data-i18n="demos_pricing.hover_a_tier_she_walks_across_click">Hover a tier — she walks across. Click a button to see her react.</p>
		</div>

		<canvas id="avatar-canvas"></canvas>

		<script type="module">
			import * as THREE from 'three';
			import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
			import { gsap } from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';

			const canvas = document.getElementById('avatar-canvas');
			const tiers  = [...document.querySelectorAll('.tier')];

			// ── Renderer / scene ──────────────────────────────────────────────
			const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
			renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
			renderer.outputColorSpace = THREE.SRGBColorSpace;
			renderer.toneMapping = THREE.ACESFilmicToneMapping;
			renderer.toneMappingExposure = 1.1;

			const scene = new THREE.Scene();
			const PX_PER_UNIT = 120;
			const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0.1, 100);
			camera.position.z = 10;

			function updateFrustum() {
				const hw = window.innerWidth  / PX_PER_UNIT / 2;
				const hh = window.innerHeight / PX_PER_UNIT / 2;
				camera.left = -hw; camera.right = hw;
				camera.top  =  hh; camera.bottom = -hh;
				camera.updateProjectionMatrix();
			}
			const _v3 = new THREE.Vector3();
			function domToWorld(sx, sy) {
				_v3.set((sx / window.innerWidth) * 2 - 1, -(sy / window.innerHeight) * 2 + 1, 0);
				_v3.unproject(camera);
				return { x: _v3.x, y: _v3.y };
			}
			// ── Avatar runtime ────────────────────────────────────────────────
			// Declared above resize() so the recalibrate path doesn't TDZ on init.
			let avatar = null, mixer = null, rootBone = null, baseRootPos = null;
			let phase = 'loading';
			let activeTier = null;

			function resize() {
				renderer.setSize(window.innerWidth, window.innerHeight, false);
				updateFrustum();
				// Re-snap to the currently-targeted tier so layout shifts don't leave her floating
				if (avatar && activeTier && phase === 'idle') {
					const t = standOnTopOf(activeTier);
					gsap.killTweensOf(avatar.position);
					gsap.to(avatar.position, { x: t.x, y: t.y, duration: 0.35, overwrite: true });
				}
			}
			window.addEventListener('resize', resize);
			resize();

			// Lights
			scene.add(new THREE.AmbientLight(0xffffff, 0.6));
			const key  = new THREE.DirectionalLight(0xfff4dc, 2.0); key.position.set(3, 6, 5);  scene.add(key);
			const rim  = new THREE.DirectionalLight(0x4060ff, 0.6); rim.position.set(-4, 3, -2); scene.add(rim);
			const fill = new THREE.DirectionalLight(0xffeedd, 0.4); fill.position.set(0, 2, 7);  scene.add(fill);

			const actions = {};
			let currentAction = null;
			const FADE_S = 0.3;

			function setAnimation(name, { loop = true, hold = false } = {}) {
				const next = actions[name];
				if (!next || next === currentAction) return;
				next.reset();
				next.setLoop(loop ? THREE.LoopRepeat : THREE.LoopOnce, loop ? Infinity : 1);
				next.clampWhenFinished = hold;
				if (currentAction) next.crossFadeFrom(currentAction, FADE_S, false).play();
				else next.fadeIn(FADE_S).play();
				currentAction = next;
			}

			// ── Tier targeting ────────────────────────────────────────────────
			// The avatar stands ON THE TOP EDGE of a card, slightly inset from center so
			// the .pad-top reserved area accepts her without colliding with the title.
			const FEET_TOP_OFFSET_PX = 0; // cz.glb origin = feet, so 0 puts feet right on the top edge

			function standOnTopOf(tierEl) {
				const r = tierEl.getBoundingClientRect();
				return domToWorld(r.left + r.width / 2, r.top + FEET_TOP_OFFSET_PX);
			}

			// phase: loading | idle | walking (declared above)
			// activeTier: tier she's currently associated with (declared above)
			let walkT = 0, walkStart = null, walkEnd = null, walkDur = 0.85, walkPeakRise = 0;
			// Optional callback fired once the avatar has fully settled into
			// idle after a move. Used by CTA clicks to queue the reaction
			// until she's actually on the right tier and standing still.
			let onArrival = null;
			const WALK_SPEED = 5; // world units per second

			function smoothstep(t) { return t * t * (3 - 2 * t); }

			function beginMove(tierEl) {
				if (activeTier) activeTier.classList.remove('is-active');
				activeTier = tierEl;
				activeTier.classList.add('is-active');
			}

			function walkToTier(tierEl) {
				if (!avatar || tierEl === activeTier) return;
				beginMove(tierEl);

				phase = 'walking';
				walkT = 0;
				walkStart = { x: avatar.position.x, y: avatar.position.y };
				walkEnd   = standOnTopOf(tierEl);
				// Distance-based duration so short hops finish quickly and long
				// strolls don't blur into a teleport.
				const dx = Math.abs(walkEnd.x - walkStart.x);
				walkDur = Math.max(0.4, dx / WALK_SPEED);
				// If a taller tier sits in between (e.g. Pro between Basic and
				// Enterprise), arc the walk path up to its top so she doesn't
				// clip through the slab mid-stride.
				const minX = Math.min(walkStart.x, walkEnd.x);
				const maxX = Math.max(walkStart.x, walkEnd.x);
				const baseY = Math.max(walkStart.y, walkEnd.y);
				let peakY = baseY;
				for (const tt of tiers) {
					const tp = standOnTopOf(tt);
					if (tp.x > minX && tp.x < maxX && tp.y > peakY) peakY = tp.y;
				}
				walkPeakRise = peakY - baseY;
				setAnimation('walk', { loop: true });
				// Turn to profile so the walk cycle reads sideways toward the destination
				const dir = Math.sign(walkEnd.x - walkStart.x) || 0;
				gsap.to(avatar.rotation, { y: dir * (Math.PI / 2), duration: 0.25, overwrite: true });
			}

			// Per-tier CTA reaction. Plays when the user clicks the tier's
			// call-to-action button (after the avatar has walked onto
			// that tier if she wasn't already there).
			//   basic:      wave           — friendly send-off for the free plan
			//   pro:        av-celebrating — "yes! great choice"
			//   enterprise: av-brag-claps  — confident, deal-closed applause
			const CTA_REACTION = {
				basic:      'wave',
				pro:        'av-celebrating',
				enterprise: 'av-brag-claps',
			};
			// Cap the reaction display so long loops (brag-claps is 10s) don't
			// hold the avatar hostage. Short clips (wave is 1s) play in full.
			const CTA_REACTION_MAX_MS = 3500;
			function ctaReactionFor(tierEl) {
				return CTA_REACTION[tierEl?.dataset.tier] ?? 'wave';
			}

			function landOnTier() {
				phase = 'idle';
				// Snap to the tier's true top-edge — guards against float drift
				// at p>=1 and any layout shift during the move.
				const snap = standOnTopOf(activeTier);
				avatar.position.set(snap.x, snap.y, 0);
				// Card "thump" on landing — sells weight
				const t = activeTier;
				gsap.killTweensOf(t);
				gsap.fromTo(t, { y: 0 }, {
					y: 3, duration: 0.08, ease: 'power3.out',
					onComplete: () => gsap.to(t, { y: 0, duration: 0.5, ease: 'elastic.out(1.2, 0.4)' })
				});
				// Face camera so the next gesture reads cleanly
				gsap.to(avatar.rotation, { y: 0, duration: 0.25, overwrite: true });
				setAnimation('idle', { loop: true });
				// Fire any queued arrival callback (e.g. a CTA click that
				// initiated this move) once the rotation tween has had time
				// to face camera so the reaction doesn't start sideways.
				if (onArrival) {
					const cb = onArrival;
					onArrival = null;
					setTimeout(cb, 300);
				}
			}

			// ── Hover dispatch with debounce ─────────────────────────────────
			// Tier cards live in a perspective-transformed grid (`transform-style:
			// preserve-3d` on .tiers + rotateX on .tier). Browsers stop hit-testing
			// individual .tier children inside that 3D context — `elementFromPoint`
			// returns the .tiers parent — so per-tier `mouseenter` listeners never
			// fire. We resolve which tier the cursor is over by walking the rects
			// from a single mousemove on the grid container.
			//
			// Debounce: ~120ms of stable hover before committing to a move, so
			// sweeping across tiers doesn't stack three trips on top of each other.
			let hoverTimer = null;
			let hoverPendingTier = null;
			function scheduleMove(tierEl) {
				if (!tierEl) {
					clearTimeout(hoverTimer);
					hoverPendingTier = null;
					return;
				}
				if (tierEl === activeTier) {
					// Already on it — cancel any pending switch.
					clearTimeout(hoverTimer);
					hoverPendingTier = null;
					return;
				}
				if (tierEl === hoverPendingTier) return; // already scheduled
				clearTimeout(hoverTimer);
				hoverPendingTier = tierEl;
				hoverTimer = setTimeout(() => {
					hoverPendingTier = null;
					if (phase === 'walking') {
						setTimeout(() => scheduleMove(tierEl), 200);
					} else {
						walkToTier(tierEl);
					}
				}, 120);
			}

			function tierAtPoint(clientX, clientY) {
				for (const t of tiers) {
					const r = t.getBoundingClientRect();
					if (clientX >= r.left && clientX <= r.right &&
					    clientY >= r.top  && clientY <= r.bottom) return t;
				}
				return null;
			}

			const tiersGrid = document.getElementById('tiers');
			tiersGrid.addEventListener('mousemove', e => {
				scheduleMove(tierAtPoint(e.clientX, e.clientY));
			});
			tiersGrid.addEventListener('mouseleave', () => scheduleMove(null));

			// CTA clicks: tier-specific reaction. If she isn't standing on
			// the clicked tier yet (or is mid-move), queue the reaction via
			// onArrival so it fires the moment she settles.
			document.querySelectorAll('[data-tier-cta]').forEach(cta => {
				cta.addEventListener('click', () => {
					if (!avatar) return;
					const tierEl = document.getElementById(`tier-${cta.dataset.tierCta}`);
					const reactionClip = ctaReactionFor(tierEl);
					const fireReaction = () => {
						// hold:true clamps the final pose when we cut a long
						// clip short (so we don't snap back to the first frame
						// before the crossfade to idle takes over).
						setAnimation(reactionClip, { loop: false, hold: true });
						const clipDur = actions[reactionClip]?.getClip().duration ?? 2.0;
						const playMs = Math.min(clipDur * 1000, CTA_REACTION_MAX_MS);
						setTimeout(() => {
							if (phase === 'idle') setAnimation('idle', { loop: true });
						}, playMs);
					};

					if (tierEl === activeTier && phase === 'idle') {
						fireReaction();
					} else {
						onArrival = fireReaction;
						if (tierEl !== activeTier) walkToTier(tierEl);
					}
				});
			});

			// ── Camera parallax ───────────────────────────────────────────────
			let mouseNx = 0, mouseNy = 0;
			window.addEventListener('mousemove', e => {
				mouseNx = (e.clientX / window.innerWidth)  * 2 - 1;
				mouseNy = (e.clientY / window.innerHeight) * 2 - 1;
			});

			// ── ResizeObserver on each tier so reflow re-snaps the avatar ────
			const ro = new ResizeObserver(() => {
				if (avatar && activeTier && phase === 'idle') {
					const t = standOnTopOf(activeTier);
					gsap.killTweensOf(avatar.position);
					gsap.to(avatar.position, { x: t.x, y: t.y, duration: 0.35, overwrite: true });
				}
			});
			tiers.forEach(t => ro.observe(t));

			// ── Loader ────────────────────────────────────────────────────────
			// Loaded up front so per-tier reactions can play
			// instantly without a fetch hiccup mid-hover.
			// Animation clips fetched up-front so per-tier reactions can play
			// instantly without a network hiccup mid-interaction.
			//   idle           — base standing pose
			//   walk           — locomotion cycle (root pinned, parent
			//                    transform drives travel)
			//   wave           — Basic CTA reaction
			//   av-celebrating — Pro CTA reaction
			//   av-brag-claps  — Enterprise CTA reaction
			const CLIPS = [
				'idle', 'walk',
				'wave', 'av-celebrating', 'av-brag-claps',
			];

			new GLTFLoader().load('/avatars/cz.glb', gltf => {
				avatar = gltf.scene;
				avatar.traverse(n => {
					if (!rootBone && /^(Hips|Root|mixamorig:?Hips)$/i.test(n.name)) rootBone = n;
				});
				avatar.rotation.y = 0;
				scene.add(avatar);

				mixer = new THREE.AnimationMixer(avatar);

				Promise.all(CLIPS.map(name =>
					fetch(`/animations/clips/${name}.json`).then(r => r.json())
				)).then(jsons => {
					CLIPS.forEach((name, i) => {
						actions[name] = mixer.clipAction(THREE.AnimationClip.parse(jsons[i]));
					});

					if (rootBone) baseRootPos = rootBone.position.clone();
					const _r = renderer.render.bind(renderer);
					renderer.render = (sc, cam) => {
						// Pin the hips so the parent transform fully owns
						// placement — otherwise the walk clip's natural forward
						// drift carries her off the pedestal.
						try { if (rootBone && baseRootPos) rootBone.position.copy(baseRootPos); } catch (_) {}
						_r(sc, cam);
					};

					// Start on the Pro tier (the recommended one) so first impression
					// matches the "most popular" badge.
					const pro = document.getElementById('tier-pro');
					activeTier = pro;
					pro.classList.add('is-active');
					const start = standOnTopOf(pro);
					avatar.position.set(start.x, start.y, 0);
					setAnimation('idle', { loop: true });
					phase = 'idle';
				});
			});

			// ── Render loop ───────────────────────────────────────────────────
			const clock = new THREE.Clock();
			(function tick() {
				requestAnimationFrame(tick);
				try {
					const dt = Math.min(clock.getDelta(), 0.05);
					mixer?.update(dt);

					if (phase === 'walking' && avatar && walkStart && walkEnd) {
						walkT += dt;
						const p = Math.min(walkT / walkDur, 1);
						const e = smoothstep(p);
						const x = walkStart.x + (walkEnd.x - walkStart.x) * e;
						const arc = walkPeakRise * 4 * p * (1 - p);
						const y = walkStart.y + (walkEnd.y - walkStart.y) * e + arc;
						avatar.position.set(x, y, 0);
						if (p >= 1) landOnTier();
					}

					// Camera parallax
					const targetCamX = mouseNx * 0.1;
					const targetCamY = -mouseNy * 0.07;
					camera.position.x += (targetCamX - camera.position.x) * 0.04;
					camera.position.y += (targetCamY - camera.position.y) * 0.04;

					renderer.render(scene, camera);
				} catch (_) {}
			})();
		</script>
		<script src="/brand.js" defer></script>
	<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>