"use client"; /** * mushroom.tsx — a red toadstool on a mound of moss. * Hover and it bounces up to meet the cursor; a boop squashes it and puffs out a cloud of glowing spores. * * Part of toy-buttons. MIT licensed. Only depends on React. */ import { useEffect, useId, useImperativeHandle, useMemo, useRef, useState, type ButtonHTMLAttributes, type MouseEvent, type Ref } from "react"; type Palette = { cap: string; spots: string; spore: string }; type Props = Omit, "children"> & { children?: string; ref?: Ref; palette?: Palette; }; const W = 230; const H = 170; const PADX = 120; const PADT = 240; const PADB = 120; const CW = W + PADX * 2; const CH = H + PADT + PADB; const CAP_W = 210; const CAP_H = 92; const STEM_H = 46; const HOVER_LIFT = 16; const SQUASH_MS = 110; const SPAWN_AT = 120; const END_MS = 3000; const SPORE_LIFE = 2800; const MAX_SPORES = 280; const ACCENT = "#f3d986"; const DEFAULT_PALETTE: Palette = { cap: "#cb2219", spots: "#f3ead6", spore: "#fff3a0" }; const clamp = (n: number, lo = 0, hi = 1) => Math.max(lo, Math.min(hi, n)); const rgb = (h: string): [number, number, number] => { const m = /^#?([0-9a-f]{6})$/i.exec(h.trim()); const n = m ? parseInt(m[1], 16) : 0xcb2219; return [(n >> 16) & 255, (n >> 8) & 255, n & 255]; }; const mix = (a: string, b: string, t: number) => { const x = rgb(a); const y = rgb(b); return `rgb(${x.map((v, i) => Math.round(v + (y[i] - v) * t)).join(",")})`; }; const rng = (seed: number) => () => ((seed = (seed * 1664525 + 1013904223) >>> 0) / 4294967296); // ---- static geometry (generated once) ---- const MOUND_TOP = (x: number) => { const t = (x - 115) / 114; return 142 - 30 * Math.sqrt(Math.max(0, 1 - t * t)) + 13 * Math.exp(-(((x - 115) / 34) ** 2)); }; const MOUND_PATH = (() => { let d = ""; for (let x = 1; x <= 229; x += 4) d += `${d ? "L" : "M"}${x} ${MOUND_TOP(x).toFixed(1)}`; return `${d}L229 150 C230 166 190 170 115 170 C40 170 0 166 1 150 Z`; })(); const CLUMPS = [[12,13],[30,16],[50,14],[72,17],[94,15],[136,15],[158,17],[180,14],[200,16],[218,13]].map(([x, r]) => ({ x, r, y: MOUND_TOP(x) + r * 0.6 })); const LEAF = "M0 0C-1 -1.5 -5.5 -3 -5.5 -6.5C-5.5 -9 -2.5 -10 0 -7.8C2.5 -10 5.5 -9 5.5 -6.5C5.5 -3 1 -1.5 0 0Z"; type Moss = { back: [string, string]; backTips: string; front: [string, string]; frontLean: { l: string; r: string } }; const MOSS: Moss = (() => { const r = rng(77); const tuft = (x: number, y: number, len: number, lean: number) => { const ex = x + Math.sin(lean) * len; const ey = y - Math.cos(lean) * len; const cx = x + Math.sin(lean * 0.4) * len * 0.5 + (r() - 0.5) * 2; return `M${x.toFixed(1)} ${y.toFixed(1)}Q${cx.toFixed(1)} ${(y - len * 0.6).toFixed(1)} ${ex.toFixed(1)} ${ey.toFixed(1)}`; }; const pick = (yMin: number, yMax: number, edgeBias = 0) => { const x = 8 + r() * 214; const top = MOUND_TOP(x); const y = edgeBias ? top + r() * 8 : top + 2 + r() * (yMax - top); return { x, y: Math.max(y, yMin) }; }; const mk = (n: number, len: [number, number], yMax: number, edge: number, filter?: (x: number) => boolean) => { let d = ""; for (let i = 0; i < n; i++) { const p = pick(100, yMax, edge && r() < edge ? 1 : 0); if (filter && !filter(p.x)) continue; d += tuft(p.x, p.y, len[0] + r() * (len[1] - len[0]), (r() - 0.5) * 0.9); } return d; }; const backDark = mk(420, [2, 4], 136, 0.3); const backMid = mk(480, [2, 4.5], 140, 0.5); const backTips = mk(160, [1.5, 3], 132, 0.8); const frontMid = mk(420, [2, 4.5], 166, 0.2); const frontLight = mk(300, [1.5, 3.5], 166, 0.45); const frontL = mk(220, [2, 4], 166, 0.4, (x) => x >= 40 && x < 115); const frontR = mk(220, [2, 4], 166, 0.4, (x) => x >= 115 && x < 190); return { back: [backDark, backMid], backTips, front: [frontMid, frontLight], frontLean: { l: frontL, r: frontR } }; })(); const SPOTS = (() => { const r = rng(5); const out: { x: number; y: number; r: number }[] = []; let guard = 0; while (out.length < 22 && guard++ < 600) { const x = 12 + r() * 186; const y = 8 + r() * 62; // inside the dome ellipse (centre 105,72; radii 100 x 66), skip the label strip const e = ((x - 105) / 100) ** 2 + ((y - 72) / 66) ** 2; if (e > 0.86) continue; if (x > 48 && x < 162 && y > 24 && y < 66) continue; const rad = (e > 0.55 ? 2.2 : 3) + r() * r() * 5; if (out.some((s) => Math.hypot(s.x - x, s.y - y) < s.r + rad + 3.5)) continue; out.push({ x, y, r: rad }); } return out; })(); const FONT = 'ui-rounded,"SF Pro Rounded","Nunito","Segoe UI",system-ui,sans-serif'; const SPECKS = (() => { const r = rng(11); let lt = "", dk = ""; for (let i = 0; i < 110; i++) { const x = 8 + r() * 194, y = 6 + r() * 70; if (((x - 105) / 100) ** 2 + ((y - 68) / 66) ** 2 > 0.95) continue; const a = 0.5 + r() * 0.7, c = `M${(x - a).toFixed(1)} ${y.toFixed(1)}a${a.toFixed(2)} ${a.toFixed(2)} 0 1 0 ${(a * 2).toFixed(2)} 0a${a.toFixed(2)} ${a.toFixed(2)} 0 1 0 ${(-a * 2).toFixed(2)} 0`; if (r() < 0.5) lt += c; else dk += c; } return { lt, dk }; })(); const CLOVERS = [ { x: 24, y: 126, s: 1 }, { x: 205, y: 123, s: 0.9 }, { x: 62, y: 118, s: 0.8 }, ]; const PEBBLES = [ { x: 36, y: 160, rx: 10, ry: 7 }, { x: 84, y: 166, rx: 8, ry: 5 }, { x: 160, y: 165, rx: 9, ry: 6 }, { x: 205, y: 156, rx: 8, ry: 6 }, ]; type Spore = { x: number; y: number; vx: number; vy: number; age: number; r: number; kind: 0 | 1 | 2; ph: number; fr: number; amp: number; tw: number; y0: number; a0: number }; export function MushroomButton({ children = "boop", palette = DEFAULT_PALETTE, onClick, className, type = "button", disabled = false, ref, ...rest }: Props) { const btnRef = useRef(null); const wrapRef = useRef(null); const canvasRef = useRef(null); const playRef = useRef<() => void>(() => {}); const [state, setState] = useState<"idle" | "playing">("idle"); const uid = `tb-mushroom-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`; useImperativeHandle(ref, () => btnRef.current!, []); const label = children.toUpperCase(); const fs = Math.round(clamp((32 * 5.2) / Math.max(5.2, label.length), 14, 32)); const cols = useMemo(() => ({ cap: palette.cap, hi: mix(palette.cap, "#ffa070", 0.45), shade: mix(palette.cap, "#000000", 0.42), }), [palette.cap]); const paletteKey = `${palette.cap}|${palette.spots}|${palette.spore}`; useEffect(() => { const btn = btnRef.current; const wrap = wrapRef.current; const canvas = canvasRef.current; if (!btn || !wrap || !canvas) return; const ctx = canvas.getContext("2d"); if (!ctx) return; const media = window.matchMedia("(prefers-reduced-motion: reduce)"); const isDisabled = () => btn.matches(":disabled"); const [, , sporeHex] = paletteKey.split("|"); const [sr, sg, sb] = rgb(sporeHex); // glow sprite, rendered once const sprite = document.createElement("canvas"); sprite.width = sprite.height = 64; { const g = sprite.getContext("2d"); if (g) { const grad = g.createRadialGradient(32, 32, 0, 32, 32, 32); grad.addColorStop(0, `rgba(${sr},${sg},${sb},1)`); grad.addColorStop(0.1, `rgba(${sr},${sg},${sb},.95)`); grad.addColorStop(0.28, "rgba(243,217,134,.55)"); grad.addColorStop(0.55, "rgba(255,200,70,.16)"); grad.addColorStop(1, "rgba(255,200,70,0)"); g.fillStyle = grad; g.fillRect(0, 0, 64, 64); } } type Spring = { x: number; v: number }; const capY: Spring = { x: 0, v: 0 }; const capSX: Spring = { x: 1, v: 0 }; const capSY: Spring = { x: 1, v: 0 }; const stemSY: Spring = { x: 1, v: 0 }; let dpr = 1; let raf = 0; let last = 0; let visible = true; let hovered = false; let hoverT0 = 0; let phase: "none" | "squash" | "release" = "none"; let t0 = -1e9; let from = { y: 0, sx: 1, sy: 1, st: 1 }; let spawnPending = 0; let spawnedAt = -1; let emitLeft = 0; let glow = 0; let spores: Spore[] = []; let idleTimer = 0; let timers: number[] = []; let anim: Animation | null = null; let playingUntil = 0; let clickSpores = 0; const r = rng(Math.floor(Math.random() * 1e9)); const allowed = () => !isDisabled() && visible && !document.hidden && !media.matches; const setVars = () => { const lift = clamp(-capY.x / HOVER_LIFT, 0, 1.4); wrap.style.setProperty("--tb-mushroom-cy", `${capY.x.toFixed(2)}px`); wrap.style.setProperty("--tb-mushroom-sx", capSX.x.toFixed(4)); wrap.style.setProperty("--tb-mushroom-sy", capSY.x.toFixed(4)); wrap.style.setProperty("--tb-mushroom-st", stemSY.x.toFixed(4)); wrap.style.setProperty("--tb-mushroom-lift", lift.toFixed(3)); wrap.style.setProperty("--tb-mushroom-glow", glow.toFixed(3)); }; const setup = () => { const rr = btn.getBoundingClientRect(); const scale = rr.width / (btn.offsetWidth || 1) || 1; dpr = Math.min(2, (window.devicePixelRatio || 1) * scale); canvas.width = Math.round(CW * dpr); canvas.height = Math.round(CH * dpr); }; const spawn = (n: number) => { for (let i = 0; i < n; i++) { const puff = r() < 0.1; const ang = puff ? ((r() - 0.5) * 72 * Math.PI) / 180 : ((r() - 0.5) * 56 * Math.PI) / 180; const sp = puff ? 180 + r() * 260 : r() < 0.3 ? 40 + r() * 110 : 150 + r() * 210; const dx = (r() - 0.5) * CAP_W * 0.6; const x = PADX + W / 2 + dx; const y = PADT + capY.x + 70 - 66 * Math.sqrt(Math.max(0, 1 - (dx / 100) ** 2)); spores.push({ x, y, vx: Math.sin(ang) * sp, vy: -Math.cos(ang) * sp, age: 0, r: puff ? 4.5 + r() * 1.5 : 0.9 + r() * 1.7, kind: puff ? 1 : 0, ph: r() * 6.283, fr: 0.8 + r() * 0.8, amp: 6 + r() * 8, tw: 3 + r() * 3, y0: y, a0: puff ? 1 : 0.55 + r() * 0.35, }); } clickSpores += n; if (spores.length > MAX_SPORES) spores = spores.slice(spores.length - MAX_SPORES); }; const idleSpore = () => { spores.push({ x: PADX + W / 2 + (r() - 0.5) * 120, y: PADT + 6 + capY.x, vx: 0, vy: -12, age: 0, r: 1.8, kind: 2, ph: r() * 6.283, fr: 1, amp: 4, tw: 0, y0: PADT + 6, a0: 0.5 }); }; const idleLoop = () => { idleTimer = 0; if (allowed()) { if (spores.length < MAX_SPORES) idleSpore(); wake(); } idleTimer = window.setTimeout(idleLoop, 1500); }; const stepSpring = (s: Spring, target: number, k: number, c: number, dt: number) => { const n = Math.max(1, Math.ceil(dt / 4)); const h = dt / n / 1000; for (let i = 0; i < n; i++) { s.v += (-k * (s.x - target) - c * s.v) * h; s.x += s.v * h; } }; const alphaOf = (s: Spore) => { const age = s.age; let a: number; if (s.kind === 2) a = 0.5 * Math.min(1, age / 0.3) * clamp(1 - age / 2); else { a = Math.min(1, age / 0.08); if (age > 0.6) { const tw = 0.5 + 0.5 * Math.sin(age * s.tw * 6.283 + s.ph); a *= s.kind === 1 ? 0.85 + 0.15 * tw : 0.6 + 0.4 * tw; } const h = clamp((s.y0 - s.y) / 200); const fs0 = (1400 + h * 600) / 1000; a *= 1 - clamp((age - fs0) / 0.8); } return a * s.a0; }; const swayOf = (s: Spore) => s.amp * Math.sin(s.age * s.fr * 6.283 + s.ph) * Math.min(1, s.age / 0.5); const draw = (now: number) => { ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, CW, CH); if (!spores.length) return; // amber under-pass so spores show on light tiles ctx.globalCompositeOperation = "source-over"; ctx.fillStyle = "#c98a12"; for (const s of spores) { if (s.kind === 1) continue; const a = alphaOf(s); if (a <= 0.01) continue; ctx.globalAlpha = a * 0.55; ctx.fillRect(s.x + swayOf(s) - s.r * 0.6, s.y - s.r * 0.6, s.r * 1.2, s.r * 1.2); } ctx.globalCompositeOperation = "lighter"; for (let pass = 0; pass < 2; pass++) { for (const s of spores) { if ((s.kind === 1) !== (pass === 1)) continue; const a = alphaOf(s); if (a <= 0.01) continue; const dx = swayOf(s); const x = s.x + dx; ctx.globalAlpha = a; if (s.kind === 1) { const sp = Math.hypot(s.vx, s.vy); const bl = clamp(sp / 120); let ux = -s.vx / (sp || 1); let uy = -s.vy / (sp || 1); ux *= bl; uy = uy * bl + (1 - bl); const ul = Math.hypot(ux, uy) || 1; const ex = x + (ux / ul) * 48 - dx * 0.2; const ey = s.y + (uy / ul) * 48; const qx = x + (ux / ul) * 24 - dx * 0.5; const qy = s.y + (uy / ul) * 24; const g = ctx.createLinearGradient(x, s.y, ex, ey); g.addColorStop(0, "rgba(255,214,110,.9)"); g.addColorStop(0.6, "rgba(255,196,80,.35)"); g.addColorStop(1, "rgba(255,196,80,0)"); ctx.strokeStyle = g; ctx.lineWidth = 1.6; ctx.beginPath(); ctx.moveTo(x, s.y); ctx.quadraticCurveTo(qx, qy, ex, ey); ctx.stroke(); ctx.globalCompositeOperation = "source-over"; ctx.strokeStyle = "rgba(185,120,20,.35)"; ctx.lineWidth = 0.8; ctx.stroke(); ctx.strokeStyle = "rgba(214,146,30,.9)"; ctx.lineWidth = 0.7; ctx.beginPath(); for (let i = 0; i < 20; i++) { const an = (i / 20) * 6.283 + s.ph; const c = Math.cos(an), n = Math.sin(an); const rl = 6.5 + (i % 3) * 0.7; ctx.moveTo(x + c * 2, s.y + n * 2); ctx.lineTo(x + c * rl, s.y + n * rl); } ctx.stroke(); ctx.globalCompositeOperation = "lighter"; ctx.globalAlpha = a * 0.7; ctx.drawImage(sprite, x - 15, s.y - 15, 30, 30); ctx.globalAlpha = a; ctx.fillStyle = "#fff6c8"; for (let i = 0; i < 20; i++) { const an = (i / 20) * 6.283 + s.ph; const rl = 6.5 + (i % 3) * 0.7; ctx.fillRect(x + Math.cos(an) * rl - 0.8, s.y + Math.sin(an) * rl - 0.8, 1.6, 1.6); } ctx.drawImage(sprite, x - 6, s.y - 6, 12, 12); } else { const sz = s.r * 5.5; ctx.drawImage(sprite, x - sz / 2, s.y - sz / 2, sz, sz); } } } ctx.globalAlpha = 1; ctx.globalCompositeOperation = "source-over"; void now; }; const finishPlay = () => { playingUntil = 0; clickSpores = 0; glow = 0; setState("idle"); }; const tick = (now: number) => { raf = 0; if (!allowed()) { last = 0; return; } const dt = last ? Math.min(48, now - last) : 16; last = now; const sec = dt / 1000; let moving = false; // click timeline const t = now - t0; if (phase === "squash") { const u = clamp(t / SQUASH_MS); const e = u * u; capY.x = from.y + (6 - from.y) * e; capSX.x = from.sx + (1.12 - from.sx) * e; capSY.x = from.sy + (0.84 - from.sy) * e; stemSY.x = from.st + (0.7 - from.st) * e; capY.v = capSX.v = capSY.v = stemSY.v = 0; if (t >= SQUASH_MS) phase = "release"; moving = true; } if (spawnPending && t >= SPAWN_AT && spawnedAt !== t0) { emitLeft += spawnPending; spawnPending = 0; spawnedAt = t0; } if (emitLeft > 0) { const k = Math.min(emitLeft, Math.max(1, Math.round((emitLeft * dt) / Math.max(16, 180 - (t - SPAWN_AT))))); spawn(k); emitLeft -= k; } if (t < 700) glow = t < SPAWN_AT ? 0 : t < 280 ? clamp((t - SPAWN_AT) / 160) : clamp(1 - (t - 280) / 420); else glow = 0; if (phase !== "squash") { const bobAmp = hovered ? Math.min(1, (now - hoverT0) / 700) * 2 : 0; const early = hovered && now - hoverT0 < 260; const liftT = early ? 22 : HOVER_LIFT; const sxT = hovered ? (early ? 0.96 : 0.99) : 1; const syT = hovered ? (early ? 1.04 : 1.01) : 1; const tgtY = hovered ? -liftT + bobAmp * Math.sin(((now - hoverT0) / 1000) * 6.283 * 1.4) : 0; const k = phase === "release" ? 260 : 180; const c = phase === "release" ? 12 : 10; stepSpring(capY, tgtY, k, c, dt); stepSpring(capSX, sxT, k, c, dt); stepSpring(capSY, syT, k, c, dt); stepSpring(stemSY, 1 + -tgtY / STEM_H, k, c, dt); const settled = Math.abs(capY.x - tgtY) < 0.05 && Math.abs(capY.v) < 0.5 && Math.abs(capSY.x - syT) < 0.002 && Math.abs(capSY.v) < 0.02; if (phase === "release" && settled) phase = "none"; if (!settled || hovered) moving = true; } // spores const drag = Math.exp(-2.2 * sec); for (const s of spores) { s.age += sec; if (s.kind !== 2) { s.vx *= drag; s.vy = s.vy * drag - 20 * sec; } s.x += s.vx * sec; s.y += s.vy * sec; } const before = spores.length; spores = spores.filter((s) => (s.kind === 2 ? s.age < 2 : s.age * 1000 < SPORE_LIFE)); if (spores.length !== before) clickSpores = spores.filter((s) => s.kind !== 2).length; if (playingUntil && now > playingUntil && clickSpores === 0 && phase === "none") finishPlay(); setVars(); draw(now); if (moving || spores.length || glow > 0 || playingUntil || emitLeft > 0 || phase !== "none") raf = requestAnimationFrame(tick); else last = 0; }; const wake = () => { if (!raf && allowed()) raf = requestAnimationFrame(tick); }; const clearTimers = () => { timers.forEach((id) => window.clearTimeout(id)); timers = []; }; const reducedClick = () => { clearTimers(); anim?.cancel(); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, CW, CH); ctx.globalCompositeOperation = "lighter"; const rr = rng(9); for (let i = 0; i < 20; i++) { const sz = 12 + rr() * 16; const x = PADX + W / 2 + (rr() - 0.5) * 170; const y = PADT - 10 - rr() * 90; ctx.globalAlpha = 0.45 + rr() * 0.5; ctx.drawImage(sprite, x - sz / 2, y - sz / 2, sz, sz); } ctx.globalAlpha = 1; ctx.globalCompositeOperation = "source-over"; glow = 1; setVars(); setState("playing"); anim = canvas.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 150, fill: "forwards" }); timers.push(window.setTimeout(() => { anim?.cancel(); glow = 0; setVars(); anim = canvas.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill: "forwards" }); }, 1150)); timers.push(window.setTimeout(() => { anim?.cancel(); anim = null; ctx.clearRect(0, 0, CW, CH); setState("idle"); }, 1320)); }; playRef.current = () => { if (isDisabled()) return; if (media.matches) { reducedClick(); return; } const now = performance.now(); from = { y: capY.x, sx: capSX.x, sy: capSY.x, st: stemSY.x }; phase = "squash"; t0 = now; spawnPending = clickSpores > 0 ? 70 : 140; playingUntil = now + END_MS; setState("playing"); wake(); }; const enter = () => { if (isDisabled() || media.matches) return; if (phase === "none") { capY.v += 70; stemSY.v -= 1.4; } hovered = true; hoverT0 = performance.now(); wrap.dataset.tbHover = "true"; wake(); }; const leave = () => { hovered = false; wrap.dataset.tbHover = "false"; wake(); }; const resize = () => { setup(); }; const syncVis = () => { wrap.dataset.tbPaused = String(!visible || document.hidden); if (allowed()) wake(); }; const onMedia = () => { if (media.matches) { cancelAnimationFrame(raf); raf = 0; spores = []; emitLeft = 0; phase = "none"; capY.x = 0; capSX.x = 1; capSY.x = 1; stemSY.x = 1; hovered = false; glow = 0; setVars(); ctx.clearRect(0, 0, CW, CH); } else wake(); }; const io = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver(([en]) => { visible = en.isIntersecting; syncVis(); }); setup(); setVars(); io?.observe(wrap); btn.addEventListener("pointerenter", enter); btn.addEventListener("pointerleave", leave); window.addEventListener("resize", resize); document.addEventListener("visibilitychange", syncVis); media.addEventListener("change", onMedia); idleTimer = window.setTimeout(idleLoop, 700); return () => { playRef.current = () => {}; cancelAnimationFrame(raf); window.clearTimeout(idleTimer); clearTimers(); anim?.cancel(); io?.disconnect(); btn.removeEventListener("pointerenter", enter); btn.removeEventListener("pointerleave", leave); window.removeEventListener("resize", resize); document.removeEventListener("visibilitychange", syncVis); media.removeEventListener("change", onMedia); }; }, [disabled, paletteKey]); const click = (e: MouseEvent) => { if (disabled || e.currentTarget.matches(":disabled")) return; onClick?.(e); if (e.defaultPrevented) return; playRef.current(); }; return ( ); } export default MushroomButton; const css = ` .tb-mushroom-wrap{display:inline-flex;position:relative;vertical-align:middle;width:${W}px;height:${H}px; --tb-mushroom-cy:0px;--tb-mushroom-sx:1;--tb-mushroom-sy:1;--tb-mushroom-st:1;--tb-mushroom-lift:0;--tb-mushroom-glow:0} .tb-mushroom-btn{position:relative;display:block;box-sizing:border-box;width:${W}px;height:${H}px;padding:0;margin:0;border:0;border-radius:40px; background:transparent;overflow:visible;cursor:pointer;-webkit-tap-highlight-color:transparent} .tb-mushroom-btn:focus-visible{outline:3px solid ${ACCENT};outline-offset:4px} .tb-mushroom-btn:disabled{cursor:default;opacity:.6;filter:saturate(.5)} .tb-mushroom-btn svg{overflow:visible;pointer-events:none} .tb-mushroom-canvas{position:absolute;left:-${PADX}px;top:-${PADT}px;width:${CW}px;height:${CH}px;max-width:none;pointer-events:none} .tb-mushroom-moss,.tb-mushroom-mossf{position:absolute;left:0;top:0} .tb-mushroom-shadow{position:absolute;left:46px;top:112px;width:138px;height:30px;border-radius:50%;pointer-events:none; background:radial-gradient(ellipse,rgba(0,0,0,.55),transparent 70%); transform:scale(calc(1 - .45 * var(--tb-mushroom-lift)));opacity:calc(1 - .55 * var(--tb-mushroom-lift))} .tb-mushroom-stem{position:absolute;left:80px;top:80px;transform-origin:50% 100%;transform:scaleY(var(--tb-mushroom-st));pointer-events:none} .tb-mushroom-cap{position:absolute;left:${(W - CAP_W) / 2}px;top:0;width:${CAP_W}px;height:${CAP_H}px;pointer-events:none; transform-origin:50% 100%;transform:translateY(var(--tb-mushroom-cy)) scale(var(--tb-mushroom-sx),var(--tb-mushroom-sy))} .tb-mushroom-breathe{display:block;width:100%;height:100%;transform-origin:50% 100%;animation:tb-mushroom-breathe 3s ease-in-out infinite alternate} .tb-mushroom-spotglow,.tb-mushroom-capglow{opacity:var(--tb-mushroom-glow)} .tb-mushroom-lean{transform-box:fill-box;transform-origin:50% 100%;transition:transform .35s ease} .tb-mushroom-wrap[data-tb-hover=true] .tb-mushroom-lean-l{transform:rotate(-2deg)} .tb-mushroom-wrap[data-tb-hover=true] .tb-mushroom-lean-r{transform:rotate(2deg)} @keyframes tb-mushroom-breathe{from{transform:scaleY(1)}to{transform:scaleY(1.015)}} .tb-mushroom-wrap[data-tb-paused=true] *{animation-play-state:paused!important} .tb-mushroom-btn:disabled *{animation:none!important} @media (prefers-reduced-motion:reduce){.tb-mushroom-wrap *,.tb-mushroom-wrap *::before,.tb-mushroom-wrap *::after{animation:none!important;transition:none!important}} `;