{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "globe-menu",
  "title": "Globe Menu",
  "description": "Navigation pinned to a slowly turning hairline globe: links ride the surface and fade as they swing round the back, drag to spin it, hover to pause, focus a link to turn it to the front, with a caption naming the link that faces you.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/globe-menu/globe-menu.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { ArrowUpRight } from \"lucide-react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type MenuTheme = \"dark\" | \"light\";\n\nexport interface GlobeMenuLink {\n  /** A stable, unique item identifier. */\n  id: string;\n  label: string;\n  href: string;\n  description?: string;\n  /** Where the pin sits on the globe, in degrees. Spread evenly when left out. */\n  lat?: number;\n  lon?: number;\n}\n\nconst DEFAULT_LINKS: GlobeMenuLink[] = [\n  { id: \"work\", label: \"Work\", href: \"/work\", description: \"A few things, thoughtfully made.\" },\n  { id: \"studio\", label: \"Studio\", href: \"/studio\", description: \"Independent minds. Shared curiosity.\" },\n  { id: \"journal\", label: \"Journal\", href: \"/journal\", description: \"Notes from the in-between.\" },\n  { id: \"objects\", label: \"Objects\", href: \"/objects\", description: \"Things you can hold, made to stay.\" },\n  { id: \"archive\", label: \"Archive\", href: \"/archive\", description: \"Ten years of considered work.\" },\n  { id: \"careers\", label: \"Careers\", href: \"/careers\", description: \"One seat open at the table.\" },\n  { id: \"contact\", label: \"Contact\", href: \"/contact\", description: \"Every good thing starts with a hello.\" },\n];\n\nfunction palette(theme: MenuTheme): React.CSSProperties & Record<`--${string}`, string> {\n  const light = theme === \"light\";\n  return {\n    \"--nav-page\": light ? \"#f5f4f1\" : \"#0e0e0e\",\n    \"--nav-ink\": light ? \"#0a0a0a\" : \"#f5f4f1\",\n    \"--nav-muted\": light ? \"rgba(10,10,10,.52)\" : \"rgba(245,244,241,.52)\",\n    \"--nav-line\": light ? \"rgba(10,10,10,.1)\" : \"rgba(245,244,241,.1)\",\n    \"--nav-soft\": light ? \"rgba(10,10,10,.045)\" : \"rgba(245,244,241,.045)\",\n    \"--nav-panel\": light ? \"rgba(245,244,241,.96)\" : \"rgba(14,14,14,.96)\",\n    \"--nav-serif\": \"var(--navbar-serif, 'Instrument Serif', Georgia, serif)\",\n    \"--globe-front\": light ? \"rgba(10,10,10,.28)\" : \"rgba(245,244,241,.26)\",\n    \"--globe-back\": light ? \"rgba(10,10,10,.07)\" : \"rgba(245,244,241,.07)\",\n  };\n}\n\nconst focus = \"outline-none focus-visible:ring-2 focus-visible:ring-[var(--nav-ink)]/40 focus-visible:ring-offset-4 focus-visible:ring-offset-[var(--nav-page)]\";\nconst muted = \"text-[color:var(--nav-muted)]\";\nconst serif = \"font-[family-name:var(--nav-serif)] font-normal tracking-[-.035em]\";\nconst EASE = [0.16, 1, 0.3, 1] as const;\nconst DEG = Math.PI / 180;\n\nfunction subscribeReducedMotion(onChange: () => void) {\n  const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n}\nconst reducedMotionSnapshot = () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\nconst serverReducedMotionSnapshot = () => false;\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(subscribeReducedMotion, reducedMotionSnapshot, serverReducedMotionSnapshot);\n}\n\nconst clamp = (v: number, a: number, b: number) => Math.min(Math.max(v, a), b);\nconst turn = (from: number, to: number) => ((((to - from) % 360) + 540) % 360) - 180;\n\n/** Orthographic projection of a point on the unit sphere, turned by yaw then tilted by pitch. z > 0 faces the viewer. */\nfunction project(lat: number, lon: number, yaw: number, pitch: number) {\n  const la = lat * DEG;\n  const lo = (lon + yaw) * DEG;\n  const p = pitch * DEG;\n  const x = Math.cos(la) * Math.sin(lo);\n  const y = Math.sin(la);\n  const z = Math.cos(la) * Math.cos(lo);\n  return { x, y: y * Math.cos(p) - z * Math.sin(p), z: y * Math.sin(p) + z * Math.cos(p) };\n}\n\n/** Pins spread over the band between ±48° with a golden-angle step, unless an item sets its own spot. */\nfunction placePins(items: GlobeMenuLink[]) {\n  const n = items.length;\n  return items.map((item, i) => {\n    if (item.lat !== undefined && item.lon !== undefined) return { lat: item.lat, lon: item.lon };\n    const t = n > 1 ? i / (n - 1) : 0.5;\n    return { lat: 48 - t * 96 * 0.92, lon: (i * 137.508) % 360 };\n  });\n}\n\n/** Wireframe paths split into the half facing the viewer and the half behind. */\nfunction wire(yaw: number, pitch: number, r: number, c: number) {\n  let front = \"\";\n  let back = \"\";\n  const trace = (pts: { x: number; y: number; z: number }[]) => {\n    let fOpen = false;\n    let bOpen = false;\n    for (const q of pts) {\n      const X = (c + q.x * r).toFixed(1);\n      const Y = (c - q.y * r).toFixed(1);\n      if (q.z >= 0) {\n        front += `${fOpen ? \"L\" : \"M\"}${X} ${Y}`;\n        fOpen = true;\n        bOpen = false;\n      } else {\n        back += `${bOpen ? \"L\" : \"M\"}${X} ${Y}`;\n        bOpen = true;\n        fOpen = false;\n      }\n    }\n  };\n  for (let lon = 0; lon < 180; lon += 20) {\n    const pts = [];\n    for (let k = 0; k <= 96; k++) pts.push(project(-90 + (k * 360) / 96, lon, yaw, pitch));\n    // latitudes past 90° carry on over the pole and down the far side, so this is a full great circle\n    trace(pts);\n  }\n  for (let lat = -60; lat <= 60; lat += 20) {\n    const pts = [];\n    for (let k = 0; k <= 96; k++) pts.push(project(lat, (k * 360) / 96, yaw, pitch));\n    trace(pts);\n  }\n  return { front, back };\n}\n\nexport interface GlobeMenuProps extends Omit<React.ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n  theme?: MenuTheme;\n  items?: GlobeMenuLink[];\n  /** Diameter of the globe in px on wide screens; it shrinks to fit narrow ones. */\n  size?: number;\n  /** Idle spin in degrees per second; 0 holds it still. */\n  autoRotate?: number;\n  /** Resting tilt toward the viewer, in degrees. */\n  tilt?: number;\n  eyebrow?: string;\n  showCaption?: boolean;\n  onNavigate?: (item: GlobeMenuLink, event: React.MouseEvent<HTMLAnchorElement>) => void;\n}\n\nexport function GlobeMenu({\n  theme = \"dark\",\n  items = DEFAULT_LINKS,\n  size = 420,\n  autoRotate = 10,\n  tilt = 18,\n  eyebrow = \"Around the studio\",\n  showCaption = true,\n  onNavigate,\n  className,\n  style,\n  ...props\n}: GlobeMenuProps) {\n  const reduce = useReducedMotion();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const stageRef = React.useRef<HTMLDivElement>(null);\n  const frontRef = React.useRef<SVGPathElement>(null);\n  const backRef = React.useRef<SVGPathElement>(null);\n  const pinRefs = React.useRef<(HTMLAnchorElement | null)[]>([]);\n  const pins = React.useMemo(() => placePins(items), [items]);\n  const [d, setD] = React.useState(size);\n  const [facing, setFacing] = React.useState(0);\n  const [hovered, setHovered] = React.useState<number | null>(null);\n  const hoveredRef = React.useRef<number | null>(null);\n  const view = React.useRef({ yaw: 0, pitch: tilt, tYaw: 0, tPitch: tilt, vYaw: 0, target: false });\n  const drag = React.useRef({ active: false, moved: false, x: 0, y: 0, lastT: 0 });\n  const idleSince = React.useRef(0);\n  const wakeRef = React.useRef<() => void>(() => {});\n  const optsRef = React.useRef({ autoRotate: reduce ? 0 : autoRotate, d, pins, tilt });\n  React.useEffect(() => {\n    optsRef.current = { autoRotate: reduce ? 0 : autoRotate, d, pins, tilt };\n    hoveredRef.current = hovered;\n    wakeRef.current();\n  }, [autoRotate, reduce, d, pins, tilt, hovered]);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const update = () => setD(Math.round(clamp(el.clientWidth - 48, 240, size)));\n    update();\n    const observer = new ResizeObserver(update);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [size]);\n\n  React.useEffect(() => {\n    let raf: number | null = null;\n    let last = 0;\n    let inView = true;\n    const paint = () => {\n      const { d, pins } = optsRef.current;\n      const v = view.current;\n      const r = d / 2 - 2;\n      const c = d / 2;\n      const w = wire(v.yaw, v.pitch, r, c);\n      frontRef.current?.setAttribute(\"d\", w.front);\n      backRef.current?.setAttribute(\"d\", w.back);\n      let best = 0;\n      let bestZ = -2;\n      pins.forEach((pin, i) => {\n        const el = pinRefs.current[i];\n        const q = project(pin.lat, pin.lon, v.yaw, v.pitch);\n        if (q.z > bestZ) {\n          bestZ = q.z;\n          best = i;\n        }\n        if (!el) return;\n        const lit = hoveredRef.current === i;\n        // Depth: pins shrink and fade as they swing round the back, and stop taking clicks there.\n        const depth = (q.z + 1) / 2;\n        el.style.transform = `translate(${(c + q.x * r).toFixed(1)}px, ${(c - q.y * r).toFixed(1)}px) scale(${(0.62 + depth * 0.42).toFixed(3)})`;\n        el.style.opacity = (lit ? 1 : q.z > 0 ? 0.45 + 0.55 * q.z : Math.max(0.08, 0.3 + q.z * 0.3)).toFixed(3);\n        el.style.zIndex = String(Math.round(100 + q.z * 100));\n        el.style.pointerEvents = q.z > -0.15 ? \"auto\" : \"none\";\n      });\n      setFacing((cur) => (hoveredRef.current !== null || cur === best ? cur : best));\n    };\n    const tick = (now: number) => {\n      const dt = last ? Math.min((now - last) / 1000, 0.05) : 1 / 60;\n      last = now;\n      const { autoRotate, tilt } = optsRef.current;\n      const v = view.current;\n      const dr = drag.current;\n      if (!dr.active) {\n        if (v.target) {\n          v.yaw += turn(v.yaw, v.tYaw) * (1 - Math.pow(0.004, dt));\n          v.pitch += (v.tPitch - v.pitch) * (1 - Math.pow(0.004, dt));\n          if (Math.abs(turn(v.yaw, v.tYaw)) < 0.05 && Math.abs(v.tPitch - v.pitch) < 0.05) v.target = false;\n        } else {\n          v.yaw += v.vYaw * dt;\n          v.vYaw *= Math.pow(0.06, dt);\n          if (Math.abs(v.vYaw) < 0.5) v.vYaw = 0;\n          // Ease the tilt back to rest, then let the idle spin carry on (paused while a pin is pointed at).\n          v.pitch += (tilt - v.pitch) * (1 - Math.pow(0.2, dt));\n          if (autoRotate && hoveredRef.current === null && v.vYaw === 0 && now - idleSince.current > 1800) v.yaw += autoRotate * dt;\n        }\n      }\n      paint();\n      const busy = dr.active || v.target || v.vYaw !== 0 || Math.abs(tilt - v.pitch) > 0.05 || (autoRotate && hoveredRef.current === null);\n      raf = inView && busy ? requestAnimationFrame(tick) : null;\n      if (raf === null) last = 0;\n    };\n    wakeRef.current = () => {\n      if (raf === null && inView) raf = requestAnimationFrame(tick);\n    };\n    paint();\n    raf = requestAnimationFrame(tick);\n    const observer = new IntersectionObserver(([entry]) => {\n      inView = entry.isIntersecting;\n      if (inView) wakeRef.current();\n    });\n    if (rootRef.current) observer.observe(rootRef.current);\n    return () => {\n      if (raf) cancelAnimationFrame(raf);\n      observer.disconnect();\n    };\n  }, []);\n\n  // Drag the globe round (and tilt it a little); pins stay clickable because a tap never becomes a drag.\n  React.useEffect(() => {\n    const el = stageRef.current;\n    if (!el) return;\n    const onDown = (e: PointerEvent) => {\n      if (e.button !== 0) return;\n      drag.current = { active: true, moved: false, x: e.clientX, y: e.clientY, lastT: e.timeStamp };\n      view.current.vYaw = 0;\n      view.current.target = false;\n      wakeRef.current();\n    };\n    const onMove = (e: PointerEvent) => {\n      const dr = drag.current;\n      if (!dr.active) return;\n      const dx = e.clientX - dr.x;\n      const dy = e.clientY - dr.y;\n      if (!dr.moved && Math.hypot(dx, dy) < 5) return;\n      if (!dr.moved) {\n        dr.moved = true;\n        el.setPointerCapture(e.pointerId);\n        el.style.cursor = \"grabbing\";\n      }\n      const perPx = 180 / (optsRef.current.d * 1.1);\n      const v = view.current;\n      v.yaw += dx * perPx;\n      v.pitch = clamp(v.pitch - dy * perPx, -45, 45);\n      const dt = Math.max((e.timeStamp - dr.lastT) / 1000, 0.008);\n      v.vYaw = v.vYaw * 0.5 + ((dx * perPx) / dt) * 0.5;\n      dr.x = e.clientX;\n      dr.y = e.clientY;\n      dr.lastT = e.timeStamp;\n      wakeRef.current();\n    };\n    const onUp = (e: PointerEvent) => {\n      const dr = drag.current;\n      if (!dr.active) return;\n      dr.active = false;\n      el.style.cursor = \"\";\n      idleSince.current = performance.now();\n      if (e.timeStamp - dr.lastT > 80) view.current.vYaw = 0;\n      wakeRef.current();\n    };\n    // A drag that ends on a pin shouldn't follow its link.\n    const onClick = (e: MouseEvent) => {\n      if (drag.current.moved) {\n        e.preventDefault();\n        e.stopPropagation();\n        drag.current.moved = false;\n      }\n    };\n    el.addEventListener(\"pointerdown\", onDown);\n    el.addEventListener(\"pointermove\", onMove);\n    el.addEventListener(\"pointerup\", onUp);\n    el.addEventListener(\"pointercancel\", onUp);\n    el.addEventListener(\"click\", onClick, true);\n    return () => {\n      el.removeEventListener(\"pointerdown\", onDown);\n      el.removeEventListener(\"pointermove\", onMove);\n      el.removeEventListener(\"pointerup\", onUp);\n      el.removeEventListener(\"pointercancel\", onUp);\n      el.removeEventListener(\"click\", onClick, true);\n    };\n  }, []);\n\n  /** Turn the globe so pin i faces the viewer. */\n  const bringToFront = React.useCallback((i: number) => {\n    const pin = optsRef.current.pins[i];\n    if (!pin) return;\n    const v = view.current;\n    v.tYaw = -pin.lon;\n    v.tPitch = clamp(pin.lat, -40, 40);\n    v.target = true;\n    v.vYaw = 0;\n    idleSince.current = performance.now();\n    wakeRef.current();\n  }, []);\n\n  const shownIndex = hovered ?? facing;\n  const shown = items[shownIndex];\n  const r = d / 2 - 2;\n  const c = d / 2;\n  const initial = React.useMemo(() => wire(0, tilt, size / 2 - 2, size / 2), [tilt, size]);\n\n  return (\n    <nav ref={rootRef} {...props} aria-label={props[\"aria-label\"] ?? \"Globe navigation\"} data-theme={theme} className={cn(\"@container flex w-full flex-col items-center text-[color:var(--nav-ink)]\", className)} style={{ ...palette(theme), ...style }}>\n      <div ref={stageRef} className=\"relative cursor-grab touch-none select-none\" style={{ width: d, height: d }} onMouseLeave={() => setHovered(null)}>\n        {/* soft fill and rim */}\n        <div aria-hidden=\"true\" className=\"absolute inset-0 rounded-full border border-[var(--nav-line)] bg-[radial-gradient(circle_at_32%_28%,var(--nav-soft),transparent_62%)]\" />\n        <svg aria-hidden=\"true\" className=\"absolute inset-0 overflow-visible\" width={d} height={d} viewBox={`0 0 ${d} ${d}`} fill=\"none\">\n          <path ref={backRef} d={d === size ? initial.back : undefined} stroke=\"var(--globe-back)\" strokeWidth={1} strokeDasharray=\"2 4\" />\n          <path ref={frontRef} d={d === size ? initial.front : undefined} stroke=\"var(--globe-front)\" strokeWidth={1} />\n        </svg>\n        <ul className=\"absolute inset-0\">\n          {items.map((item, i) => {\n            const q = project(pins[i].lat, pins[i].lon, 0, tilt);\n            const lit = hovered === i;\n            return (\n              <li key={item.id}>\n                <a\n                  ref={(el) => {\n                    pinRefs.current[i] = el;\n                  }}\n                  href={item.href}\n                  draggable={false}\n                  onMouseEnter={() => setHovered(i)}\n                  onMouseLeave={() => setHovered((h) => (h === i ? null : h))}\n                  onFocus={() => {\n                    setHovered(i);\n                    bringToFront(i);\n                  }}\n                  onBlur={() => setHovered(null)}\n                  onClick={(e) => onNavigate?.(item, e)}\n                  className={cn(\"group absolute top-0 left-0 flex origin-left items-center gap-2 pr-2 whitespace-nowrap\", focus, \"rounded-full focus-visible:ring-offset-2\")}\n                  style={{\n                    transform: `translate(${(c + q.x * r).toFixed(1)}px, ${(c - q.y * r).toFixed(1)}px) scale(${(0.62 + ((q.z + 1) / 2) * 0.42).toFixed(3)})`,\n                    opacity: q.z > 0 ? 0.45 + 0.55 * q.z : 0.15,\n                    marginTop: -14,\n                    marginLeft: -7,\n                  }}\n                >\n                  <span className=\"relative flex size-3.5 shrink-0 items-center justify-center\">\n                    <span className={cn(\"absolute inset-0 rounded-full border border-[var(--nav-ink)] transition-transform duration-300\", lit ? \"scale-150 opacity-40\" : \"scale-100 opacity-60\")} />\n                    <span className={cn(\"block size-1.5 rounded-full bg-[var(--nav-ink)] transition-transform duration-300\", lit && \"scale-125\")} />\n                  </span>\n                  <span className={cn(serif, \"text-[22px] leading-7\")}>{item.label}</span>\n                  <span className={cn(\"text-[9px] tabular-nums transition-opacity duration-300\", muted, lit ? \"opacity-100\" : \"opacity-0 group-hover:opacity-100\")}>{String(i + 1).padStart(2, \"0\")}</span>\n                </a>\n              </li>\n            );\n          })}\n        </ul>\n      </div>\n\n      {showCaption && shown && (\n        <div className=\"mt-8 flex w-full max-w-[420px] flex-col items-center text-center\" aria-live=\"polite\">\n          <p className={cn(\"mb-3 text-[9px] font-medium tracking-[.2em] uppercase\", muted)}>\n            ✦ {eyebrow} / {String(shownIndex + 1).padStart(2, \"0\")}\n          </p>\n          <AnimatePresence mode=\"wait\" initial={false}>\n            <motion.div key={shown.id} initial={{ opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -6 }} transition={{ duration: reduce ? 0 : 0.28, ease: EASE }}>\n              <p className={cn(serif, \"text-[34px] leading-none\")}>{shown.label}</p>\n              {shown.description && <p className={cn(\"mt-2 text-xs leading-6\", muted)}>{shown.description}</p>}\n            </motion.div>\n          </AnimatePresence>\n          <a\n            href={shown.href}\n            onClick={(e) => onNavigate?.(shown, e)}\n            className={cn(\"mt-5 inline-flex items-center gap-2 rounded-full border border-[var(--nav-line)] px-4 py-2 text-xs transition-colors hover:bg-[var(--nav-soft)]\", focus)}\n            tabIndex={-1}\n          >\n            Visit {shown.label.toLowerCase()}\n            <ArrowUpRight size={13} />\n          </a>\n        </div>\n      )}\n    </nav>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}