{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pour-hero",
  "type": "registry:block",
  "title": "Pour Hero",
  "description": "A hero whose headline drips in as lime liquid: drops pinch off the top edge, splash on landing and set into real, selectable type, with a droplet button that squashes and splashes when pressed.",
  "categories": [
    "block",
    "Heroes"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/devl/pour-hero.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { ArrowRight, CirclePlay, RotateCcw } from \"lucide-react\";\nimport { animate, motion, useInView, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform } from \"motion/react\";\nimport {\n  Fragment,\n  type KeyboardEvent,\n  type PointerEvent,\n  type ReactNode,\n  useCallback,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useRef,\n  useState,\n} from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nconst headlineType =\n  \"font-heading font-semibold text-[42px] leading-[0.98] tracking-[-0.045em] sm:text-6xl sm:leading-[0.98] lg:text-[88px] lg:leading-[0.95]\";\n\nconst gravity = 3400;\nconst wordGap = 0.085;\nconst swell = 0.14;\nconst neck = 0.36;\nconst formFor = 0.84;\nconst fall = [0.11, 0, 0.5, 0] as const;\nconst settle = [0.2, 0.8, 0.4, 1] as const;\nconst stretch = [0.45, 0, 0.55, 1] as const;\nconst pressSpring = { stiffness: 650, damping: 22, mass: 1 };\n\ntype Phase = \"waiting\" | \"clearing\" | \"pouring\" | \"settled\";\ntype WordState = \"wet\" | \"set\";\n\ninterface Box {\n  x: number;\n  y: number;\n  width: number;\n  height: number;\n}\n\ninterface Action {\n  label: string;\n  href: string;\n}\n\nfunction useSafeReducedMotion() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && !!prefers;\n}\n\nfunction offsetWithin(element: HTMLElement, root: HTMLElement): Box {\n  let x = 0;\n  let y = 0;\n  let node: HTMLElement | null = element;\n  while (node && node !== root) {\n    x += node.offsetLeft;\n    y += node.offsetTop;\n    node = node.offsetParent as HTMLElement | null;\n  }\n  return { x, y, width: element.offsetWidth, height: element.offsetHeight };\n}\n\nfunction gooMatrix(slope: number, offset: number) {\n  return `1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 ${slope} ${offset}`;\n}\n\nfunction at(start: number, total: number, time: number) {\n  return Math.min(Math.max((time - start) / total, 0), 1);\n}\n\nfunction Drip({\n  x,\n  start,\n  land,\n  landY,\n  radius,\n  bead,\n}: {\n  x: number;\n  start: number;\n  land: number;\n  landY: number;\n  radius: number;\n  bead: number;\n}) {\n  const hang = bead * 0.15;\n  const neckY = hang + bead + radius * 1.4;\n  const total = land + 0.24 - start;\n  const times = [0, at(start, total, start + swell), at(start, total, start + neck), at(start, total, land), at(start, total, land + 0.08), 1];\n  const tailTotal = land + 0.14 - start;\n  const tailTimes = [0, at(start, tailTotal, start + swell), at(start, tailTotal, start + neck + 0.02), at(start, tailTotal, land + 0.05), 1];\n  const tail = radius * 0.5;\n  return (\n    <>\n      <motion.span\n        animate={{ y: [-bead * 1.05, hang, hang, hang + bead * 0.12, -bead * 1.1], scaleY: [1, 1, 1.14, 0.84, 1] }}\n        className=\"absolute rounded-full bg-(--liquid)\"\n        initial={{ y: -bead * 1.05, scaleY: 1 }}\n        style={{ left: x - bead, top: -bead, width: bead * 2, height: bead * 2, originY: 0 }}\n        transition={{ delay: start, duration: 0.8, times: [0, 0.2, 0.48, 0.56, 1], ease: [\"easeOut\", stretch, \"easeIn\", settle] }}\n      />\n      <motion.span\n        animate={{\n          y: [hang, hang, neckY, landY, landY + radius * 0.4, landY + radius * 0.4],\n          scaleX: [0.9, 0.9, 0.86, 0.84, 1.6, 0.4],\n          scaleY: [1, 1, 1.28, 1.3, 0.5, 0.3],\n          opacity: [0, 1, 1, 1, 1, 0],\n        }}\n        className=\"absolute rounded-full bg-(--liquid)\"\n        initial={{ y: hang, scaleX: 0.9, scaleY: 1, opacity: 0 }}\n        style={{ left: x - radius, top: -radius, width: radius * 2, height: radius * 2 }}\n        transition={{ delay: start, duration: total, times, ease: [\"linear\", stretch, fall, settle, \"easeIn\"] }}\n      />\n      <motion.span\n        animate={{ y: [hang, hang, neckY - radius * 1.25, landY, landY], scale: [1, 1, 1, 1, 0.3], opacity: [0, 1, 1, 1, 0] }}\n        className=\"absolute rounded-full bg-(--liquid)\"\n        initial={{ y: hang, scale: 1, opacity: 0 }}\n        style={{ left: x - tail, top: -tail, width: tail * 2, height: tail * 2 }}\n        transition={{ delay: start, duration: tailTotal, times: tailTimes, ease: [\"linear\", stretch, fall, \"easeIn\"] }}\n      />\n    </>\n  );\n}\n\nfunction Splash({\n  x,\n  y,\n  land,\n  radius,\n  reach,\n  rise,\n  floor,\n}: {\n  x: number;\n  y: number;\n  land: number;\n  radius: number;\n  reach: number[];\n  rise: number;\n  floor: number;\n}) {\n  const puddle = { width: radius * 3.4, height: radius * 1.5 };\n  return (\n    <>\n      <motion.span\n        animate={{ scaleX: [0.4, 0.45, 1.3, 1.6], scaleY: [1, 1, 0.7, 0.2], opacity: [0, 1, 1, 0] }}\n        className=\"absolute rounded-full bg-(--liquid)\"\n        initial={{ scaleX: 0.4, scaleY: 1, opacity: 0 }}\n        style={{ left: x - puddle.width / 2, top: y + radius * 0.4 - puddle.height / 2, ...puddle }}\n        transition={{ delay: land - 0.01, duration: 0.42, times: [0, 0.03, 0.4, 1], ease: [\"linear\", \"easeOut\", \"easeIn\"] }}\n      />\n      {reach.map((to) => {\n        const size = radius * 0.55;\n        return (\n          <motion.span\n            animate={{\n              x: [0, (to - x) * 0.55, to - x],\n              y: [0, -rise, floor - y],\n              scale: [0.6, 1, 0.35],\n              opacity: [0, 1, 1, 0],\n            }}\n            className=\"absolute rounded-full bg-(--liquid)\"\n            initial={{ x: 0, y: 0, scale: 0.6, opacity: 0 }}\n            key={to}\n            style={{ left: x - size, top: y - size, width: size * 2, height: size * 2 }}\n            transition={{\n              delay: land + 0.01,\n              duration: 0.46,\n              times: [0, 0.42, 1],\n              ease: [settle, fall],\n              x: { delay: land + 0.01, duration: 0.46, ease: \"linear\" },\n              opacity: { delay: land + 0.01, duration: 0.46, times: [0, 0.04, 0.8, 1], ease: \"linear\" },\n            }}\n          />\n        );\n      })}\n    </>\n  );\n}\n\nfunction PouringWord({\n  word,\n  box,\n  em,\n  delay,\n  onFormed,\n  typeClass,\n}: {\n  word: string;\n  box: Box;\n  em: number;\n  delay: number;\n  onFormed: () => void;\n  typeClass: string;\n}) {\n  const filterId = `pour-word-${useId().replace(/[^a-zA-Z0-9-]/g, \"\")}`;\n  const blurRef = useRef<SVGFEGaussianBlurElement>(null);\n  const matrixRef = useRef<SVGFEColorMatrixElement>(null);\n  const formed = useRef(onFormed);\n  formed.current = onFormed;\n\n  const radius = Math.max(em * 0.1, 4.5);\n  const bead = radius * 1.35;\n  const goo = radius * 0.6;\n  const padX = Math.max(em * 0.6, radius * 6);\n  const { x, y, width, height } = box;\n  const landY = y + height * 0.58;\n  const floor = y + height * 0.5;\n  const spots = word.length > 5 ? [0.3, 0.72] : [0.5];\n  const drops = spots.map((spot, index) => {\n    const start = delay + index * 0.07;\n    const from = bead * 1.15 + radius * 1.4;\n    return {\n      x: padX + width * spot,\n      start,\n      land: start + neck + Math.sqrt((2 * Math.max(landY - from, 1)) / gravity),\n    };\n  });\n  const landed = drops[0].land;\n  const clampX = (value: number) => Math.min(Math.max(value, padX + radius), padX + width - radius);\n\n  useEffect(() => {\n    const controls = animate(0, 1, {\n      delay: landed + 0.12,\n      duration: 0.7,\n      ease: [0.5, 0, 0.2, 1],\n      onUpdate: (progress) => {\n        const fade = Math.max(0, (progress - 0.6) / 0.4);\n        blurRef.current?.setAttribute(\"stdDeviation\", String(goo * (1 - progress)));\n        matrixRef.current?.setAttribute(\"values\", gooMatrix(20 - 19 * fade, -9 * (1 - fade)));\n      },\n    });\n    const timer = setTimeout(() => formed.current(), (landed + formFor) * 1000);\n    return () => {\n      controls.stop();\n      clearTimeout(timer);\n    };\n  }, [goo, landed]);\n\n  return (\n    <span\n      className=\"absolute block\"\n      style={{ left: x - padX, top: 0, width: width + padX * 2, height: y + height + em * 0.3, filter: `url(#${filterId})` }}\n    >\n      <svg className=\"absolute size-0\">\n        <filter colorInterpolationFilters=\"sRGB\" height=\"100%\" id={filterId} width=\"100%\" x=\"0\" y=\"0\">\n          <feGaussianBlur in=\"SourceGraphic\" ref={blurRef} stdDeviation={goo} />\n          <feColorMatrix ref={matrixRef} type=\"matrix\" values={gooMatrix(20, -9)} />\n        </filter>\n      </svg>\n      {drops.map((drop) => (\n        <Drip bead={bead} key={drop.x} land={drop.land} landY={landY} radius={radius} start={drop.start} x={drop.x} />\n      ))}\n      <motion.span\n        animate={{ opacity: 1, scaleX: 1, scaleY: 1 }}\n        className={cn(typeClass, \"absolute block whitespace-nowrap text-(--liquid)\")}\n        initial={{ opacity: 0, scaleX: 0.16, scaleY: 0.1 }}\n        style={{ left: padX, top: y, originX: spots[0], originY: 0.78 }}\n        transition={{\n          opacity: { delay: landed - 0.02, duration: 0.12 },\n          scaleX: { delay: landed, type: \"spring\", stiffness: 170, damping: 19 },\n          scaleY: { delay: landed + 0.05, type: \"spring\", stiffness: 240, damping: 13 },\n        }}\n      >\n        {word}\n      </motion.span>\n      {drops.map((drop) => (\n        <Splash\n          floor={floor}\n          key={drop.x}\n          land={drop.land}\n          radius={radius}\n          reach={[clampX(drop.x - em * 0.34), clampX(drop.x + em * 0.3)]}\n          rise={em * 0.3}\n          x={drop.x}\n          y={landY}\n        />\n      ))}\n    </span>\n  );\n}\n\ninterface Droplet {\n  id: number;\n  x: number;\n}\n\nfunction SplashDrop({\n  from,\n  to,\n  rise,\n  radius,\n  duration,\n  onLand,\n}: {\n  from: number;\n  to: number;\n  rise: number;\n  radius: number;\n  duration: number;\n  onLand?: () => void;\n}) {\n  const sunk = radius + 2;\n  return (\n    <motion.span\n      animate={{ x: [from, (from + to) / 2, to], y: [sunk, -rise, sunk], scaleY: [1.25, 1, 1.2] }}\n      className=\"absolute top-0 left-0 rounded-full bg-(--liquid) transition-colors duration-150\"\n      initial={{ x: from, y: sunk, scaleY: 1.25 }}\n      onAnimationComplete={onLand}\n      style={{ width: radius * 2, height: radius * 2, marginLeft: -radius, marginTop: -radius }}\n      transition={{\n        duration,\n        times: [0, 0.46, 1],\n        ease: [settle, fall],\n        x: { duration, ease: \"linear\" },\n      }}\n    />\n  );\n}\n\nfunction PourButton({ href, children, reduce }: { href: string; children: ReactNode; reduce: boolean }) {\n  const filterId = `pour-button-${useId().replace(/[^a-zA-Z0-9-]/g, \"\")}`;\n  const bodyRef = useRef<HTMLSpanElement>(null);\n  const [pressed, setPressed] = useState(false);\n  const [droplets, setDroplets] = useState<Droplet[]>([]);\n  const nextId = useRef(0);\n  const holding = useRef(false);\n  const where = useRef(0.5);\n  const tapTimer = useRef<ReturnType<typeof setTimeout>>(undefined);\n  const scaleX = useSpring(1, pressSpring);\n  const squash = useSpring(1, pressSpring);\n  const ripple = useMotionValue(1);\n  const scaleY = useTransform(() => squash.get() * ripple.get());\n  const originX = useMotionValue(0.5);\n\n  useEffect(() => () => clearTimeout(tapTimer.current), []);\n\n  const squeeze = (fraction: number) => {\n    setPressed(true);\n    where.current = Math.min(Math.max(fraction, 0.22), 0.78);\n    originX.set(where.current);\n    if (reduce) return;\n    scaleX.set(1.045);\n    squash.set(0.84);\n  };\n\n  const letGo = (splash: boolean) => {\n    setPressed(false);\n    scaleX.set(1);\n    squash.set(1);\n    if (reduce || !splash) return;\n    const width = bodyRef.current?.offsetWidth ?? 0;\n    const id = nextId.current++;\n    setDroplets((current) => [...current.slice(-2), { id, x: where.current * width }]);\n  };\n\n  const land = (id: number) => {\n    setDroplets((current) => current.filter((droplet) => droplet.id !== id));\n    animate(ripple, [1, 0.95, 1.015, 1], { duration: 0.32, ease: \"easeOut\" });\n  };\n\n  const fractionOf = (event: PointerEvent<HTMLAnchorElement>) => {\n    const rect = event.currentTarget.getBoundingClientRect();\n    return rect.width ? (event.clientX - rect.left) / rect.width : 0.5;\n  };\n\n  const room = { x: 30, top: 44, bottom: 10 };\n  const width = bodyRef.current?.offsetWidth ?? 0;\n  const edge = 22;\n  const clamp = (value: number) => (width ? Math.min(Math.max(value, edge), width - edge) : value);\n\n  return (\n    <a\n      className=\"group/pour relative isolate inline-flex h-12 shrink-0 cursor-pointer touch-manipulation select-none items-center justify-center rounded-full px-6 font-medium text-lime-950 text-sm outline-none [-webkit-tap-highlight-color:transparent] hover:[--liquid:var(--color-lime-400)] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background dark:hover:[--liquid:var(--color-lime-300)]\"\n      data-pressed={pressed ? \"\" : undefined}\n      href={href}\n      onBlur={() => {\n        if (holding.current) {\n          holding.current = false;\n          letGo(false);\n        }\n      }}\n      onKeyDown={(event: KeyboardEvent<HTMLAnchorElement>) => {\n        if (event.key !== \"Enter\" || event.repeat) return;\n        clearTimeout(tapTimer.current);\n        squeeze(0.5);\n        tapTimer.current = setTimeout(() => letGo(true), 80);\n      }}\n      onPointerCancel={() => {\n        holding.current = false;\n        letGo(false);\n      }}\n      onPointerDown={(event) => {\n        if (event.button !== 0) return;\n        holding.current = true;\n        squeeze(fractionOf(event));\n      }}\n      onPointerLeave={() => {\n        if (!holding.current) return;\n        holding.current = false;\n        letGo(false);\n      }}\n      onPointerUp={() => {\n        if (!holding.current) return;\n        holding.current = false;\n        letGo(true);\n      }}\n    >\n      <svg aria-hidden className=\"absolute size-0\">\n        <filter colorInterpolationFilters=\"sRGB\" height=\"100%\" id={filterId} width=\"100%\" x=\"0\" y=\"0\">\n          <feGaussianBlur in=\"SourceGraphic\" stdDeviation={4} />\n          <feColorMatrix type=\"matrix\" values={gooMatrix(22, -10)} />\n        </filter>\n      </svg>\n      <span\n        aria-hidden\n        className=\"pointer-events-none absolute\"\n        style={{\n          inset: `-${room.top}px -${room.x}px -${room.bottom}px`,\n          filter: `${reduce ? \"\" : `url(#${filterId}) `}drop-shadow(0 1px 1px color-mix(in srgb, var(--color-black) 12%, transparent))`,\n        }}\n      >\n        <span className=\"absolute\" ref={bodyRef} style={{ inset: `${room.top}px ${room.x}px ${room.bottom}px` }}>\n          <motion.span\n            className=\"absolute inset-0 rounded-full bg-(--liquid) transition-colors duration-150\"\n            style={{ scaleX, scaleY, originX, originY: 1 }}\n          />\n          {droplets.map((droplet) => (\n            <Fragment key={droplet.id}>\n              <SplashDrop duration={0.3} from={droplet.x - 7} radius={4} rise={10} to={clamp(droplet.x - 24)} />\n              <SplashDrop duration={0.3} from={droplet.x + 7} radius={4} rise={10} to={clamp(droplet.x + 24)} />\n              <SplashDrop\n                duration={0.4}\n                from={droplet.x}\n                onLand={() => land(droplet.id)}\n                radius={6}\n                rise={20}\n                to={droplet.x + (width / 2 - droplet.x) * 0.06}\n              />\n            </Fragment>\n          ))}\n        </span>\n      </span>\n      <motion.span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-full shadow-[inset_0_1px_0_color-mix(in_srgb,var(--color-white)_40%,transparent)]\"\n        style={{ scaleX, scaleY, originX, originY: 1 }}\n      />\n      <span\n        className={cn(\n          \"relative inline-flex items-center gap-2 transition-transform duration-100 ease-out\",\n          !reduce && \"group-data-pressed/pour:scale-[0.97]\",\n        )}\n      >\n        {children}\n        <ArrowRight className=\"size-4 transition-transform duration-200 ease-out group-hover/pour:translate-x-0.5\" />\n      </span>\n    </a>\n  );\n}\n\nconst headroom = 128;\n\nfunction GooCursor({ lines, typeClass, x, y, active }: { lines: string[][]; typeClass: string; x: ReturnType<typeof useMotionValue<number>>; y: ReturnType<typeof useMotionValue<number>>; active: boolean }) {\n  const filterId = `pour-cursor-${useId().replace(/[^a-zA-Z0-9-]/g, \"\")}`;\n  const blobX = useSpring(x, { stiffness: 380, damping: 28 });\n  const blobY = useSpring(y, { stiffness: 380, damping: 28 });\n  const tailX = useSpring(x, { stiffness: 120, damping: 18 });\n  const tailY = useSpring(y, { stiffness: 120, damping: 18 });\n  const lagX = useSpring(x, { stiffness: 60, damping: 14 });\n  const lagY = useSpring(y, { stiffness: 60, damping: 14 });\n  const mask = useMotionTemplate`radial-gradient(circle 8rem at ${blobX}px ${blobY}px, #000 58%, transparent 74%)`;\n\n  return (\n    <motion.div\n      aria-hidden\n      className=\"pointer-events-none absolute inset-0 transition-opacity duration-300\"\n      style={{ opacity: active ? 1 : 0, maskImage: mask, WebkitMaskImage: mask }}\n    >\n      <svg className=\"absolute size-0\">\n        <filter colorInterpolationFilters=\"sRGB\" height=\"140%\" id={filterId} width=\"140%\" x=\"-20%\" y=\"-20%\">\n          <feGaussianBlur stdDeviation=\"4.5\" />\n          <feColorMatrix type=\"matrix\" values={gooMatrix(20, -9)} />\n        </filter>\n      </svg>\n      <div className=\"absolute inset-0\" style={{ filter: `url(#${filterId})` }}>\n        <div className={cn(typeClass, \"text-(--liquid)\")}>\n          {lines.map((line, index) => (\n            <span className=\"block\" key={`${index}-${line.join(\" \")}`}>\n              {line.join(\" \")}\n            </span>\n          ))}\n        </div>\n        <motion.span className=\"absolute top-0 left-0 size-14 rounded-full bg-(--liquid)\" style={{ x: blobX, y: blobY, translateX: \"-50%\", translateY: \"-50%\" }} />\n        <motion.span className=\"absolute top-0 left-0 size-7 rounded-full bg-(--liquid)\" style={{ x: tailX, y: tailY, translateX: \"-50%\", translateY: \"-50%\" }} />\n        <motion.span className=\"absolute top-0 left-0 size-4 rounded-full bg-(--liquid)\" style={{ x: lagX, y: lagY, translateX: \"-50%\", translateY: \"-50%\" }} />\n      </div>\n    </motion.div>\n  );\n}\n\nexport interface PourHeadlineProps {\n  lines: string[];\n  className?: string;\n  replay?: number;\n  playful?: boolean;\n}\n\nexport function PourHeadline({ lines: headline, className, replay = 0, playful = false }: PourHeadlineProps) {\n  const reduce = useSafeReducedMotion();\n  const rootRef = useRef<HTMLDivElement>(null);\n  const wordRefs = useRef<(HTMLSpanElement | null)[]>([]);\n  const inView = useInView(rootRef, { once: true, amount: 0.3 });\n  const [phase, setPhase] = useState<Phase>(\"waiting\");\n  const [run, setRun] = useState(0);\n  const [boxes, setBoxes] = useState<Box[]>([]);\n  const [em, setEm] = useState(0);\n  const [states, setStates] = useState<WordState[]>([]);\n  const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n  const typeClass = cn(headlineType, className);\n  const pointerX = useMotionValue(0);\n  const pointerY = useMotionValue(0);\n  const [hovering, setHovering] = useState(false);\n  const [finePointer, setFinePointer] = useState(false);\n  useEffect(() => setFinePointer(window.matchMedia(\"(hover: hover) and (pointer: fine)\").matches), []);\n  const toy = playful && finePointer && !reduce;\n\n  const lines = headline.map((line) => line.split(/\\s+/).filter(Boolean));\n  const words = lines.flat();\n  const settledCount = states.filter((state) => state === \"set\").length;\n\n  const clearTimers = useCallback(() => {\n    for (const timer of timers.current) clearTimeout(timer);\n    timers.current = [];\n  }, []);\n\n  const later = useCallback((callback: () => void, ms: number) => {\n    timers.current.push(setTimeout(callback, ms));\n  }, []);\n\n  const pour = useCallback(() => {\n    clearTimers();\n    setStates([]);\n    setBoxes([]);\n    setRun((current) => current + 1);\n    setPhase(\"pouring\");\n  }, [clearTimers]);\n\n  const again = useRef(() => {});\n  again.current = () => {\n    clearTimers();\n    if (phase === \"settled\") {\n      setPhase(\"clearing\");\n      later(pour, 180);\n    } else {\n      pour();\n    }\n  };\n\n  useEffect(() => clearTimers, [clearTimers]);\n\n  useEffect(() => {\n    if (replay > 0) again.current();\n  }, [replay]);\n\n  useEffect(() => {\n    if (!reduce) return;\n    clearTimers();\n    setPhase(\"settled\");\n  }, [reduce, clearTimers]);\n\n  useEffect(() => {\n    if (inView && !reduce && phase === \"waiting\") pour();\n  }, [inView, reduce, phase, pour]);\n\n  useLayoutEffect(() => {\n    if (phase !== \"pouring\" || run === 0) return;\n    const root = rootRef.current;\n    const first = wordRefs.current[0];\n    if (!root || !first) return;\n    setEm(Number.parseFloat(getComputedStyle(first).fontSize) || 64);\n    setBoxes(\n      wordRefs.current.slice(0, words.length).map((element) => {\n        const box = element ? offsetWithin(element, root) : { x: 0, y: 0, width: 0, height: 0 };\n        return { ...box, y: box.y + headroom };\n      }),\n    );\n  }, [phase, run, words.length]);\n\n  useEffect(() => {\n    if (phase !== \"pouring\" || words.length === 0 || settledCount < words.length) return;\n    const timer = setTimeout(() => setPhase(\"settled\"), 650);\n    return () => clearTimeout(timer);\n  }, [phase, settledCount, words.length]);\n\n  const mark = (index: number, state: WordState) =>\n    setStates((current) => {\n      const next = [...current];\n      next[index] = state;\n      return next;\n    });\n\n  const formWord = (index: number) => {\n    mark(index, \"wet\");\n    later(() => mark(index, \"set\"), 160);\n  };\n\n  const wordTone = (index: number) => {\n    if (phase === \"waiting\") return \"motion-safe:text-transparent\";\n    if (phase === \"clearing\") return undefined;\n    const state = states[index];\n    if (state === \"set\") return \"text-foreground transition-colors duration-500 ease-out\";\n    if (state === \"wet\") return \"text-(--liquid)\";\n    return \"text-transparent\";\n  };\n\n  let wordIndex = 0;\n\n  return (\n    <div\n      className={cn(\"relative [--liquid:var(--color-lime-500)] dark:[--liquid:var(--color-lime-400)]\", toy && phase === \"settled\" && \"cursor-pointer\")}\n      onClick={toy && phase === \"settled\" ? () => again.current() : undefined}\n      onPointerLeave={toy ? () => setHovering(false) : undefined}\n      onPointerMove={\n        toy\n          ? (event: PointerEvent<HTMLDivElement>) => {\n              const box = event.currentTarget.getBoundingClientRect();\n              if (!hovering) {\n                pointerX.jump(event.clientX - box.left);\n                pointerY.jump(event.clientY - box.top);\n              }\n              pointerX.set(event.clientX - box.left);\n              pointerY.set(event.clientY - box.top);\n              setHovering(true);\n            }\n          : undefined\n      }\n      ref={rootRef}\n    >\n      <h1 className={cn(typeClass, \"relative transition-opacity duration-150 ease-out\", phase === \"clearing\" && \"opacity-0\")}>\n        {lines.map((line, lineIndex) => (\n          <span className=\"block\" key={`${lineIndex}-${line.join(\" \")}`}>\n            {phase === \"settled\"\n              ? line.join(\" \")\n              : line.map((word, position) => {\n                  const index = wordIndex++;\n                  return (\n                    <Fragment key={`${index}-${word}`}>\n                      {position > 0 && \" \"}\n                      <span\n                        className={cn(\"inline-block\", wordTone(index))}\n                        ref={(element) => {\n                          wordRefs.current[index] = element;\n                        }}\n                      >\n                        {word}\n                      </span>\n                    </Fragment>\n                  );\n                })}\n          </span>\n        ))}\n      </h1>\n      {toy && phase === \"settled\" && <GooCursor active={hovering} lines={lines} typeClass={typeClass} x={pointerX} y={pointerY} />}\n      {phase === \"pouring\" && em > 0 && boxes.length === words.length && (\n        <div aria-hidden className=\"pointer-events-none absolute inset-x-0 bottom-0\" key={run} style={{ top: -headroom }}>\n          {boxes.map((box, index) =>\n            states[index] ? null : (\n              <PouringWord\n                box={box}\n                delay={index * wordGap + (((index * 37) % 7) - 3) * 0.008 + 0.03}\n                em={em}\n                key={`${index}-${words[index]}`}\n                onFormed={() => formWord(index)}\n                typeClass={typeClass}\n                word={words[index]}\n              />\n            ),\n          )}\n        </div>\n      )}\n    </div>\n  );\n}\n\nexport interface PourHeroProps {\n  headline: string[];\n  description: string;\n  primaryAction: Action;\n  secondaryAction?: Action;\n  className?: string;\n}\n\nexport function PourHero({ headline, description, primaryAction, secondaryAction, className }: PourHeroProps) {\n  const reduce = useSafeReducedMotion();\n  const [replays, setReplays] = useState(0);\n\n  return (\n    <section\n      className={cn(\n        \"relative isolate w-full overflow-hidden bg-background text-foreground [--liquid:var(--color-lime-500)] dark:[--liquid:var(--color-lime-400)]\",\n        className,\n      )}\n    >\n      <div className=\"mx-auto flex min-h-[600px] w-full max-w-[1100px] flex-col justify-center px-6 pt-32 pb-16 sm:min-h-[704px] sm:px-12 sm:pt-36 sm:pb-20\">\n        <PourHeadline className=\"max-w-[15ch] text-balance sm:max-w-none\" lines={headline} replay={replays} />\n        <p className=\"mt-6 max-w-[36rem] text-pretty text-base text-muted-foreground sm:mt-8 sm:text-lg\">{description}</p>\n        <div className=\"mt-9 flex flex-wrap items-center gap-x-6 gap-y-3 sm:mt-10\">\n          <PourButton href={primaryAction.href} reduce={reduce}>\n            {primaryAction.label}\n          </PourButton>\n          {secondaryAction && (\n            <a\n              className=\"-mx-2 inline-flex h-10 items-center gap-2 rounded-md px-2 font-medium text-muted-foreground text-sm outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n              href={secondaryAction.href}\n            >\n              <CirclePlay className=\"size-4\" />\n              {secondaryAction.label}\n            </a>\n          )}\n        </div>\n      </div>\n      {!reduce && (\n        <button\n          aria-label=\"Pour the headline again\"\n          className=\"absolute right-4 bottom-4 inline-flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:after:absolute pointer-coarse:after:-inset-1 sm:right-6 sm:bottom-6\"\n          onClick={() => setReplays((count) => count + 1)}\n          type=\"button\"\n        >\n          <RotateCcw className=\"size-3.5\" />\n          <span className=\"hidden sm:inline\">Replay</span>\n        </button>\n      )}\n    </section>\n  );\n}\n"
    }
  ]
}