"use client"; /** * geode.tsx — a rough stone with light behind its cracks. * Hover and the cracks glow violet; click and the stone splits open on an amethyst heart, then closes up again. * * Part of toy-buttons. MIT licensed. Only depends on React. */ import { useEffect, useImperativeHandle, useRef, type ButtonHTMLAttributes, type MouseEvent, type Ref } from "react"; type Palette = { stone: string; crystal: string; glow: string }; type Props = Omit, "children"> & { children?: string; ref?: Ref; palette?: Palette; }; const W = 260; const H = 100; const PAD_X = 70; const PAD_T = 90; const PAD_B = 50; const CW = W + PAD_X * 2; const CH = H + PAD_T + PAD_B; const ACCENT = "#b26cff"; const GRAVITY = 1600; const OPEN_DEG = 16; const OPEN_X = 22; const PIVOT_L = { x: 30, y: H - 2 }; const PIVOT_R = { x: W - 30, y: H - 2 }; const T_SPLIT = 80; const T_CLOSE = 1800; const T_IMPACT = 2180; const T_END = 3000; const DEFAULT_PALETTE: Palette = { stone: "#8e8784", crystal: "#8b3fd5", glow: "#b26cff" }; const clamp01 = (u: number) => (u < 0 ? 0 : u > 1 ? 1 : u); const outCubic = (u: number) => 1 - Math.pow(1 - clamp01(u), 3); const outBack = (u: number) => { const c = 1.1, v = clamp01(u) - 1; return 1 + (c + 1) * v * v * v + c * v * v; }; const lerp = (a: number, b: number, u: number) => a + (b - a) * u; const rng = (seed: number) => () => { seed |= 0; seed = (seed + 0x6d2b79f5) | 0; let t = Math.imul(seed ^ (seed >>> 15), 1 | seed); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; type Crystal = { x: number; y: number; w: number; h: number; tilt: number; shade: number }; type Chip = { rad: number; floor: number; x: number; y: number; vx: number; vy: number; rot: number; vr: number; pts: number[]; col: string; born: number; landed: number; bounced: boolean }; type Glint = { x: number; y: number; vx: number; vy: number; born: number }; type Click = { t0: number; crystals: Crystal[]; chips: Chip[]; glints: Glint[]; flash: number }; function makeHeroCrystals(r: () => number, cx: number): Crystal[] { const y = H - 5, list: Crystal[] = []; [[-34, -38], [-26, -30], [26, 30], [34, 38]].forEach(([dx, t]) => list.push({ x: cx + dx, y, w: 13, h: 18 + r() * 8, tilt: t + (r() - 0.5) * 8, shade: 0 })); [[-15, -17], [15, 17]].forEach(([dx, t]) => list.push({ x: cx + dx, y, w: 22, h: 42, tilt: t, shade: 0 })); list.push({ x: cx, y, w: 30, h: 60, tilt: (r() - 0.5) * 6, shade: 0 }); return list; } function makeCrystals(r: () => number, n: number, cx: number, baseY: number, spread: number): Crystal[] { const list: Crystal[] = []; for (let i = 0; i < n; i++) { const k = n === 1 ? 0 : (i / (n - 1)) * 2 - 1; const x = cx + k * spread + (r() - 0.5) * 6; list.push({ x, y: baseY + (r() - 0.5) * 8 + Math.abs(k) * 4, w: 18 + r() * 14, h: 42 + r() * 46 * (1 - Math.abs(k) * 0.35), tilt: k * 24 + (r() - 0.5) * 14, shade: r() }); } // tall ones in the middle are drawn last return list.sort((a, b) => Math.abs(b.x - cx) - Math.abs(a.x - cx)); } export function GeodeButton({ children = "open", palette = DEFAULT_PALETTE, onClick, className, type = "button", disabled = false, ref, ...rest }: Props) { const btnRef = useRef(null); useImperativeHandle(ref, () => btnRef.current!, []); const wrapRef = useRef(null); const canvasRef = useRef(null); const api = useRef<{ play: () => void }>({ play: () => {} }); const { stone, crystal, glow } = palette; useEffect(() => { const btn = btnRef.current, wrap = wrapRef.current, canvas = canvasRef.current; if (!btn || !wrap || !canvas) return; const ctx = canvas.getContext("2d"); if (!ctx) return; const media = window.matchMedia("(prefers-reduced-motion: reduce)"); let reduced = media.matches; let visible = true; let hover = btn.matches(":hover"); let hoverT0 = hover ? performance.now() : 0; let raf = 0, last = 0; let rect: DOMRect | undefined; let scale = 1, dpr = 1; let dirty = true; let curX = -1e4, curY = -1e4; let hg = hover ? 1 : 0; // hover glow, 0..1 let click: Click | null = null; let pressK = 0, pressT = 0; let pulse = -1; // ms start of the idle pulse, or -1 let pulseCrack = 0; let reducedLit = false; let tex: HTMLCanvasElement | null = null; let labelGlow: HTMLCanvasElement | null = null; const timers = new Set(); const later = (fn: () => void, ms: number) => { const id = window.setTimeout(() => { timers.delete(id); fn(); }, ms); timers.add(id); return id; }; const allowed = () => !disabled && !btn.matches(":disabled") && visible && !document.hidden; // ---- static geometry (built once) ---- const R = rng(11); const outline = new Path2D(); { const rad = H / 2, straight = W - H, arc = Math.PI * rad, total = straight * 2 + arc * 2; const N = 76; const wob: number[] = []; for (let i = 0; i < N; i++) wob.push((R() - 0.5) * 5 + Math.sin(i * 0.7) * 1.2); const P: number[] = []; for (let i = 0; i < N; i++) { let s = (i / N) * total, x = 0, y = 0, nx = 0, ny = 0; if (s < straight) { x = rad + s; y = 0; ny = -1; } else if ((s -= straight) < arc) { const a = -Math.PI / 2 + (s / arc) * Math.PI; x = W - rad + Math.cos(a) * rad; y = rad + Math.sin(a) * rad; nx = Math.cos(a); ny = Math.sin(a); } else if ((s -= arc) < straight) { x = W - rad - s; y = H; ny = 1; } else { s -= straight; const a = Math.PI / 2 + (s / arc) * Math.PI; x = rad + Math.cos(a) * rad; y = rad + Math.sin(a) * rad; nx = Math.cos(a); ny = Math.sin(a); } P.push(x + nx * wob[i], y + ny * wob[i]); } const mx = (i: number) => (P[(i % N) * 2] + P[((i + 1) % N) * 2]) / 2; const my = (i: number) => (P[(i % N) * 2 + 1] + P[((i + 1) % N) * 2 + 1]) / 2; outline.moveTo(mx(N - 1), my(N - 1)); for (let i = 0; i < N; i++) outline.quadraticCurveTo(P[i * 2], P[i * 2 + 1], mx(i), my(i)); outline.closePath(); } // jagged seam, x 48-55% of the width for (let i = 0; i <= 10; i++) R(); // keep crack seeds identical const SR = rng(17); const seam: number[] = []; for (let i = 0; i <= 15; i++) { const y = -10 + i * 8; const base = W * 0.48 + ((y + 10) / 120) * W * 0.07; const amp = SR() < 0.25 ? 6 + SR() * 3 : 1.5 + SR() * 3.5; seam.push(base + (i % 2 ? 1 : -1) * amp, y); } const regionL = new Path2D(), regionR = new Path2D(); regionL.moveTo(-200, -200); regionL.lineTo(seam[0], -200); regionR.moveTo(W + 200, -200); regionR.lineTo(seam[0], -200); for (let i = 0; i < seam.length; i += 2) { regionL.lineTo(seam[i], seam[i + 1]); regionR.lineTo(seam[i], seam[i + 1]); } regionL.lineTo(seam[seam.length - 2], 300); regionL.lineTo(-200, 300); regionL.closePath(); regionR.lineTo(seam[seam.length - 2], 300); regionR.lineTo(W + 200, 300); regionR.closePath(); const seamPath = new Path2D(); seamPath.moveTo(seam[0], seam[1]); for (let i = 2; i < seam.length; i += 2) seamPath.lineTo(seam[i], seam[i + 1]); const seamMidX = W * 0.515; // drusy teeth along the seam type Tooth = { x: number; y: number; tx: number; ty: number; s: number; col: string; dot: boolean }; const teeth: Tooth[] = []; { const dr = rng(21); for (let i = 0; i < seam.length - 2; i += 2) { const x0 = seam[i], y0 = seam[i + 1], x1 = seam[i + 2], y1 = seam[i + 3]; const len = Math.hypot(x1 - x0, y1 - y0), tx = (x1 - x0) / len, ty = (y1 - y0) / len; for (let d = 0; d < len; d += 3) { const s = 1.5 + dr() * 3.5, q = dr(), col = q < 0.33 ? "#e7c9ff" : q < 0.66 ? "#a769d8" : "#6e3294"; teeth.push({ x: x0 + tx * d, y: y0 + ty * d, tx, ty, s, col, dot: dr() < 0.25 }); } } } // cracks: a main crack and its branch, as separate paths type Crack = { pts: number[][]; main: Path2D; branch: Path2D; wy: number }; const cracks: Crack[] = []; const inLabel = (x: number, y: number) => x > 72 && x < 188 && y > 28 && y < 72; const insideBody = (x: number, y: number) => { const dx = Math.max(Math.abs(x - W / 2) - (W - H) / 2, 0); return Math.hypot(dx, y - H / 2) < H / 2 - 1.5; }; { const starts = [[30, 30], [70, 78], [100, 14], [160, 82], [190, 20], [225, 60], [128, 88], [60, 40]]; for (const [sx0, sy0] of starts) { const pts: number[][] = []; const main = new Path2D(), branch = new Path2D(); const walk = (x: number, y: number, a: number, n: number, len: number, path: Path2D) => { const line: number[] = [x, y]; path.moveTo(x, y); for (let i = 0; i < n; i++) { a += (R() - 0.5) * 1.0; const l = len * (0.6 + R() * 0.8); let nx = x + Math.cos(a) * l, ny = y + Math.sin(a) * l, tries = 0; while ((inLabel(nx, ny) || !insideBody(nx, ny)) && tries < 3) { a += 1.2; nx = x + Math.cos(a) * l; ny = y + Math.sin(a) * l; tries++; } if (inLabel(nx, ny) || !insideBody(nx, ny)) break; x = nx; y = ny; path.lineTo(x, y); line.push(x, y); if (i === 2 && n > 4) walk(x, y, a + (R() < 0.5 ? 1 : -1) * (0.7 + R() * 0.6), 3, len * 0.8, branch); } pts.push(line); }; walk(sx0, sy0, R() * Math.PI * 2, 9 + Math.floor(R() * 4), 9, main); let ys = 0, yn = 0; for (let q = 1; q < pts[0].length; q += 2) { ys += pts[0][q]; yn++; } cracks.push({ pts, main, branch, wy: yn ? ys / yn / H : 0.5 }); } } const crackDist = (c: Crack, x: number, y: number) => { let d = 1e9; for (const l of c.pts) for (let i = 0; i < l.length; i += 2) d = Math.min(d, Math.hypot(l[i] - x, l[i + 1] - y)); return d; }; // ---- offscreen textures (per dpr) ---- const FONT = '800 30px ui-sans-serif,system-ui,"Segoe UI",sans-serif'; const setSpacing = (g: CanvasRenderingContext2D) => { if ("letterSpacing" in g) (g as CanvasRenderingContext2D & { letterSpacing: string }).letterSpacing = "3px"; }; const buildTex = () => { const c = document.createElement("canvas"); c.width = Math.round(W * dpr); c.height = Math.round(H * dpr); const g = c.getContext("2d"); if (!g) return c; g.scale(dpr, dpr); const base = g.createLinearGradient(W * 0.15, 0, W * 0.75, H * 1.25); base.addColorStop(0, "#a8a19e"); base.addColorStop(0.4, stone); base.addColorStop(0.8, "#6b6664"); base.addColorStop(1, "#4a4644"); g.fillStyle = base; g.fillRect(-10, -10, W + 20, H + 20); const r = rng(5); for (let i = 0; i < 26; i++) { // strata blotches const x = r() * W, y = r() * H, rr = 10 + r() * 28; const gr = g.createRadialGradient(x, y, 0, x, y, rr); const light = r() < 0.5; gr.addColorStop(0, light ? "rgba(190,184,180,.14)" : "rgba(40,36,35,.16)"); gr.addColorStop(1, "rgba(0,0,0,0)"); g.fillStyle = gr; g.fillRect(x - rr, y - rr, rr * 2, rr * 2); } // dome pass + end falloff const dome = g.createLinearGradient(0, 0, 0, H); dome.addColorStop(0, "rgba(255,250,245,.32)"); dome.addColorStop(0.18, "rgba(255,250,245,.10)"); dome.addColorStop(0.5, "rgba(0,0,0,0)"); dome.addColorStop(0.82, "rgba(20,18,18,.30)"); dome.addColorStop(1, "rgba(10,9,9,.58)"); g.fillStyle = dome; g.fillRect(-10, -10, W + 20, H + 20); const endf = g.createLinearGradient(0, 0, W, 0); endf.addColorStop(0, "rgba(0,0,0,.30)"); endf.addColorStop(0.13, "rgba(0,0,0,0)"); endf.addColorStop(0.87, "rgba(0,0,0,0)"); endf.addColorStop(1, "rgba(0,0,0,.30)"); g.fillStyle = endf; g.fillRect(-10, -10, W + 20, H + 20); // engraved label (before facets and pitting so the speckle crosses the letters) g.font = FONT; g.textAlign = "center"; g.textBaseline = "middle"; setSpacing(g); const t = children.toUpperCase(), cx = W / 2, cy = H / 2 + 1; g.fillStyle = "rgba(200,193,189,.7)"; g.fillText(t, cx + 0.4, cy + 1.3); const rec = g.createLinearGradient(0, cy - 15, 0, cy + 15); rec.addColorStop(0, "#1f1c1c"); rec.addColorStop(0.45, "#3a3634"); rec.addColorStop(1, "#57504e"); g.fillStyle = rec; g.fillText(t, cx, cy); // chiselled facets const fr = rng(9); for (let i = 0; i < 16; i++) { const fx = fr() * W, fy = fr() * H, rad = 16 + fr() * 14; const cs: number[][] = []; for (let k = 0; k < 4; k++) { const an = (k * Math.PI) / 2 + (fr() - 0.5) * 0.8, rr = rad * (0.6 + fr() * 0.5); cs.push([fx + Math.cos(an) * rr, fy + Math.sin(an) * rr]); } g.fillStyle = i % 2 ? "rgba(28,25,24,.10)" : "rgba(225,219,215,.07)"; g.beginPath(); g.moveTo(cs[0][0], cs[0][1]); for (let k = 1; k < 4; k++) g.lineTo(cs[k][0], cs[k][1]); g.closePath(); g.fill(); g.strokeStyle = "rgba(235,230,226,.16)"; g.lineWidth = 1; g.beginPath(); g.moveTo(cs[3][0], cs[3][1]); g.lineTo(cs[0][0], cs[0][1]); g.stroke(); } const br = rng(41); for (let i = 0; i < 700; i++) { const x = br() * W, y = br() * H, rx = 1.2 + br() * 2.6, ry = rx * (0.6 + br() * 0.4), an = br() * Math.PI; if (x > 76 && x < 184 && y > 34 && y < 68) continue; g.fillStyle = "rgba(22,20,19,.20)"; g.beginPath(); g.ellipse(x + 0.6, y + 0.7, rx, ry, an, 0, Math.PI * 2); g.fill(); g.fillStyle = "rgba(232,226,222,.13)"; g.beginPath(); g.ellipse(x - 0.4, y - 0.5, rx * 0.8, ry * 0.8, an, 0, Math.PI * 2); g.fill(); } // cracks and seam: lip + core g.lineCap = "round"; g.lineJoin = "round"; const strokeCrack = (p: Path2D, main: boolean) => { g.save(); g.translate(0.5, 0.8); g.strokeStyle = "rgba(208,201,197,.40)"; g.lineWidth = main ? 1.1 : 0.7; g.stroke(p); g.restore(); g.strokeStyle = "rgba(24,21,21,.14)"; g.lineWidth = main ? 2.8 : 1.6; g.stroke(p); g.strokeStyle = "rgba(24,21,21,.70)"; g.lineWidth = main ? 1.35 : 0.75; g.stroke(p); }; for (const ck of cracks) { strokeCrack(ck.main, true); strokeCrack(ck.branch, false); } strokeCrack(seamPath, true); // pitting: dark everywhere, light only on the top for (let i = 0; i < 2600; i++) { const x = r() * W, y = r() * H, q = r(), s = q < 0.6 ? 1 : q < 0.9 ? 1.5 : 2.2; g.fillStyle = `rgba(32,29,28,${(0.1 + r() * 0.2).toFixed(2)})`; g.fillRect(x, y, s, s); } for (let i = 0; i < 1400; i++) { const x = r() * W, y = r() * H * 0.62; g.fillStyle = `rgba(205,199,195,${(0.08 + r() * 0.14).toFixed(2)})`; g.fillRect(x, y, 1, 1); } return c; }; const buildLabelGlow = () => { const c = document.createElement("canvas"); c.width = Math.round(W * dpr); c.height = Math.round(H * dpr); const g = c.getContext("2d"); if (!g) return c; g.scale(dpr, dpr); g.font = FONT; g.textAlign = "center"; g.textBaseline = "middle"; setSpacing(g); const cy = H / 2 + 1, t = children.toUpperCase(); const lg = g.createLinearGradient(0, cy - 15, 0, cy + 15); lg.addColorStop(0, "#f3e2ff"); lg.addColorStop(0.5, glow); lg.addColorStop(1, "#7d34e0"); g.fillStyle = lg; g.fillStyle = "rgba(225,200,255,.5)"; g.fillText(t, W / 2 + 0.4, cy + 1.3); g.fillStyle = lg; g.shadowColor = "rgba(178,108,255,.85)"; g.shadowBlur = 10; g.fillText(t, W / 2, cy); g.shadowBlur = 0; g.shadowColor = "transparent"; g.fillText(t, W / 2, cy); g.globalCompositeOperation = "source-atop"; const sh = g.createLinearGradient(0, cy - 15, 0, cy - 4); sh.addColorStop(0, "rgba(28,8,48,.6)"); sh.addColorStop(1, "rgba(28,8,48,0)"); g.fillStyle = sh; g.fillRect(0, cy - 15, W, 11); g.globalCompositeOperation = "source-over"; return c; }; const fit = () => { rect = btn.getBoundingClientRect(); scale = rect.width / (btn.offsetWidth || 1) || 1; const nd = Math.min(2, (window.devicePixelRatio || 1) * scale); const w = Math.round(CW * nd), h = Math.round(CH * nd); if (canvas.width !== w || canvas.height !== h) { canvas.width = w; canvas.height = h; } if (!tex || nd !== dpr) { dpr = nd; tex = buildTex(); labelGlow = buildLabelGlow(); } dpr = nd; ctx.setTransform(dpr, 0, 0, dpr, 0, 0); dirty = false; }; // ---- crystals ---- const crystalPath = (c: Crystal, s: number) => { const w = c.w * s, h = c.h * s, tip = w * 0.8; return { w, h, tip }; }; const drawCrystals = (list: Crystal[], now: number, ct: number, alpha: number, grow: (i: number) => number, glint: number) => { for (let i = 0; i < list.length; i++) { const c = list[i]; const gi = grow(i); if (gi <= 0.001) continue; const s = lerp(0.6, 1, gi); const { w, h, tip } = crystalPath(c, s); ctx.save(); ctx.globalAlpha = alpha * gi; ctx.translate(c.x, c.y); ctx.rotate((c.tilt * Math.PI) / 180); const th = h + tip; const faces: [number, number, string, string][] = [ [-w / 2, -w / 6, "#4a1d70", "#6e3294"], [-w / 6, w / 6, "#7f3ad0", "#b27ae6"], [w / 6, w / 2, "#9b55e0", "#d7b0ff"], ]; for (const [x0, x1, c0, c1] of faces) { const g = ctx.createLinearGradient(0, 0, 0, -th); g.addColorStop(0, c0); g.addColorStop(1, c1); ctx.fillStyle = g; ctx.beginPath(); ctx.moveTo(x0, 0); ctx.lineTo(x1, 0); ctx.lineTo(x1, -h); ctx.lineTo(0, -th); ctx.lineTo(x0, -h); ctx.closePath(); ctx.fill(); } ctx.fillStyle = "rgba(243,228,255,.75)"; ctx.beginPath(); ctx.moveTo(0, -th); ctx.lineTo(w / 6, -h); ctx.lineTo(w / 2, -h); ctx.closePath(); ctx.fill(); ctx.globalCompositeOperation = "lighter"; { const ig = ctx.createLinearGradient(0, 0, 0, -th); ig.addColorStop(0, "rgba(178,108,255,0)"); ig.addColorStop(0.55, "rgba(178,108,255,.16)"); ig.addColorStop(0.86, "rgba(231,201,255,.34)"); ig.addColorStop(1, "rgba(231,201,255,0)"); ctx.fillStyle = ig; ctx.beginPath(); ctx.moveTo(-w / 2, 0); ctx.lineTo(-w / 2, -h); ctx.lineTo(0, -th); ctx.lineTo(w / 2, -h); ctx.lineTo(w / 2, 0); ctx.closePath(); ctx.fill(); } ctx.globalCompositeOperation = "source-over"; ctx.strokeStyle = "rgba(255,255,255,.18)"; ctx.lineWidth = 0.6; ctx.beginPath(); ctx.moveTo(-w / 12, -h * 0.15); ctx.lineTo(-w / 12, -h * 0.8); ctx.moveTo(w / 10, -h * 0.15); ctx.lineTo(w / 10, -h * 0.8); ctx.stroke(); ctx.strokeStyle = "rgba(231,201,255,.45)"; ctx.lineWidth = 0.8; ctx.beginPath(); ctx.moveTo(-w / 6, 0); ctx.lineTo(-w / 6, -h); ctx.lineTo(0, -th); ctx.moveTo(w / 6, 0); ctx.lineTo(w / 6, -h); ctx.lineTo(0, -th); ctx.moveTo(-w / 2, -h); ctx.lineTo(w / 2, -h); ctx.stroke(); ctx.strokeStyle = "rgba(40,12,70,.85)"; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(-w / 2, 0); ctx.lineTo(-w / 2, -h); ctx.lineTo(0, -th); ctx.lineTo(w / 2, -h); ctx.lineTo(w / 2, 0); ctx.stroke(); if (i === list.length - 1) { const sp = glint > 0 ? 0.35 + 0.65 * Math.sin(Math.PI * glint) : 0.35; ctx.globalCompositeOperation = "lighter"; const rg2 = ctx.createRadialGradient(0, -th, 0, 0, -th, 7); rg2.addColorStop(0, `rgba(243,228,255,${(0.7 * sp).toFixed(3)})`); rg2.addColorStop(1, "rgba(243,228,255,0)"); ctx.fillStyle = rg2; ctx.fillRect(-7, -th - 7, 14, 14); ctx.strokeStyle = `rgba(255,255,255,${(0.9 * sp).toFixed(3)})`; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(-4, -th); ctx.lineTo(4, -th); ctx.moveTo(0, -th - 6); ctx.lineTo(0, -th + 6); ctx.stroke(); ctx.globalCompositeOperation = "source-over"; } if (glint > 0) { // highlight sweep, clipped to this crystal ctx.beginPath(); ctx.moveTo(-w / 2, 0); ctx.lineTo(-w / 2, -h); ctx.lineTo(0, -th); ctx.lineTo(w / 2, -h); ctx.lineTo(w / 2, 0); ctx.closePath(); ctx.clip(); const gx = lerp(-w * 1.2, w * 1.2, glint); ctx.strokeStyle = "rgba(255,255,255,.85)"; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(gx - 10, 4); ctx.lineTo(gx + 10, -th - 4); ctx.stroke(); } ctx.restore(); void now; void ct; } }; // ---- drawing ---- const strokeGlow = (p: Path2D, a: number, wm = 1) => { if (a <= 0.01) return; const al = Math.min(1, a); ctx.globalAlpha = 1; ctx.strokeStyle = `rgba(150,70,240,${(0.07 * al).toFixed(3)})`; ctx.lineWidth = 18 * wm; ctx.stroke(p); ctx.strokeStyle = `rgba(150,70,240,${(0.16 * al).toFixed(3)})`; ctx.lineWidth = 9 * wm; ctx.stroke(p); ctx.strokeStyle = glow; ctx.globalAlpha = 0.6 * al; ctx.lineWidth = 2.6 * wm; ctx.stroke(p); ctx.strokeStyle = "#f6ecff"; ctx.globalAlpha = 0.85 * al; ctx.lineWidth = 0.9 * wm; ctx.stroke(p); ctx.globalAlpha = 1; }; const drawGlowCracks = (g: number, boost: number, now: number, open: number) => { const quiet = 1 - 0.75 * clamp01(open); const cx = rect ? (curX - rect.left) / scale : -1e4, cy = rect ? (curY - rect.top) / scale : -1e4; void boost; ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.globalCompositeOperation = "lighter"; for (let i = 0; i < cracks.length; i++) { const c = cracks[i]; let k = g; if (hover && g > 0) k = g * (0.35 + 0.65 * clamp01(1 - crackDist(c, cx, cy) / 60)); k *= Math.min(1, 0.5 + 0.7 * c.wy); k *= quiet; let pk = 0; if (pulse >= 0 && i === pulseCrack) { const u = (now - pulse) / 900; if (u >= 0 && u <= 1) pk = 0.15 * Math.sin(u * Math.PI); } strokeGlow(c.main, k); strokeGlow(c.branch, k * 0.6, 0.6); if (pk > 0) { strokeGlow(c.main, pk); strokeGlow(c.branch, pk * 0.6, 0.6); } } strokeGlow(seamPath, Math.min(1, 1.3 * g) * quiet * (1 - clamp01(open * 3))); ctx.globalCompositeOperation = "source-over"; }; const drawHalf = (side: 0 | 1, open: number, g: number, boost: number, lab: number, rindA: number, spill: number, now: number) => { const pv = side === 0 ? PIVOT_L : PIVOT_R; const dir = side === 0 ? -1 : 1; ctx.save(); ctx.translate(pv.x + dir * OPEN_X * open, pv.y); ctx.rotate(dir * ((OPEN_DEG * Math.PI) / 180) * open); ctx.translate(-pv.x, -pv.y); ctx.clip(outline); ctx.clip(side === 0 ? regionL : regionR); if (tex) ctx.drawImage(tex, 0, 0, W, H); // bevel const rg = ctx.createLinearGradient(0, 0, 0, H); rg.addColorStop(0, "rgba(238,232,228,.62)"); rg.addColorStop(0.3, "rgba(0,0,0,0)"); rg.addColorStop(0.78, "rgba(0,0,0,0)"); rg.addColorStop(1, "rgba(12,11,11,.75)"); ctx.strokeStyle = rg; ctx.lineWidth = 7; ctx.stroke(outline); ctx.strokeStyle = "rgba(14,12,12,.5)"; ctx.lineWidth = 1.4; ctx.stroke(outline); if (spill > 0.01) { // crystal light spilling on the inner faces const sg = ctx.createRadialGradient(seamMidX, 92, 0, seamMidX, 92, 80); sg.addColorStop(0, `rgba(178,108,255,${(0.55 * spill).toFixed(3)})`); sg.addColorStop(1, "rgba(178,108,255,0)"); ctx.fillStyle = sg; ctx.fillRect(-20, -20, W + 40, H + 40); } if (rindA > 0.01) { ctx.globalAlpha = rindA; ctx.lineJoin = "round"; ctx.strokeStyle = "#d6cfd3"; ctx.lineWidth = 16; ctx.stroke(seamPath); ctx.strokeStyle = "#8a7a8c"; ctx.lineWidth = 11; ctx.stroke(seamPath); ctx.strokeStyle = "#3a1460"; ctx.lineWidth = 7; ctx.stroke(seamPath); for (const t of teeth) { const nxx = side === 0 ? -t.ty : t.ty, nyy = side === 0 ? t.tx : -t.tx; const bx = t.x + nxx * 9, by = t.y + nyy * 9, ax = t.x + nxx * (8 - t.s * 0.9), ay = t.y + nyy * (8 - t.s * 0.9); ctx.fillStyle = "#8a8380"; ctx.beginPath(); ctx.moveTo(bx + t.tx * 2.4, by + t.ty * 2.4); ctx.lineTo(bx - t.tx * 2.4, by - t.ty * 2.4); ctx.lineTo(ax, ay); ctx.closePath(); ctx.fill(); } for (const t of teeth) { const nxx = side === 0 ? -t.ty : t.ty, nyy = side === 0 ? t.tx : -t.tx; const bx = t.x + nxx * 6.5, by = t.y + nyy * 6.5, ax = t.x + nxx * (6.5 - 1.2 - t.s), ay = t.y + nyy * (6.5 - 1.2 - t.s); ctx.fillStyle = t.col; ctx.beginPath(); ctx.moveTo(bx + t.tx * 2.2, by + t.ty * 2.2); ctx.lineTo(bx - t.tx * 2.2, by - t.ty * 2.2); ctx.lineTo(ax, ay); ctx.closePath(); ctx.fill(); if (t.dot) { ctx.fillStyle = "#f6ecff"; ctx.fillRect(ax, ay, 1, 1); } } ctx.globalAlpha = 1; } ctx.save(); ctx.clip(outline); drawGlowCracks(g, boost, now, open); ctx.restore(); if (labelGlow && lab > 0.01) { ctx.globalAlpha = Math.min(1, lab); ctx.drawImage(labelGlow, 0, 0, W, H); ctx.globalAlpha = 1; } ctx.restore(); }; const softEllipse = (cxp: number, y: number, rx: number, ry: number, stops: [number, string][]) => { ctx.save(); ctx.translate(cxp, y); ctx.scale(1, ry / rx); const gr = ctx.createRadialGradient(0, 0, 0, 0, 0, rx); for (const [o, c] of stops) gr.addColorStop(o, c); ctx.fillStyle = gr; ctx.fillRect(-rx, -rx, rx * 2, rx * 2); ctx.restore(); }; const draw = (now: number) => { ctx.clearRect(0, 0, CW, CH); ctx.save(); ctx.translate(PAD_X, PAD_T); const ct = click ? now - click.t0 : -1; // open amount let open = 0; if (click) { if (ct >= T_SPLIT && ct < 600) open = outBack((ct - T_SPLIT) / 520); else if (ct >= 600 && ct < T_CLOSE) open = 1; else if (ct >= T_CLOSE && ct < T_IMPACT) open = 1 - Math.pow((ct - T_CLOSE) / (T_IMPACT - T_CLOSE), 2.2); } // glow levels let breathe = 1; if (hover) breathe = 0.9 + 0.1 * Math.sin(((now - hoverT0) / 1000) * Math.PI * 2 * 1.3); let g = hg * breathe, boost = 0, crystalK = 1; if (click) { const cg = ct < 60 ? lerp(hg, 1.4, ct / 60) : ct < 400 ? lerp(1.4, 0.9, (ct - 60) / 340) : ct < T_CLOSE ? 0.9 : ct < T_END - 400 ? lerp(0.9, 0, (ct - T_CLOSE) / (T_END - 400 - T_CLOSE)) : 0; g = Math.max(g, cg); boost = ct < 400 ? clamp01((cg - 1) / 0.4 + 0.2) * (ct < 400 ? 1 : 0) : 0; if (click.flash && now - click.flash < 200) crystalK = 1 + 0.4 * Math.sin(((now - click.flash) / 200) * Math.PI); } // jolt + tremor + impact let jolt = 1, tx = 0, ty = 0; if (click && ct < 60) jolt = 1 + 0.03 * Math.sin((ct / 60) * Math.PI); if (click && ct >= T_IMPACT && ct < T_IMPACT + 70) jolt = 1 - 0.02 * Math.sin(((ct - T_IMPACT) / 70) * Math.PI); if (hover && !reduced && now - hoverT0 > 1200 && !click) { const f = Math.floor(now / 33), rr = rng(f); tx = (rr() - 0.5) * 2; ty = (rr() - 0.5) * 2; } const hgv = reduced ? 0 : hg; ctx.translate(W / 2 + tx, H + ty); ctx.scale((1 + 0.018 * pressK) * jolt, (1 - 0.035 * pressK) * jolt); ctx.translate(-W / 2, -H); // floor shadow (stays on the ground while the stone lifts) ctx.save(); ctx.globalAlpha = 1 - 0.25 * hgv; ctx.translate(W / 2, 0); ctx.scale(1 - 0.06 * hgv, 1); ctx.translate(-W / 2, 0); softEllipse(W / 2, H + 4, W * 0.54, 15, [[0, "rgba(0,0,0,.42)"], [1, "rgba(0,0,0,0)"]]); softEllipse(W / 2, H + 1, W * 0.4, 4.5, [[0, "rgba(0,0,0,.70)"], [0.7, "rgba(0,0,0,.35)"], [1, "rgba(0,0,0,0)"]]); ctx.restore(); if (click && open > 0.01) softEllipse(seamMidX, H + 2, 64, 9, [[0, `rgba(178,108,255,${(0.45 * open).toFixed(3)})`], [1, "rgba(178,108,255,0)"]]); ctx.translate(0, -2.5 * hgv + 2.5 * pressK); // inside: cavity, glow, crystals if (click && open > 0.01) { const pulseK = ct >= 120 ? 1 + 0.45 * Math.sin(clamp01((ct - 120) / 500) * Math.PI) : 1; ctx.save(); ctx.beginPath(); ctx.rect(-PAD_X, -PAD_T, CW, PAD_T + H - 3); ctx.clip(); ctx.fillStyle = `rgba(22,8,34,${(0.85 * clamp01(open * 1.5)).toFixed(3)})`; ctx.beginPath(); ctx.ellipse(seamMidX, 92, 46 * open, 12, 0, 0, Math.PI * 2); ctx.fill(); const rg = ctx.createRadialGradient(seamMidX, 62, 0, seamMidX, 62, 62); const ga = Math.min(1, 0.6 * open * crystalK * pulseK); rg.addColorStop(0, `rgba(178,108,255,${ga.toFixed(3)})`); rg.addColorStop(1, "rgba(178,108,255,0)"); ctx.fillStyle = rg; ctx.fillRect(seamMidX - 75, -20, 150, H + 20); const glint = ct >= 600 && ct < 1000 ? (ct - 600) / 400 : 0; const nc = click.crystals.length; drawCrystals(click.crystals, now, ct, 1, (i) => outCubic((ct - 120 - (nc - 1 - i) * 30) / 300) * (0.5 + 0.5 * clamp01(open)), glint); if (crystalK > 1) { ctx.fillStyle = `rgba(231,201,255,${(0.25 * (crystalK - 1) / 0.4).toFixed(3)})`; ctx.fillRect(seamMidX - 40, 10, 80, 90); } { // crystal bed const bw = 46 * outCubic((ct - 80) / 220); if (bw > 0.5) { const bg = ctx.createLinearGradient(0, H - 16, 0, H - 3); bg.addColorStop(0, "#5b2a86"); bg.addColorStop(1, "#1c0a2c"); ctx.fillStyle = bg; ctx.beginPath(); ctx.moveTo(seamMidX - bw, H - 3); ctx.quadraticCurveTo(seamMidX, H - 24, seamMidX + bw, H - 3); ctx.closePath(); ctx.fill(); const br = rng(33), cols = ["#e7c9ff", "#a769d8", "#6e3294"]; ctx.globalAlpha = clamp01(open * 2); for (let j = 0; j < 11; j++) { const u = 0.08 + (j / 10) * 0.84, v = 1 - u; const px = v * v * (seamMidX - bw) + 2 * u * v * seamMidX + u * u * (seamMidX + bw); const py = v * v * (H - 3) + 2 * u * v * (H - 24) + u * u * (H - 3); const th2 = 3 + br() * 3; ctx.fillStyle = cols[j % 3]; ctx.beginPath(); ctx.moveTo(px - 1.7, py + 0.5); ctx.lineTo(px + 1.7, py + 0.5); ctx.lineTo(px, py - th2); ctx.closePath(); ctx.fill(); } ctx.globalAlpha = 1; } } ctx.restore(); } // halves const lab = reduced ? (reducedLit ? 1 : 0) : g * (1 - 0.7 * clamp01(open)); const gg = reduced ? (reducedLit ? 1 : 0) : g; const spill = click ? clamp01(open * crystalK) : 0; const rindA = clamp01(open * 4); drawHalf(0, open, gg, boost, lab, rindA, spill, now); drawHalf(1, open, gg, boost, lab, rindA, spill, now); if (reduced && reducedLit) { ctx.save(); ctx.clip(outline); ctx.translate(W / 2, H / 2 + 22); ctx.scale(0.5, 0.5); ctx.translate(-W / 2, -(H / 2 + 22)); drawCrystals(reducedCluster, now, 0, 0.5, () => 1, 0); ctx.restore(); if (labelGlow) { ctx.save(); ctx.clip(outline); ctx.drawImage(labelGlow, 0, 0, W, H); ctx.restore(); } } // seam glow after it closes if (click && ct >= T_IMPACT && ct < 2900) { const a = ct < 2300 ? (ct - T_IMPACT) / 120 : 1 - (ct - 2300) / 600; ctx.save(); ctx.clip(outline); ctx.lineJoin = "round"; ctx.globalCompositeOperation = "lighter"; strokeGlow(seamPath, clamp01(a)); ctx.globalCompositeOperation = "source-over"; ctx.restore(); } // chips, glints, dust (body space) if (click) { for (const c of click.chips) { if (now < c.born) continue; let alpha = 1; if (c.landed) { const u = (now - c.landed) / 500; alpha = 1 - u * u; if (u >= 1 || alpha <= 0) continue; } if (c.landed) { ctx.globalAlpha = 0.35 * alpha; ctx.fillStyle = "#000"; ctx.beginPath(); ctx.ellipse(c.x, c.y + c.rad * 0.6, c.rad, 1.3, 0, 0, Math.PI * 2); ctx.fill(); } ctx.globalAlpha = alpha; ctx.fillStyle = c.col; ctx.save(); ctx.translate(c.x, c.y); ctx.rotate(c.rot); ctx.beginPath(); ctx.moveTo(c.pts[0], c.pts[1]); for (let i = 2; i < c.pts.length; i += 2) ctx.lineTo(c.pts[i], c.pts[i + 1]); ctx.closePath(); ctx.fill(); ctx.globalAlpha = 0.75 * alpha; ctx.fillStyle = "#b3aca8"; ctx.beginPath(); ctx.moveTo(c.pts[0] * 0.55 - 0.25 * c.rad, c.pts[1] * 0.55 - 0.25 * c.rad); for (let i = 2; i < c.pts.length; i += 2) ctx.lineTo(c.pts[i] * 0.55 - 0.25 * c.rad, c.pts[i + 1] * 0.55 - 0.25 * c.rad); ctx.closePath(); ctx.fill(); ctx.globalAlpha = alpha; ctx.fillStyle = "rgba(28,25,24,.5)"; ctx.beginPath(); ctx.moveTo(c.pts[0] * 0.6 + 0.3 * c.rad, c.pts[1] * 0.6 + 0.35 * c.rad); for (let i = 2; i < c.pts.length; i += 2) ctx.lineTo(c.pts[i] * 0.6 + 0.3 * c.rad, c.pts[i + 1] * 0.6 + 0.35 * c.rad); ctx.closePath(); ctx.fill(); ctx.globalAlpha = alpha; ctx.strokeStyle = "rgba(26,23,22,.6)"; ctx.lineWidth = 0.8; ctx.beginPath(); ctx.moveTo(c.pts[0], c.pts[1]); for (let i = 2; i < c.pts.length; i += 2) ctx.lineTo(c.pts[i], c.pts[i + 1]); ctx.closePath(); ctx.stroke(); ctx.restore(); } ctx.globalAlpha = 1; for (const gl of click.glints) { const age = now - gl.born; if (age < 0 || age > 500) continue; const ga = (1 - age / 500).toFixed(3), sz = 2 + 3 * Math.sin(Math.PI * age / 500); const gx = gl.x + gl.vx * age / 1000, gy = gl.y + gl.vy * age / 1000; ctx.globalCompositeOperation = "lighter"; ctx.strokeStyle = `rgba(231,201,255,${ga})`; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(gx - sz, gy); ctx.lineTo(gx + sz, gy); ctx.moveTo(gx, gy - sz); ctx.lineTo(gx, gy + sz); ctx.stroke(); ctx.fillStyle = `rgba(255,255,255,${ga})`; ctx.beginPath(); ctx.arc(gx, gy, 1.2, 0, Math.PI * 2); ctx.fill(); ctx.globalCompositeOperation = "source-over"; } if (ct >= T_IMPACT && ct < T_IMPACT + 450) { const u = (ct - T_IMPACT) / 450; [-22, -8, 7, 21].forEach((dx, i) => { const x = seamMidX + dx * (1 + u * 0.8), y = H - 2 - u * (8 + i * 2), r = 3 + u * 10; const dg = ctx.createRadialGradient(x, y, 0, x, y, r); dg.addColorStop(0, `rgba(170,163,160,${(0.35 * (1 - u)).toFixed(3)})`); dg.addColorStop(1, "rgba(170,163,160,0)"); ctx.fillStyle = dg; ctx.fillRect(x - r, y - r, 2 * r, 2 * r); }); } } ctx.restore(); }; const reducedCluster = makeCrystals(rng(3), 5, W / 2, H / 2 + 22, 24); // ---- loop ---- const stepChips = (dt: number, now: number) => { if (!click) return false; let live = false; for (const c of click.chips) { if (now < c.born) { live = true; continue; } if (c.landed) { if (now - c.landed < 500) live = true; continue; } live = true; let rem = dt; while (rem > 0) { const h = Math.min(rem, 0.008); rem -= h; c.vy += GRAVITY * h; c.x += c.vx * h; c.y += c.vy * h; c.rot += c.vr * h; if (c.y >= c.floor) { c.y = c.floor; if (!c.bounced) { c.bounced = true; c.vy = -c.vy * 0.3; c.vx *= 0.5; c.vr *= 0.4; } else { c.landed = now; c.vy = 0; c.vx = 0; break; } } } } return live; }; const tick = (now: number) => { raf = 0; if (!allowed() || reduced) return; if (dirty) fit(); const dt = last ? Math.min(0.048, (now - last) / 1000) : 0.016; last = now; let moving = false; const tgt = hover ? 1 : 0; const k = hover ? 1 - Math.exp(-dt / 0.13) : 1 - Math.exp(-dt / 0.2); hg += (tgt - hg) * k; if (Math.abs(tgt - hg) > 0.002) moving = true; else hg = tgt; pressK += (pressT - pressK) * (pressT ? 1 - Math.exp(-dt / 0.05) : 1 - Math.exp(-dt / 0.09)); if (Math.abs(pressT - pressK) > 0.002) moving = true; else pressK = pressT; if (hover) moving = true; // breathing + tremor if (click) { if (now - click.t0 >= T_END) click = null; else { moving = true; if (stepChips(dt, now) || true) moving = true; } } if (pulse >= 0) { if (now - pulse > 900) pulse = -1; else moving = true; } draw(now); if (moving) raf = requestAnimationFrame(tick); }; const start = () => { if (!raf && allowed() && !reduced) { last = 0; raf = requestAnimationFrame(tick); } }; const pause = () => { wrap.dataset.tbPaused = String(disabled || !visible || document.hidden); if (!allowed() || reduced) { cancelAnimationFrame(raf); raf = 0; } if (dirty) fit(); draw(performance.now()); start(); }; const invalidate = () => { dirty = true; if (!raf) { fit(); draw(performance.now()); } }; const enter = (e: PointerEvent) => { if (disabled) return; hover = true; hoverT0 = performance.now(); curX = e.clientX; curY = e.clientY; wrap.dataset.tbState = click ? "click" : "hover"; start(); }; const leave = () => { hover = false; pressT = 0; wrap.dataset.tbState = click ? "click" : "rest"; start(); if (!raf) draw(performance.now()); }; const move = (e: PointerEvent) => { curX = e.clientX; curY = e.clientY; }; const pdown = () => { if (disabled || reduced) return; pressT = 1; start(); }; const pup = () => { pressT = 0; start(); }; // idle pulse every 4 s along one crack const schedulePulse = () => { later(() => { if (allowed() && !reduced && !click && !hover) { pulseCrack = Math.floor(Math.random() * cracks.length); pulse = performance.now(); start(); } schedulePulse(); }, 4000); }; api.current.play = () => { if (disabled) return; const now = performance.now(); if (reduced) { reducedLit = true; wrap.dataset.tbState = "lit"; draw(now); later(() => { reducedLit = false; wrap.dataset.tbState = hover ? "hover" : "rest"; draw(performance.now()); }, 900); return; } if (click) { const ct = now - click.t0; if (ct < T_CLOSE) click.flash = now; return; } const r = rng((Math.random() * 1e9) | 0); const chips: Chip[] = []; for (let i = 0; i < 14; i++) { const sp = 180 + r() * 180, a = (r() - 0.5) * 2 * 1.05; const boulder = i < 4; const n = 4 + Math.floor(r() * 3), rad = boulder ? 4.5 + r() * 1.5 : 2.5 + r() * 3, pts: number[] = []; for (let j = 0; j < n; j++) { const an = (j / n) * Math.PI * 2, rr = rad * (0.7 + r() * 0.6); pts.push(Math.cos(an) * rr, Math.sin(an) * rr); } chips.push({ x: seamMidX + (r() - 0.5) * 24, y: 4 + r() * 46, vx: (i % 2 ? 1 : -1) * (60 + r() * 150), vy: -sp * Math.cos(a), rot: r() * 6, vr: (r() - 0.5) * 21, pts, col: r() < 0.5 ? "#6b6664" : "#8e8784", born: now + T_SPLIT, landed: 0, bounced: false, rad, floor: H + 1 + r() * 9 }); } const glints: Glint[] = []; for (let i = 0; i < 6; i++) glints.push({ x: seamMidX + (r() - 0.5) * 16, y: 20 + r() * 70, vx: (r() - 0.5) * 70, vy: -20 - r() * 60, born: now + T_SPLIT }); click = { t0: now, crystals: makeHeroCrystals(r, seamMidX), chips, glints, flash: 0 }; wrap.dataset.tbState = "click"; start(); }; const onMedia = () => { reduced = media.matches; click = null; reducedLit = false; pulse = -1; timers.forEach((id) => window.clearTimeout(id)); timers.clear(); schedulePulse(); pause(); }; const io = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver(([en]) => { visible = en.isIntersecting; pause(); }); io?.observe(wrap); const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(invalidate); ro?.observe(btn); window.addEventListener("pointermove", move, { passive: true }); window.addEventListener("resize", invalidate); window.addEventListener("scroll", invalidate, true); document.addEventListener("visibilitychange", pause); btn.addEventListener("pointerenter", enter); btn.addEventListener("pointerdown", pdown); btn.addEventListener("pointerup", pup); btn.addEventListener("pointercancel", pup); btn.addEventListener("pointerleave", leave); media.addEventListener("change", onMedia); wrap.dataset.tbState = hover && !disabled ? "hover" : "rest"; fit(); schedulePulse(); pause(); return () => { api.current.play = () => {}; cancelAnimationFrame(raf); timers.forEach((id) => window.clearTimeout(id)); timers.clear(); io?.disconnect(); ro?.disconnect(); window.removeEventListener("pointermove", move); window.removeEventListener("resize", invalidate); window.removeEventListener("scroll", invalidate, true); document.removeEventListener("visibilitychange", pause); btn.removeEventListener("pointerenter", enter); btn.removeEventListener("pointerdown", pdown); btn.removeEventListener("pointerup", pup); btn.removeEventListener("pointercancel", pup); btn.removeEventListener("pointerleave", leave); media.removeEventListener("change", onMedia); }; }, [disabled, children, stone, glow, crystal]); const press = (e: MouseEvent) => { if (disabled || e.currentTarget.matches(":disabled")) return; onClick?.(e); if (e.defaultPrevented) return; api.current.play(); }; return ( ); } export default GeodeButton; const css = ` .tb-geode-wrap{display:inline-block;position:relative;width:${W}px;height:${H}px;vertical-align:middle} .tb-geode-btn{position:relative;display:block;width:${W}px;height:${H}px;padding:0;margin:0;border:0;border-radius:${H / 2}px;background:none;cursor:pointer;overflow:visible;-webkit-tap-highlight-color:transparent;font:inherit} .tb-geode-btn:focus-visible{outline:3px solid ${ACCENT};outline-offset:6px} .tb-geode-canvas{position:absolute;left:-${PAD_X}px;top:-${PAD_T}px;width:${CW}px;height:${CH}px;max-width:none;pointer-events:none} .tb-geode-btn:disabled{cursor:not-allowed;opacity:.6;filter:saturate(.5)} .tb-geode-wrap[data-tb-paused=true] *{animation-play-state:paused!important} @media (prefers-reduced-motion:reduce){.tb-geode-wrap *,.tb-geode-wrap *::before,.tb-geode-wrap *::after{animation:none!important;transition:none!important}} `;