{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "lodestar",
  "type": "registry:ui",
  "title": "Lodestar",
  "description": "A floating pill navbar — a frosted near-black bar with a subtle white bottom hairline — that hides on scroll down and reveals on scroll up. Scroll-velocity aware, and never hides while any child has keyboard focus.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://crucibleui.com/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/default/navigation/lodestar/lodestar.tsx",
      "type": "registry:ui",
      "target": "components/crucible/lodestar.tsx",
      "content": "\"use client\";\n\nimport { motion, useMotionValueEvent, useScroll, type HTMLMotionProps } from \"motion/react\";\nimport * as React from \"react\";\n\nimport { useReducedMotion } from \"@/hooks/use-reduced-motion\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface LodestarProps\n  extends Omit<HTMLMotionProps<\"nav\">, \"children\" | \"ref\" | \"animate\" | \"variants\" | \"transition\"> {\n  /** Nav content — links, buttons, a logo, whatever the bar should hold. */\n  children: React.ReactNode;\n  /**\n   * Scroll container to track instead of the window. Pass a ref to an\n   * internal `overflow-y-auto` element (used by this component's own demo).\n   * When provided, Lodestar positions itself `sticky` inside that container\n   * instead of `fixed` to the viewport.\n   */\n  scrollContainer?: React.RefObject<HTMLElement | null>;\n  /** Scroll distance in px from the top before the bar is allowed to hide. @default 80 */\n  hideThreshold?: number;\n}\n\n/** Scroll speed (px/s) below which direction changes are ignored. */\nconst MIN_VELOCITY = 60;\n\n/**\n * Lodestar — a floating pill navbar that hides on scroll down and reveals on\n * scroll up, scroll-velocity aware via `useScroll`/`useMotionValueEvent` (slow\n * drift below ~60px/s never toggles it). It\n * never hides while any child has `:focus-visible`, so keyboard users never\n * lose the bar mid-navigation. Collapses to an instant (non-springy)\n * transition under `prefers-reduced-motion` — it still hides/shows, since\n * that's the component's function, but without the springy travel.\n */\nexport function Lodestar({\n  children,\n  className,\n  scrollContainer,\n  hideThreshold = 80,\n  ...props\n}: LodestarProps) {\n  const reducedMotion = useReducedMotion();\n  const navRef = React.useRef<HTMLElement | null>(null);\n  const [hidden, setHidden] = React.useState(false);\n\n  const { scrollY } = useScroll(scrollContainer ? { container: scrollContainer } : undefined);\n\n  useMotionValueEvent(scrollY, \"change\", (latest) => {\n    const previous = scrollY.getPrevious() ?? latest;\n    const scrollingDown = latest > previous;\n    // Velocity gate: slow drift and trackpad jitter (< MIN_VELOCITY px/s, in\n    // small steps) never toggles the bar — a deliberate scroll or a discrete\n    // jump (PageDown, anchor) in either direction does.\n    const velocity = Math.abs(scrollY.getVelocity());\n    if (velocity < MIN_VELOCITY && Math.abs(latest - previous) < 12 && latest >= hideThreshold) return;\n\n    setHidden((wasHidden) => {\n      if (latest < hideThreshold) return false;\n\n      const activeElement = typeof document !== \"undefined\" ? document.activeElement : null;\n      const focusedInside =\n        !!navRef.current &&\n        !!activeElement &&\n        navRef.current.contains(activeElement) &&\n        (activeElement as HTMLElement).matches?.(\":focus-visible\");\n      if (focusedInside) return false;\n\n      if (scrollingDown && !wasHidden) return true;\n      if (!scrollingDown && wasHidden) return false;\n      return wasHidden;\n    });\n  });\n\n  return (\n    <motion.nav\n      {...props}\n      ref={navRef}\n      data-crucible=\"lodestar\"\n      onFocusCapture={() => setHidden(false)}\n      animate={hidden ? \"hidden\" : \"visible\"}\n      // Sticky mode centers with mx-auto/w-fit — an x:-50% there shoves the\n      // full-width flow box half out of the scroller and clips every item.\n      variants={{\n        visible: { y: 0, opacity: 1, ...(scrollContainer ? {} : { x: \"-50%\" }) },\n        hidden: { y: \"-140%\", opacity: 0, ...(scrollContainer ? {} : { x: \"-50%\" }) },\n      }}\n      transition={\n        reducedMotion\n          ? { duration: 0.15, ease: \"linear\" }\n          : { type: \"spring\", stiffness: 380, damping: 34 }\n      }\n      className={cn(\n        \"top-4 z-50 flex items-center gap-1 rounded-full border border-white/10 bg-neutral-950/70 px-2 py-2 shadow-[0_8px_30px_rgba(0,0,0,0.35)] backdrop-blur-md\",\n        \"before:pointer-events-none before:absolute before:inset-x-3 before:bottom-[1px] before:h-px before:bg-white/0 before:transition-colors before:duration-500\",\n        \"data-[hidden=false]:before:bg-white/25\",\n        scrollContainer ? \"sticky mx-auto w-fit\" : \"fixed left-1/2\",\n        className\n      )}\n      data-hidden={hidden}\n    >\n      {children}\n    </motion.nav>\n  );\n}\n"
    }
  ]
}