{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "burger-menu",
  "title": "Burger Menu",
  "description": "A header whose round burger folds into a cross (or a back arrow) and drops a soft panel of numbered serif links, with a gliding highlight, a second level that slides in, keyboard arrows and a footer CTA.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/burger-menu/burger-menu.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { ArrowLeft, ArrowUpRight, ChevronRight } 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 BurgerMenuLink {\n  /** A stable, unique item identifier. */\n  id: string;\n  label: string;\n  href: string;\n  description?: string;\n  badge?: string;\n  /** A second level, shown by sliding the panel over. */\n  children?: Omit<BurgerMenuLink, \"children\">[];\n}\n\nconst DEFAULT_LINKS: BurgerMenuLink[] = [\n  {\n    id: \"work\",\n    label: \"Work\",\n    href: \"/work\",\n    description: \"A few things, thoughtfully made.\",\n    children: [\n      { id: \"identity\", label: \"Identity\", href: \"/work/identity\", description: \"Names, marks and voices.\" },\n      { id: \"digital\", label: \"Digital\", href: \"/work/digital\", description: \"Sites and small tools.\" },\n      { id: \"objects\", label: \"Objects\", href: \"/work/objects\", description: \"Things you can hold.\", badge: \"New\" },\n      { id: \"archive\", label: \"Archive\", href: \"/work/archive\", description: \"Everything since 2014.\" },\n    ],\n  },\n  {\n    id: \"studio\",\n    label: \"Studio\",\n    href: \"/studio\",\n    description: \"Independent minds. Shared curiosity.\",\n    children: [\n      { id: \"about\", label: \"About\", href: \"/studio/about\", description: \"How we like to work.\" },\n      { id: \"people\", label: \"People\", href: \"/studio/people\", description: \"Seven curious minds.\" },\n      { id: \"careers\", label: \"Careers\", href: \"/studio/careers\", description: \"One seat open.\", badge: \"01\" },\n    ],\n  },\n  { id: \"journal\", label: \"Journal\", href: \"/journal\", description: \"Notes from the in-between.\" },\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  };\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 SPRING = { type: \"spring\" as const, stiffness: 420, damping: 34, mass: 0.7 };\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\nfunction useDisclosure(value: boolean | undefined, defaultValue: boolean, onChange?: (open: boolean) => void) {\n  const [internal, setInternal] = React.useState(defaultValue);\n  const open = value ?? internal;\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (value === undefined) setInternal(next);\n      onChange?.(next);\n    },\n    [value, onChange],\n  );\n  return [open, setOpen] as const;\n}\n\n/** Three lines that fold into a cross, or into an arrow pointing back (plain CSS transitions). */\nfunction BurgerIcon({ open, variant, reduce }: { open: boolean; variant: \"cross\" | \"arrow\"; reduce: boolean }) {\n  const lines =\n    variant === \"cross\"\n      ? [\n          open ? { y: 0, rotate: 45, width: 18, x: 0 } : { y: -5, rotate: 0, width: 18, x: 0 },\n          open ? { y: 0, rotate: 0, width: 0, x: 9 } : { y: 0, rotate: 0, width: 12, x: 6 },\n          open ? { y: 0, rotate: -45, width: 18, x: 0 } : { y: 5, rotate: 0, width: 18, x: 0 },\n        ]\n      : [\n          open ? { y: 0, rotate: -40, width: 10, x: 0 } : { y: -5, rotate: 0, width: 18, x: 0 },\n          open ? { y: 0, rotate: 0, width: 18, x: 0 } : { y: 0, rotate: 0, width: 12, x: 6 },\n          open ? { y: 0, rotate: 40, width: 10, x: 0 } : { y: 5, rotate: 0, width: 18, x: 0 },\n        ];\n  return (\n    <span className=\"relative block h-[18px] w-[18px]\" aria-hidden=\"true\">\n      {lines.map((l, i) => (\n        <span\n          key={i}\n          className=\"absolute top-1/2 left-0 -mt-px block h-[1.5px] rounded-full bg-current\"\n          style={{\n            width: l.width,\n            transform: `translate(${l.x}px, ${l.y}px) rotate(${l.rotate}deg)`,\n            // The arrow's two strokes pivot on its tip; the cross turns about the centre.\n            transformOrigin: variant === \"arrow\" && i !== 1 ? \"0% 50%\" : \"50% 50%\",\n            transition: reduce ? \"none\" : \"transform 420ms cubic-bezier(.77,0,.175,1), width 420ms cubic-bezier(.77,0,.175,1)\",\n          }}\n        />\n      ))}\n    </span>\n  );\n}\n\nexport interface BurgerMenuProps extends Omit<React.ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n  theme?: MenuTheme;\n  logo?: React.ReactNode;\n  logoHref?: string;\n  items?: BurgerMenuLink[];\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** How the burger folds when open. */\n  variant?: \"cross\" | \"arrow\";\n  showNumbers?: boolean;\n  ctaLabel?: string;\n  ctaHref?: string;\n  footnote?: string;\n  onNavigate?: (item: Omit<BurgerMenuLink, \"children\">, event: React.MouseEvent<HTMLAnchorElement>) => void;\n}\n\nexport function BurgerMenu({\n  theme = \"dark\",\n  logo = \"Forme.\",\n  logoHref = \"/\",\n  items = DEFAULT_LINKS,\n  open: controlledOpen,\n  defaultOpen = false,\n  onOpenChange,\n  variant = \"cross\",\n  showNumbers = true,\n  ctaLabel = \"Let's talk\",\n  ctaHref = \"/contact\",\n  footnote = \"Good things start with a hello.\",\n  onNavigate,\n  className,\n  style,\n  ...props\n}: BurgerMenuProps) {\n  const [open, setOpenRaw] = useDisclosure(controlledOpen, defaultOpen, onOpenChange);\n  const reduce = useReducedMotion();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const panelRef = React.useRef<HTMLDivElement>(null);\n  const bodyRef = React.useRef<HTMLDivElement>(null);\n  const id = React.useId();\n  const [level, setLevel] = React.useState<string | null>(null);\n  const [hovered, setHovered] = React.useState<string | null>(null);\n  const [height, setHeight] = React.useState<number | \"auto\">(\"auto\");\n  const sub = level ? items.find((i) => i.id === level) : undefined;\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      setOpenRaw(next);\n      if (!next) {\n        setLevel(null);\n        setHovered(null);\n      }\n    },\n    [setOpenRaw],\n  );\n\n  // The panel's height follows whichever level is showing.\n  React.useLayoutEffect(() => {\n    const el = bodyRef.current;\n    if (!open || !el) return;\n    const update = () => setHeight(el.offsetHeight);\n    update();\n    const observer = new ResizeObserver(update);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [open, level]);\n\n  // Focus the first row of whichever level opens; give focus back to the trigger on close.\n  const wasOpen = React.useRef(open);\n  React.useEffect(() => {\n    if (open) {\n      const t = window.setTimeout(() => panelRef.current?.querySelector<HTMLElement>(\"[data-row]\")?.focus({ preventScroll: true }), reduce ? 0 : 60);\n      wasOpen.current = true;\n      return () => window.clearTimeout(t);\n    }\n    if (wasOpen.current) triggerRef.current?.focus({ preventScroll: true });\n    wasOpen.current = false;\n  }, [open, level, reduce]);\n\n  // Close on a click outside, Escape, or focus leaving.\n  React.useEffect(() => {\n    if (!open) return;\n    const pointer = (e: PointerEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n    };\n    const key = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        setOpen(false);\n      }\n    };\n    const focusOut = (e: FocusEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n    };\n    document.addEventListener(\"pointerdown\", pointer);\n    document.addEventListener(\"keydown\", key);\n    document.addEventListener(\"focusin\", focusOut);\n    return () => {\n      document.removeEventListener(\"pointerdown\", pointer);\n      document.removeEventListener(\"keydown\", key);\n      document.removeEventListener(\"focusin\", focusOut);\n    };\n  }, [open, setOpen]);\n\n  // Arrow keys move between rows; Right opens a second level, Left goes back.\n  const onPanelKey = (e: React.KeyboardEvent) => {\n    const rows = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(\"[data-row]\") ?? []);\n    const at = rows.indexOf(document.activeElement as HTMLElement);\n    if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n      e.preventDefault();\n      const next = e.key === \"ArrowDown\" ? (at + 1) % rows.length : (at - 1 + rows.length) % rows.length;\n      rows[next]?.focus();\n    } else if (e.key === \"ArrowLeft\" && level) {\n      e.preventDefault();\n      setLevel(null);\n    } else if (e.key === \"ArrowRight\" && !level) {\n      const el = document.activeElement as HTMLElement | null;\n      const target = el?.dataset.parent;\n      if (target) {\n        e.preventDefault();\n        setLevel(target);\n      }\n    }\n  };\n\n  const rowBase = cn(\"group relative flex w-full cursor-pointer items-center gap-4 rounded-[14px] px-4 text-left\", focus, \"focus-visible:ring-offset-0\");\n  const highlight = (key: string) =>\n    hovered === key && (\n      <motion.span layoutId={`${id}-hl`} className=\"absolute inset-0 rounded-[14px] bg-[var(--nav-soft)] ring-1 ring-[var(--nav-line)]\" transition={reduce ? { duration: 0 } : SPRING} />\n    );\n\n  return (\n    <nav ref={rootRef} {...props} aria-label={props[\"aria-label\"] ?? \"Main navigation\"} data-theme={theme} className={cn(\"@container relative z-20 text-[color:var(--nav-ink)]\", className)} style={{ ...palette(theme), ...style }}>\n      <div className=\"flex min-h-20 items-center justify-between gap-4 px-6 @[700px]:px-10\">\n        <a href={logoHref} className={cn(serif, \"text-[30px] leading-none\", focus)}>\n          {logo}\n        </a>\n        <button\n          ref={triggerRef}\n          type=\"button\"\n          onClick={() => setOpen(!open)}\n          aria-expanded={open}\n          aria-controls={id}\n          aria-label={open ? \"Close menu\" : \"Open menu\"}\n          className={cn(\n            \"flex size-11 cursor-pointer items-center justify-center rounded-full border border-[var(--nav-line)] transition-colors duration-300\",\n            open ? \"bg-[var(--nav-ink)] text-[color:var(--nav-page)]\" : \"bg-[var(--nav-page)] hover:bg-[var(--nav-soft)]\",\n            focus,\n          )}\n        >\n          <BurgerIcon open={open} variant={variant} reduce={reduce} />\n        </button>\n      </div>\n\n      <AnimatePresence>\n        {open && (\n          <motion.div\n            ref={panelRef}\n            id={id}\n            onKeyDown={onPanelKey}\n            className=\"absolute top-[74px] right-4 w-[min(calc(100%-32px),380px)] origin-top-right overflow-hidden rounded-[22px] border border-[var(--nav-line)] bg-[var(--nav-panel)] shadow-[0_24px_70px_rgba(0,0,0,.22)] backdrop-blur-xl @[700px]:right-8\"\n            initial={{ opacity: 0, scale: 0.94, y: -8, filter: \"blur(4px)\" }}\n            animate={{ opacity: 1, scale: 1, y: 0, filter: \"blur(0px)\", height }}\n            exit={{ opacity: 0, scale: 0.96, y: -6, filter: \"blur(4px)\" }}\n            transition={reduce ? { duration: 0 } : { duration: 0.42, ease: EASE, height: { duration: 0.45, ease: EASE } }}\n          >\n            <div ref={bodyRef}>\n              <AnimatePresence mode=\"popLayout\" initial={false}>\n                {!sub ? (\n                  <motion.div\n                    key=\"root\"\n                    initial={{ x: \"-30%\", opacity: 0 }}\n                    animate={{ x: 0, opacity: 1 }}\n                    exit={{ x: \"-30%\", opacity: 0 }}\n                    transition={{ duration: reduce ? 0 : 0.42, ease: EASE }}\n                  >\n                    <div className={cn(\"flex items-center justify-between px-6 pt-5 pb-2 text-[9px] tracking-[.2em] uppercase\", muted)}>\n                      <span>✦ Menu</span>\n                      <span className=\"tabular-nums\">{String(items.length).padStart(2, \"0\")}</span>\n                    </div>\n                    <ul className=\"px-2\" onMouseLeave={() => setHovered(null)}>\n                      {items.map((item, index) => {\n                        const content = (\n                          <>\n                            {highlight(item.id)}\n                            {showNumbers && <span className={cn(\"relative w-5 shrink-0 text-[10px] tabular-nums\", muted)}>{String(index + 1).padStart(2, \"0\")}</span>}\n                            <span className=\"relative min-w-0 flex-1\">\n                              <span className={cn(serif, \"block text-[30px] leading-[1.05]\")}>{item.label}</span>\n                              {item.description && <span className={cn(\"mt-0.5 block truncate text-[11px]\", muted)}>{item.description}</span>}\n                            </span>\n                            {item.badge && <span className=\"relative rounded-full border border-[var(--nav-line)] px-2 py-0.5 text-[9px]\">{item.badge}</span>}\n                            <span className={cn(\"relative flex size-7 shrink-0 items-center justify-center rounded-full border border-[var(--nav-line)] transition-transform duration-300 group-hover:translate-x-0.5\", muted)}>\n                              {item.children?.length ? <ChevronRight size={13} /> : <ArrowUpRight size={13} />}\n                            </span>\n                          </>\n                        );\n                        return (\n                          <motion.li\n                            key={item.id}\n                            initial={{ opacity: 0, y: 10 }}\n                            animate={{ opacity: 1, y: 0 }}\n                            transition={{ duration: reduce ? 0 : 0.45, ease: EASE, delay: reduce ? 0 : 0.05 + index * 0.045 }}\n                          >\n                            {item.children?.length ? (\n                              <button\n                                type=\"button\"\n                                data-row\n                                data-parent={item.id}\n                                aria-haspopup=\"true\"\n                                onClick={() => setLevel(item.id)}\n                                onMouseEnter={() => setHovered(item.id)}\n                                onFocus={() => setHovered(item.id)}\n                                className={cn(rowBase, \"py-3\")}\n                              >\n                                {content}\n                              </button>\n                            ) : (\n                              <a\n                                href={item.href}\n                                data-row\n                                onClick={(e) => {\n                                  onNavigate?.(item, e);\n                                  setOpen(false);\n                                }}\n                                onMouseEnter={() => setHovered(item.id)}\n                                onFocus={() => setHovered(item.id)}\n                                className={cn(rowBase, \"py-3\")}\n                              >\n                                {content}\n                              </a>\n                            )}\n                          </motion.li>\n                        );\n                      })}\n                    </ul>\n                    <div className=\"mt-2 flex items-center justify-between gap-3 border-t border-[var(--nav-line)] px-6 py-4\">\n                      <span className={cn(\"text-[10px]\", muted)}>{footnote}</span>\n                      {ctaLabel && (\n                        <a href={ctaHref} className={cn(\"inline-flex shrink-0 items-center gap-2 rounded-full bg-[var(--nav-ink)] px-4 py-2.5 text-xs text-[color:var(--nav-page)]\", focus)}>\n                          {ctaLabel}\n                          <ArrowUpRight size={13} />\n                        </a>\n                      )}\n                    </div>\n                  </motion.div>\n                ) : (\n                  <motion.div\n                    key={sub.id}\n                    initial={{ x: \"30%\", opacity: 0 }}\n                    animate={{ x: 0, opacity: 1 }}\n                    exit={{ x: \"30%\", opacity: 0 }}\n                    transition={{ duration: reduce ? 0 : 0.42, ease: EASE }}\n                  >\n                    <div className=\"flex items-center gap-3 px-4 pt-4 pb-1\">\n                      <button\n                        type=\"button\"\n                        onClick={() => setLevel(null)}\n                        aria-label=\"Back to menu\"\n                        className={cn(\"flex size-8 cursor-pointer items-center justify-center rounded-full border border-[var(--nav-line)] transition-colors hover:bg-[var(--nav-soft)]\", focus)}\n                      >\n                        <ArrowLeft size={14} />\n                      </button>\n                      <span className={cn(\"text-[9px] tracking-[.2em] uppercase\", muted)}>Menu / {sub.label}</span>\n                    </div>\n                    <div className=\"px-6 pt-3 pb-1\">\n                      <p className={cn(serif, \"text-[38px] leading-none\")}>{sub.label}</p>\n                      {sub.description && <p className={cn(\"mt-2 text-[11px]\", muted)}>{sub.description}</p>}\n                    </div>\n                    <ul className=\"px-2 pt-3 pb-3\" onMouseLeave={() => setHovered(null)}>\n                      {sub.children!.map((child, index) => (\n                        <motion.li\n                          key={child.id}\n                          initial={{ opacity: 0, x: 12 }}\n                          animate={{ opacity: 1, x: 0 }}\n                          transition={{ duration: reduce ? 0 : 0.4, ease: EASE, delay: reduce ? 0 : 0.08 + index * 0.04 }}\n                        >\n                          <a\n                            href={child.href}\n                            data-row\n                            onClick={(e) => {\n                              onNavigate?.(child, e);\n                              setOpen(false);\n                            }}\n                            onMouseEnter={() => setHovered(child.id)}\n                            onFocus={() => setHovered(child.id)}\n                            className={cn(rowBase, \"py-2.5\")}\n                          >\n                            {highlight(child.id)}\n                            <span className=\"relative min-w-0 flex-1\">\n                              <span className=\"block text-[14px]\">{child.label}</span>\n                              {child.description && <span className={cn(\"block truncate text-[11px]\", muted)}>{child.description}</span>}\n                            </span>\n                            {child.badge && <span className=\"relative rounded-full border border-[var(--nav-line)] px-2 py-0.5 text-[9px]\">{child.badge}</span>}\n                            <ArrowUpRight size={14} className={cn(\"relative opacity-0 transition-all duration-300 group-hover:opacity-100 group-focus-visible:opacity-100\", muted)} />\n                          </a>\n                        </motion.li>\n                      ))}\n                    </ul>\n                  </motion.div>\n                )}\n              </AnimatePresence>\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </nav>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}