Contour map 3D hero
A relief map drawn like paper: contour lines, hatched lake, a height read-out under the cursor. Click to add stops; the route, elevation profile, distance, climb and walking time update live.
"use client";
import { useEffect, useMemo, useRef, useState } from "react";
import * as THREE from "three";
import "./terrain-hero.css";
type Stop = [number, number];
type TerrainHeroProps = {
title?: string;
text?: string;
cta?: { label: string; href: string };
/** Seed for the made-up mountains: change it for a different range. */
seed?: number;
/** Starting route, in map units (-6 to 6 on both axes). */
route?: Stop[];
};
const SIZE = 12;
const RES = 180;
const MAX_STOPS = 8;
/** One map unit in kilometres, and how heights turn into metres. */
const KM_PER_UNIT = 0.8;
const metres = (h: number) => Math.round(420 + h * 1100);
/** A small seeded value-noise, shared by the mesh and by every height lookup. */
function makeHeight(seed: number) {
const hash = (x: number, z: number) => {
const s = Math.sin(x * 127.1 + z * 311.7 + seed * 74.7) * 43758.5453;
return s - Math.floor(s);
};
const smooth = (t: number) => t * t * (3 - 2 * t);
const noise = (x: number, z: number) => {
const ix = Math.floor(x);
const iz = Math.floor(z);
const fx = smooth(x - ix);
const fz = smooth(z - iz);
const a = hash(ix, iz);
const b = hash(ix + 1, iz);
const c = hash(ix, iz + 1);
const d = hash(ix + 1, iz + 1);
return a + (b - a) * fx + (c - a) * fz + (a - b - c + d) * fx * fz;
};
return (x: number, z: number) => {
let amp = 1;
let freq = 0.22;
let sum = 0;
let norm = 0;
for (let o = 0; o < 5; o++) {
sum += noise(x * freq + 11, z * freq + 7) * amp;
norm += amp;
amp *= 0.5;
freq *= 2.1;
}
const n = sum / norm;
const edge = Math.max(Math.abs(x), Math.abs(z));
const mask = 1 - THREE.MathUtils.smoothstep(edge, 3.8, 6);
const lake = Math.exp(-((x + 1.9) ** 2 + (z - 1.6) ** 2) / 1.6) * 0.55;
return Math.max(0.02, 0.18 + Math.pow(n, 1.7) * 2.0 * mask - lake);
};
}
/** Points along the route (straight lines over the ground), with total distance and climb. */
function trace(stops: Stop[], height: (x: number, z: number) => number) {
const pts: THREE.Vector3[] = [];
let dist = 0;
let climb = 0;
for (let i = 0; i < stops.length - 1; i++) {
const [ax, az] = stops[i];
const [bx, bz] = stops[i + 1];
const steps = 48;
for (let s = i === 0 ? 0 : 1; s <= steps; s++) {
const t = s / steps;
const x = ax + (bx - ax) * t;
const z = az + (bz - az) * t;
const p = new THREE.Vector3(x, height(x, z), z);
const prev = pts[pts.length - 1];
if (prev) {
dist += Math.hypot(p.x - prev.x, p.z - prev.z);
const dh = metres(p.y) - metres(prev.y);
if (dh > 0) climb += dh;
}
pts.push(p);
}
}
const km = dist * KM_PER_UNIT;
// Naismith's rule: 5 km an hour, plus 10 minutes for every 100 m of climb.
const minutes = Math.round((km / 5) * 60 + (climb / 100) * 10);
return { pts, km, climb: Math.round(climb), minutes };
}
const vertex = /* glsl */ `
varying float vH;
varying vec3 vN;
varying vec3 vP;
void main() {
vH = position.y;
vN = normal;
vP = position;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
const fragment = /* glsl */ `
uniform vec2 uHover;
uniform float uHoverOn;
varying float vH;
varying vec3 vN;
varying vec3 vP;
float contour(float v, float width) {
float f = abs(fract(v - 0.5) - 0.5) / fwidth(v);
return 1.0 - min(f / width, 1.0);
}
void main() {
vec3 low = vec3(0.79, 0.82, 0.66);
vec3 mid = vec3(0.89, 0.82, 0.63);
vec3 high = vec3(0.96, 0.94, 0.9);
vec3 col = mix(low, mid, smoothstep(0.15, 0.9, vH));
col = mix(col, high, smoothstep(1.0, 1.9, vH));
float light = clamp(dot(normalize(vN), normalize(vec3(-0.55, 0.75, 0.35))), 0.0, 1.0);
col *= 0.7 + 0.42 * light;
// Water: flat blue with the fine hatching old maps use.
float water = 1.0 - smoothstep(0.11, 0.13, vH);
float hatch = contour(vP.z * 14.0, 1.0) * 0.35;
col = mix(col, mix(vec3(0.62, 0.76, 0.8), vec3(0.4, 0.55, 0.62), hatch), water);
// Contour lines every 0.08 units, a darker index line every fifth.
float minor = contour(vH / 0.08, 1.0) * (1.0 - water);
float major = contour(vH / 0.4, 1.6) * (1.0 - water);
vec3 ink = vec3(0.5, 0.32, 0.22);
col = mix(col, ink, minor * 0.32 + major * 0.6);
// The ring under the cursor.
float d = length(vP.xz - uHover);
float ring = 1.0 - smoothstep(0.0, 0.03, abs(d - 0.32));
float dot2 = 1.0 - smoothstep(0.05, 0.07, d);
col = mix(col, vec3(1.0, 0.35, 0.12), (ring + dot2) * uHoverOn);
gl_FragColor = vec4(col, 1.0);
}
`;
/**
* TerrainHero
* - A made-up mountain range, drawn like a paper map: hypsometric colours, contour lines,
* hatched water. Heights come from one JS function, so lookups always match the mesh.
* - Hover reads the height under the cursor; click adds a stop; the route, an elevation
* profile, distance, climb and walking time update as you go.
* - Drag turns the map. It drifts slowly until touched.
*/
export function TerrainHero({
title = "Plan the climb before you lace up.",
text = "Contour turns any ridge into a route you can read: every stop, every metre of climb and an honest walking time.",
cta = { label: "Get Contour for free", href: "#contour-get" },
seed = 3,
route: initial = [
[-3.4, 2.6],
[-0.6, 0.2],
[1.6, -1.4],
[3.3, -3.2],
],
}: TerrainHeroProps) {
const rootRef = useRef<HTMLElement>(null);
const stageRef = useRef<HTMLDivElement>(null);
const tipRef = useRef<HTMLDivElement>(null);
const apiRef = useRef<{ setRoute: (pts: THREE.Vector3[]) => void } | null>(
null,
);
const [stops, setStops] = useState<Stop[]>(initial);
const [failed, setFailed] = useState(false);
const height = useMemo(() => makeHeight(seed), [seed]);
const info = useMemo(() => trace(stops, height), [stops, height]);
useEffect(() => {
const root = rootRef.current;
const stage = stageRef.current;
if (!root || !stage) return;
const reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
let renderer: THREE.WebGLRenderer;
try {
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
} catch {
const id = requestAnimationFrame(() => setFailed(true));
return () => cancelAnimationFrame(id);
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(32, 1, 0.1, 100);
const target = new THREE.Vector3(0, 0.4, 0);
/* ---- The ground ---- */
const geo = new THREE.PlaneGeometry(SIZE, SIZE, RES, RES);
geo.rotateX(-Math.PI / 2);
const pos = geo.attributes.position;
for (let i = 0; i < pos.count; i++)
pos.setY(i, height(pos.getX(i), pos.getZ(i)));
geo.computeVertexNormals();
const uniforms = {
uHover: { value: new THREE.Vector2(99, 99) },
uHoverOn: { value: 0 },
};
const ground = new THREE.Mesh(
geo,
new THREE.ShaderMaterial({
uniforms,
vertexShader: vertex,
fragmentShader: fragment,
}),
);
const map = new THREE.Group();
map.add(ground);
// The map's cut edge: a thin dark base, like a mounted relief model.
const base = new THREE.Mesh(
new THREE.BoxGeometry(SIZE, 0.35, SIZE),
new THREE.MeshBasicMaterial({ color: "#3d2b20" }),
);
base.position.y = -0.05;
map.add(base);
scene.add(map);
/* ---- The route ---- */
const routeMat = new THREE.MeshBasicMaterial({ color: "#ff5a1f" });
let tube: THREE.Mesh | null = null;
apiRef.current = {
setRoute(pts) {
if (tube) {
map.remove(tube);
tube.geometry.dispose();
tube = null;
}
if (pts.length > 1) {
const lifted = pts.map(
(p) => new THREE.Vector3(p.x, p.y + 0.04, p.z),
);
const curve = new THREE.CatmullRomCurve3(
lifted,
false,
"centripetal",
);
tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, lifted.length * 2, 0.04, 6),
routeMat,
);
map.add(tube);
}
},
};
/* ---- Camera orbit ---- */
let az = 0.6;
let polar = 0.92;
let radius = 16;
const place = () => {
camera.position.set(
target.x + radius * Math.sin(polar) * Math.sin(az),
target.y + radius * Math.cos(polar),
target.z + radius * Math.sin(polar) * Math.cos(az),
);
camera.lookAt(target);
};
const resize = (w: number, h: number) => {
if (w < 2 || h < 2) return;
renderer.setSize(w, h, false);
camera.aspect = w / h;
const wide = camera.aspect > 1.05;
// Wide: the map sits to the right of the copy. Narrow: it sits on top.
camera.setViewOffset(
w,
h,
wide ? -w * 0.25 : 0,
wide ? h * 0.04 : -h * 0.07,
w,
h,
);
// Far enough back that the whole tile fits the width.
const fit =
8.4 /
(Math.tan(THREE.MathUtils.degToRad(camera.fov / 2)) * camera.aspect);
radius = Math.max(
wide ? 22 * Math.max(1, 1.55 / camera.aspect) : 26,
fit,
);
camera.updateProjectionMatrix();
};
const ro = new ResizeObserver(([e]) =>
resize(e.contentRect.width, e.contentRect.height),
);
ro.observe(stage);
/* ---- Reading the ground under the cursor: march the ray over the height field ---- */
const ray = new THREE.Raycaster();
const ndc = new THREE.Vector2();
const groundAt = (clientX: number, clientY: number) => {
const r = stage.getBoundingClientRect();
ndc.set(
((clientX - r.left) / r.width) * 2 - 1,
-((clientY - r.top) / r.height) * 2 + 1,
);
ray.setFromCamera(ndc, camera);
const o = ray.ray.origin
.clone()
.applyMatrix4(new THREE.Matrix4().copy(map.matrixWorld).invert());
const dir = ray.ray.direction
.clone()
.transformDirection(new THREE.Matrix4().copy(map.matrixWorld).invert());
// March only through the box the ground lives in.
const box = new THREE.Box3(
new THREE.Vector3(-SIZE / 2, 0, -SIZE / 2),
new THREE.Vector3(SIZE / 2, 3, SIZE / 2),
);
const local = new THREE.Ray(o, dir);
const enter = local.intersectBox(box, new THREE.Vector3());
if (!enter) return null;
let t = enter.distanceTo(o);
let prevT = t;
for (let i = 0; i < 360; i++) {
const p = o.clone().addScaledVector(dir, t);
if (
Math.abs(p.x) > SIZE / 2 + 0.01 ||
Math.abs(p.z) > SIZE / 2 + 0.01 ||
p.y < -0.5
)
return null;
if (p.y <= height(p.x, p.z)) {
// Refine between the last two steps.
let lo = prevT;
let hi = t;
for (let k = 0; k < 10; k++) {
const mid = (lo + hi) / 2;
const q = o.clone().addScaledVector(dir, mid);
if (q.y <= height(q.x, q.z)) hi = mid;
else lo = mid;
}
return o.clone().addScaledVector(dir, hi);
}
prevT = t;
t += 0.05;
}
return null;
};
let dragging = false;
let moved = 0;
let lastX = 0;
let lastY = 0;
let touched = -1e9;
let pointer: { x: number; y: number } | null = null;
const onDown = (e: PointerEvent) => {
dragging = true;
moved = 0;
lastX = e.clientX;
lastY = e.clientY;
stage.setPointerCapture?.(e.pointerId);
};
const onMove = (e: PointerEvent) => {
pointer = { x: e.clientX, y: e.clientY };
if (!dragging) return;
const dx = e.clientX - lastX;
const dy = e.clientY - lastY;
moved += Math.abs(dx) + Math.abs(dy);
lastX = e.clientX;
lastY = e.clientY;
if (moved > 6) {
stage.dataset.dragging = "true";
az -= dx * 0.006;
polar = THREE.MathUtils.clamp(polar - dy * 0.004, 0.45, 1.2);
touched = performance.now();
}
};
const onUp = (e: PointerEvent) => {
if (dragging && moved <= 6) {
const hit = groundAt(e.clientX, e.clientY);
if (hit) {
const stop: Stop = [
Math.round(hit.x * 100) / 100,
Math.round(hit.z * 100) / 100,
];
setStops((s) => [...s, stop].slice(-MAX_STOPS));
}
}
dragging = false;
delete stage.dataset.dragging;
};
const onLeave = () => {
pointer = null;
};
const onKey = (e: KeyboardEvent) => {
if (e.key === "ArrowLeft") az += 0.1;
else if (e.key === "ArrowRight") az -= 0.1;
else if (e.key === "ArrowUp") polar = Math.max(0.45, polar - 0.06);
else if (e.key === "ArrowDown") polar = Math.min(1.2, polar + 0.06);
else return;
e.preventDefault();
touched = performance.now();
};
stage.addEventListener("pointerdown", onDown);
stage.addEventListener("pointermove", onMove);
stage.addEventListener("pointerup", onUp);
stage.addEventListener("pointercancel", onUp);
stage.addEventListener("pointerleave", onLeave);
stage.addEventListener("keydown", onKey);
/* ---- Loop ---- */
let raf = 0;
let visible = true;
let last = performance.now();
const v = new THREE.Vector3();
const loop = (now: number) => {
raf = 0;
if (!visible || document.hidden) return;
const dt = Math.min(0.05, (now - last) / 1000);
last = now;
if (!reduce && !dragging && now - touched > 3000) az += dt * 0.05;
place();
map.updateMatrixWorld();
// Hover read-out.
const tip = tipRef.current;
const hit = pointer && !dragging ? groundAt(pointer.x, pointer.y) : null;
if (hit) {
uniforms.uHover.value.set(hit.x, hit.z);
uniforms.uHoverOn.value = Math.min(1, uniforms.uHoverOn.value + 0.15);
if (tip && pointer) {
const r = stage.getBoundingClientRect();
const sx = stage.offsetWidth / r.width;
tip.style.transform = `translate(${(pointer.x - r.left) * sx + 16}px, ${(pointer.y - r.top) * sx - 40}px)`;
tip.textContent = `${metres(hit.y).toLocaleString("en")} m`;
tip.dataset.on = "true";
}
} else {
uniforms.uHoverOn.value = Math.max(0, uniforms.uHoverOn.value - 0.15);
if (tip) delete tip.dataset.on;
}
// Numbered pins follow their stops on screen.
const pins = root.querySelectorAll<HTMLElement>("[data-pin]");
const w = stage.offsetWidth;
const h = stage.offsetHeight;
pins.forEach((pin) => {
const x = Number(pin.dataset.x);
const z = Number(pin.dataset.z);
v.set(x, height(x, z) + 0.72, z).project(camera);
pin.style.transform = `translate(${((v.x + 1) / 2) * w}px, ${((1 - v.y) / 2) * h}px)`;
});
renderer.render(scene, camera);
raf = requestAnimationFrame(loop);
};
const wake = () => {
if (!raf && visible && !document.hidden) {
last = performance.now();
raf = requestAnimationFrame(loop);
}
};
const io = new IntersectionObserver(([e]) => {
visible = e.isIntersecting;
wake();
});
io.observe(stage);
document.addEventListener("visibilitychange", wake);
wake();
return () => {
cancelAnimationFrame(raf);
ro.disconnect();
io.disconnect();
document.removeEventListener("visibilitychange", wake);
stage.removeEventListener("pointerdown", onDown);
stage.removeEventListener("pointermove", onMove);
stage.removeEventListener("pointerup", onUp);
stage.removeEventListener("pointercancel", onUp);
stage.removeEventListener("pointerleave", onLeave);
stage.removeEventListener("keydown", onKey);
apiRef.current = null;
scene.traverse((o) => {
if (o instanceof THREE.Mesh) {
o.geometry.dispose();
(o.material as THREE.Material).dispose();
}
});
renderer.dispose();
renderer.forceContextLoss();
renderer.domElement.remove();
};
}, [height]);
// Push the route into the scene whenever it changes (runs after the scene exists).
useEffect(() => {
apiRef.current?.setRoute(info.pts);
}, [info]);
// The elevation profile, as an SVG path across the route.
const profile = useMemo(() => {
if (info.pts.length < 2) return null;
const hs = info.pts.map((p) => metres(p.y));
const lo = Math.min(...hs) - 40;
const hi = Math.max(...hs) + 40;
const line = hs
.map(
(m, i) =>
`${((i / (hs.length - 1)) * 300).toFixed(1)},${(78 - ((m - lo) / (hi - lo)) * 70).toFixed(1)}`,
)
.join(" L");
return {
line: `M${line}`,
area: `M0,80 L${line} L300,80 Z`,
top: Math.max(...hs),
bottom: Math.min(...hs),
};
}, [info]);
const hours = Math.floor(info.minutes / 60);
const mins = info.minutes % 60;
return (
<section
ref={rootRef}
className="gu-contour"
data-failed={failed || undefined}
aria-labelledby="gu-contour-title"
>
<div
ref={stageRef}
className="gu-contour__stage"
tabIndex={0}
aria-label="3D map. Click to add a stop to the route; drag or use the arrow keys to turn the map."
/>
{failed && <div className="gu-contour__fallback" aria-hidden="true" />}
<div ref={tipRef} className="gu-contour__tip" aria-hidden="true" />
<div className="gu-contour__pins" aria-hidden="true">
{stops.map(([x, z], i) => (
<span key={`${x},${z},${i}`} data-pin data-x={x} data-z={z}>
<b>{i + 1}</b>
</span>
))}
</div>
<header className="gu-contour__bar">
<a className="gu-contour__mark" href="#">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M2 18c4-1 5-6 9-6s4 4 8 3M4 13c3-1 4-5 7-5s3 3 6 2M7 8c2-1 3-3 5-3s2 2 4 1" />
</svg>
Contour
</a>
<nav aria-label="Main">
<a href="#contour-maps">Maps</a>
<a href="#contour-routes">Routes</a>
<a href="#contour-pricing">Pricing</a>
</nav>
</header>
<div className="gu-contour__copy">
<h1 id="gu-contour-title">{title}</h1>
<p>{text}</p>
<a className="gu-contour__cta" href={cta.href}>
{cta.label}
</a>
</div>
<aside className="gu-contour__card" aria-label="Your route">
<dl>
<div>
<dt>Distance</dt>
<dd>{info.km.toFixed(1)} km</dd>
</div>
<div>
<dt>Climb</dt>
<dd>{info.climb.toLocaleString("en")} m</dd>
</div>
<div>
<dt>Walking time</dt>
<dd>{hours > 0 ? `${hours} h ${mins} min` : `${mins} min`}</dd>
</div>
</dl>
{profile ? (
<svg
className="gu-contour__profile"
viewBox="0 0 300 80"
preserveAspectRatio="none"
role="img"
aria-label={`Elevation from ${profile.bottom} to ${profile.top} metres`}
>
<path d={profile.area} />
<path d={profile.line} />
</svg>
) : (
<p className="gu-contour__empty">
Click two places on the map to draw a route.
</p>
)}
<div className="gu-contour__actions">
<span>
{stops.length} {stops.length === 1 ? "stop" : "stops"}
</span>
<button
type="button"
onClick={() => setStops((s) => s.slice(0, -1))}
disabled={!stops.length}
>
Undo
</button>
<button
type="button"
onClick={() => setStops([])}
disabled={!stops.length}
>
Clear
</button>
</div>
</aside>
</section>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Contour map 3D hero
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A hero for a hiking map app ("Contour"). A made-up mountain range is shown as a 3D relief model (three.js) drawn in a paper-map style. Visitors read heights under the cursor, click to add stops, and watch the route and its numbers update.
## Layout and look
- Section min-height 740px. Paper #efe8d8 with a faint 32px drafting grid and a lighter glow behind the map. Ink #2a211b, muted #6e6152, route orange #ff5a1f.
- Top bar: a three-line contour logo in orange + bold wordmark, three nav links.
- Left: a heavy, tight h1, a muted paragraph and a dark 12px-radius button. Bottom left: a frosted route card with Distance, Climb and Walking time in big tabular numbers, an SVG elevation profile (orange line over a pale fill), the stop count, and Undo and Clear buttons.
- The map sits right of the copy (camera.setViewOffset shifts it) and turns slowly.
## The 3D scene
1. Heights come from one seeded JS value-noise function (5 octaves, raised to the power 1.7, faded at the tile edges, with a gaussian dip for a lake). The PlaneGeometry (12 × 12, 180 segments) and every lookup use the same function.
2. ShaderMaterial: hypsometric tints (sage → sand → pale cream), light from the upper left, flat blue water below 0.12 with fine hatching, contour lines every 0.08 units with a darker index line every fifth (drawn with fract + fwidth), and an orange ring + dot under the cursor.
3. A dark box under the plane makes it read like a mounted relief model.
4. Route: straight lines between stops sampled 48 times each, lifted 0.04 above the ground, drawn as a TubeGeometry along a centripetal CatmullRomCurve3.
## Behaviour
- Pointer hits are found by marching the camera ray over the height field, then refining with a binary search (no mesh raycast). A small dark tag next to the cursor shows the height in metres (420 + h × 1100).
- Click (pointer moved under 6px) adds a stop (8 at most). Drag turns the map (azimuth + clamped tilt). The map drifts on its own 3s after the last touch.
- Numbered orange pins are HTML, placed each frame by projecting their stops.
- Stats: distance × 0.8 km per unit, climb is the sum of rises, and time uses Naismith's rule (5 km/h + 10 min per 100 m of climb).
- Rendering pauses off screen; dispose everything and call `forceContextLoss()` on unmount. Without WebGL a CSS contour drawing stands in.
## Accessibility
The stage is focusable with a label explaining click and drag, and arrow keys turn the map. The route card is an aside with a dl; the profile is an SVG with role img and a text range.
## Props
title, text, cta ({ label, href }), seed, route ([x, z] stops).
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: three. Translate it faithfully; do not add new libraries unless my framework needs them.
### TerrainHero.tsx
```tsx
"use client";
import { useEffect, useMemo, useRef, useState } from "react";
import * as THREE from "three";
import "./terrain-hero.css";
type Stop = [number, number];
type TerrainHeroProps = {
title?: string;
text?: string;
cta?: { label: string; href: string };
/** Seed for the made-up mountains: change it for a different range. */
seed?: number;
/** Starting route, in map units (-6 to 6 on both axes). */
route?: Stop[];
};
const SIZE = 12;
const RES = 180;
const MAX_STOPS = 8;
/** One map unit in kilometres, and how heights turn into metres. */
const KM_PER_UNIT = 0.8;
const metres = (h: number) => Math.round(420 + h * 1100);
/** A small seeded value-noise, shared by the mesh and by every height lookup. */
function makeHeight(seed: number) {
const hash = (x: number, z: number) => {
const s = Math.sin(x * 127.1 + z * 311.7 + seed * 74.7) * 43758.5453;
return s - Math.floor(s);
};
const smooth = (t: number) => t * t * (3 - 2 * t);
const noise = (x: number, z: number) => {
const ix = Math.floor(x);
const iz = Math.floor(z);
const fx = smooth(x - ix);
const fz = smooth(z - iz);
const a = hash(ix, iz);
const b = hash(ix + 1, iz);
const c = hash(ix, iz + 1);
const d = hash(ix + 1, iz + 1);
return a + (b - a) * fx + (c - a) * fz + (a - b - c + d) * fx * fz;
};
return (x: number, z: number) => {
let amp = 1;
let freq = 0.22;
let sum = 0;
let norm = 0;
for (let o = 0; o < 5; o++) {
sum += noise(x * freq + 11, z * freq + 7) * amp;
norm += amp;
amp *= 0.5;
freq *= 2.1;
}
const n = sum / norm;
const edge = Math.max(Math.abs(x), Math.abs(z));
const mask = 1 - THREE.MathUtils.smoothstep(edge, 3.8, 6);
const lake = Math.exp(-((x + 1.9) ** 2 + (z - 1.6) ** 2) / 1.6) * 0.55;
return Math.max(0.02, 0.18 + Math.pow(n, 1.7) * 2.0 * mask - lake);
};
}
/** Points along the route (straight lines over the ground), with total distance and climb. */
function trace(stops: Stop[], height: (x: number, z: number) => number) {
const pts: THREE.Vector3[] = [];
let dist = 0;
let climb = 0;
for (let i = 0; i < stops.length - 1; i++) {
const [ax, az] = stops[i];
const [bx, bz] = stops[i + 1];
const steps = 48;
for (let s = i === 0 ? 0 : 1; s <= steps; s++) {
const t = s / steps;
const x = ax + (bx - ax) * t;
const z = az + (bz - az) * t;
const p = new THREE.Vector3(x, height(x, z), z);
const prev = pts[pts.length - 1];
if (prev) {
dist += Math.hypot(p.x - prev.x, p.z - prev.z);
const dh = metres(p.y) - metres(prev.y);
if (dh > 0) climb += dh;
}
pts.push(p);
}
}
const km = dist * KM_PER_UNIT;
// Naismith's rule: 5 km an hour, plus 10 minutes for every 100 m of climb.
const minutes = Math.round((km / 5) * 60 + (climb / 100) * 10);
return { pts, km, climb: Math.round(climb), minutes };
}
const vertex = /* glsl */ `
varying float vH;
varying vec3 vN;
varying vec3 vP;
void main() {
vH = position.y;
vN = normal;
vP = position;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
const fragment = /* glsl */ `
uniform vec2 uHover;
uniform float uHoverOn;
varying float vH;
varying vec3 vN;
varying vec3 vP;
float contour(float v, float width) {
float f = abs(fract(v - 0.5) - 0.5) / fwidth(v);
return 1.0 - min(f / width, 1.0);
}
void main() {
vec3 low = vec3(0.79, 0.82, 0.66);
vec3 mid = vec3(0.89, 0.82, 0.63);
vec3 high = vec3(0.96, 0.94, 0.9);
vec3 col = mix(low, mid, smoothstep(0.15, 0.9, vH));
col = mix(col, high, smoothstep(1.0, 1.9, vH));
float light = clamp(dot(normalize(vN), normalize(vec3(-0.55, 0.75, 0.35))), 0.0, 1.0);
col *= 0.7 + 0.42 * light;
// Water: flat blue with the fine hatching old maps use.
float water = 1.0 - smoothstep(0.11, 0.13, vH);
float hatch = contour(vP.z * 14.0, 1.0) * 0.35;
col = mix(col, mix(vec3(0.62, 0.76, 0.8), vec3(0.4, 0.55, 0.62), hatch), water);
// Contour lines every 0.08 units, a darker index line every fifth.
float minor = contour(vH / 0.08, 1.0) * (1.0 - water);
float major = contour(vH / 0.4, 1.6) * (1.0 - water);
vec3 ink = vec3(0.5, 0.32, 0.22);
col = mix(col, ink, minor * 0.32 + major * 0.6);
// The ring under the cursor.
float d = length(vP.xz - uHover);
float ring = 1.0 - smoothstep(0.0, 0.03, abs(d - 0.32));
float dot2 = 1.0 - smoothstep(0.05, 0.07, d);
col = mix(col, vec3(1.0, 0.35, 0.12), (ring + dot2) * uHoverOn);
gl_FragColor = vec4(col, 1.0);
}
`;
/**
* TerrainHero
* - A made-up mountain range, drawn like a paper map: hypsometric colours, contour lines,
* hatched water. Heights come from one JS function, so lookups always match the mesh.
* - Hover reads the height under the cursor; click adds a stop; the route, an elevation
* profile, distance, climb and walking time update as you go.
* - Drag turns the map. It drifts slowly until touched.
*/
export function TerrainHero({
title = "Plan the climb before you lace up.",
text = "Contour turns any ridge into a route you can read: every stop, every metre of climb and an honest walking time.",
cta = { label: "Get Contour for free", href: "#contour-get" },
seed = 3,
route: initial = [
[-3.4, 2.6],
[-0.6, 0.2],
[1.6, -1.4],
[3.3, -3.2],
],
}: TerrainHeroProps) {
const rootRef = useRef<HTMLElement>(null);
const stageRef = useRef<HTMLDivElement>(null);
const tipRef = useRef<HTMLDivElement>(null);
const apiRef = useRef<{ setRoute: (pts: THREE.Vector3[]) => void } | null>(
null,
);
const [stops, setStops] = useState<Stop[]>(initial);
const [failed, setFailed] = useState(false);
const height = useMemo(() => makeHeight(seed), [seed]);
const info = useMemo(() => trace(stops, height), [stops, height]);
useEffect(() => {
const root = rootRef.current;
const stage = stageRef.current;
if (!root || !stage) return;
const reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
let renderer: THREE.WebGLRenderer;
try {
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
} catch {
const id = requestAnimationFrame(() => setFailed(true));
return () => cancelAnimationFrame(id);
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(32, 1, 0.1, 100);
const target = new THREE.Vector3(0, 0.4, 0);
/* ---- The ground ---- */
const geo = new THREE.PlaneGeometry(SIZE, SIZE, RES, RES);
geo.rotateX(-Math.PI / 2);
const pos = geo.attributes.position;
for (let i = 0; i < pos.count; i++)
pos.setY(i, height(pos.getX(i), pos.getZ(i)));
geo.computeVertexNormals();
const uniforms = {
uHover: { value: new THREE.Vector2(99, 99) },
uHoverOn: { value: 0 },
};
const ground = new THREE.Mesh(
geo,
new THREE.ShaderMaterial({
uniforms,
vertexShader: vertex,
fragmentShader: fragment,
}),
);
const map = new THREE.Group();
map.add(ground);
// The map's cut edge: a thin dark base, like a mounted relief model.
const base = new THREE.Mesh(
new THREE.BoxGeometry(SIZE, 0.35, SIZE),
new THREE.MeshBasicMaterial({ color: "#3d2b20" }),
);
base.position.y = -0.05;
map.add(base);
scene.add(map);
/* ---- The route ---- */
const routeMat = new THREE.MeshBasicMaterial({ color: "#ff5a1f" });
let tube: THREE.Mesh | null = null;
apiRef.current = {
setRoute(pts) {
if (tube) {
map.remove(tube);
tube.geometry.dispose();
tube = null;
}
if (pts.length > 1) {
const lifted = pts.map(
(p) => new THREE.Vector3(p.x, p.y + 0.04, p.z),
);
const curve = new THREE.CatmullRomCurve3(
lifted,
false,
"centripetal",
);
tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, lifted.length * 2, 0.04, 6),
routeMat,
);
map.add(tube);
}
},
};
/* ---- Camera orbit ---- */
let az = 0.6;
let polar = 0.92;
let radius = 16;
const place = () => {
camera.position.set(
target.x + radius * Math.sin(polar) * Math.sin(az),
target.y + radius * Math.cos(polar),
target.z + radius * Math.sin(polar) * Math.cos(az),
);
camera.lookAt(target);
};
const resize = (w: number, h: number) => {
if (w < 2 || h < 2) return;
renderer.setSize(w, h, false);
camera.aspect = w / h;
const wide = camera.aspect > 1.05;
// Wide: the map sits to the right of the copy. Narrow: it sits on top.
camera.setViewOffset(
w,
h,
wide ? -w * 0.25 : 0,
wide ? h * 0.04 : -h * 0.07,
w,
h,
);
// Far enough back that the whole tile fits the width.
const fit =
8.4 /
(Math.tan(THREE.MathUtils.degToRad(camera.fov / 2)) * camera.aspect);
radius = Math.max(
wide ? 22 * Math.max(1, 1.55 / camera.aspect) : 26,
fit,
);
camera.updateProjectionMatrix();
};
const ro = new ResizeObserver(([e]) =>
resize(e.contentRect.width, e.contentRect.height),
);
ro.observe(stage);
/* ---- Reading the ground under the cursor: march the ray over the height field ---- */
const ray = new THREE.Raycaster();
const ndc = new THREE.Vector2();
const groundAt = (clientX: number, clientY: number) => {
const r = stage.getBoundingClientRect();
ndc.set(
((clientX - r.left) / r.width) * 2 - 1,
-((clientY - r.top) / r.height) * 2 + 1,
);
ray.setFromCamera(ndc, camera);
const o = ray.ray.origin
.clone()
.applyMatrix4(new THREE.Matrix4().copy(map.matrixWorld).invert());
const dir = ray.ray.direction
.clone()
.transformDirection(new THREE.Matrix4().copy(map.matrixWorld).invert());
// March only through the box the ground lives in.
const box = new THREE.Box3(
new THREE.Vector3(-SIZE / 2, 0, -SIZE / 2),
new THREE.Vector3(SIZE / 2, 3, SIZE / 2),
);
const local = new THREE.Ray(o, dir);
const enter = local.intersectBox(box, new THREE.Vector3());
if (!enter) return null;
let t = enter.distanceTo(o);
let prevT = t;
for (let i = 0; i < 360; i++) {
const p = o.clone().addScaledVector(dir, t);
if (
Math.abs(p.x) > SIZE / 2 + 0.01 ||
Math.abs(p.z) > SIZE / 2 + 0.01 ||
p.y < -0.5
)
return null;
if (p.y <= height(p.x, p.z)) {
// Refine between the last two steps.
let lo = prevT;
let hi = t;
for (let k = 0; k < 10; k++) {
const mid = (lo + hi) / 2;
const q = o.clone().addScaledVector(dir, mid);
if (q.y <= height(q.x, q.z)) hi = mid;
else lo = mid;
}
return o.clone().addScaledVector(dir, hi);
}
prevT = t;
t += 0.05;
}
return null;
};
let dragging = false;
let moved = 0;
let lastX = 0;
let lastY = 0;
let touched = -1e9;
let pointer: { x: number; y: number } | null = null;
const onDown = (e: PointerEvent) => {
dragging = true;
moved = 0;
lastX = e.clientX;
lastY = e.clientY;
stage.setPointerCapture?.(e.pointerId);
};
const onMove = (e: PointerEvent) => {
pointer = { x: e.clientX, y: e.clientY };
if (!dragging) return;
const dx = e.clientX - lastX;
const dy = e.clientY - lastY;
moved += Math.abs(dx) + Math.abs(dy);
lastX = e.clientX;
lastY = e.clientY;
if (moved > 6) {
stage.dataset.dragging = "true";
az -= dx * 0.006;
polar = THREE.MathUtils.clamp(polar - dy * 0.004, 0.45, 1.2);
touched = performance.now();
}
};
const onUp = (e: PointerEvent) => {
if (dragging && moved <= 6) {
const hit = groundAt(e.clientX, e.clientY);
if (hit) {
const stop: Stop = [
Math.round(hit.x * 100) / 100,
Math.round(hit.z * 100) / 100,
];
setStops((s) => [...s, stop].slice(-MAX_STOPS));
}
}
dragging = false;
delete stage.dataset.dragging;
};
const onLeave = () => {
pointer = null;
};
const onKey = (e: KeyboardEvent) => {
if (e.key === "ArrowLeft") az += 0.1;
else if (e.key === "ArrowRight") az -= 0.1;
else if (e.key === "ArrowUp") polar = Math.max(0.45, polar - 0.06);
else if (e.key === "ArrowDown") polar = Math.min(1.2, polar + 0.06);
else return;
e.preventDefault();
touched = performance.now();
};
stage.addEventListener("pointerdown", onDown);
stage.addEventListener("pointermove", onMove);
stage.addEventListener("pointerup", onUp);
stage.addEventListener("pointercancel", onUp);
stage.addEventListener("pointerleave", onLeave);
stage.addEventListener("keydown", onKey);
/* ---- Loop ---- */
let raf = 0;
let visible = true;
let last = performance.now();
const v = new THREE.Vector3();
const loop = (now: number) => {
raf = 0;
if (!visible || document.hidden) return;
const dt = Math.min(0.05, (now - last) / 1000);
last = now;
if (!reduce && !dragging && now - touched > 3000) az += dt * 0.05;
place();
map.updateMatrixWorld();
// Hover read-out.
const tip = tipRef.current;
const hit = pointer && !dragging ? groundAt(pointer.x, pointer.y) : null;
if (hit) {
uniforms.uHover.value.set(hit.x, hit.z);
uniforms.uHoverOn.value = Math.min(1, uniforms.uHoverOn.value + 0.15);
if (tip && pointer) {
const r = stage.getBoundingClientRect();
const sx = stage.offsetWidth / r.width;
tip.style.transform = `translate(${(pointer.x - r.left) * sx + 16}px, ${(pointer.y - r.top) * sx - 40}px)`;
tip.textContent = `${metres(hit.y).toLocaleString("en")} m`;
tip.dataset.on = "true";
}
} else {
uniforms.uHoverOn.value = Math.max(0, uniforms.uHoverOn.value - 0.15);
if (tip) delete tip.dataset.on;
}
// Numbered pins follow their stops on screen.
const pins = root.querySelectorAll<HTMLElement>("[data-pin]");
const w = stage.offsetWidth;
const h = stage.offsetHeight;
pins.forEach((pin) => {
const x = Number(pin.dataset.x);
const z = Number(pin.dataset.z);
v.set(x, height(x, z) + 0.72, z).project(camera);
pin.style.transform = `translate(${((v.x + 1) / 2) * w}px, ${((1 - v.y) / 2) * h}px)`;
});
renderer.render(scene, camera);
raf = requestAnimationFrame(loop);
};
const wake = () => {
if (!raf && visible && !document.hidden) {
last = performance.now();
raf = requestAnimationFrame(loop);
}
};
const io = new IntersectionObserver(([e]) => {
visible = e.isIntersecting;
wake();
});
io.observe(stage);
document.addEventListener("visibilitychange", wake);
wake();
return () => {
cancelAnimationFrame(raf);
ro.disconnect();
io.disconnect();
document.removeEventListener("visibilitychange", wake);
stage.removeEventListener("pointerdown", onDown);
stage.removeEventListener("pointermove", onMove);
stage.removeEventListener("pointerup", onUp);
stage.removeEventListener("pointercancel", onUp);
stage.removeEventListener("pointerleave", onLeave);
stage.removeEventListener("keydown", onKey);
apiRef.current = null;
scene.traverse((o) => {
if (o instanceof THREE.Mesh) {
o.geometry.dispose();
(o.material as THREE.Material).dispose();
}
});
renderer.dispose();
renderer.forceContextLoss();
renderer.domElement.remove();
};
}, [height]);
// Push the route into the scene whenever it changes (runs after the scene exists).
useEffect(() => {
apiRef.current?.setRoute(info.pts);
}, [info]);
// The elevation profile, as an SVG path across the route.
const profile = useMemo(() => {
if (info.pts.length < 2) return null;
const hs = info.pts.map((p) => metres(p.y));
const lo = Math.min(...hs) - 40;
const hi = Math.max(...hs) + 40;
const line = hs
.map(
(m, i) =>
`${((i / (hs.length - 1)) * 300).toFixed(1)},${(78 - ((m - lo) / (hi - lo)) * 70).toFixed(1)}`,
)
.join(" L");
return {
line: `M${line}`,
area: `M0,80 L${line} L300,80 Z`,
top: Math.max(...hs),
bottom: Math.min(...hs),
};
}, [info]);
const hours = Math.floor(info.minutes / 60);
const mins = info.minutes % 60;
return (
<section
ref={rootRef}
className="gu-contour"
data-failed={failed || undefined}
aria-labelledby="gu-contour-title"
>
<div
ref={stageRef}
className="gu-contour__stage"
tabIndex={0}
aria-label="3D map. Click to add a stop to the route; drag or use the arrow keys to turn the map."
/>
{failed && <div className="gu-contour__fallback" aria-hidden="true" />}
<div ref={tipRef} className="gu-contour__tip" aria-hidden="true" />
<div className="gu-contour__pins" aria-hidden="true">
{stops.map(([x, z], i) => (
<span key={`${x},${z},${i}`} data-pin data-x={x} data-z={z}>
<b>{i + 1}</b>
</span>
))}
</div>
<header className="gu-contour__bar">
<a className="gu-contour__mark" href="#">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M2 18c4-1 5-6 9-6s4 4 8 3M4 13c3-1 4-5 7-5s3 3 6 2M7 8c2-1 3-3 5-3s2 2 4 1" />
</svg>
Contour
</a>
<nav aria-label="Main">
<a href="#contour-maps">Maps</a>
<a href="#contour-routes">Routes</a>
<a href="#contour-pricing">Pricing</a>
</nav>
</header>
<div className="gu-contour__copy">
<h1 id="gu-contour-title">{title}</h1>
<p>{text}</p>
<a className="gu-contour__cta" href={cta.href}>
{cta.label}
</a>
</div>
<aside className="gu-contour__card" aria-label="Your route">
<dl>
<div>
<dt>Distance</dt>
<dd>{info.km.toFixed(1)} km</dd>
</div>
<div>
<dt>Climb</dt>
<dd>{info.climb.toLocaleString("en")} m</dd>
</div>
<div>
<dt>Walking time</dt>
<dd>{hours > 0 ? `${hours} h ${mins} min` : `${mins} min`}</dd>
</div>
</dl>
{profile ? (
<svg
className="gu-contour__profile"
viewBox="0 0 300 80"
preserveAspectRatio="none"
role="img"
aria-label={`Elevation from ${profile.bottom} to ${profile.top} metres`}
>
<path d={profile.area} />
<path d={profile.line} />
</svg>
) : (
<p className="gu-contour__empty">
Click two places on the map to draw a route.
</p>
)}
<div className="gu-contour__actions">
<span>
{stops.length} {stops.length === 1 ? "stop" : "stops"}
</span>
<button
type="button"
onClick={() => setStops((s) => s.slice(0, -1))}
disabled={!stops.length}
>
Undo
</button>
<button
type="button"
onClick={() => setStops([])}
disabled={!stops.length}
>
Clear
</button>
</div>
</aside>
</section>
);
}
```
### terrain-hero.css
```css
/* Contour: a relief map on a drafting table, with a route drawn in signal orange. */
.gu-contour {
--bg: #efe8d8;
--paper: #f7f2e7;
--ink: #2a211b;
--muted: #6e6152;
--line: rgb(42 33 27 / 0.16);
--route: #ff5a1f;
--focus: #2b35ff;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
position: relative;
container-type: inline-size;
min-height: 740px;
overflow: hidden;
isolation: isolate;
background:
linear-gradient(rgb(42 33 27 / 0.045) 1px, transparent 1px) 0 0 / 32px 32px,
linear-gradient(90deg, rgb(42 33 27 / 0.045) 1px, transparent 1px) 0 0 /
32px 32px,
radial-gradient(70% 80% at 65% 55%, var(--paper), var(--bg));
color: var(--ink);
font-family:
system-ui,
-apple-system,
"Segoe UI",
sans-serif;
line-height: 1.5;
}
.gu-contour *,
.gu-contour *::before,
.gu-contour *::after {
box-sizing: border-box;
}
.gu-contour a {
color: inherit;
}
.gu-contour :focus-visible {
outline: 3px solid var(--focus);
outline-offset: 3px;
}
.gu-contour__stage {
position: absolute;
inset: 0;
z-index: 0;
cursor: crosshair;
}
.gu-contour__stage[data-dragging] {
cursor: grabbing;
}
.gu-contour__stage:focus-visible {
outline-offset: -6px;
}
.gu-contour__stage canvas {
display: block;
width: 100%;
height: 100%;
}
/* Height read-out that follows the cursor. */
.gu-contour__tip {
position: absolute;
left: 0;
top: 0;
z-index: 2;
padding: 4px 9px;
border-radius: 6px;
background: var(--ink);
color: var(--paper);
font-size: 0.8rem;
font-weight: 650;
font-variant-numeric: tabular-nums;
white-space: nowrap;
pointer-events: none;
opacity: 0;
transition: opacity 0.2s;
}
.gu-contour__tip[data-on] {
opacity: 1;
}
/* Numbered flags on each stop. */
.gu-contour__pins {
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
}
.gu-contour__pins span {
position: absolute;
left: 0;
top: 0;
}
.gu-contour__pins b {
position: absolute;
left: -13px;
bottom: 8px;
display: grid;
place-items: center;
width: 26px;
height: 26px;
border: 2px solid var(--paper);
border-radius: 50%;
background: var(--route);
color: #fff;
font-size: 0.75rem;
box-shadow: 0 6px 14px -6px rgb(42 33 27 / 0.7);
animation: gu-contour-drop 0.6s var(--ease) both;
}
.gu-contour__pins b::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 2px;
height: 9px;
translate: -50% 1px;
background: var(--ink);
}
@keyframes gu-contour-drop {
from {
opacity: 0;
translate: 0 -24px;
}
}
.gu-contour__bar {
position: relative;
z-index: 3;
display: flex;
align-items: center;
justify-content: space-between;
padding: 24px 5%;
pointer-events: none;
}
.gu-contour__bar a {
pointer-events: auto;
}
.gu-contour__mark {
display: inline-flex;
align-items: center;
gap: 8px;
font-weight: 800;
font-size: 1.2rem;
letter-spacing: -0.02em;
text-decoration: none;
}
.gu-contour__mark svg {
width: 26px;
fill: none;
stroke: var(--route);
stroke-width: 1.8;
stroke-linecap: round;
}
.gu-contour__bar nav {
display: flex;
gap: 24px;
font-size: 0.92rem;
}
.gu-contour__bar nav a {
text-decoration: none;
opacity: 0.75;
transition: opacity 0.2s;
}
.gu-contour__bar nav a:hover {
opacity: 1;
}
.gu-contour__copy {
position: relative;
z-index: 3;
width: min(440px, 40cqi);
margin: 56px 0 0 5%;
pointer-events: none;
}
.gu-contour__copy a {
pointer-events: auto;
}
.gu-contour__copy h1 {
margin: 0 0 16px;
font-size: clamp(2.2rem, 4.6cqi, 3.8rem);
font-weight: 850;
line-height: 0.98;
letter-spacing: -0.035em;
text-wrap: balance;
animation: gu-contour-rise 1s var(--ease) both;
}
.gu-contour__copy p {
margin: 0 0 26px;
max-width: 38ch;
color: var(--muted);
animation: gu-contour-rise 1s var(--ease) 0.1s both;
}
.gu-contour__cta {
display: inline-flex;
align-items: center;
min-height: 48px;
padding: 0 22px;
border-radius: 12px;
background: var(--ink);
color: var(--paper) !important;
font-weight: 700;
text-decoration: none;
transition: transform 0.35s var(--ease);
animation: gu-contour-rise 1s var(--ease) 0.2s both;
}
.gu-contour__cta:hover {
transform: translateY(-2px);
}
/* The route card: three numbers, the elevation profile and two small actions. */
.gu-contour__card {
position: absolute;
left: 5%;
bottom: 36px;
z-index: 3;
width: min(380px, 40cqi);
padding: 18px 18px 14px;
border: 1px solid var(--line);
border-radius: 16px;
background: rgb(247 242 231 / 0.86);
backdrop-filter: blur(10px);
box-shadow: 0 24px 50px -30px rgb(42 33 27 / 0.6);
animation: gu-contour-rise 1s var(--ease) 0.3s both;
}
.gu-contour__card dl {
display: grid;
grid-template-columns: repeat(3, auto);
gap: 12px;
margin: 0 0 12px;
}
.gu-contour__card dt {
font-size: 0.72rem;
color: var(--muted);
}
.gu-contour__card dd {
margin: 0;
font-size: 1.15rem;
font-weight: 800;
font-variant-numeric: tabular-nums;
letter-spacing: -0.02em;
white-space: nowrap;
}
.gu-contour__profile {
display: block;
width: 100%;
height: 64px;
overflow: visible;
}
.gu-contour__profile path:first-child {
fill: rgb(255 90 31 / 0.14);
}
.gu-contour__profile path:last-child {
fill: none;
stroke: var(--route);
stroke-width: 2;
vector-effect: non-scaling-stroke;
stroke-linejoin: round;
}
.gu-contour__empty {
display: grid;
place-items: center;
height: 64px;
margin: 0;
border: 1px dashed var(--line);
border-radius: 10px;
color: var(--muted);
font-size: 0.85rem;
text-align: center;
}
.gu-contour__actions {
display: flex;
align-items: center;
gap: 8px;
margin-top: 10px;
font-size: 0.82rem;
color: var(--muted);
}
.gu-contour__actions span {
margin-right: auto;
}
.gu-contour__actions button {
min-height: 32px;
padding: 0 12px;
border: 1px solid var(--line);
border-radius: 8px;
background: transparent;
color: var(--ink);
font: inherit;
cursor: pointer;
transition: background-color 0.2s;
}
.gu-contour__actions button:hover:not(:disabled) {
background: rgb(42 33 27 / 0.06);
}
.gu-contour__actions button:disabled {
opacity: 0.4;
cursor: default;
}
@keyframes gu-contour-rise {
from {
opacity: 0;
transform: translateY(18px);
}
}
/* No WebGL: a flat contour drawing in CSS. */
.gu-contour__fallback {
position: absolute;
right: 6%;
top: 50%;
width: 46cqi;
aspect-ratio: 1;
translate: 0 -50%;
border-radius: 12px;
background: repeating-radial-gradient(
circle at 55% 45%,
#e4d3a0 0 14px,
rgb(128 82 56 / 0.5) 14px 15px
);
}
@container (max-width: 760px) {
.gu-contour__bar nav {
display: none;
}
.gu-contour__copy {
width: auto;
margin: 20px 5% 470px;
}
.gu-contour__card {
left: 5%;
right: 5%;
width: auto;
}
.gu-contour__fallback {
top: 62%;
left: 50%;
right: auto;
width: 80cqi;
translate: -50% -50%;
}
}
@media (prefers-reduced-motion: reduce) {
.gu-contour *,
.gu-contour *::before {
animation: none !important;
transition: none !important;
}
}
```
You might also want
Next piece: Cook mode appGlass prism 3D hero
Components, advanced, needs three
Glossy toys physics 3D hero
Components, advanced, needs three
Liquid blob album 3D hero
Components, advanced, needs three