"use client"; /** * egg.tsx — a speckled egg in a straw nest. * Hover and it rocks and a hairline crack draws in; click and the lid pops, a chick says hi, then it tucks back in. * * Part of toy-buttons. MIT licensed. Only depends on React. */ import { useEffect, useId, useImperativeHandle, useRef, type ButtonHTMLAttributes, type CSSProperties, type MouseEvent, type ReactNode, type Ref } from "react"; type Palette = { shell: string; speckle: string; chick: string; straw: string }; type Props = Omit, "children"> & { children?: ReactNode; ref?: Ref; palette?: Palette; }; const W = 150; const H = 180; const PAD_TOP = 90; const PAD_SIDE = 60; const PAD_BOT = 60; const CW = W + 2 * PAD_SIDE; const CH = H + PAD_TOP + PAD_BOT; const RESET_MS = 3200; const DEFAULT_PALETTE: Palette = { shell: "#ecd7bf", speckle: "#a56d2c", chick: "#ffd23a", straw: "#d0993a" }; const EGG = "M75 8C104 8 127 44 129 92C130 128 107 148 75 148C43 148 20 128 21 92C23 44 46 8 75 8Z"; const CRACK_Y = 74; const mulberry = (seed: number) => () => { 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; }; const ZZ: [number, number][] = [[-10,74],[10,71],[18,80.5],[27,68.8],[34,80.7],[44,68.7],[52,83.3],[60,72.7],[69,84],[78,71],[86,82.8],[95,68.4],[103,83.9],[112,71.1],[120,83.2],[129,70],[138,77],[170,74]]; const zzLine = ZZ.map(([x, y], i) => `${i ? "L" : "M"}${x} ${y}`).join(" "); const TOP_CLIP = `${zzLine} L170 -140 L-10 -140 Z`; const BOT_CLIP = `${zzLine} L170 320 L-10 320 Z`; const SPECKLES = (() => { const r = mulberry(11); const out: { x: number; y: number; rx: number; ry: number; rot: number; c: string; o: number }[] = []; let guard = 0; while (out.length < 80 && guard++ < 1500) { const y = 12 + 134 * Math.pow(r(), 1.15); const x = 19 + ((out.length % 13) + r()) * 8.6; if (((x - 75) / 54) ** 2 + ((y - 82) / 66) ** 2 > 0.92) continue; const s = 0.9 + Math.pow(r(), 2.2) * 5.2; const long = r() < 0.25; const k = r(); out.push({ x, y, rx: (long ? s * 1.8 : s) / 2 + 0.4, ry: s / 2 + 0.3, rot: r() * 180, c: k < 0.5 ? "" : k < 0.8 ? "#7a4a1e" : "#b97a3a", o: 0.78 + r() * 0.22 }); } return out; })(); const GRAIN = (() => { const r = mulberry(23); const out: { x: number; y: number; r: number }[] = []; let guard = 0; while (out.length < 140 && guard++ < 2000) { const x = 20 + r() * 110, y = 10 + r() * 138; if (((x - 75) / 54) ** 2 + ((y - 82) / 66) ** 2 > 0.95) continue; out.push({ x, y, r: 0.35 + r() * 0.35 }); } return out; })(); const FUR = (() => { const r = mulberry(31); const P = (rad: number, a: number) => `${(75 + Math.cos(a) * rad).toFixed(1)} ${(62 + Math.sin(a) * rad).toFixed(1)}`; return Array.from({ length: 44 }, (_, k) => { const t = ((k * 360) / 44 + (r() - 0.5) * 5) * Math.PI / 180; const bend = (r() < 0.5 ? -1 : 1) * (4 + r() * 6) * Math.PI / 180; const r0 = 25 + r() * 1.5, r1 = r0 + 3 + r() * 3.5; return `M${P(r0, t)}Q${P((r0 + r1) / 2, t + bend * 0.5)} ${P(r1, t + bend)}`; }); })(); const FLUFF = Array.from({ length: 16 }, (_, k) => { const t = ((11.25 + k * 22.5) * Math.PI) / 180; return [75 + Math.cos(t) * 25, 62 + Math.sin(t) * 25] as const; }); // straw strokes grouped by colour: back half behind the egg, front half in front const NEST_CY = 124, NEST_RX = 72, NEST_RY = 12, NEST_BELLY = 46; const ell = (x: number, rx: number) => Math.sqrt(Math.max(0, 1 - ((x - 75) / rx) ** 2)); const rimFront = (x: number) => NEST_CY + NEST_RY * ell(x, NEST_RX); const rimBack = (x: number) => NEST_CY - NEST_RY * ell(x, NEST_RX); const belly = (x: number) => NEST_CY + NEST_BELLY * ell(x, NEST_RX - 2); const straw = (seed: number, n: number, front: boolean) => { const r = mulberry(seed); const d: string[] = ["", "", "", ""]; for (let i = 0; i < n; i++) { const x1 = 5 + r() * 140, len = 24 + r() * 32, dir = r() < 0.5 ? -1 : 1; const x2 = Math.max(4, Math.min(146, x1 + dir * len)); const t = Math.pow(r(), 0.75); const yAt = (x: number) => front ? rimFront(x) + t * (belly(x) - rimFront(x)) : rimBack(x) + t * (NEST_CY + 4 - rimBack(x)); const y1 = yAt(x1) + (r() - 0.5) * 5; const y2 = yAt(x2) + (r() - 0.5) * 5 + (front ? (r() - 0.5) * 14 : 0); const cx = (x1 + x2) / 2 + (r() - 0.5) * 10, cy = (y1 + y2) / 2 + (front ? 3 : -2) * r(); d[i % 4] += `M${x1.toFixed(1)} ${y1.toFixed(1)}Q${cx.toFixed(1)} ${cy.toFixed(1)} ${x2.toFixed(1)} ${y2.toFixed(1)}`; } if (front) for (let i = 0; i < 14; i++) { const side = i % 2 ? 1 : -1; const x1 = 75 + side * (30 + r() * 40), y1 = rimFront(x1) + r() * 8; const a = -Math.PI / 2 + side * (0.5 + r() * 0.9), L = 10 + r() * 14; d[i % 4] += `M${x1.toFixed(1)} ${y1.toFixed(1)}l${(Math.cos(a) * L).toFixed(1)} ${(Math.sin(a) * L).toFixed(1)}`; } return d; }; const STRAW_BACK = straw(5, 70, false); const STRAW_FRONT = straw(9, 190, true); const RIM = (() => { const r = mulberry(41); const back = ["", ""], front = ["", ""]; for (let i = 0; i < 90; i++) { const a0 = r() * Math.PI * 2, span = (16 + r() * 22) * Math.PI / 180, a1 = a0 + span, am = (a0 + a1) / 2; const j = (r() - 0.5) * 6, rx = 73 + j, ry = 13 + j * 0.4, dy = (r() - 0.5) * 4; const P = (a: number, k = 1) => `${(75 + Math.cos(a) * rx * k).toFixed(1)} ${(124 + dy + Math.sin(a) * ry * k).toFixed(1)}`; (Math.sin(am) > 0 ? front : back)[i % 2] += `M${P(a0)}Q${P(am, 1.04)} ${P(a1)}`; } return { back, front }; })(); type Chip = { k: 0 | 1 | 2; x: number; y: number; vx: number; vy: number; rot: number; vr: number; s: number; age: number; life: number; floor: number; a0: number }; type Phase = "idle" | "playing" | "closing"; export function EggButton({ children = "hatch", palette = DEFAULT_PALETTE, onClick, className, type = "button", disabled = false, ref, ...rest }: Props) { const btnRef = useRef(null); const wrapRef = useRef(null); const rockRef = useRef(null); const sqRef = useRef(null); const capRef = useRef(null); const chickRef = useRef(null); const wingsRef = useRef(null); const beakRef = useRef(null); const eyesRef = useRef(null); const crackRef = useRef(null); const frontRef = useRef(null); const canvasRef = useRef(null); const play = useRef<() => void>(() => {}); const uid = `tb-egg-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`; useImperativeHandle(ref, () => btnRef.current!, []); useEffect(() => { const btn = btnRef.current; const wrap = wrapRef.current; const rock = rockRef.current; const sq = sqRef.current; const cap = capRef.current; const chick = chickRef.current; const wings = wingsRef.current; const beak = beakRef.current; const eyes = eyesRef.current; const crack = crackRef.current; const front = frontRef.current; const canvas = canvasRef.current; if (!btn || !wrap || !rock || !sq || !cap || !chick || !wings || !beak || !eyes || !crack || !front || !canvas) return; const ctx = canvas.getContext("2d"); if (!ctx) return; const media = window.matchMedia("(prefers-reduced-motion: reduce)"); let epoch = 0; let phase: Phase = "idle"; let queued = false; let visible = true; let raf = 0; let last = 0; let chips: Chip[] = []; const timers = new Set(); const anims = new Set(); const later = (fn: () => void, ms: number) => { const my = epoch; const id = window.setTimeout(() => { timers.delete(id); if (my === epoch) fn(); }, ms); timers.add(id); }; const anim = (el: Element, kf: Keyframe[], opt: KeyframeAnimationOptions) => { const a = el.animate(kf, opt); anims.add(a); if (!opt.fill || opt.fill === "none") a.onfinish = () => anims.delete(a); return a; }; const cancelAll = () => { anims.forEach((a) => a.cancel()); anims.clear(); }; const setState = (s: string) => { wrap.dataset.tbState = s; }; const setup = () => { const r = btn.getBoundingClientRect(); const scale = r.width / (btn.offsetWidth || 1) || 1; const dpr = Math.min(2, (window.devicePixelRatio || 1) * scale); canvas.width = Math.round(CW * dpr); canvas.height = Math.round(CH * dpr); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); }; const tick = (now: number) => { raf = 0; const dt = last ? Math.min(0.048, (now - last) / 1000) : 0.016; last = now; ctx.clearRect(0, 0, CW, CH); for (const c of chips) { c.age += dt; if (c.k === 2) continue; c.vy += (c.k === 0 ? 1400 : 600) * dt; c.vx *= 1 - 1.8 * dt; c.x += c.vx * dt; c.y += c.vy * dt; c.rot += c.vr * dt; if (c.x < 6 || c.x > CW - 6) { c.x = Math.min(CW - 6, Math.max(6, c.x)); c.vx *= -0.3; } if (c.k === 0 && c.y > c.floor && c.vy > 0) { c.y = c.floor; c.vy *= -0.28; c.vx *= 0.45; c.vr *= 0.4; } } chips = chips.filter((c) => c.age < c.life); for (const c of chips) { ctx.save(); if (c.k === 2) { const t = Math.min(1, c.age / 0.26), e = 1 - (1 - t) ** 3, r0 = 42 + 18 * e, L = 3 + 7 * e; ctx.globalAlpha = c.age < 0.26 ? 1 : Math.max(0, 1 - (c.age - 0.26) / 0.16); ctx.strokeStyle = "#ffc531"; ctx.lineWidth = 2.4; ctx.lineCap = "round"; ctx.beginPath(); ctx.moveTo(c.x + Math.cos(c.a0) * r0, c.y + Math.sin(c.a0) * r0); ctx.lineTo(c.x + Math.cos(c.a0) * (r0 + L), c.y + Math.sin(c.a0) * (r0 + L)); ctx.stroke(); } else if (c.k === 1) { ctx.globalAlpha = Math.max(0, 1 - c.age / c.life); ctx.fillStyle = "#f6ead9"; ctx.beginPath(); ctx.arc(c.x, c.y, c.s, 0, Math.PI * 2); ctx.fill(); } else { ctx.translate(c.x, c.y); ctx.rotate(c.rot); ctx.globalAlpha = c.age < 0.95 ? 1 : Math.max(0, 1 - (c.age - 0.95) / 0.45); const s = c.s, outer = Math.cos(c.rot * 1.7) > 0; ctx.fillStyle = outer ? "#efdcc3" : "#fbf3e8"; ctx.strokeStyle = "#a8865f"; ctx.lineWidth = 0.7; ctx.lineJoin = "round"; ctx.beginPath(); ctx.moveTo(-0.6 * s, 0.45 * s); ctx.lineTo(-0.1 * s, -0.6 * s); ctx.lineTo(0.55 * s, -0.2 * s); ctx.lineTo(0.4 * s, 0.5 * s); ctx.closePath(); ctx.fill(); ctx.stroke(); if (outer) { ctx.fillStyle = "#a56d2c"; ctx.beginPath(); ctx.arc(0.1 * s, 0.05 * s, 0.9, 0, Math.PI * 2); ctx.fill(); } } ctx.restore(); } if (chips.length && visible && !document.hidden) raf = requestAnimationFrame(tick); else { last = 0; ctx.clearRect(0, 0, CW, CH); } }; const kick = () => { if (!raf) { last = 0; raf = requestAnimationFrame(tick); } }; const burst = () => { const cx = PAD_SIDE + 75; for (let i = 0; i < 12; i++) { const x = cx + (Math.random() - 0.5) * 80, a = -Math.PI / 2 + (Math.random() - 0.5) * 1.6, sp = 170 + Math.random() * 120; const floor = Math.abs(x - cx) < 60 ? PAD_TOP + 124 + Math.random() * 8 : PAD_TOP + 170; chips.push({ k: 0, x, y: PAD_TOP + CRACK_Y, vx: Math.cos(a) * sp, vy: Math.sin(a) * sp, rot: Math.random() * 6, vr: (Math.random() < 0.5 ? -1 : 1) * (4 + Math.random() * 6), s: 5 + Math.random() * 5, age: 0, life: 1.4, floor, a0: 0 }); } for (let i = 0; i < 8; i++) { const a = -Math.PI / 2 + (Math.random() - 0.5) * 2.6, sp = 60 + Math.random() * 80; chips.push({ k: 1, x: cx + (Math.random() - 0.5) * 70, y: PAD_TOP + CRACK_Y, vx: Math.cos(a) * sp, vy: Math.sin(a) * sp, rot: 0, vr: 0, s: 0.8 + Math.random() * 0.6, age: 0, life: 0.5, floor: 0, a0: 0 }); } kick(); }; const dashes = () => { for (const deg of [-168, -150, -132, -48, -30, -12]) { chips.push({ k: 2, x: PAD_SIDE + 75, y: PAD_TOP + 46, vx: 0, vy: 0, rot: 0, vr: 0, s: 0, age: 0, life: 0.42, floor: 0, a0: ((deg + (Math.random() - 0.5) * 12) * Math.PI) / 180 }); } kick(); }; const chirp = () => { anim(beak, [{ transform: "translateY(0)" }, { transform: "translateY(4px)" }, { transform: "translateY(0)" }, { transform: "translateY(4px)" }, { transform: "translateY(0)" }], { duration: 360 }); anim(eyes, [{ transform: "scaleY(1)" }, { transform: "scaleY(.1)" }, { transform: "scaleY(1)" }], { duration: 120, delay: 60 }); }; const reset = () => { cancelAll(); phase = "idle"; setState("idle"); if (queued) { queued = false; start(); } else wobbleLater(); }; const start = () => { phase = "playing"; setState("playing"); anim(sq, [ { transform: "scale(1,1) rotate(0deg)", offset: 0 }, { transform: "scale(1.04,.94) rotate(0deg)", offset: 90 / 330, easing: "ease-in" }, { transform: "scale(1.04,.94) rotate(7deg)", offset: 160 / 330 }, { transform: "scale(1.04,.94) rotate(-7deg)", offset: 230 / 330 }, { transform: "scale(1.04,.94) rotate(0deg)", offset: 270 / 330 }, { transform: "scale(1,1) rotate(0deg)", offset: 1 }, ], { duration: 330 }); anim(front, [{ transform: "translateY(0) scaleY(1)" }, { transform: "translateY(1.5px) scaleY(.96)", offset: 0.27, easing: "ease-out" }, { transform: "translateY(0) scaleY(1)" }], { duration: 330 }); anim(crack, [{ strokeDashoffset: 1 }, { strokeDashoffset: 0 }], { delay: 90, duration: 180, fill: "forwards", easing: "ease-out" }); anim(crack, [{ opacity: 1 }, { opacity: 0 }], { delay: 2800, duration: 400, fill: "forwards" }); const T = 2560; const ck = (ms: number, tr: string, easing?: string): Keyframe => ({ transform: tr, offset: ms / T, easing }); anim(cap, [ ck(0, "translate(0px,0px) rotate(0deg)", "cubic-bezier(.2,.8,.3,1)"), ck(380, "translate(18px,-74px) rotate(-26deg)", "ease-in"), ck(620, "translate(6px,-44px) rotate(-10deg)", "ease-out"), ck(700, "translate(6px,-46px) rotate(-12deg)", "ease-in-out"), ck(790, "translate(6px,-49px) rotate(-13deg)", "ease-in-out"), ck(940, "translate(6px,-46px) rotate(-12deg)", "ease-in-out"), ck(1090, "translate(6px,-49px) rotate(-11deg)", "ease-in-out"), ck(1240, "translate(6px,-46px) rotate(-12deg)"), ck(2040, "translate(6px,-46px) rotate(-12deg)", "ease-in"), ck(2300, "translate(0px,0px) rotate(0deg)", "ease-out"), ck(2400, "translate(0px,-4px) rotate(0deg)", "ease-in"), ck(2560, "translate(0px,0px) rotate(0deg)"), ], { delay: 260, duration: T }); const C = 2220; const cy = (ms: number, y: number, easing?: string): Keyframe => ({ transform: `translateY(${y}px)`, opacity: 1, offset: (ms - 300) / C, easing }); anim(chick, [ cy(300, 70, "cubic-bezier(.2,.8,.3,1)"), cy(520, -20), cy(640, -11.5), cy(750, -14), cy(900, -14, "ease-in-out"), cy(1050, -17, "ease-in-out"), cy(1200, -14, "ease-in-out"), cy(1350, -17, "ease-in-out"), cy(1500, -14), cy(2300, -14, "ease-in"), cy(2520, 70), ], { delay: 300, duration: C }); const wy = (ms: number, y: number, op?: number, easing?: string): Keyframe => ({ transform: `translateY(${y}px)`, opacity: op ?? 1, offset: (ms - 470) / 2050, easing }); anim(wings, [ wy(470, -15, 0), wy(520, -20, 1), wy(640, -11.5), wy(750, -14), wy(900, -14, 1, "ease-in-out"), wy(1050, -17, 1, "ease-in-out"), wy(1200, -14, 1, "ease-in-out"), wy(1350, -17, 1, "ease-in-out"), wy(1500, -14), wy(2300, -14, 1, "ease-in"), wy(2350, -4, 0), wy(2520, 70, 0), ], { delay: 470, duration: 2050 }); anim(beak, [{ transform: "translateY(0)" }, { transform: "translateY(4px)", offset: 0.3 }, { transform: "translateY(4px)", offset: 0.75 }, { transform: "translateY(0)" }], { delay: 520, duration: 500 }); anim(eyes, [{ transform: "scaleY(1)" }, { transform: "scaleY(.1)" }, { transform: "scaleY(1)" }], { delay: 700, duration: 120 }); later(burst, 260); later(dashes, 560); later(() => { phase = "closing"; }, 2300); later(reset, RESET_MS); }; // idle micro-wobble every 6-9 s const wobbleLater = () => { later(() => { if (phase === "idle" && visible && !document.hidden && !media.matches && wrap.dataset.tbHover !== "true" && !disabled) { anim(rock, [{ transform: "rotate(0deg)" }, { transform: "rotate(1.5deg)" }, { transform: "rotate(-1.5deg)" }, { transform: "rotate(.7deg)" }, { transform: "rotate(0deg)" }], { duration: 360 }); } wobbleLater(); }, 6000 + Math.random() * 3000); }; play.current = () => { if (disabled) return; if (media.matches) { if (phase !== "idle") return; phase = "closing"; setState("open"); anim(chick, [{ opacity: 0 }, { opacity: 1 }], { duration: 150 }); anim(wings, [{ opacity: 0 }, { opacity: 1 }], { duration: 150 }); anim(cap, [{ opacity: 0 }, { opacity: 1 }], { duration: 150 }); later(() => { anim(chick, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill: "forwards" }); anim(wings, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill: "forwards" }); anim(cap, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill: "forwards" }); }, 1350); later(() => { cancelAll(); phase = "idle"; setState("idle"); }, 1500); return; } if (phase === "idle") start(); else if (phase === "playing") chirp(); else queued = true; }; const enter = () => { if (!disabled) wrap.dataset.tbHover = "true"; }; const leave = () => { delete wrap.dataset.tbHover; }; const io = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver(([en]) => { visible = en.isIntersecting; wrap.dataset.tbPaused = String(!visible); if (visible && chips.length && !raf) raf = requestAnimationFrame(tick); }); const mq = () => { if (media.matches) { cancelAll(); chips = []; phase = "idle"; queued = false; setState("idle"); } }; setup(); io?.observe(wrap); btn.addEventListener("pointerenter", enter); btn.addEventListener("pointerleave", leave); window.addEventListener("resize", setup); media.addEventListener("change", mq); wobbleLater(); return () => { epoch++; play.current = () => {}; cancelAnimationFrame(raf); timers.forEach((id) => window.clearTimeout(id)); timers.clear(); cancelAll(); io?.disconnect(); btn.removeEventListener("pointerenter", enter); btn.removeEventListener("pointerleave", leave); window.removeEventListener("resize", setup); media.removeEventListener("change", mq); }; }, [disabled]); const click = (e: MouseEvent) => { if (disabled || e.currentTarget.matches(":disabled")) return; onClick?.(e); if (e.defaultPrevented) return; play.current(); }; const p = palette; return ( ); } export default EggButton; const css = ` .tb-egg-wrap{display:inline-flex;position:relative;vertical-align:middle} .tb-egg-btn{position:relative;display:block;box-sizing:border-box;width:${W}px;height:${H}px;padding:0;border:0;background:transparent;overflow:visible; color:#f6ead9;cursor:pointer;-webkit-tap-highlight-color:transparent;border-radius:70px 70px 40px 40px; font:800 17px/1 ui-rounded,"SF Pro Rounded","Nunito","Segoe UI",system-ui,sans-serif;letter-spacing:.04em} .tb-egg-btn:focus-visible{outline:2px solid #b07a24;outline-offset:5px;box-shadow:none} .tb-egg-btn:disabled{cursor:default;opacity:.6;filter:saturate(.5)} .tb-egg-svg{position:absolute;left:0;top:0;width:${W}px;height:${H}px;overflow:visible;pointer-events:none} .tb-egg-front{transition:transform .3s ease;transform-origin:50% 85%} .tb-egg-wrap[data-tb-hover=true] .tb-egg-front{transform:translateX(1px)} .tb-egg-rock,.tb-egg-sq{will-change:transform,rotate;position:absolute;left:0;top:0;width:${W}px;height:${H}px;transform-origin:50% 92%;pointer-events:none} .tb-egg-rock{rotate:0deg;transition:rotate 380ms cubic-bezier(.34,1.56,.64,1)} .tb-egg-wrap[data-tb-hover=true]:not([data-tb-state=playing]):not([data-tb-state=open]) .tb-egg-rock{rotate:5deg} .tb-egg-wrap[data-tb-hover=true]:not([data-tb-state=playing]):not([data-tb-state=open]) .tb-egg-rock{ animation:tb-egg-intro 1150ms ease-out both,tb-egg-loop 385ms ease-in-out 1150ms infinite} @keyframes tb-egg-intro{0%{transform:rotate(0)}8.4%{transform:rotate(6deg)}25%{transform:rotate(-4.8deg)}41.8%{transform:rotate(3.6deg)}58.5%{transform:rotate(-2.6deg)}75.2%{transform:rotate(1.9deg)}92%{transform:rotate(-1.3deg)}100%{transform:rotate(0)}} @keyframes tb-egg-loop{0%,100%{transform:rotate(0)}25%{transform:rotate(1.8deg)}75%{transform:rotate(-1.8deg)}} .tb-egg-hair{stroke-dasharray:1;stroke-dashoffset:1;transition:stroke-dashoffset 420ms ease-out} .tb-egg-wrap[data-tb-hover=true] .tb-egg-hair,.tb-egg-wrap[data-tb-state=playing] .tb-egg-hair{stroke-dashoffset:0} .tb-egg-edge{opacity:0} .tb-egg-wrap[data-tb-state=playing] .tb-egg-edge,.tb-egg-wrap[data-tb-state=open] .tb-egg-edge{opacity:1} .tb-egg-wob{stroke-dasharray:1;stroke-dashoffset:1;opacity:0;transition:stroke-dashoffset 280ms ease-out,opacity 200ms} .tb-egg-wrap[data-tb-hover=true]:not([data-tb-state=playing]):not([data-tb-state=open]) .tb-egg-wob{stroke-dashoffset:0;opacity:.85;animation:tb-egg-wobpulse 770ms ease-in-out 1150ms infinite} @keyframes tb-egg-wobpulse{0%,100%{opacity:.85}50%{opacity:.35}} .tb-egg-lip{opacity:0} .tb-egg-wrap[data-tb-state=playing] .tb-egg-lip{opacity:1;transition:opacity 80ms linear 330ms} .tb-egg-wrap[data-tb-state=open] .tb-egg-lip{opacity:1} .tb-egg-wrap[data-tb-state=playing] .tb-egg-whole,.tb-egg-wrap[data-tb-state=open] .tb-egg-whole{opacity:0} .tb-egg-ring{stroke-dasharray:1;stroke-dashoffset:1} .tb-egg-chick{opacity:0} .tb-egg-wrap[data-tb-state=open] .tb-egg-chick{opacity:1;transform:translateY(-14px)} .tb-egg-wrap[data-tb-state=open] .tb-egg-cap{transform:translate(6px,-46px) rotate(-12deg)} .tb-egg-wrap[data-tb-state=open] .tb-egg-edge{opacity:0} .tb-egg-wrap[data-tb-state=open] .tb-egg-ring{stroke-dashoffset:0} .tb-egg-hair2{transition-delay:200ms} .tb-egg-wrap:not([data-tb-hover=true]):not([data-tb-state=playing]) .tb-egg-hair2{transition-delay:0ms} .tb-egg-plaque{position:absolute;left:${(W - 92) / 2}px;top:90px;display:flex;align-items:center;justify-content:center;width:92px;height:30px;box-sizing:border-box; border-radius:15px;background:linear-gradient(180deg,rgba(255,220,170,.2),rgba(255,220,170,0) 45%),repeating-linear-gradient(176deg,rgba(70,35,8,0) 0 5px,rgba(70,35,8,.16) 5px 6px),linear-gradient(180deg,#a56d2c,#8a5520); border:1px solid #6e4114;box-shadow:inset 0 1px 0 #d8a463,inset 0 -2px 3px #5d3710,0 1px 0 rgba(60,35,10,.35),0 3px 7px rgba(60,35,10,.38)} .tb-egg-label{text-transform:uppercase;white-space:nowrap;letter-spacing:.06em;text-shadow:0 -1px 0 rgba(60,30,5,.6),0 1px 0 rgba(255,225,180,.22)} .tb-egg-canvas{position:absolute;left:-${PAD_SIDE}px;top:-${PAD_TOP}px;width:${CW}px;height:${CH}px;pointer-events:none} .tb-egg-wrap[data-tb-paused=true] *{animation-play-state:paused!important} @media (prefers-reduced-motion:reduce){.tb-egg-wrap *,.tb-egg-wrap *::before,.tb-egg-wrap *::after{animation:none!important;transition:none!important}} `;