{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "falling-tags",
  "title": "Falling Tags",
  "author": "AlgorizeTech",
  "description": "A physics-based interactive tags playground where badges float, fall under gravity, collide realistically, and can be dragged and thrown.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/FallingTagsBlock.tsx",
      "content": "\"use client\";\n\nimport React, {\n  useCallback,\n  useEffect,\n  useRef,\n  useState,\n  useSyncExternalStore,\n} from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport {\n  RotateCcw,\n  Sparkles,\n  Flame,\n  MousePointer2,\n} from \"lucide-react\";\n\nconst subscribeToNothing = () => () => {};\nconst useIsMounted = () =>\n  useSyncExternalStore(\n    subscribeToNothing,\n    () => true,\n    () => false,\n  );\n\nexport type FallingTagPalette =\n  | \"default\"\n  | \"colorful\"\n  | \"glass\"\n  | \"pastel\"\n  | \"monochrome\"\n  | \"neon\"\n  | \"black-and-white\"\n  | \"black-white\";\n\nexport interface FallingTagItem {\n  id: string;\n  label: string;\n  icon?: React.ReactNode;\n  color?: string;\n  bg?: string;\n  border?: string;\n  text?: string;\n  className?: string;\n}\n\nexport interface FallingTagsProps extends React.HTMLAttributes<HTMLDivElement> {\n  /** Array of tag labels or tag objects */\n  tags?: (string | FallingTagItem)[];\n  /** Color palette preset */\n  palette?: FallingTagPalette;\n  /** Gravity strength (default: 0.55) */\n  gravity?: number;\n  /** Bounce / restitution between 0 and 1 (default: 0.48) */\n  bounce?: number;\n  /** Air and wall friction (default: 0.985) */\n  friction?: number;\n  /** Hover time in seconds before tags begin to fall (default: 1.4) */\n  hoverDuration?: number;\n  /** Height of the physics arena (default: 520) */\n  height?: number | string;\n  /** Show top control bar with Drop Again / Scatter / Zero-G buttons (default: false) */\n  showControls?: boolean;\n  /** Auto trigger falling when scrolled into view (default: true) */\n  autoStartOnView?: boolean;\n  /** Allow mouse/touch drag and throwing (default: true) */\n  interactive?: boolean;\n  /** Header title above the falling arena */\n  title?: string;\n  /** Header description */\n  description?: string;\n}\n\nconst DEFAULT_TAG_LABELS = [\n  \"React\",\n  \"Next.js\",\n  \"TypeScript\",\n  \"Tailwind CSS\",\n  \"Framer\",\n  \"Motion\",\n  \"Figma\",\n  \"UI/UX\",\n  \"JavaScript\",\n  \"Design Systems\",\n  \"Three.js\",\n  \"Node.js\",\n  \"PostgreSQL\",\n  \"GraphQL\",\n  \"Animation\",\n  \"Web Development\",\n  \"Accessibility\",\n  \"Frontend\",\n  \"Docker\",\n  \"Performance\",\n  \"Micro-Interactions\",\n  \"Creative Coding\",\n];\n\nconst PALETTES: Record<FallingTagPalette, { bg: string; text: string; border: string }[]> = {\n  default: [\n    { bg: \"bg-zinc-900 dark:bg-white\", text: \"text-white dark:text-zinc-950\", border: \"border-zinc-800 dark:border-zinc-200\" },\n    { bg: \"bg-blue-500\", text: \"text-white\", border: \"border-blue-400\" },\n    { bg: \"bg-emerald-500\", text: \"text-white\", border: \"border-emerald-400\" },\n    { bg: \"bg-amber-400\", text: \"text-zinc-950\", border: \"border-amber-300\" },\n    { bg: \"bg-violet-500\", text: \"text-white\", border: \"border-violet-400\" },\n    { bg: \"bg-rose-500\", text: \"text-white\", border: \"border-rose-400\" },\n    { bg: \"bg-cyan-500\", text: \"text-white\", border: \"border-cyan-400\" },\n    { bg: \"bg-orange-500\", text: \"text-white\", border: \"border-orange-400\" },\n  ],\n  colorful: [\n    { bg: \"bg-indigo-600\", text: \"text-white\", border: \"border-indigo-400/60\" },\n    { bg: \"bg-emerald-500\", text: \"text-white\", border: \"border-emerald-400/60\" },\n    { bg: \"bg-rose-500\", text: \"text-white\", border: \"border-rose-400/60\" },\n    { bg: \"bg-amber-500\", text: \"text-white\", border: \"border-amber-400/60\" },\n    { bg: \"bg-sky-500\", text: \"text-white\", border: \"border-sky-400/60\" },\n    { bg: \"bg-purple-600\", text: \"text-white\", border: \"border-purple-400/60\" },\n    { bg: \"bg-teal-500\", text: \"text-white\", border: \"border-teal-400/60\" },\n    { bg: \"bg-fuchsia-500\", text: \"text-white\", border: \"border-fuchsia-400/60\" },\n  ],\n  glass: [\n    { bg: \"bg-white/40 dark:bg-zinc-900/50 backdrop-blur-md\", text: \"text-zinc-900 dark:text-white\", border: \"border-white/50 dark:border-white/20\" },\n    { bg: \"bg-blue-500/25 dark:bg-blue-500/20 backdrop-blur-md\", text: \"text-blue-900 dark:text-blue-200\", border: \"border-blue-400/40\" },\n    { bg: \"bg-emerald-500/25 dark:bg-emerald-500/20 backdrop-blur-md\", text: \"text-emerald-900 dark:text-emerald-200\", border: \"border-emerald-400/40\" },\n    { bg: \"bg-amber-500/25 dark:bg-amber-500/20 backdrop-blur-md\", text: \"text-amber-900 dark:text-amber-200\", border: \"border-amber-400/40\" },\n    { bg: \"bg-purple-500/25 dark:bg-purple-500/20 backdrop-blur-md\", text: \"text-purple-900 dark:text-purple-200\", border: \"border-purple-400/40\" },\n  ],\n  pastel: [\n    { bg: \"bg-rose-100 dark:bg-rose-950/60\", text: \"text-rose-900 dark:text-rose-200\", border: \"border-rose-200 dark:border-rose-800\" },\n    { bg: \"bg-sky-100 dark:bg-sky-950/60\", text: \"text-sky-900 dark:text-sky-200\", border: \"border-sky-200 dark:border-sky-800\" },\n    { bg: \"bg-emerald-100 dark:bg-emerald-950/60\", text: \"text-emerald-900 dark:text-emerald-200\", border: \"border-emerald-200 dark:border-emerald-800\" },\n    { bg: \"bg-amber-100 dark:bg-amber-950/60\", text: \"text-amber-900 dark:text-amber-200\", border: \"border-amber-200 dark:border-amber-800\" },\n    { bg: \"bg-violet-100 dark:bg-violet-950/60\", text: \"text-violet-900 dark:text-violet-200\", border: \"border-violet-200 dark:border-violet-800\" },\n    { bg: \"bg-teal-100 dark:bg-teal-950/60\", text: \"text-teal-900 dark:text-teal-200\", border: \"border-teal-200 dark:border-teal-800\" },\n  ],\n  monochrome: [\n    { bg: \"bg-zinc-950 dark:bg-white\", text: \"text-white dark:text-zinc-950\", border: \"border-zinc-800 dark:border-zinc-200\" },\n    { bg: \"bg-zinc-800 dark:bg-zinc-100\", text: \"text-zinc-100 dark:text-zinc-900\", border: \"border-zinc-700 dark:border-zinc-300\" },\n    { bg: \"bg-zinc-700 dark:bg-zinc-200\", text: \"text-zinc-100 dark:text-zinc-800\", border: \"border-zinc-600 dark:border-zinc-400\" },\n    { bg: \"bg-zinc-900 dark:bg-zinc-50\", text: \"text-zinc-200 dark:text-zinc-900\", border: \"border-zinc-800 dark:border-zinc-200\" },\n  ],\n  neon: [\n    { bg: \"bg-emerald-500\", text: \"text-zinc-950 font-bold\", border: \"border-emerald-300 shadow-[0_0_15px_rgba(16,185,129,0.5)]\" },\n    { bg: \"bg-cyan-400\", text: \"text-zinc-950 font-bold\", border: \"border-cyan-200 shadow-[0_0_15px_rgba(34,211,238,0.5)]\" },\n    { bg: \"bg-fuchsia-500\", text: \"text-white font-bold\", border: \"border-fuchsia-300 shadow-[0_0_15px_rgba(217,70,239,0.5)]\" },\n    { bg: \"bg-yellow-400\", text: \"text-zinc-950 font-bold\", border: \"border-yellow-200 shadow-[0_0_15px_rgba(250,204,21,0.5)]\" },\n    { bg: \"bg-violet-500\", text: \"text-white font-bold\", border: \"border-violet-300 shadow-[0_0_15px_rgba(139,92,246,0.5)]\" },\n  ],\n  \"black-and-white\": [\n    {\n      bg: \"bg-black dark:bg-black\",\n      text: \"text-white dark:text-white font-medium\",\n      border: \"border-white dark:border-white shadow-xs\",\n    },\n    {\n      bg: \"bg-white dark:bg-white\",\n      text: \"text-black dark:text-black font-medium\",\n      border: \"border-black dark:border-black shadow-xs\",\n    },\n  ],\n  \"black-white\": [\n    {\n      bg: \"bg-black dark:bg-black\",\n      text: \"text-white dark:text-white font-medium\",\n      border: \"border-white dark:border-white shadow-xs\",\n    },\n    {\n      bg: \"bg-white dark:bg-white\",\n      text: \"text-black dark:text-black font-medium\",\n      border: \"border-black dark:border-black shadow-xs\",\n    },\n  ],\n};\n\n// Physics Rigid-Body Tag\ninterface PhysicsTag {\n  id: string;\n  item: FallingTagItem;\n  x: number;\n  y: number;\n  prevX: number;\n  prevY: number;\n  prevAngle: number;\n  vx: number;\n  vy: number;\n  angle: number;\n  baseAngle: number;\n  angularVelocity: number;\n  width: number;\n  height: number;\n  radius: number;\n  mass: number;\n  invMass: number;\n  inertia: number;\n  invInertia: number;\n  floatPhase: number;\n  floatSpeed: number;\n  styleClass: { bg: string; text: string; border: string };\n  initialTargetY: number;\n  isSleeping: boolean;\n  sleepFrames: number;\n  isSupported: boolean;\n  supportLeft: boolean;\n  supportRight: boolean;\n}\n\nfunction clamp(v: number, min: number, max: number): number {\n  return Math.max(min, Math.min(max, v));\n}\n\nfunction getOBBVertices(\n  t: { x: number; y: number; width: number; height: number; angle: number },\n  extraGap = 0,\n): { x: number; y: number }[] {\n  const hw = t.width * 0.5 + extraGap * 0.5;\n  const hh = t.height * 0.5 + extraGap * 0.5;\n  const c = Math.cos(t.angle);\n  const s = Math.sin(t.angle);\n  const ux = hw * c;\n  const uy = hw * s;\n  const vx = -hh * s;\n  const vy = hh * c;\n  return [\n    { x: t.x - ux - vx, y: t.y - uy - vy },\n    { x: t.x + ux - vx, y: t.y + uy - vy },\n    { x: t.x + ux + vx, y: t.y + uy + vy },\n    { x: t.x - ux + vx, y: t.y - uy + vy },\n  ];\n}\n\nfunction getBoxExtents(t: { x: number; y: number; width: number; height: number; angle: number }) {\n  const hw = t.width * 0.5;\n  const hh = t.height * 0.5;\n  const c = Math.abs(Math.cos(t.angle));\n  const s = Math.abs(Math.sin(t.angle));\n  const ex = hw * c + hh * s;\n  const ey = hw * s + hh * c;\n  return {\n    minX: t.x - ex,\n    maxX: t.x + ex,\n    minY: t.y - ey,\n    maxY: t.y + ey,\n    ex,\n    ey,\n  };\n}\n\n// Exact 2D Oriented Bounding Box (OBB) SAT Collision Detection + Support Contact Point\nfunction checkOBBCollision(\n  a: PhysicsTag,\n  b: PhysicsTag,\n  extraGap = 1.5,\n): { collided: boolean; nx: number; ny: number; pen: number; cx: number; cy: number } {\n  const hwA = a.width * 0.5 + extraGap * 0.5;\n  const hhA = a.height * 0.5 + extraGap * 0.5;\n  const hwB = b.width * 0.5 + extraGap * 0.5;\n  const hhB = b.height * 0.5 + extraGap * 0.5;\n\n  const cosA = Math.cos(a.angle);\n  const sinA = Math.sin(a.angle);\n  const cosB = Math.cos(b.angle);\n  const sinB = Math.sin(b.angle);\n\n  const axes = [\n    { x: cosA, y: sinA },\n    { x: -sinA, y: cosA },\n    { x: cosB, y: sinB },\n    { x: -sinB, y: cosB },\n  ];\n\n  const dx = b.x - a.x;\n  const dy = b.y - a.y;\n\n  let minOverlap = Infinity;\n  let bestAxis = { x: 0, y: -1 };\n  let bestAxisIndex = 0;\n\n  for (let i = 0; i < 4; i++) {\n    const L = axes[i];\n    const rA = hwA * Math.abs(cosA * L.x + sinA * L.y) + hhA * Math.abs(-sinA * L.x + cosA * L.y);\n    const rB = hwB * Math.abs(cosB * L.x + sinB * L.y) + hhB * Math.abs(-sinB * L.x + cosB * L.y);\n    const dist = Math.abs(dx * L.x + dy * L.y);\n    const overlap = rA + rB - dist;\n\n    if (overlap <= 0) {\n      return { collided: false, nx: 0, ny: 0, pen: 0, cx: 0, cy: 0 };\n    }\n\n    if (overlap < minOverlap) {\n      minOverlap = overlap;\n      const sign = dx * L.x + dy * L.y >= 0 ? 1 : -1;\n      bestAxis = { x: L.x * sign, y: L.y * sign };\n      bestAxisIndex = i;\n    }\n  }\n\n  const nx = bestAxis.x;\n  const ny = bestAxis.y;\n  let cx = (a.x + b.x) * 0.5;\n  let cy = (a.y + b.y) * 0.5;\n\n  if (bestAxisIndex < 2) {\n    const vertsB = getOBBVertices(b, 0);\n    let minProj = Infinity;\n    for (let k = 0; k < 4; k++) {\n      const p = vertsB[k].x * nx + vertsB[k].y * ny;\n      if (p < minProj) {\n        minProj = p;\n        cx = vertsB[k].x;\n        cy = vertsB[k].y;\n      }\n    }\n  } else {\n    const vertsA = getOBBVertices(a, 0);\n    let maxProj = -Infinity;\n    for (let k = 0; k < 4; k++) {\n      const p = vertsA[k].x * nx + vertsA[k].y * ny;\n      if (p > maxProj) {\n        maxProj = p;\n        cx = vertsA[k].x;\n        cy = vertsA[k].y;\n      }\n    }\n  }\n\n  return {\n    collided: true,\n    nx,\n    ny,\n    pen: minOverlap,\n    cx,\n    cy,\n  };\n}\n\nexport default function FallingTagsBlock({\n  tags = DEFAULT_TAG_LABELS,\n  palette = \"default\",\n  gravity = 0.55,\n  bounce = 0.48,\n  friction = 0.985,\n  hoverDuration = 1.4,\n  height = 520,\n  showControls = false,\n  autoStartOnView = true,\n  interactive = true,\n  title,\n  description,\n  className,\n  ...props\n}: FallingTagsProps) {\n  const isMounted = useIsMounted();\n  const containerRef = useRef<HTMLDivElement>(null);\n  const tagElementsRef = useRef<Map<string, HTMLDivElement>>(new Map());\n\n  const [, setPhase] = useState<\"floating\" | \"falling\" | \"zeroG\">(\"floating\");\n  const [activeGravity, setActiveGravity] = useState<boolean>(true);\n  const [, setActiveTagsCount] = useState<number>(0);\n  const [, setArenaDimensions] = useState<{ width: number; height: number }>({\n    width: 800,\n    height: 520,\n  });\n\n  // Physics state\n  const physicsTagsRef = useRef<PhysicsTag[]>([]);\n  const stateRef = useRef<{\n    phase: \"floating\" | \"falling\" | \"zeroG\";\n    startTime: number;\n    fallStartTime: number;\n    hoverDuration: number;\n    gravity: number;\n    activeGravity: boolean;\n    bounce: number;\n    friction: number;\n    width: number;\n    height: number;\n    isDragging: boolean;\n    draggedId: string | null;\n    dragOffset: { x: number; y: number };\n    mousePos: { x: number; y: number };\n    mouseHistory: { x: number; y: number; time: number }[];\n    animId: number | null;\n    lastTime: number;\n    isIntersecting: boolean;\n    hasTriggered: boolean;\n  }>({\n    phase: \"floating\",\n    startTime: performance.now(),\n    fallStartTime: performance.now(),\n    hoverDuration,\n    gravity,\n    activeGravity: true,\n    bounce,\n    friction,\n    width: 800,\n    height: 520,\n    isDragging: false,\n    draggedId: null,\n    dragOffset: { x: 0, y: 0 },\n    mousePos: { x: 0, y: 0 },\n    mouseHistory: [],\n    animId: null,\n    lastTime: performance.now(),\n    isIntersecting: true,\n    hasTriggered: false,\n  });\n\n  // Keep stateRef synced with props\n  useEffect(() => {\n    stateRef.current.gravity = gravity;\n    stateRef.current.bounce = bounce;\n    stateRef.current.friction = friction;\n    stateRef.current.hoverDuration = hoverDuration;\n  }, [gravity, bounce, friction, hoverDuration]);\n\n  // Normalized tag list\n  const normalizedTags: FallingTagItem[] = React.useMemo(() => {\n    return tags.map((t, idx) => {\n      if (typeof t === \"string\") {\n        return { id: `tag-${idx}-${t.toLowerCase().replace(/[^a-z0-9]/g, \"-\")}`, label: t };\n      }\n      return { ...t, id: t.id || `tag-${idx}` };\n    });\n  }, [tags]);\n\n  // Measure exact unrotated rendered DOM dimensions\n  const measureTags = useCallback(() => {\n    let measuredAny = false;\n    physicsTagsRef.current.forEach((t) => {\n      const el = tagElementsRef.current.get(t.id);\n      if (el) {\n        const w = el.offsetWidth;\n        const h = el.offsetHeight;\n        if (w > 0 && h > 0) {\n          if (Math.abs(t.width - w) >= 1 || Math.abs(t.height - h) >= 1) {\n            t.width = w;\n            t.height = h;\n            t.radius = h / 2;\n            t.mass = (w * h) / 1000;\n            t.invMass = 1 / t.mass;\n            t.inertia = (t.mass * (w * w + h * h)) / 12;\n            t.invInertia = 1 / t.inertia;\n            t.isSleeping = false;\n            t.sleepFrames = 0;\n            measuredAny = true;\n          }\n        }\n      }\n    });\n\n    if (measuredAny && stateRef.current.phase === \"floating\") {\n      const W = stateRef.current.width;\n      const leftX = 8;\n      const rightX = W - 8;\n      const ceilingY = 8;\n      const list = physicsTagsRef.current;\n      for (let pre = 0; pre < 6; pre++) {\n        for (let i = 0; i < list.length; i++) {\n          for (let j = i + 1; j < list.length; j++) {\n            const col = checkOBBCollision(list[i], list[j], 3);\n            if (col.collided) {\n              list[i].x -= col.nx * col.pen * 0.5;\n              list[i].y -= col.ny * col.pen * 0.5;\n              list[j].x += col.nx * col.pen * 0.5;\n              list[j].y += col.ny * col.pen * 0.5;\n            }\n          }\n          const ext = getBoxExtents(list[i]);\n          if (ext.minX < leftX) list[i].x += leftX - ext.minX;\n          if (ext.maxX > rightX) list[i].x -= ext.maxX - rightX;\n          if (ext.minY < ceilingY) list[i].y += ceilingY - ext.minY;\n          list[i].initialTargetY = list[i].y;\n        }\n      }\n    }\n\n    return measuredAny;\n  }, []);\n\n  // Initialize tags\n  const initTags = useCallback((quickDrop = false) => {\n    if (!containerRef.current) return;\n    const rect = containerRef.current.getBoundingClientRect();\n    const rawW = containerRef.current.clientWidth || rect.width;\n    const rawH = containerRef.current.clientHeight || rect.height;\n    const width = Math.max(rawW, 280);\n    const h = typeof height === \"number\" ? height : (rawH || 520);\n    stateRef.current.width = width;\n    stateRef.current.height = h;\n    setArenaDimensions({ width, height: h });\n\n    const isSmallScreen = width < 520;\n    const paletteList = PALETTES[palette] || PALETTES.default;\n    const padding = isSmallScreen ? 10 : 16;\n    const availableWidth = width - padding * 2;\n\n    const items: PhysicsTag[] = [];\n    const tagsPerRow = isSmallScreen ? 3 : 6;\n\n    normalizedTags.forEach((item, index) => {\n      const rowIndex = Math.floor(index / tagsPerRow);\n      const colIndex = index % tagsPerRow;\n\n      const el = tagElementsRef.current.get(item.id);\n      const scale = isSmallScreen ? 0.88 : 1.0;\n      const tagW =\n        el && el.offsetWidth > 0\n          ? el.offsetWidth\n          : Math.round(Math.max(Math.min((item.label.length * 8.2 + 32) * scale, width * 0.65), 64));\n      const tagH = el && el.offsetHeight > 0 ? el.offsetHeight : isSmallScreen ? 32 : 36;\n      const tagRadius = tagH / 2;\n      const mass = (tagW * tagH) / 1000;\n      const inertia = (mass * (tagW * tagW + tagH * tagH)) / 12;\n\n      const colStep = availableWidth / Math.max(tagsPerRow, 1);\n      const staggerX = (rowIndex % 2 === 1) ? colStep * 0.28 : -colStep * 0.14;\n      const startX = padding + colIndex * colStep + colStep * 0.5 + staggerX + (Math.random() - 0.5) * 14;\n      const startY = 36 + rowIndex * (isSmallScreen ? 36 : 42) + (Math.random() - 0.5) * 8;\n      const baseAngle = (Math.random() - 0.5) * 0.28;\n\n      const styleClass = paletteList[index % paletteList.length];\n      const clampedX = clamp(startX, tagW / 2 + 8, width - tagW / 2 - 8);\n\n      items.push({\n        id: item.id,\n        item,\n        x: clampedX,\n        y: startY,\n        prevX: clampedX,\n        prevY: startY,\n        prevAngle: baseAngle,\n        vx: (Math.random() - 0.5) * 1.2,\n        vy: 0,\n        angle: baseAngle,\n        baseAngle,\n        angularVelocity: (Math.random() - 0.5) * 0.025,\n        width: tagW,\n        height: tagH,\n        radius: tagRadius,\n        mass,\n        invMass: 1 / mass,\n        inertia,\n        invInertia: 1 / inertia,\n        floatPhase: Math.random() * Math.PI * 2,\n        floatSpeed: 1.2 + Math.random() * 1.2,\n        styleClass,\n        initialTargetY: startY,\n        isSleeping: false,\n        sleepFrames: 0,\n        isSupported: false,\n        supportLeft: false,\n        supportRight: false,\n      });\n    });\n\n    // Pre-separate initial floating tags\n    const leftX = 8;\n    const rightX = width - 8;\n    const ceilingY = 8;\n    for (let pre = 0; pre < 8; pre++) {\n      for (let i = 0; i < items.length; i++) {\n        for (let j = i + 1; j < items.length; j++) {\n          const col = checkOBBCollision(items[i], items[j], 3);\n          if (col.collided) {\n            items[i].x -= col.nx * col.pen * 0.5;\n            items[i].y -= col.ny * col.pen * 0.5;\n            items[j].x += col.nx * col.pen * 0.5;\n            items[j].y += col.ny * col.pen * 0.5;\n          }\n        }\n        const ext = getBoxExtents(items[i]);\n        if (ext.minX < leftX) items[i].x += leftX - ext.minX;\n        if (ext.maxX > rightX) items[i].x -= ext.maxX - rightX;\n        if (ext.minY < ceilingY) items[i].y += ceilingY - ext.minY;\n        items[i].initialTargetY = items[i].y;\n      }\n    }\n\n    physicsTagsRef.current = items;\n    setActiveTagsCount(items.length);\n    const now = performance.now();\n    const effectiveHover = quickDrop ? Math.min(0.25, stateRef.current.hoverDuration) : stateRef.current.hoverDuration;\n    stateRef.current.phase = \"floating\";\n    stateRef.current.startTime = now - (stateRef.current.hoverDuration - effectiveHover) * 1000;\n    stateRef.current.fallStartTime = now + effectiveHover * 1000;\n    setPhase(\"floating\");\n\n    requestAnimationFrame(() => {\n      measureTags();\n    });\n  }, [normalizedTags, height, palette, measureTags]);\n\n  // Main Physics Simulation Loop\n  useEffect(() => {\n    if (!isMounted) return;\n\n    let animFrame: number;\n\n    const loop = (currentTime: number) => {\n      const state = stateRef.current;\n      const tags = physicsTagsRef.current;\n      const W = state.width;\n      const H = state.height;\n\n      const elapsed = (currentTime - state.startTime) / 1000;\n\n      // Phase Transition: Floating -> Falling\n      if (state.phase === \"floating\" && elapsed >= state.hoverDuration) {\n        state.phase = \"falling\";\n        state.fallStartTime = currentTime;\n        setPhase(\"falling\");\n        for (let i = 0; i < tags.length; i++) {\n          tags[i].vx = (Math.random() - 0.5) * 1.2;\n          tags[i].angularVelocity = (Math.random() - 0.5) * 0.025;\n        }\n      }\n\n      // Check prefers-reduced-motion\n      const prefersReduced =\n        typeof window !== \"undefined\" &&\n        window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n      // Boundary floor and wall coordinates\n      const floorY = H - 8;\n      const leftX = 8;\n      const rightX = W - 8;\n      const ceilingY = 8;\n      const gap = 1.5; // Tight 1.5px visual separation so boxes take ONLY their exact width & height\n      const elapsedAfterHover = Math.max(0, (currentTime - state.fallStartTime) / 1000);\n      const fallFrame = Math.floor(elapsedAfterHover * 60);\n\n      // Keep DOM dimensions synced to actual rendered offsetWidth & offsetHeight\n      if (elapsed < 2.5 || elapsedAfterHover < 2.5) {\n        measureTags();\n      }\n\n      // 1. UPDATE BODIES (Integration & Floating)\n      for (let i = 0; i < tags.length; i++) {\n        const t = tags[i];\n        t.prevX = t.x;\n        t.prevY = t.y;\n        t.prevAngle = t.angle;\n\n        const isBeingDragged = state.isDragging && state.draggedId === t.id;\n\n        if (isBeingDragged) {\n          t.isSleeping = false;\n          t.sleepFrames = 0;\n          t.isSupported = false;\n          t.supportLeft = false;\n          t.supportRight = false;\n          const targetX = state.mousePos.x - state.dragOffset.x;\n          const targetY = state.mousePos.y - state.dragOffset.y;\n          t.vx = (targetX - t.x) * 0.45;\n          t.vy = (targetY - t.y) * 0.45;\n          t.x = targetX;\n          t.y = targetY;\n          t.angularVelocity *= 0.85;\n          continue;\n        }\n\n        if (prefersReduced) {\n          continue;\n        }\n\n        if (state.phase === \"floating\") {\n          t.isSleeping = false;\n          t.sleepFrames = 0;\n          t.isSupported = false;\n          t.supportLeft = false;\n          t.supportRight = false;\n          const floatOffset = Math.sin(currentTime * 0.002 * t.floatSpeed + t.floatPhase) * 4;\n          t.y = t.initialTargetY + floatOffset;\n          t.angle = t.baseAngle + Math.sin(currentTime * 0.0015 * t.floatSpeed + t.floatPhase) * 0.04;\n          t.vy = 0;\n          continue;\n        }\n\n        // Falling phase: if sleeping peacefully, keep 100% rock-solid still\n        if (t.isSleeping) {\n          t.isSupported = true;\n          continue;\n        }\n\n        if (state.activeGravity) {\n          const dropStagger = Math.max(\n            0,\n            Math.min(1, elapsedAfterHover * 3.2 - (tags.length - 1 - i) * 0.03),\n          );\n          if (dropStagger <= 0) {\n            const floatOffset = Math.sin(currentTime * 0.002 * t.floatSpeed + t.floatPhase) * 4;\n            t.y = t.initialTargetY + floatOffset;\n            continue;\n          }\n          const wasSupported = t.isSupported && Math.hypot(t.vx, t.vy) < 0.6;\n          t.vy += state.gravity * (wasSupported ? 0.25 : 0.88) * dropStagger;\n        } else {\n          t.vx += (Math.random() - 0.5) * 0.04;\n          t.vy += (Math.random() - 0.5) * 0.04;\n        }\n\n        t.x += t.vx;\n        t.y += t.vy;\n        t.angle += t.angularVelocity;\n        // Allow up to ~62° (1.08 rad) so tags can wedge diagonally (\"baka\") into narrow gaps or lie flat (\"soza\")\n        t.angle = clamp(t.angle, -1.08, 1.08);\n\n        t.vx *= 0.94;\n        t.vy *= 0.98;\n        t.angularVelocity *= 0.88;\n        t.isSupported = false;\n        t.supportLeft = false;\n        t.supportRight = false;\n      }\n\n      // 2. ADAPTIVE OBB SOLVER (\"Soza Paile Soza, Baka Paile Baka\" — Flat where flat space exists, tilted into gaps!)\n      if (state.phase !== \"floating\" && !prefersReduced) {\n        const solverIterations = 16;\n\n        for (let iter = 0; iter < solverIterations; iter++) {\n          // A. Floor & Wall Constraints\n          for (let i = 0; i < tags.length; i++) {\n            const t = tags[i];\n            const isBeingDragged = state.isDragging && state.draggedId === t.id;\n            if (t.isSleeping && !isBeingDragged) continue;\n\n            const verts = getOBBVertices(t, 0);\n            let maxPenY = 0;\n            let floorContactX = 0;\n            let floorVerts = 0;\n\n            for (let k = 0; k < 4; k++) {\n              const penY = verts[k].y - floorY;\n              if (penY >= -1.5 && state.activeGravity) {\n                t.isSupported = true;\n                floorVerts++;\n                floorContactX += verts[k].x;\n                if (verts[k].x <= t.x + 6) t.supportLeft = true;\n                if (verts[k].x >= t.x - 6) t.supportRight = true;\n              }\n              if (penY > maxPenY) {\n                maxPenY = penY;\n              }\n            }\n\n            if (maxPenY > 0) {\n              t.y -= maxPenY;\n              if (t.vy > 0) t.vy = 0;\n              t.vx *= 0.82;\n              t.angularVelocity *= 0.78;\n            }\n\n            // If touching floor on 1 corner with open space around it, gravity torque rotates raised end down to floor (\"soza\")\n            if (state.activeGravity && iter === 0 && floorVerts === 1 && fallFrame < 140 && !isBeingDragged) {\n              const leverX = t.x - floorContactX;\n              t.angularVelocity += clamp(leverX * 0.0018, -0.035, 0.035);\n              if (Math.abs(t.angle) < 0.35) {\n                t.angle *= 0.85;\n              }\n            }\n\n            const ext = getBoxExtents(t);\n            if (ext.minX < leftX) {\n              t.x += leftX - ext.minX;\n              if (t.vx < 0) t.vx = 0;\n            }\n            if (ext.maxX > rightX) {\n              t.x -= ext.maxX - rightX;\n              if (t.vx > 0) t.vx = 0;\n            }\n            if (ext.minY < ceilingY) {\n              t.y += ceilingY - ext.minY;\n              if (t.vy < 0) t.vy = 0;\n            }\n          }\n\n          // B. Pairwise OBB SAT Collisions\n          for (let i = 0; i < tags.length; i++) {\n            const a = tags[i];\n            const isDraggingA = state.isDragging && state.draggedId === a.id;\n\n            for (let j = i + 1; j < tags.length; j++) {\n              const b = tags[j];\n              const isDraggingB = state.isDragging && state.draggedId === b.id;\n\n              if (a.isSleeping && b.isSleeping && !isDraggingA && !isDraggingB) continue;\n\n              if (Math.abs(b.x - a.x) > (a.width + b.width) * 0.65) continue;\n              if (Math.abs(b.y - a.y) > (a.width + b.width) * 0.65) continue;\n\n              const col = checkOBBCollision(a, b, gap);\n              if (!col.collided) {\n                if (state.activeGravity) {\n                  const supCol = checkOBBCollision(a, b, gap + 2.8);\n                  if (supCol.collided) {\n                    const top = a.y < b.y ? a : b;\n                    const bot = a.y < b.y ? b : a;\n                    if (bot.isSupported || bot.isSleeping) {\n                      top.isSupported = true;\n                      if (supCol.cx <= top.x + 8) top.supportLeft = true;\n                      if (supCol.cx >= top.x - 8) top.supportRight = true;\n                    }\n                  }\n                }\n                continue;\n              }\n\n              const nx = col.nx;\n              const ny = col.ny;\n              const pen = col.pen;\n\n              const top = a.y <= b.y ? a : b;\n              const bot = a.y <= b.y ? b : a;\n              const isTopDragging = top.id === a.id ? isDraggingA : isDraggingB;\n\n              if (state.activeGravity && (bot.isSupported || bot.isSleeping)) {\n                top.isSupported = true;\n                if (col.cx <= top.x + 8) top.supportLeft = true;\n                if (col.cx >= top.x - 8) top.supportRight = true;\n              }\n\n              if (pen <= 0.01) continue;\n\n              if (a.isSleeping && (isDraggingB || Math.min(pen, 2) > 0.6)) {\n                a.isSleeping = false;\n                a.sleepFrames = 0;\n              }\n              if (b.isSleeping && (isDraggingA || Math.min(pen, 2) > 0.6)) {\n                b.isSleeping = false;\n                b.sleepFrames = 0;\n              }\n\n              // Upward Unjamming on later iterations (iter >= 10) if horizontally wedged between walls\n              if (iter >= 10 && pen > 0.8 && !top.isSleeping && !isTopDragging) {\n                top.y -= pen * 0.9;\n                if (Math.abs(ny) < 0.45 && fallFrame < 140) {\n                  const tiltDir = top.x >= bot.x ? -1 : 1;\n                  top.angle = clamp(top.angle + tiltDir * 0.04, -1.05, 1.05);\n                }\n                continue;\n              }\n\n              let wA = a.isSleeping || isDraggingA ? 0 : a.invMass;\n              let wB = b.isSleeping || isDraggingB ? 0 : b.invMass;\n              if (wA > 0 && a.isSupported && a.y > b.y) wA *= 0.25;\n              if (wB > 0 && b.isSupported && b.y > a.y) wB *= 0.25;\n\n              const sumW = wA + wB;\n              if (sumW <= 0) continue;\n\n              const rA = wA / sumW;\n              const rB = wB / sumW;\n\n              a.x -= nx * pen * rA;\n              a.y -= ny * pen * rA;\n              b.x += nx * pen * rB;\n              b.y += ny * pen * rB;\n\n              // Lever-arm rotation so tags naturally tilt (\"baka hoye\") into gaps when off-center\n              const rAx = col.cx - a.x;\n              const rAy = col.cy - a.y;\n              const rBx = col.cx - b.x;\n              const rBy = col.cy - b.y;\n              const crossA = rAx * ny - rAy * nx;\n              const crossB = rBx * ny - rBy * nx;\n\n              if (wA > 0 && fallFrame < 145) {\n                a.angle = clamp(a.angle - crossA * pen * a.invInertia * 0.22 * rA, -1.05, 1.05);\n              }\n              if (wB > 0 && fallFrame < 145) {\n                b.angle = clamp(b.angle + crossB * pen * b.invInertia * 0.22 * rB, -1.05, 1.05);\n              }\n\n              if (iter === 0) {\n                const rvx = b.vx - a.vx;\n                const rvy = b.vy - a.vy;\n                const vn = rvx * nx + rvy * ny;\n                if (vn < 0) {\n                  const imp = -vn;\n                  if (wA > 0) {\n                    a.vx -= imp * nx * rA;\n                    a.vy -= imp * ny * rA;\n                    a.vx *= 0.85;\n                    a.vy *= 0.85;\n                  }\n                  if (wB > 0) {\n                    b.vx += imp * nx * rB;\n                    b.vy += imp * ny * rB;\n                    b.vx *= 0.85;\n                    b.vy *= 0.85;\n                  }\n                }\n              }\n            }\n          }\n\n          // C. Adaptive Gravity Tipping into Gaps (\"Soza Paile Soza, Baka Paile Baka\"):\n          // If a tag is supported on ONLY ONE side (overhanging into an empty gap!),\n          // tip its unsupported end DOWNWARD into the gap AND slide it into the gap so it wedges in diagonally or drops flat!\n          if (state.activeGravity && iter === 0 && fallFrame < 140) {\n            for (let i = 0; i < tags.length; i++) {\n              const t = tags[i];\n              const isBeingDragged = state.isDragging && state.draggedId === t.id;\n              if (t.isSleeping || !t.isSupported || isBeingDragged) continue;\n\n              if (t.supportLeft && !t.supportRight) {\n                // Supported on left, empty gap on right -> tip right end DOWN (+angle) and slide right into gap\n                t.angularVelocity += 0.018;\n                t.vx += 0.45;\n              } else if (t.supportRight && !t.supportLeft) {\n                // Supported on right, empty gap on left -> tip left end DOWN (-angle) and slide left into gap\n                t.angularVelocity -= 0.018;\n                t.vx -= 0.45;\n              } else if (t.supportLeft && t.supportRight && Math.abs(t.angle) < 0.22) {\n                // Supported on both sides and nearly flat -> settle cleanly flat (\"soza\")\n                t.angle *= 0.85;\n                t.angularVelocity *= 0.6;\n              }\n            }\n          }\n\n          // D. Final Wall & Floor Clamp Inside Solver\n          for (let i = 0; i < tags.length; i++) {\n            const t = tags[i];\n            const isBeingDragged = state.isDragging && state.draggedId === t.id;\n            if (t.isSleeping && !isBeingDragged) continue;\n\n            const ext = getBoxExtents(t);\n            if (ext.maxY > floorY) {\n              t.y -= ext.maxY - floorY;\n              if (t.vy > 0) t.vy = 0;\n              if (state.activeGravity) t.isSupported = true;\n            }\n            if (ext.minX < leftX) {\n              t.x += leftX - ext.minX;\n              if (t.vx < 0) t.vx = 0;\n            }\n            if (ext.maxX > rightX) {\n              t.x -= ext.maxX - rightX;\n              if (t.vx > 0) t.vx = 0;\n            }\n            if (ext.minY < ceilingY) {\n              t.y += ceilingY - ext.minY;\n              if (t.vy < 0) t.vy = 0;\n            }\n          }\n        }\n\n        // 3. SLEEP EVALUATION (100% Rock-Solid Stillness Once Settled)\n        if (state.activeGravity) {\n          for (let i = 0; i < tags.length; i++) {\n            const t = tags[i];\n            if (t.isSleeping) continue;\n            if (state.isDragging && state.draggedId === t.id) continue;\n\n            const dropStagger = Math.max(\n              0,\n              Math.min(1, elapsedAfterHover * 3.2 - (tags.length - 1 - i) * 0.03),\n            );\n            if (dropStagger < 1) continue;\n\n            const netDx = t.x - t.prevX;\n            const netDy = t.y - t.prevY;\n            const netDa = t.angle - t.prevAngle;\n            const netMotion = Math.hypot(netDx, netDy) + Math.abs(netDa) * 25;\n\n            if (t.isSupported || fallFrame > 140) {\n              t.vx = t.vx * 0.5 + netDx * 0.5;\n              t.vy = t.vy * 0.5 + netDy * 0.5;\n              t.angularVelocity = t.angularVelocity * 0.5 + netDa * 0.5;\n            }\n\n            if ((fallFrame > 142 || (t.isSupported && fallFrame > 95)) && netMotion < 0.5) {\n              t.sleepFrames++;\n              t.vx *= 0.4;\n              t.vy *= 0.4;\n              t.angularVelocity *= 0.4;\n              if (t.sleepFrames >= 6) {\n                t.isSleeping = true;\n                t.vx = 0;\n                t.vy = 0;\n                t.angularVelocity = 0;\n              }\n            } else {\n              t.sleepFrames = Math.max(0, t.sleepFrames - 1);\n            }\n          }\n        }\n      }\n\n      // 4. SYNC DOM TRANSFORMS\n      for (let i = 0; i < tags.length; i++) {\n        const t = tags[i];\n        const el = tagElementsRef.current.get(t.id);\n        if (el) {\n          el.style.transform = `translate3d(${t.x.toFixed(2)}px, ${t.y.toFixed(2)}px, 0) translate(-50%, -50%) rotate(${t.angle.toFixed(4)}rad)`;\n        }\n      }\n\n      animFrame = requestAnimationFrame(loop);\n    };\n\n    animFrame = requestAnimationFrame(loop);\n    stateRef.current.animId = animFrame;\n\n    return () => {\n      cancelAnimationFrame(animFrame);\n    };\n  }, [isMounted, measureTags]);\n\n  // Viewport Intersection Observer & Resize handling\n  useEffect(() => {\n    if (!isMounted || !containerRef.current) return;\n    const el = containerRef.current;\n    let resizeTimer: ReturnType<typeof setTimeout> | null = null;\n\n    // Resize Observer\n    const ro = new ResizeObserver((entries) => {\n      for (const entry of entries) {\n        const { width, height: h } = entry.contentRect;\n        if (width > 0 && h > 0) {\n          const prevW = stateRef.current.width;\n          const prevH = stateRef.current.height;\n          const widthDiff = Math.abs(width - prevW);\n          const heightDiff = Math.abs(h - prevH);\n\n          if (widthDiff > 2 || heightDiff > 2) {\n            stateRef.current.width = width;\n            stateRef.current.height = h;\n            setArenaDimensions({ width, height: h });\n\n            // Immediately re-measure DOM dimensions (in case responsive sm: breakpoint changed)\n            measureTags();\n\n            // Proportionally scale X positions so tags don't jam against one wall during live drag\n            const scaleX = prevW > 0 ? width / prevW : 1;\n            stateRef.current.fallStartTime = performance.now() - 800;\n            physicsTagsRef.current.forEach((t) => {\n              t.x = clamp(t.x * scaleX, t.width * 0.5 + 8, width - t.width * 0.5 - 8);\n              t.prevX = t.x;\n              t.isSleeping = false;\n              t.sleepFrames = 0;\n            });\n\n            // When switching between screen sizes (e.g. Large -> Small or dragging resize handle),\n            // cleanly re-initialize for the new container width once resize settles (same as reload!)\n            if (widthDiff > 6) {\n              if (resizeTimer) clearTimeout(resizeTimer);\n              resizeTimer = setTimeout(() => {\n                initTags(true);\n              }, 120);\n            }\n          }\n        }\n      }\n    });\n    ro.observe(el);\n\n    // Initial tags setup\n    initTags();\n\n    // Intersection Observer\n    let observer: IntersectionObserver | null = null;\n    if (autoStartOnView && typeof IntersectionObserver !== \"undefined\") {\n      observer = new IntersectionObserver(\n        (entries) => {\n          const entry = entries[0];\n          if (entry.isIntersecting && !stateRef.current.hasTriggered) {\n            stateRef.current.hasTriggered = true;\n            initTags();\n          }\n        },\n        { threshold: 0.25 },\n      );\n      observer.observe(el);\n    }\n\n    return () => {\n      if (resizeTimer) clearTimeout(resizeTimer);\n      ro.disconnect();\n      if (observer) observer.disconnect();\n    };\n  }, [isMounted, autoStartOnView, initTags, measureTags]);\n\n  // Pointer Interaction (Mouse & Touch Grab & Throw)\n  const handlePointerDown = (id: string, e: React.PointerEvent) => {\n    if (!interactive) return;\n    e.preventDefault();\n    const tag = physicsTagsRef.current.find((t) => t.id === id);\n    if (!tag || !containerRef.current) return;\n\n    const rect = containerRef.current.getBoundingClientRect();\n    const clientX = e.clientX - rect.left;\n    const clientY = e.clientY - rect.top;\n\n    stateRef.current.isDragging = true;\n    stateRef.current.draggedId = id;\n    stateRef.current.dragOffset = { x: clientX - tag.x, y: clientY - tag.y };\n    stateRef.current.mousePos = { x: clientX, y: clientY };\n    stateRef.current.mouseHistory = [{ x: clientX, y: clientY, time: performance.now() }];\n    stateRef.current.fallStartTime = performance.now() - 1000;\n    tag.isSleeping = false;\n    tag.sleepFrames = 0;\n\n    const onPointerMove = (moveEvt: PointerEvent) => {\n      const mx = moveEvt.clientX - rect.left;\n      const my = moveEvt.clientY - rect.top;\n      stateRef.current.mousePos = { x: mx, y: my };\n\n      const now = performance.now();\n      stateRef.current.mouseHistory.push({ x: mx, y: my, time: now });\n      if (stateRef.current.mouseHistory.length > 5) {\n        stateRef.current.mouseHistory.shift();\n      }\n    };\n\n    const onPointerUp = () => {\n      window.removeEventListener(\"pointermove\", onPointerMove);\n      window.removeEventListener(\"pointerup\", onPointerUp);\n      window.removeEventListener(\"pointercancel\", onPointerUp);\n\n      const history = stateRef.current.mouseHistory;\n      if (history.length >= 2 && stateRef.current.draggedId) {\n        const last = history[history.length - 1];\n        const prev = history[0];\n        const dt = (last.time - prev.time) / 1000;\n        if (dt > 0.01) {\n          const vx = ((last.x - prev.x) / dt) * 0.035;\n          const vy = ((last.y - prev.y) / dt) * 0.035;\n          tag.vx = clamp(vx, -18, 18);\n          tag.vy = clamp(vy, -18, 18);\n          tag.angularVelocity = clamp((Math.random() - 0.5) * 0.2 + tag.vx * 0.015, -0.25, 0.25);\n        }\n      }\n\n      stateRef.current.isDragging = false;\n      stateRef.current.draggedId = null;\n      stateRef.current.fallStartTime = performance.now() - 800;\n    };\n\n    window.addEventListener(\"pointermove\", onPointerMove);\n    window.addEventListener(\"pointerup\", onPointerUp);\n    window.addEventListener(\"pointercancel\", onPointerUp);\n  };\n\n  // Actions\n  const handleDropAgain = () => {\n    initTags(false);\n  };\n\n  const handleScatter = () => {\n    const tags = physicsTagsRef.current;\n    stateRef.current.fallStartTime = performance.now() - 800;\n    tags.forEach((t) => {\n      t.isSleeping = false;\n      t.sleepFrames = 0;\n      t.isSupported = false;\n      t.supportLeft = false;\n      t.supportRight = false;\n      t.vy = -8 - Math.random() * 10;\n      t.vx = (Math.random() - 0.5) * 14;\n      t.angularVelocity = (Math.random() - 0.5) * 0.25;\n    });\n    if (stateRef.current.phase === \"floating\") {\n      stateRef.current.phase = \"falling\";\n      setPhase(\"falling\");\n    }\n  };\n\n  const handleToggleGravity = () => {\n    const next = !activeGravity;\n    setActiveGravity(next);\n    stateRef.current.activeGravity = next;\n    stateRef.current.fallStartTime = performance.now() - 800;\n    physicsTagsRef.current.forEach((t) => {\n      t.isSleeping = false;\n      t.sleepFrames = 0;\n      t.isSupported = false;\n      t.supportLeft = false;\n      t.supportRight = false;\n    });\n    if (!next) {\n      // Float tags gently upwards\n      physicsTagsRef.current.forEach((t) => {\n        t.vy = -1 - Math.random() * 2;\n        t.vx = (Math.random() - 0.5) * 3;\n      });\n    }\n  };\n\n  return (\n    <div\n      className={cn(\n        \"relative w-full rounded-3xl border overflow-hidden flex flex-col select-none\",\n        palette === \"glass\"\n          ? \"border-white/20 bg-black/20 dark:bg-black/35 backdrop-blur-xs text-white\"\n          : \"border-border/80 bg-background/95 dark:bg-zinc-950/95\",\n        className,\n      )}\n      {...props}\n    >\n      {/* Header & Controls Bar */}\n      {(title || showControls) && (\n        <div className=\"relative z-20 flex flex-wrap items-center justify-between gap-3 p-4 sm:p-5 border-b border-border/60 backdrop-blur-sm bg-background/50 dark:bg-zinc-950/50\">\n          <div>\n            {title && (\n              <h3 className=\"text-base sm:text-lg font-bold tracking-tight text-foreground flex items-center gap-2\">\n                <Sparkles className=\"w-4 h-4 text-amber-500\" />\n                {title}\n              </h3>\n            )}\n            {description && (\n              <p className=\"text-xs text-muted-foreground mt-0.5 max-w-md\">\n                {description}\n              </p>\n            )}\n          </div>\n\n          {showControls && (\n            <div className=\"flex items-center gap-2 ml-auto\">\n              <button\n                type=\"button\"\n                onClick={handleDropAgain}\n                className=\"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold rounded-lg bg-muted hover:bg-muted/80 text-foreground transition-all cursor-pointer active:scale-95 shadow-xs\"\n                title=\"Restart falling animation\"\n              >\n                <RotateCcw className=\"w-3.5 h-3.5\" />\n                <span>Drop Again</span>\n              </button>\n\n              <button\n                type=\"button\"\n                onClick={handleScatter}\n                className=\"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold rounded-lg bg-muted hover:bg-muted/80 text-foreground transition-all cursor-pointer active:scale-95 shadow-xs\"\n                title=\"Explode/scatter all tags upwards\"\n              >\n                <Flame className=\"w-3.5 h-3.5 text-orange-500\" />\n                <span>Scatter</span>\n              </button>\n\n              <button\n                type=\"button\"\n                onClick={handleToggleGravity}\n                className={cn(\n                  \"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer active:scale-95 shadow-xs\",\n                  activeGravity\n                    ? \"bg-muted hover:bg-muted/80 text-foreground\"\n                    : \"bg-primary text-primary-foreground font-bold shadow-md\",\n                )}\n                title=\"Toggle zero-gravity float\"\n              >\n                <span>{activeGravity ? \"Gravity On\" : \"Zero-G Float\"}</span>\n              </button>\n            </div>\n          )}\n        </div>\n      )}\n\n      {/* Interactive Physics Arena */}\n      <div\n        ref={containerRef}\n        style={{ height }}\n        className=\"relative w-full overflow-hidden touch-none cursor-default bg-radial-[at_50%_0%] from-muted/30 to-transparent\"\n      >\n        {/* Subtle Watermark or Floor line */}\n        <div className=\"absolute inset-x-0 bottom-0 h-px bg-gradient-to-r from-transparent via-border to-transparent pointer-events-none\" />\n\n        {/* Tags Container */}\n        {normalizedTags.map((item, index) => {\n          const paletteList = PALETTES[palette] || PALETTES.default;\n          const style = paletteList[index % paletteList.length];\n\n          return (\n            <div\n              key={item.id}\n              ref={(el) => {\n                if (el) tagElementsRef.current.set(item.id, el);\n                else tagElementsRef.current.delete(item.id);\n              }}\n              onPointerDown={(e) => handlePointerDown(item.id, e)}\n              className={cn(\n                \"absolute left-0 top-0 will-change-transform flex items-center justify-center gap-1.5 px-3 py-1.5 sm:px-4 sm:py-2 text-xs sm:text-sm font-semibold tracking-wide border rounded-[var(--radius)] shadow-xs transition-[box-shadow,filter] cursor-grab active:cursor-grabbing select-none leading-none whitespace-nowrap\",\n                item.bg || style.bg,\n                item.text || style.text,\n                item.border || style.border,\n                item.className,\n                interactive && \"hover:shadow-md hover:brightness-105\",\n              )}\n              style={{\n                transformOrigin: \"center center\",\n                touchAction: \"none\",\n                WebkitUserSelect: \"none\",\n                userSelect: \"none\",\n              }}\n            >\n              {item.icon && <span className=\"shrink-0\">{item.icon}</span>}\n              <span className=\"truncate\">{item.label}</span>\n            </div>\n          );\n        })}\n\n        {/* Drag Hint overlay */}\n        <div className=\"absolute right-4 bottom-3 z-10 pointer-events-none flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground/60\">\n          <MousePointer2 className=\"w-3.5 h-3.5\" />\n          <span>Grab & toss any tag</span>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/custom/blocks/FallingTagsBlock.tsx"
    }
  ],
  "docs": "Named exports: FallingTagsBlock (default), FallingTagItem, FallingTagPalette.",
  "categories": [
    "marketing",
    "data-display"
  ],
  "type": "registry:component"
}
