{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"site-header","type":"registry:block","title":"Site header","description":"A sticky website header that turns solid on scroll, with a gliding active link, mega menu panels, and a mobile sheet.","categories":["blocks"],"dependencies":["lucide-react","motion"],"registryDependencies":["https://ui.teamofsilicons.com/r/silicon-motion-tokens.json","https://ui.teamofsilicons.com/r/segmented-control.json"],"files":[{"path":"registry/blocks/site-header/site-header.tsx","type":"registry:component","target":"@components/silicon-ui/blocks/site-header/site-header.tsx","content":"\"use client\";\n\nimport { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { AnchorHTMLAttributes, ButtonHTMLAttributes, HTMLAttributes, KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent, PointerEvent as ReactPointerEvent, ReactNode, RefObject } from \"react\";\nimport Image from \"next/image\";\nimport { AnimatePresence, LayoutGroup, motion, useIsPresent, useReducedMotion } from \"motion/react\";\nimport type { Transition, Variants } from \"motion/react\";\nimport { ArrowRight, BookOpen, Boxes, ChevronDown, History, LayoutTemplate, Menu, MessagesSquare, Palette, PanelsTopLeft, Route, X } from \"lucide-react\";\nimport SegmentedControl from \"../../segmented-control/segmented-control\";\nimport { motionTokens } from \"../../lib/motion-tokens\";\nimport { photo } from \"../../lib/media\";\nimport styles from \"./site-header.module.css\";\n\nexport type SiteHeaderVariant = \"simple\" | \"centered\" | \"mega\";\n\n/** One destination inside a mega menu panel. */\nexport interface SiteHeaderLink {\n  label: string;\n  /** One short line under the label. */\n  description?: string;\n  /** A plain decorative icon beside the label. */\n  icon?: ReactNode;\n  href?: string;\n}\n\n/** A card beside the links in a mega menu panel. */\nexport interface SiteHeaderFeature {\n  title: string;\n  description?: string;\n  href?: string;\n  image?: { src: string; alt: string };\n}\n\n/** A top level destination. With `links` and the mega variant it opens a panel; otherwise it is a plain link. */\nexport interface SiteHeaderItem {\n  /** Stable value, also used for `current`. */\n  value: string;\n  label: string;\n  href?: string;\n  links?: SiteHeaderLink[];\n  feature?: SiteHeaderFeature;\n}\n\nexport interface SiteHeaderAction {\n  label: string;\n  href?: string;\n  onClick?: () => void;\n}\n\n/** What `onNavigate` receives. */\nexport interface SiteHeaderDestination {\n  label: string;\n  href?: string;\n  /** The top level item the destination belongs to. */\n  section?: string;\n}\n\nexport interface SiteHeaderProps {\n  /** `simple` puts links beside the brand, `centered` centers them in a quiet capsule, `mega` opens panels for items with links. */\n  variant?: SiteHeaderVariant;\n  brand?: { name: string; href?: string; mark?: ReactNode };\n  items?: SiteHeaderItem[];\n  /** Value of the item that holds the current page (controlled). */\n  current?: string;\n  /** Initial current item when uncontrolled. */\n  defaultCurrent?: string;\n  /** Called when a destination inside an item is chosen, with that item's value. */\n  onCurrentChange?: (value: string) => void;\n  /** Called for every destination: items, panel links, the brand, and actions with an href. */\n  onNavigate?: (destination: SiteHeaderDestination) => void;\n  /** A quiet action before the primary one, such as Sign in. Pass null to hide it. */\n  secondaryAction?: SiteHeaderAction | null;\n  /** The one primary action at the end of the bar. Pass null to hide it. */\n  primaryAction?: SiteHeaderAction | null;\n  /** Sticks to the top of its scroll container. Defaults to true. */\n  sticky?: boolean;\n  /** The element that scrolls, when it is not the window. The header turns solid once it scrolls. */\n  scrollContainer?: RefObject<HTMLElement | null>;\n  /** Pixels of scroll before the background turns solid. Defaults to 8. */\n  scrollThreshold?: number;\n  /** Accessible name of the navigation landmark. */\n  label?: string;\n  className?: string;\n}\n\ntype Bezier = [number, number, number, number];\nconst enter = [...motionTokens.ease.enter] as Bezier;\nconst standard = [...motionTokens.ease.standard] as Bezier;\n/** Duration based springs restated as stiffness and damping, so a retarget keeps the velocity already in flight. */\nconst physical = (visualDuration: number, bounce: number): Transition => {\n  const root = 2 * Math.PI / (visualDuration * 1.2);\n  return { type: \"spring\", stiffness: root * root, damping: 2 * (1 - bounce) * root, mass: 1 };\n};\nconst GROW = physical(.44, .12), SHRINK = physical(.34, 0), GLIDE = physical(.3, .1), SLIDE = physical(.4, .06);\nconst HOVER_INTENT = 70, LEAVE_GRACE = 180, TRAVEL = 36;\n/** Matches the container query in site-header.module.css. */\nconst COLLAPSE_BELOW = 760;\n\n/** Panel content slides in from the side of the newly opened item; opening from closed drops in from the bar. */\nconst faceVariants: Variants = {\n  hidden: (direction: number) => ({ opacity: 0, x: direction * TRAVEL, y: direction ? 0 : -6, filter: `blur(${motionTokens.blur.subtle}px)` }),\n  shown: { opacity: 1, x: 0, y: 0, filter: \"blur(0px)\", transition: { x: SLIDE, y: SLIDE, opacity: { duration: motionTokens.duration.fast, ease: enter, delay: .02 }, filter: { duration: motionTokens.duration.standard, ease: enter } } },\n  gone: (direction: number) => ({ opacity: 0, x: direction * -TRAVEL * .6, filter: `blur(${motionTokens.blur.subtle}px)`, transition: { x: SLIDE, opacity: { duration: motionTokens.duration.instant, ease: standard }, filter: { duration: motionTokens.duration.instant, ease: standard } } }),\n};\nconst fadeVariants: Variants = { hidden: { opacity: 0 }, shown: { opacity: 1, transition: { duration: motionTokens.duration.fast } }, gone: { opacity: 0, transition: { duration: motionTokens.duration.instant } } };\n\nexport function SiliconMark(props: { className?: string }) {\n  return <svg className={props.className} viewBox=\"40 40 204 204\" fill=\"currentColor\" aria-hidden=\"true\">\n    <rect x=\"49\" y=\"117.9\" width=\"47.7\" height=\"47.7\" /><rect x=\"70.2\" y=\"70.2\" width=\"47.7\" height=\"47.7\" /><rect x=\"70.2\" y=\"165.6\" width=\"47.7\" height=\"47.7\" /><rect x=\"90.06\" y=\"141.75\" width=\"72.78\" height=\"72.78\" transform=\"rotate(-45 90.06 141.75)\" /><rect x=\"117.9\" y=\"49\" width=\"47.7\" height=\"47.7\" /><rect x=\"117.9\" y=\"186.8\" width=\"47.7\" height=\"47.7\" /><rect x=\"186.8\" y=\"117.9\" width=\"47.7\" height=\"47.7\" /><rect x=\"165.6\" y=\"70.2\" width=\"47.7\" height=\"47.7\" /><rect x=\"165.6\" y=\"165.6\" width=\"47.7\" height=\"47.7\" />\n  </svg>;\n}\n\nconst ICON = { size: 16, strokeWidth: 1.75, \"aria-hidden\": true } as const;\nconst curvedFacade = photo(\"curved-facade\");\n\nexport const siteHeaderExampleItems: SiteHeaderItem[] = [\n  {\n    value: \"product\", label: \"Product\",\n    links: [\n      { label: \"Components\", description: \"140 interactive React components\", icon: <Boxes {...ICON} /> },\n      { label: \"Blocks\", description: \"Complete sections, ready to ship\", icon: <PanelsTopLeft {...ICON} /> },\n      { label: \"Templates\", description: \"Starter sites with every page\", icon: <LayoutTemplate {...ICON} /> },\n      { label: \"Themes\", description: \"Tune color, radius, and motion\", icon: <Palette {...ICON} /> },\n    ],\n    feature: { title: \"What's new in 2.4\", description: \"Site headers, footers, and hero sections.\", image: { src: curvedFacade.src, alt: curvedFacade.alt } },\n  },\n  {\n    value: \"resources\", label: \"Resources\",\n    links: [\n      { label: \"Documentation\", description: \"Install, theme, and compose\", icon: <BookOpen {...ICON} /> },\n      { label: \"Guides\", description: \"Patterns for real product work\", icon: <Route {...ICON} /> },\n      { label: \"Changelog\", description: \"Every release, week by week\", icon: <History {...ICON} /> },\n      { label: \"Community\", description: \"Questions, answers, and showcases\", icon: <MessagesSquare {...ICON} /> },\n    ],\n  },\n  { value: \"pricing\", label: \"Pricing\" },\n  { value: \"customers\", label: \"Customers\" },\n];\n\nfunction useScrolled(threshold: number, container?: RefObject<HTMLElement | null>) {\n  const [scrolled, setScrolled] = useState(false);\n  useEffect(() => {\n    const node = container?.current ?? null;\n    const target: HTMLElement | Window = node ?? window;\n    const read = () => node ? node.scrollTop : window.scrollY;\n    // Turns solid past the threshold and clear again only near the top, so it never flickers at the edge.\n    const update = () => { const y = read(); setScrolled(previous => previous ? y > threshold / 2 : y > threshold); };\n    update();\n    target.addEventListener(\"scroll\", update, { passive: true });\n    return () => target.removeEventListener(\"scroll\", update);\n  }, [threshold, container]);\n  return scrolled;\n}\n\n/** A panel face reports its natural height while current; a leaving face floats out of flow and turns inert. */\nfunction Face({ direction, reduced, onHeight, children }: { direction: number; reduced: boolean; onHeight: (height: number) => void; children: ReactNode }) {\n  const ref = useRef<HTMLDivElement>(null);\n  const present = useIsPresent();\n  useLayoutEffect(() => {\n    const node = ref.current;\n    if (!node || !present) return;\n    onHeight(node.offsetHeight);\n    if (typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(() => onHeight(node.offsetHeight));\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, [present, onHeight]);\n  return <motion.div ref={ref} className={styles.face} data-face=\"\" data-leaving={present ? undefined : \"\"} inert={!present} custom={direction} variants={reduced ? fadeVariants : faceVariants} initial=\"hidden\" animate=\"shown\" exit=\"gone\">\n    {children}\n  </motion.div>;\n}\n\ntype DestinationProps = Omit<HTMLAttributes<HTMLElement>, \"onClick\" | \"children\"> & { link: { href?: string; label: string }; onChoose: (event: ReactMouseEvent) => void; children: ReactNode };\n/** Renders an anchor when the destination has an href and a button otherwise, so demos and real sites share one path. */\nfunction Destination({ link, onChoose, children, ...rest }: DestinationProps) {\n  return link.href\n    ? <a {...(rest as AnchorHTMLAttributes<HTMLAnchorElement>)} href={link.href} onClick={onChoose}>{children}</a>\n    : <button {...(rest as ButtonHTMLAttributes<HTMLButtonElement>)} type=\"button\" onClick={onChoose}>{children}</button>;\n}\n\n/**\n * A website header in three layouts. It sticks to the top and turns solid once the page scrolls, marks the current section\n * with an indicator that glides between links, opens springy mega menu panels whose content slides in from the side you\n * moved toward, and folds into a menu sheet on narrow containers.\n */\nexport const SiteHeader = forwardRef<HTMLElement, SiteHeaderProps>(function SiteHeader({\n  variant = \"mega\",\n  brand = { name: \"Silicon\" },\n  items = siteHeaderExampleItems,\n  current: currentProp,\n  defaultCurrent,\n  onCurrentChange,\n  onNavigate,\n  secondaryAction = { label: \"Sign in\" },\n  primaryAction = { label: \"Get Silicon\" },\n  sticky = true,\n  scrollContainer,\n  scrollThreshold = 8,\n  label = \"Main\",\n  className,\n}, ref) {\n  const id = useId();\n  const reduced = !!useReducedMotion();\n  const scrolled = useScrolled(scrollThreshold, scrollContainer);\n  const [innerCurrent, setInnerCurrent] = useState(defaultCurrent);\n  const current = currentProp ?? innerCurrent;\n  const [hovered, setHovered] = useState<string | null>(null);\n  const [open, setOpen] = useState<{ value: string; direction: number } | null>(null);\n  const [panel, setPanel] = useState<{ height: number | null; grow: boolean }>({ height: null, grow: true });\n  const [menuOpen, setMenuOpen] = useState(false);\n  const [expanded, setExpanded] = useState<string | null>(null);\n  const rootRef = useRef<HTMLElement | null>(null);\n  const menuButtonRef = useRef<HTMLButtonElement>(null);\n  const triggerRefs = useRef(new Map<string, HTMLButtonElement | HTMLAnchorElement>());\n  const panelRef = useRef<HTMLDivElement>(null);\n  const openTimer = useRef<number | undefined>(undefined), closeTimer = useRef<number | undefined>(undefined);\n  const focusFirst = useRef(false);\n  const hasPanels = variant === \"mega\";\n  const openItem = open ? items.find(item => item.value === open.value) : undefined;\n\n  const setRefs = useCallback((node: HTMLElement | null) => {\n    rootRef.current = node;\n    if (typeof ref === \"function\") ref(node); else if (ref) ref.current = node;\n  }, [ref]);\n\n  const clearTimers = useCallback(() => { window.clearTimeout(openTimer.current); window.clearTimeout(closeTimer.current); }, []);\n  useEffect(() => clearTimers, [clearTimers]);\n\n  const openPanel = useCallback((value: string | null) => {\n    setOpen(previous => {\n      if (!value) return null;\n      if (previous?.value === value) return previous;\n      const from = previous ? items.findIndex(item => item.value === previous.value) : -1;\n      const to = items.findIndex(item => item.value === value);\n      return { value, direction: from < 0 ? 0 : Math.sign(to - from) };\n    });\n    if (!value) setPanel({ height: null, grow: true });\n  }, [items]);\n\n  const close = useCallback((restoreFocus = false) => {\n    clearTimers();\n    const was = open?.value;\n    openPanel(null);\n    if (restoreFocus && was) triggerRefs.current.get(was)?.focus();\n  }, [open, openPanel, clearTimers]);\n\n  const closeMenu = useCallback((restoreFocus = false) => {\n    setMenuOpen(false);\n    setExpanded(null);\n    if (restoreFocus) menuButtonRef.current?.focus();\n  }, []);\n\n  const choose = useCallback((destination: SiteHeaderDestination, section: string | undefined) => {\n    if (section) {\n      if (currentProp === undefined) setInnerCurrent(section);\n      onCurrentChange?.(section);\n    }\n    onNavigate?.(destination);\n    close();\n    closeMenu();\n  }, [close, closeMenu, currentProp, onCurrentChange, onNavigate]);\n\n  // Outside presses and Escape close whichever layer is open.\n  useEffect(() => {\n    if (!open && !menuOpen) return;\n    const onPointer = (event: PointerEvent) => { if (!rootRef.current?.contains(event.target as Node)) { close(); closeMenu(); } };\n    const onKey = (event: KeyboardEvent) => { if (event.key === \"Escape\") { if (open) close(true); else closeMenu(true); } };\n    document.addEventListener(\"pointerdown\", onPointer);\n    document.addEventListener(\"keydown\", onKey);\n    return () => { document.removeEventListener(\"pointerdown\", onPointer); document.removeEventListener(\"keydown\", onKey); };\n  }, [open, menuOpen, close, closeMenu]);\n\n  // The sheet belongs to narrow layouts: widening the container closes it, and it holds the page still while open.\n  useEffect(() => {\n    const node = rootRef.current;\n    if (!node || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(([entry]) => {\n      if (!entry) return;\n      if (entry.contentRect.width >= COLLAPSE_BELOW) { setMenuOpen(false); setExpanded(null); } else setOpen(null);\n    });\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, []);\n  useEffect(() => {\n    if (!menuOpen) return;\n    const scroller: HTMLElement = scrollContainer?.current ?? document.documentElement;\n    const previous = scroller.style.getPropertyValue(\"overflow\");\n    scroller.style.setProperty(\"overflow\", \"hidden\");\n    return () => { if (previous) scroller.style.setProperty(\"overflow\", previous); else scroller.style.removeProperty(\"overflow\"); };\n  }, [menuOpen, scrollContainer]);\n\n  useEffect(() => {\n    if (!open || !focusFirst.current) return;\n    focusFirst.current = false;\n    const frame = requestAnimationFrame(() => panelRef.current?.querySelector<HTMLElement>(\"[data-panel-link]\")?.focus());\n    return () => cancelAnimationFrame(frame);\n  }, [open]);\n\n  function onTriggerPointerEnter(event: ReactPointerEvent, value: string) {\n    if (event.pointerType !== \"mouse\") return;\n    window.clearTimeout(closeTimer.current);\n    window.clearTimeout(openTimer.current);\n    if (open) openPanel(value);\n    else openTimer.current = window.setTimeout(() => openPanel(value), HOVER_INTENT);\n  }\n  function onRegionPointerLeave(event: ReactPointerEvent) {\n    if (event.pointerType !== \"mouse\") return;\n    window.clearTimeout(openTimer.current);\n    closeTimer.current = window.setTimeout(() => openPanel(null), LEAVE_GRACE);\n  }\n  function onRegionPointerEnter(event: ReactPointerEvent) {\n    if (event.pointerType === \"mouse\") window.clearTimeout(closeTimer.current);\n  }\n\n  function onNavKeyDown(event: ReactKeyboardEvent<HTMLElement>) {\n    if (event.key !== \"ArrowLeft\" && event.key !== \"ArrowRight\") return;\n    const triggers = Array.from(event.currentTarget.querySelectorAll<HTMLElement>(\"[data-nav-item]\"));\n    const index = triggers.indexOf(document.activeElement as HTMLElement);\n    if (index < 0) return;\n    event.preventDefault();\n    const nextIndex = (index + (event.key === \"ArrowRight\" ? 1 : -1) + triggers.length) % triggers.length;\n    triggers[nextIndex]!.focus();\n    if (open) { const item = items[nextIndex]; openPanel(item && hasPanels && item.links?.length ? item.value : null); }\n  }\n  function onTriggerKeyDown(event: ReactKeyboardEvent, value: string) {\n    if (event.key === \"ArrowDown\") { event.preventDefault(); focusFirst.current = true; openPanel(value); if (open?.value === value) panelRef.current?.querySelector<HTMLElement>(\"[data-panel-link]\")?.focus(); }\n  }\n  function onPanelKeyDown(event: ReactKeyboardEvent<HTMLDivElement>) {\n    if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\" && event.key !== \"Home\" && event.key !== \"End\") return;\n    const unique = Array.from(event.currentTarget.querySelectorAll<HTMLElement>(\"[data-face]:not([data-leaving]) [data-panel-link]\"));\n    if (!unique.length) return;\n    event.preventDefault();\n    const index = unique.indexOf(document.activeElement as HTMLElement);\n    const next = event.key === \"Home\" ? 0 : event.key === \"End\" ? unique.length - 1 : event.key === \"ArrowDown\" ? Math.min(index + 1, unique.length - 1) : index - 1;\n    if (next < 0) { close(true); return; }\n    unique[next]?.focus();\n  }\n\n  // Growing carries a little life; shrinking settles without overshoot.\n  const onHeight = useCallback((height: number) => setPanel(previous => previous.height === height ? previous : { height, grow: previous.height === null || height > previous.height }), []);\n\n  const actionNode = (action: SiteHeaderAction, kind: \"secondary\" | \"primary\", extra = \"\") => {\n    const onClick = () => { action.onClick?.(); if (action.href) onNavigate?.({ label: action.label, href: action.href }); closeMenu(); };\n    const cls = `${styles.action} ${styles[kind]} ${extra}`;\n    return action.href ? <a className={cls} href={action.href} onClick={onClick}>{action.label}</a> : <button type=\"button\" className={cls} onClick={onClick}>{action.label}</button>;\n  };\n\n  const brandNode = <Destination link={{ label: brand.name, href: brand.href }} className={styles.brand} onChoose={() => { onNavigate?.({ label: brand.name, href: brand.href }); close(); closeMenu(); }}>\n    {brand.mark ?? <SiliconMark className={styles.brandMark} />}<span>{brand.name}</span>\n  </Destination>;\n\n  return <header\n    ref={setRefs}\n    className={[styles.header, sticky ? styles.sticky : \"\", className].filter(Boolean).join(\" \")}\n    data-variant={variant}\n    data-scrolled={scrolled || menuOpen || !!open ? \"\" : undefined}\n  >\n    <div className={styles.inner} onPointerLeave={onRegionPointerLeave} onPointerEnter={onRegionPointerEnter}>\n      <div className={styles.bar}>\n        <div className={styles.brandSlot}>{brandNode}</div>\n        <LayoutGroup id={id}>\n          <nav className={styles.nav} aria-label={label} onKeyDown={onNavKeyDown} onPointerLeave={() => setHovered(null)}>\n            <ul className={styles.navList}>\n              {items.map(item => {\n                const isCurrent = current === item.value;\n                const withPanel = hasPanels && !!item.links?.length;\n                const isOpen = open?.value === item.value;\n                const panelId = `${id}-panel`;\n                const common = {\n                  className: styles.navItem,\n                  \"data-nav-item\": \"\",\n                  \"data-current\": isCurrent ? \"\" : undefined,\n                  \"data-open\": isOpen ? \"\" : undefined,\n                  onPointerEnter: (event: ReactPointerEvent) => { if (event.pointerType === \"mouse\") setHovered(item.value); if (withPanel) onTriggerPointerEnter(event, item.value); else if (event.pointerType === \"mouse\" && open) closeTimer.current = window.setTimeout(() => openPanel(null), LEAVE_GRACE); },\n                  onFocus: () => setHovered(null),\n                };\n                const decorations = <>\n                  {hovered === item.value && variant !== \"centered\" && <motion.span key={`hover-${variant}`} layoutId={`hover-${variant}`} className={styles.hover} transition={reduced ? { duration: 0 } : GLIDE} aria-hidden=\"true\" />}\n                  {isCurrent && <motion.span key={`current-${variant}`} layoutId={`current-${variant}`} className={styles.indicator} transition={reduced ? { duration: 0 } : motionTokens.spring.morph} aria-hidden=\"true\" />}\n                </>;\n                return <li key={item.value} className={styles.navCell}>\n                  {withPanel\n                    ? <button\n                        {...common}\n                        ref={(node: HTMLButtonElement | null) => { if (node) triggerRefs.current.set(item.value, node); else triggerRefs.current.delete(item.value); }}\n                        type=\"button\"\n                        aria-expanded={isOpen}\n                        aria-controls={isOpen ? panelId : undefined}\n                        onClick={() => { clearTimers(); openPanel(isOpen ? null : item.value); }}\n                        onKeyDown={event => onTriggerKeyDown(event, item.value)}\n                      >\n                        {decorations}\n                        <span className={styles.navLabel}>{item.label}</span>\n                        <ChevronDown className={styles.chevron} size={14} strokeWidth={2} aria-hidden=\"true\" />\n                      </button>\n                    : <Destination\n                        link={item}\n                        {...common}\n                        aria-current={isCurrent ? \"page\" : undefined}\n                        onChoose={() => choose({ label: item.label, href: item.href, section: item.value }, item.value)}\n                      >\n                        {decorations}\n                        <span className={styles.navLabel}>{item.label}</span>\n                      </Destination>}\n                </li>;\n              })}\n            </ul>\n          </nav>\n        </LayoutGroup>\n        <div className={styles.actions}>\n          {secondaryAction && actionNode(secondaryAction, \"secondary\", styles.wideOnly)}\n          {primaryAction && actionNode(primaryAction, \"primary\")}\n          <button ref={menuButtonRef} type=\"button\" className={styles.menuButton} aria-expanded={menuOpen} aria-controls={`${id}-sheet`} aria-label={menuOpen ? \"Close menu\" : \"Open menu\"} onClick={() => { if (menuOpen) closeMenu(); else setMenuOpen(true); }}>\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              <motion.span key={menuOpen ? \"close\" : \"open\"} className={styles.menuIcon} initial={reduced ? { opacity: 0 } : { opacity: 0, rotate: menuOpen ? -45 : 45, scale: .8 }} animate={{ opacity: 1, rotate: 0, scale: 1 }} exit={reduced ? { opacity: 0 } : { opacity: 0, rotate: menuOpen ? 45 : -45, scale: .8 }} transition={reduced ? { duration: 0 } : { ...motionTokens.spring.snappy, opacity: { duration: motionTokens.duration.instant } }}>\n                {menuOpen ? <X size={20} strokeWidth={1.75} aria-hidden=\"true\" /> : <Menu size={20} strokeWidth={1.75} aria-hidden=\"true\" />}\n              </motion.span>\n            </AnimatePresence>\n          </button>\n        </div>\n      </div>\n\n      {hasPanels && <AnimatePresence>\n        {openItem?.links && <motion.div\n          key=\"panel\"\n          id={`${id}-panel`}\n          ref={panelRef}\n          className={styles.panel}\n          role=\"region\"\n          aria-label={openItem.label}\n          onKeyDown={onPanelKeyDown}\n          initial={reduced ? { opacity: 0 } : { opacity: 0, y: -6, scale: .985 }}\n          animate={{ opacity: 1, y: 0, scale: 1, height: panel.height ?? \"auto\" }}\n          exit={reduced ? { opacity: 0, transition: { duration: motionTokens.duration.instant } } : { opacity: 0, y: -4, scale: .99, transition: { duration: motionTokens.duration.exit, ease: standard } }}\n          transition={reduced ? { duration: 0 } : { height: panel.grow ? GROW : SHRINK, y: GROW, scale: GROW, opacity: { duration: motionTokens.duration.fast, ease: enter } }}\n        >\n          <AnimatePresence initial={false} custom={open?.direction ?? 0}>\n            <Face key={openItem.value} direction={open?.direction ?? 0} reduced={reduced} onHeight={onHeight}>\n              <div className={styles.faceGrid} data-featured={openItem.feature ? \"\" : undefined}>\n                <ul className={styles.panelLinks}>\n                  {openItem.links.map(link => <li key={link.label}>\n                    <Destination link={link} className={styles.panelLink} data-panel-link=\"\" onChoose={() => choose({ label: link.label, href: link.href, section: openItem.value }, openItem.value)}>\n                      {link.icon && <span className={styles.panelIcon}>{link.icon}</span>}\n                      <span className={styles.panelText}><span>{link.label}</span>{link.description && <span>{link.description}</span>}</span>\n                    </Destination>\n                  </li>)}\n                </ul>\n                {openItem.feature && <Destination link={{ label: openItem.feature.title, href: openItem.feature.href }} className={styles.feature} data-panel-link=\"\" onChoose={() => choose({ label: openItem.feature!.title, href: openItem.feature!.href, section: openItem.value }, openItem.value)}>\n                  {openItem.feature.image && <span className={styles.featureImage}><Image src={openItem.feature.image.src} alt={openItem.feature.image.alt} fill sizes=\"260px\" /></span>}\n                  <span className={styles.featureTitle}>{openItem.feature.title}<ArrowRight size={14} strokeWidth={2} aria-hidden=\"true\" /></span>\n                  {openItem.feature.description && <span className={styles.featureText}>{openItem.feature.description}</span>}\n                </Destination>}\n              </div>\n            </Face>\n          </AnimatePresence>\n        </motion.div>}\n      </AnimatePresence>}\n    </div>\n\n    <AnimatePresence>\n      {menuOpen && <>\n        <motion.div key=\"scrim\" className={styles.scrim} onClick={() => closeMenu()} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: reduced ? 0 : motionTokens.duration.standard, ease: standard }} aria-hidden=\"true\" />\n        <motion.div\n          key=\"sheet\"\n          id={`${id}-sheet`}\n          className={styles.sheet}\n          initial={reduced ? { opacity: 0 } : { height: 0 }}\n          animate={reduced ? { opacity: 1 } : { height: \"auto\" }}\n          exit={reduced ? { opacity: 0 } : { height: 0, transition: SHRINK }}\n          transition={reduced ? { duration: 0 } : GROW}\n        >\n          <nav className={styles.sheetInner} aria-label={label}>\n            <ul className={styles.sheetList}>\n              {items.map((item, index) => {\n                const isCurrent = current === item.value;\n                const group = !!item.links?.length && variant === \"mega\";\n                const isExpanded = expanded === item.value;\n                const rowMotion = { initial: reduced ? false : { opacity: 0, y: -6 }, animate: { opacity: 1, y: 0 }, transition: { duration: motionTokens.duration.standard, ease: enter, delay: reduced ? 0 : .04 + index * motionTokens.stagger.item } } as const;\n                return <motion.li key={item.value} className={styles.sheetItem} {...rowMotion}>\n                  {group ? <>\n                    <button type=\"button\" className={styles.sheetRow} data-current={isCurrent ? \"\" : undefined} aria-expanded={isExpanded} aria-controls={`${id}-group-${item.value}`} onClick={() => setExpanded(isExpanded ? null : item.value)}>\n                      <span>{item.label}</span><ChevronDown className={styles.sheetChevron} size={18} strokeWidth={1.75} aria-hidden=\"true\" />\n                    </button>\n                    <AnimatePresence initial={false}>\n                      {isExpanded && <motion.div key=\"group\" id={`${id}-group-${item.value}`} className={styles.sheetGroup} initial={reduced ? { opacity: 0 } : { height: 0, opacity: 0 }} animate={reduced ? { opacity: 1 } : { height: \"auto\", opacity: 1 }} exit={reduced ? { opacity: 0 } : { height: 0, opacity: 0 }} transition={reduced ? { duration: 0 } : { height: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.fast } }}>\n                        <ul>{item.links!.map(link => <li key={link.label}>\n                          <Destination link={link} className={styles.sheetLink} onChoose={() => choose({ label: link.label, href: link.href, section: item.value }, item.value)}>\n                            {link.icon}<span>{link.label}</span>\n                          </Destination>\n                        </li>)}</ul>\n                      </motion.div>}\n                    </AnimatePresence>\n                  </> : <Destination link={item} className={styles.sheetRow} data-current={isCurrent ? \"\" : undefined} aria-current={isCurrent ? \"page\" : undefined} onChoose={() => choose({ label: item.label, href: item.href, section: item.value }, item.value)}>\n                    <span>{item.label}</span>{isCurrent && <span className={styles.sheetDot} aria-hidden=\"true\" />}\n                  </Destination>}\n                </motion.li>;\n              })}\n            </ul>\n            {(secondaryAction || primaryAction) && <motion.div className={styles.sheetActions} initial={reduced ? false : { opacity: 0, y: -6 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: motionTokens.duration.standard, ease: enter, delay: reduced ? 0 : .04 + items.length * motionTokens.stagger.item }}>\n              {secondaryAction && actionNode(secondaryAction, \"secondary\")}\n              {primaryAction && actionNode(primaryAction, \"primary\")}\n            </motion.div>}\n          </nav>\n        </motion.div>\n      </>}\n    </AnimatePresence>\n  </header>;\n});\n\nSiteHeader.displayName = \"SiteHeader\";\n\nconst variantOptions = [{ value: \"mega\", label: \"Mega menu\" }, { value: \"simple\", label: \"Simple\" }, { value: \"centered\", label: \"Centered\" }];\nconst pageLabels: Record<string, string> = { product: \"Product\", resources: \"Resources\", pricing: \"Pricing\", customers: \"Customers\" };\n\n/** Preview: the header inside a small scrolling page, with a switch between its three layouts. */\nexport function SiteHeaderBlock({ variant: initial = \"mega\" }: { variant?: SiteHeaderVariant }) {\n  const [variant, setVariant] = useState<SiteHeaderVariant>(initial);\n  const [current, setCurrent] = useState(\"product\");\n  const [last, setLast] = useState<string | null>(null);\n  const scrollRef = useRef<HTMLDivElement>(null);\n  return <div className={styles.preview}>\n    <SegmentedControl label=\"Header layout\" options={variantOptions} value={variant} onValueChange={value => setVariant(value as SiteHeaderVariant)} />\n    <div className={styles.frame} ref={scrollRef}>\n      <SiteHeader\n        variant={variant}\n        current={current}\n        onCurrentChange={setCurrent}\n        onNavigate={destination => setLast(destination.label)}\n        scrollContainer={scrollRef}\n        secondaryAction={{ label: \"Sign in\", onClick: () => setLast(\"Sign in\") }}\n        primaryAction={{ label: \"Get Silicon\", onClick: () => setLast(\"Get Silicon\") }}\n      />\n      <div className={styles.page}>\n        <div className={styles.pageHero}>\n          <h2>{pageLabels[current] ?? \"Silicon\"}</h2>\n          <p className={styles.srOnly} aria-live=\"polite\">{last ? `Opened ${last}` : \"\"}</p>\n        </div>\n        <div className={styles.pageRows} aria-hidden=\"true\">\n          {Array.from({ length: 6 }, (_, index) => <div key={index} className={styles.pageRow}><span /><span /><span /></div>)}\n        </div>\n      </div>\n    </div>\n  </div>;\n}\n\nexport default SiteHeaderBlock;\n"},{"path":"registry/blocks/site-header/site-header.module.css","type":"registry:component","target":"@components/silicon-ui/blocks/site-header/site-header.module.css","content":"/* The header is its own size container, so the layout folds by the space it has rather than the viewport. */\n.header { position: relative; z-index: var(--layer-sticky); container: site-header / inline-size; border-bottom: 1px solid transparent; background: transparent; color: var(--foreground); font-family: var(--font-body); letter-spacing: var(--tracking-body); transition: background-color var(--duration-standard) var(--ease-standard), border-color var(--duration-standard) var(--ease-standard), box-shadow var(--duration-standard) var(--ease-standard); }\n.sticky { position: sticky; top: 0; }\n.header[data-scrolled] { border-bottom-color: var(--border); background: var(--background); box-shadow: var(--shadow-resting); }\n\n.inner { position: relative; max-width: 1200px; margin: 0 auto; padding: 0 var(--space-section); }\n.bar { display: flex; height: 64px; align-items: center; gap: var(--space-related); }\n.header[data-variant=\"centered\"] .bar { display: grid; grid-template-columns: 1fr auto 1fr; }\n.brandSlot { display: flex; min-width: 0; }\n.brand { display: inline-flex; align-items: center; gap: var(--space-related); border: 0; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: var(--space-related) var(--space-related) var(--space-related) 0; background: none; color: var(--foreground); font: inherit; font-size: var(--text-base); font-weight: var(--weight-medium); text-decoration: none; cursor: pointer; }\n.brandMark { width: 22px; height: 22px; flex: none; }\n\n.nav { min-width: 0; margin-left: var(--space-inset); }\n.header[data-variant=\"centered\"] .nav { margin: 0; }\n.navList { display: flex; align-items: center; gap: var(--space-hair); margin: 0; padding: 0; list-style: none; }\n.header[data-variant=\"centered\"] .navList { padding: var(--space-tight); border: 1px solid var(--border); border-radius: var(--radius-full); corner-shape: round; background: var(--surface-muted); }\n.navCell { display: flex; }\n.navItem { position: relative; isolation: isolate; display: inline-flex; height: 36px; align-items: center; gap: var(--space-tight); border: 0; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: 0 var(--space-group); background: none; color: var(--text-secondary); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); text-decoration: none; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard); }\n.header[data-variant=\"centered\"] .navItem { height: 32px; border-radius: var(--radius-full); corner-shape: round; padding: 0 var(--space-inset); }\n.navItem:is([data-current], [data-open]) { color: var(--foreground); }\n@media (hover: hover) and (pointer: fine) { .navItem:hover { color: var(--foreground); } }\n.navLabel { position: relative; }\n.chevron { color: var(--text-muted); transition: transform var(--duration-standard) var(--ease-standard); }\n.navItem[data-open] .chevron { transform: rotate(180deg); }\n.hover { position: absolute; z-index: -1; inset: 0; border-radius: inherit; corner-shape: inherit; background: var(--surface-muted); }\n.indicator { position: absolute; right: var(--space-group); bottom: var(--space-tight); left: var(--space-group); height: 2px; border-radius: var(--radius-full); corner-shape: round; background: var(--accent); }\n.navItem:has(.chevron) .indicator { right: calc(var(--space-group) + var(--space-comfort)); }\n.header[data-variant=\"centered\"] .indicator { z-index: -1; inset: 0; height: auto; border: 1px solid var(--border); border-radius: inherit; corner-shape: inherit; background: var(--surface); box-shadow: var(--shadow-resting); }\n\n.actions { display: flex; align-items: center; gap: var(--space-related); margin-left: auto; }\n.header[data-variant=\"centered\"] .actions { justify-self: end; }\n.action { display: inline-flex; height: 36px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: 0 var(--space-inset); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); text-decoration: none; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard), opacity var(--duration-fast) var(--ease-standard); }\n.action:active { transform: scale(.97); }\n.secondary { background: none; color: var(--text-secondary); }\n.primary { background: var(--foreground); color: var(--background); }\n@media (hover: hover) and (pointer: fine) {\n  .secondary:hover { background: var(--surface-muted); color: var(--foreground); }\n  .primary:hover { opacity: .9; }\n}\n.menuButton { position: relative; display: none; width: 40px; height: 40px; place-items: center; border: 0; border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: none; color: var(--foreground); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color var(--duration-fast) var(--ease-standard); }\n.menuButton:active { background: var(--surface-muted); }\n.menuIcon { display: grid; place-items: center; }\n\n/* Mega menu panel: one surface whose height springs to each section's content. */\n.panel { position: absolute; top: calc(100% - var(--space-tight)); right: var(--space-section); left: var(--space-section); overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-container); corner-shape: var(--corner-shape); background: var(--surface-raised); box-shadow: var(--shadow-floating); transform-origin: 50% 0; }\n.face { position: relative; padding: var(--space-group); }\n.face[data-leaving] { position: absolute; top: 0; right: 0; left: 0; pointer-events: none; }\n.faceGrid { display: grid; gap: var(--space-related); }\n.faceGrid[data-featured] { grid-template-columns: minmax(0, 1fr) minmax(200px, 260px); }\n.panelLinks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-hair); margin: 0; padding: 0; list-style: none; }\n.panelLink { display: flex; width: 100%; height: 100%; align-items: flex-start; gap: var(--space-group); border: 0; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: var(--space-group); background: none; color: var(--foreground); font: inherit; text-align: left; text-decoration: none; cursor: pointer; transition: background-color var(--duration-fast) var(--ease-standard); }\n.panelLink:focus-visible, .feature:focus-visible { background: var(--surface-muted); }\n.panelIcon { display: flex; flex: none; margin-top: var(--space-hair); color: var(--text-secondary); }\n.panelText { display: grid; gap: var(--space-hair); min-width: 0; }\n.panelText > span:first-child { font-size: var(--text-sm); font-weight: var(--weight-medium); }\n.panelText > span:last-child:not(:first-child) { color: var(--text-muted); font-size: var(--text-sm); }\n.feature { display: grid; align-content: start; gap: var(--space-related); border: 0; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: var(--space-related) var(--space-related) var(--space-group); background: var(--surface-muted); color: var(--foreground); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }\n.featureImage { position: relative; display: block; overflow: hidden; aspect-ratio: 16 / 10; margin-bottom: var(--space-tight); border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: var(--border); }\n.featureImage img { object-fit: cover; transition: transform var(--duration-expressive) var(--ease-standard); }\n.featureTitle { display: inline-flex; align-items: center; gap: var(--space-related); padding: 0 var(--space-tight); font-size: var(--text-sm); font-weight: var(--weight-medium); }\n.featureTitle svg { color: var(--text-muted); transition: transform var(--duration-fast) var(--ease-standard); }\n.featureText { padding: 0 var(--space-tight); color: var(--text-muted); font-size: var(--text-sm); }\n@media (hover: hover) and (pointer: fine) {\n  .panelLink:hover { background: var(--surface-muted); }\n  .feature:hover .featureImage img { transform: scale(1.03); }\n  .feature:hover .featureTitle svg { transform: translateX(2px); }\n}\n\n/* Mobile sheet: drops from the bar and pushes nothing; the scrim closes it. */\n.scrim { position: absolute; top: 100%; right: 0; left: 0; height: 100dvh; background: var(--scrim-soft); }\n.sheet { position: absolute; top: 100%; right: 0; left: 0; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--background); }\n/* --site-header-sheet-max lets a header inside a fixed height scroller keep its actions in view. */\n.sheetInner { max-height: var(--site-header-sheet-max, calc(100dvh - 65px)); overflow-y: auto; overscroll-behavior: contain; padding: var(--space-related) var(--space-inset) var(--space-comfort); }\n.sheetList { margin: 0; padding: 0; list-style: none; }\n.sheetItem { border-bottom: 1px solid var(--border-subtle); }\n.sheetRow { display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: space-between; gap: var(--space-group); border: 0; padding: 0 var(--space-tight); background: none; color: var(--foreground); font: inherit; font-size: var(--text-base); font-weight: var(--weight-medium); text-align: left; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }\n.sheetChevron { color: var(--text-muted); transition: transform var(--duration-standard) var(--ease-standard); }\n.sheetRow[aria-expanded=\"true\"] .sheetChevron { transform: rotate(180deg); }\n.sheetDot { width: 6px; height: 6px; border-radius: 50%; corner-shape: round; background: var(--accent); }\n.sheetGroup { overflow: hidden; }\n.sheetGroup ul { display: grid; margin: 0; padding: 0 0 var(--space-group); list-style: none; }\n.sheetLink { display: flex; width: 100%; min-height: 44px; align-items: center; gap: var(--space-group); border: 0; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: 0 var(--space-related); background: none; color: var(--text-secondary); font: inherit; font-size: var(--text-sm); text-align: left; text-decoration: none; cursor: pointer; }\n.sheetLink:active { background: var(--surface-muted); color: var(--foreground); }\n.sheetActions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-related); margin-top: var(--space-comfort); }\n.sheetActions .action { height: var(--control-height-md); }\n.sheetActions .secondary { border-color: var(--border); }\n\n@container site-header (max-width: 759px) {\n  .inner { padding: 0 var(--space-inset); }\n  .nav, .wideOnly, .panel { display: none; }\n  .menuButton { display: grid; }\n  .header[data-variant=\"centered\"] .bar { display: flex; }\n}\n@container site-header (min-width: 760px) {\n  .sheet, .scrim { display: none; }\n}\n\n/* Preview frame: a small page that scrolls under the header. */\n.preview { display: grid; width: 100%; justify-items: center; gap: var(--space-inset); }\n.frame { position: relative; width: 100%; height: 520px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: var(--background); container-type: inline-size; --site-header-sheet-max: calc(520px - 67px); }\n.page { margin-top: calc(var(--space-stage) * -1); }\n.pageHero { display: grid; justify-items: center; gap: var(--space-group); padding: calc(var(--space-screen) + var(--space-page)) var(--space-section) var(--space-screen); background: var(--silicon-gradient-soft, var(--surface-muted)); text-align: center; }\n.pageHero h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-3xl); font-weight: var(--weight-medium); letter-spacing: var(--tracking-display); line-height: var(--leading-display); }\n.pageHero p { max-width: 420px; margin: 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: var(--leading-body); }\n.pageRows { display: grid; gap: var(--space-group); padding: var(--space-section); }\n.pageRow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-group); }\n.pageRow span { height: 120px; border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: var(--surface-muted); }\n@container (max-width: 520px) { .pageRow { grid-template-columns: 1fr; } .pageRow span:not(:first-child) { display: none; } .pageHero { padding: calc(var(--space-screen) + var(--space-block)) var(--space-inset) var(--space-stage); } }\n\n@media (prefers-reduced-motion: reduce) {\n  .header, .navItem, .chevron, .action, .panelLink, .featureImage img, .featureTitle svg, .sheetChevron { transition: none; }\n  .action:active { transform: none; }\n}\n\n.srOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n"},{"path":"lib/media.ts","type":"registry:lib","target":"@components/silicon-ui/lib/media.ts","content":"/**\n * Shared demo media. Files live in `public/media/`, credits in `public/media/CREDITS.md`.\n * Portraits are 400 px squares; photos are 1600 px on the long side.\n */\n\nexport interface MediaPerson {\n  id: string;\n  name: string;\n  role?: string;\n  src: string;\n}\n\nexport interface MediaPhoto {\n  id: string;\n  alt: string;\n  src: string;\n  width: number;\n  height: number;\n}\n\nexport const people = [\n  { id: \"emma-collins\", name: \"Emma Collins\", role: \"Product designer\", src: \"/media/people/emma-collins.jpg\" },\n  { id: \"marcus-johnson\", name: \"Marcus Johnson\", role: \"Frontend engineer\", src: \"/media/people/marcus-johnson.jpg\" },\n  { id: \"jasmine-brooks\", name: \"Jasmine Brooks\", role: \"Design lead\", src: \"/media/people/jasmine-brooks.jpg\" },\n  { id: \"olivia-bennett\", name: \"Olivia Bennett\", role: \"Platform engineer\", src: \"/media/people/olivia-bennett.jpg\" },\n  { id: \"sofia-ramirez\", name: \"Sofia Ramirez\", role: \"Operations lead\", src: \"/media/people/sofia-ramirez.jpg\" },\n  { id: \"ryan-sullivan\", name: \"Ryan Sullivan\", role: \"Account executive\", src: \"/media/people/ryan-sullivan.jpg\" },\n  { id: \"hannah-walsh\", name: \"Hannah Walsh\", role: \"Customer success\", src: \"/media/people/hannah-walsh.jpg\" },\n  { id: \"chloe-nguyen\", name: \"Chloe Nguyen\", role: \"Data analyst\", src: \"/media/people/chloe-nguyen.jpg\" },\n  { id: \"ava-mitchell\", name: \"Ava Mitchell\", role: \"Marketing manager\", src: \"/media/people/ava-mitchell.jpg\" },\n  { id: \"daniel-kim\", name: \"Daniel Kim\", role: \"Backend engineer\", src: \"/media/people/daniel-kim.jpg\" },\n  { id: \"jordan-reyes\", name: \"Jordan Reyes\", role: \"Support specialist\", src: \"/media/people/jordan-reyes.jpg\" },\n  { id: \"mateo-alvarez\", name: \"Mateo Alvarez\", role: \"Mobile engineer\", src: \"/media/people/mateo-alvarez.jpg\" },\n  { id: \"tyler-hayes\", name: \"Tyler Hayes\", role: \"Sales lead\", src: \"/media/people/tyler-hayes.jpg\" },\n  { id: \"andre-williams\", name: \"Andre Williams\", role: \"Finance partner\", src: \"/media/people/andre-williams.jpg\" },\n  { id: \"nathan-cole\", name: \"Nathan Cole\", role: \"Engineering manager\", src: \"/media/people/nathan-cole.jpg\" },\n  { id: \"diane-foster\", name: \"Diane Foster\", role: \"Chief operating officer\", src: \"/media/people/diane-foster.jpg\" },\n] as const satisfies readonly MediaPerson[];\n\nexport const photos = [\n  { id: \"lounge-chair\", alt: \"A woven oak lounge chair with a sheepskin and linen cushion on a concrete floor\", src: \"/media/photos/lounge-chair.jpg\", width: 1280, height: 1600 },\n  { id: \"table-lamp\", alt: \"A white mushroom table lamp glowing beside books and a small vase\", src: \"/media/photos/table-lamp.jpg\", width: 1600, height: 900 },\n  { id: \"linen-throw\", alt: \"Folded natural linen throws with fringed edges in soft window light\", src: \"/media/photos/linen-throw.jpg\", width: 1067, height: 1600 },\n  { id: \"glass-carafe\", alt: \"A hand pouring water from a ribbed glass carafe into tumblers\", src: \"/media/photos/glass-carafe.jpg\", width: 1280, height: 1600 },\n  { id: \"stoneware-cups\", alt: \"Two speckled stoneware cups with a lid on a pale table\", src: \"/media/photos/stoneware-cups.jpg\", width: 1067, height: 1600 },\n  { id: \"stacked-bowls\", alt: \"Two stacked speckled ceramic bowls against a dark wall\", src: \"/media/photos/stacked-bowls.jpg\", width: 1600, height: 1067 },\n  { id: \"ceramic-lamp\", alt: \"A sculptural ceramic lamp with a linen shade on a walnut sideboard\", src: \"/media/photos/ceramic-lamp.jpg\", width: 1067, height: 1600 },\n  { id: \"living-room\", alt: \"A bright living room with timber beams, arched windows, and cream sofas\", src: \"/media/photos/living-room.jpg\", width: 1200, height: 1600 },\n  { id: \"sunroom\", alt: \"A sunroom with a round dining table, plants, and windows on three sides\", src: \"/media/photos/sunroom.jpg\", width: 1600, height: 1067 },\n  { id: \"home-office\", alt: \"A home office with a wooden desk and deep green walls\", src: \"/media/photos/home-office.jpg\", width: 1600, height: 1200 },\n  { id: \"reading-chair\", alt: \"A grey armchair and ottoman with a knit throw in a dark green room\", src: \"/media/photos/reading-chair.jpg\", width: 1600, height: 900 },\n  { id: \"bedroom\", alt: \"A made bed with striped linen pillows against an oak headboard\", src: \"/media/photos/bedroom.jpg\", width: 1067, height: 1600 },\n  { id: \"restaurant\", alt: \"A warm restaurant dining room with woven pendant lights and a tree\", src: \"/media/photos/restaurant.jpg\", width: 1067, height: 1600 },\n  { id: \"wine-bar\", alt: \"A glass carafe of red wine on a bar table in low evening light\", src: \"/media/photos/wine-bar.jpg\", width: 1600, height: 1067 },\n  { id: \"concert-hall\", alt: \"Curved stainless steel panels of the Walt Disney Concert Hall against a blue sky\", src: \"/media/photos/concert-hall.jpg\", width: 1600, height: 1143 },\n  { id: \"curved-facade\", alt: \"A white tiled building facade with curved balconies\", src: \"/media/photos/curved-facade.jpg\", width: 1600, height: 1067 },\n  { id: \"pool-house\", alt: \"A modern glass house beside a long pool under a clear sky\", src: \"/media/photos/pool-house.jpg\", width: 1600, height: 900 },\n  { id: \"terracotta-waves\", alt: \"Wavy terracotta walls rising toward a blue sky\", src: \"/media/photos/terracotta-waves.jpg\", width: 1067, height: 1600 },\n  { id: \"mountain-ridges\", alt: \"Layered mountain ridges under a warm evening sky\", src: \"/media/photos/mountain-ridges.jpg\", width: 1600, height: 1068 },\n  { id: \"alpine-lake\", alt: \"A calm alpine lake reflecting a rocky peak at golden hour\", src: \"/media/photos/alpine-lake.jpg\", width: 1067, height: 1600 },\n  { id: \"coastline\", alt: \"A long coastline with waves rolling onto a beach below green cliffs\", src: \"/media/photos/coastline.jpg\", width: 1200, height: 1600 },\n  { id: \"sea-at-dusk\", alt: \"A calm sea at dusk with a low island on the horizon\", src: \"/media/photos/sea-at-dusk.jpg\", width: 1067, height: 1600 },\n  { id: \"lisbon-tram\", alt: \"A yellow tram on a street lined with historic buildings in Lisbon\", src: \"/media/photos/lisbon-tram.jpg\", width: 1600, height: 1064 },\n  { id: \"lisbon-bridge\", alt: \"The 25 de Abril Bridge crossing the Tagus in Lisbon\", src: \"/media/photos/lisbon-bridge.jpg\", width: 1600, height: 1166 },\n  { id: \"lisbon-rooftops\", alt: \"Terracotta rooftops of Lisbon running down to the river\", src: \"/media/photos/lisbon-rooftops.jpg\", width: 1280, height: 1600 },\n  { id: \"salmon-dinner\", alt: \"Seared salmon with a bright herb salsa and a glass of red wine\", src: \"/media/photos/salmon-dinner.jpg\", width: 1067, height: 1600 },\n  { id: \"chef-plating\", alt: \"A chef spooning sauce onto a plated dish in a dark kitchen\", src: \"/media/photos/chef-plating.jpg\", width: 1600, height: 1600 },\n] as const satisfies readonly MediaPhoto[];\n\nexport type PersonId = (typeof people)[number][\"id\"];\nexport type PhotoId = (typeof photos)[number][\"id\"];\n\n/** Looks up a person by id. */\nexport function person(id: PersonId): MediaPerson {\n  return people.find(entry => entry.id === id)!;\n}\n\n/** Looks up a photo by id. */\nexport function photo(id: PhotoId): MediaPhoto {\n  return photos.find(entry => entry.id === id)!;\n}\n\n/** Square 400 px avatar path for a person id, for `src` props. */\nexport const avatar = (id: PersonId) => person(id).src;\n\n/** 800 × 1000 portrait crop of the same photo, for image-led layouts. */\nexport const portrait = (id: PersonId) => `/media/people/portrait/${id}.jpg`;\n\n/** The first `count` people, for avatar stacks and lists. */\nexport const peopleSample = (count: number) => people.slice(0, count);\n"},{"path":"registry/components/segmented-control/segmented-control.tsx","type":"registry:component","target":"@components/silicon-ui/segmented-control/segmented-control.tsx","content":"\"use client\";\n\nimport { useEffect, useId, useLayoutEffect, useRef, type KeyboardEvent, type ReactNode } from \"react\";\nimport { LayoutGroup, motion, useReducedMotion } from \"motion/react\";\nimport { motionTokens } from \"../lib/motion-tokens\";\nimport { FluidHoverHighlight, useFluidHover } from \"../lib/fluid-hover\";\nimport styles from \"./segmented-control.module.css\";\n\nexport interface Segment { value: string; label: string; /** Optional content after the label, such as a badge. */ accessory?: ReactNode; }\nexport interface SegmentedControlProps {\n  options: Segment[];\n  value: string;\n  onValueChange: (value: string) => void;\n  label?: string;\n  /** Called when the pointer or focus reaches an option, before it is chosen. Use it to start loading what that option shows. */\n  onOptionIntent?: (value: string) => void;\n  /** `sm` (default) or `xs`, a compact 24px control for dense UI such as an Edit/Read toggle in a toolbar. */\n  size?: \"sm\" | \"xs\";\n  className?: string;\n}\n\nexport default function SegmentedControl({ options, value, onValueChange, label, onOptionIntent, size = \"sm\", className }: SegmentedControlProps) {\n  const id = useId();\n  const reduced = useReducedMotion();\n  const track = useRef<HTMLDivElement>(null);\n  // Fluid hover: the nearest option is lit and a click in a gap picks it. Focus already moves the selection, so it leaves the fill alone.\n  const hover = useFluidHover(track, { items: \"[data-value]\", axis: \"x\", followFocus: false });\n\n  // When the options are wider than the container, the track scrolls inside itself. Edges fade only on the side with more to see.\n  useLayoutEffect(() => {\n    const node = track.current;\n    if (!node) return;\n    const edges = () => {\n      const rest = node.scrollWidth - node.clientWidth - node.scrollLeft;\n      node.toggleAttribute(\"data-fade-start\", node.scrollLeft > 1);\n      node.toggleAttribute(\"data-fade-end\", rest > 1);\n    };\n    edges();\n    node.addEventListener(\"scroll\", edges, { passive: true });\n    const observer = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(edges);\n    observer?.observe(node);\n    return () => { node.removeEventListener(\"scroll\", edges); observer?.disconnect(); };\n  }, [options.length]);\n\n  // The selected option is always scrolled fully into view, with a little room so it clears the fade.\n  const first = useRef(true);\n  useEffect(() => {\n    const node = track.current;\n    const button = node?.querySelector<HTMLElement>('[aria-pressed=\"true\"]');\n    if (!node || !button || node.scrollWidth <= node.clientWidth) { first.current = false; return; }\n    const room = 20, start = button.offsetLeft - room, end = button.offsetLeft + button.offsetWidth + room - node.clientWidth;\n    const left = node.scrollLeft > start ? start : node.scrollLeft < end ? end : node.scrollLeft;\n    if (left !== node.scrollLeft) node.scrollTo({ left: Math.max(0, left), behavior: first.current || reduced ? \"auto\" : \"smooth\" });\n    first.current = false;\n  }, [value, reduced]);\n\n  // Arrow keys, Home and End move the selection like a tab list; only the selected option is a tab stop.\n  const selectedIndex = Math.max(0, options.findIndex(option => option.value === value));\n  const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n    const last = options.length - 1;\n    const target = event.key === \"ArrowRight\" || event.key === \"ArrowDown\" ? (selectedIndex === last ? 0 : selectedIndex + 1)\n      : event.key === \"ArrowLeft\" || event.key === \"ArrowUp\" ? (selectedIndex === 0 ? last : selectedIndex - 1)\n        : event.key === \"Home\" ? 0 : event.key === \"End\" ? last : -1;\n    if (target < 0 || !options[target]) return;\n    event.preventDefault();\n    onValueChange(options[target].value);\n    track.current?.querySelector<HTMLElement>(`[data-value=\"${CSS.escape(options[target].value)}\"]`)?.focus({ preventScroll: true });\n  };\n\n  return <div className={`${styles.root} ${className ?? \"\"}`} role=\"group\" aria-label={label} data-size={size}>\n    <LayoutGroup id={id}><motion.div ref={track} layoutScroll className={styles.track} {...hover.handlers}>\n      <FluidHoverHighlight hover={hover} className={styles.hover} />\n      {options.map((option, index) => <button key={option.value} id={`${id}-${option.value}`} className={styles.button} type=\"button\" data-value={option.value} aria-pressed={value === option.value} tabIndex={index === selectedIndex ? 0 : -1} onClick={() => onValueChange(option.value)} onKeyDown={onKeyDown} onPointerEnter={onOptionIntent ? () => onOptionIntent(option.value) : undefined} onFocus={onOptionIntent ? () => onOptionIntent(option.value) : undefined}>\n        {value === option.value && <motion.span className={styles.selection} layoutId=\"selection\" layoutDependency={value} transition={reduced ? { duration: 0 } : motionTokens.spring.morph} aria-hidden=\"true\" />}\n        <span className={styles.label}>{option.label}{option.accessory}</span>\n      </button>)}\n    </motion.div></LayoutGroup>\n  </div>;\n}\n"},{"path":"registry/components/segmented-control/segmented-control.module.css","type":"registry:component","target":"@components/silicon-ui/segmented-control/segmented-control.module.css","content":"/* The frame can shrink below its content inside flex and grid parents; the track then scrolls inside it. */\n.root { display: inline-flex; min-width: 0; max-width: 100%; flex-shrink: 1; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-muted); }\n/* The track owns the stacking context so the gliding highlight passes under every label, not over earlier ones. */\n.track { --fade-start: 0px; --fade-end: 0px; position: relative; isolation: isolate; display: flex; min-width: 0; gap: var(--space-hair); overflow-x: auto; overscroll-behavior-x: contain; padding: var(--space-hair); border-radius: inherit; corner-shape: inherit; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); }\n.track::-webkit-scrollbar { display: none; }\n.track[data-fade-start] { --fade-start: 20px; }\n.track[data-fade-end] { --fade-end: 20px; }\n/* Items never scale or change weight; only the highlight travels and the label color follows it. */\n.button { position: relative; flex: 0 0 auto; min-height: var(--control-height-sm); border: 0; border-radius: calc(var(--radius-control) - var(--space-hair)); padding: 0 var(--space-group); background: transparent; color: var(--text-muted); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard); }\n/* The frame around the options is 2px, as in Tabs: too thin to hold the keyboard ring outside an option, so it is drawn inside. */\n.button:focus-visible { --focus-outline-offset: -3px; }\n@media (hover: hover) and (pointer: fine) { .button:hover { color: var(--foreground); } }\n.button:active, .button[aria-pressed=\"true\"] { color: var(--foreground); }\n/* The hover fill glides under the options and under the selection, so the selected option never changes on hover. */\n.hover { z-index: -1; border-radius: calc(var(--radius-control) - var(--space-hair)); corner-shape: var(--corner-shape); background: color-mix(in oklab, var(--foreground) 5%, transparent); }\n.selection { position: absolute; z-index: -1; inset: 0; border: 1px solid var(--border); border-radius: inherit; corner-shape: inherit; background: var(--surface); box-shadow: var(--shadow-resting); }\n.label { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: var(--space-related); }\n/* Compact: 24px segments at the small type step. */\n.root[data-size=\"xs\"] .button { min-height: var(--control-height-xs); padding: 0 var(--space-related); font-size: var(--text-xs); }\n@media (max-width: 380px) { .button { padding: 0 var(--space-group); } }\n@media (prefers-reduced-motion: reduce) { .button { transition: none; } }\n"},{"path":"lib/fluid-hover.tsx","type":"registry:lib","target":"@components/silicon-ui/lib/fluid-hover.tsx","content":"\"use client\";\n\n/**\n * Fluid hover: in a set of items (a menu, a list, tabs, a grid), the item nearest the pointer is lit, even while the\n * pointer is in a gap, the padding or past the last item, and one highlight springs between items. A click in a gap goes\n * to the lit item, so what is lit is what a click hits. A new pointer entry fades the highlight in where it lands instead\n * of sliding it over from the last item. The keyboard moves it without travel, and reduced motion keeps the fade but\n * drops the travel.\n *\n *   const list = useRef<HTMLUListElement>(null);\n *   const hover = useFluidHover(list, { items: \"[data-item]\" });\n *   <ul ref={list} className={styles.list} {...hover.handlers}>      // .list { position: relative }\n *     <FluidHoverHighlight hover={hover} className={styles.highlight} />\n *     …items…\n *   </ul>\n *\n * Adapted from Fluid Functionalism's use-fluid-hover and fluid-hover-highlight by Micka Touillaud (MIT),\n * https://github.com/mickadesign/fluid-functionalism. Items are found by a selector instead of registering themselves,\n * so a component adopts it without changing its items.\n */\nimport { useEffect, useEffectEvent, useRef, useState } from \"react\";\nimport type { FocusEvent, MouseEvent, PointerEvent, RefObject } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { motionTokens } from \"./motion-tokens\";\n\n/** An item's box in the container's own layout space (unaffected by transforms or scrolling). */\nexport interface FluidRect { top: number; left: number; width: number; height: number }\n\nexport interface FluidHoverState {\n  /** Where the highlight sits, or null when nothing is lit. */\n  rect: FluidRect | null;\n  /** The lit item. */\n  item: HTMLElement | null;\n  /** False when the highlight should jump (keyboard, a resize) rather than travel. */\n  glide: boolean;\n  /** Steps on each new pointer entry, so the highlight fades in where it lands. */\n  session: number;\n}\n\nexport interface FluidHoverOptions {\n  /** Selector for the items inside the container. */\n  items: string;\n  /** \"y\" for lists (default), \"x\" for a row of tabs, \"xy\" for grids. */\n  axis?: \"x\" | \"y\" | \"xy\";\n  /** Items the highlight skips (and a gap click never activates). Defaults to disabled or aria-disabled items. */\n  isItemDisabled?: (item: HTMLElement) => boolean;\n  /** \"skip\" (default) lights the nearest enabled item even over a disabled one; \"clear\" lights nothing over a disabled item (a calendar's unavailable days). */\n  disabled?: \"skip\" | \"clear\";\n  /** Route a click in a gap to the lit item. On by default; turn it off where empty space should stay inert. */\n  gapClick?: boolean;\n  /** Light the item that receives keyboard focus. On by default. */\n  followFocus?: boolean;\n}\n\nconst defaultDisabled = (item: HTMLElement) =>\n  item.matches(\":disabled, [aria-disabled='true'], [data-disabled]\");\n\n/** Controls that sit between items keep their own clicks. */\nconst CONTROL = \"input, textarea, select, button, a, summary, [contenteditable], [role='textbox'], [role='searchbox'], [role='button']\";\n\n/** The item's box relative to the container, summing offsets through positioned ancestors in between. */\nexport function rectOf(item: HTMLElement, container: HTMLElement): FluidRect {\n  let top = item.offsetTop, left = item.offsetLeft;\n  let parent = item.offsetParent as HTMLElement | null;\n  while (parent && parent !== container && container.contains(parent)) {\n    top += parent.offsetTop + parent.clientTop;\n    left += parent.offsetLeft + parent.clientLeft;\n    parent = parent.offsetParent as HTMLElement | null;\n  }\n  return { top, left, width: item.offsetWidth, height: item.offsetHeight };\n}\n\n/**\n * The item the pointer is inside, or else the one whose edge is nearest along the axis (both axes for a grid). Edges, not\n * centres, so a gap next to a wide item still lights the item the pointer is closer to.\n */\nexport function pickNearest(items: HTMLElement[], x: number, y: number, axis: \"x\" | \"y\" | \"xy\"): HTMLElement | null {\n  let nearest: HTMLElement | null = null, best = Infinity;\n  for (const item of items) {\n    const r = item.getBoundingClientRect();\n    if (!r.width && !r.height) continue;\n    if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) return item;\n    const dx = Math.max(r.left - x, 0, x - r.right), dy = Math.max(r.top - y, 0, y - r.bottom);\n    const distance = axis === \"x\" ? dx : axis === \"y\" ? dy : Math.hypot(dx, dy);\n    if (distance < best) { best = distance; nearest = item; }\n  }\n  return nearest;\n}\n\n/** Hands a gap click to the item as a real mouse click (detail, modifiers and coordinates kept), so the item reads it as a pointer press, not a keyboard one. */\nfunction forwardClick(item: HTMLElement, event: MouseEvent<HTMLElement>) {\n  const { detail, clientX, clientY, screenX, screenY, ctrlKey, shiftKey, altKey, metaKey, button, buttons } = event;\n  item.dispatchEvent(new globalThis.MouseEvent(\"click\", { bubbles: true, cancelable: true, composed: true, view: window, detail, clientX, clientY, screenX, screenY, ctrlKey, shiftKey, altKey, metaKey, button, buttons }));\n}\n\n/** Whether an event happened inside the element whose handler hears it, not in a portalled child (a submenu, a tooltip). */\nconst isOwn = (event: { currentTarget: EventTarget; target: EventTarget }) =>\n  !(event.currentTarget instanceof Node) || !(event.target instanceof Node) || event.currentTarget.contains(event.target);\n\nexport function useFluidHover<T extends HTMLElement>(container: RefObject<T | null>, options: FluidHoverOptions) {\n  const { items: selector, axis = \"y\", isItemDisabled = defaultDisabled, disabled = \"skip\", gapClick = true, followFocus = true } = options;\n  const [state, setState] = useState<FluidHoverState>({ rect: null, item: null, glide: false, session: 0 });\n  const current = useRef(state);\n  const pointer = useRef(false);\n  const entering = useRef(false);\n  const frame = useRef(0);\n\n  function commit(next: FluidHoverState) {\n    const prev = current.current;\n    if (prev.item === next.item && prev.session === next.session && sameRect(prev.rect, next.rect)) return;\n    current.current = next;\n    setState(next);\n  }\n\n  function light(item: HTMLElement | null, glide: boolean) {\n    const root = container.current;\n    if (!root || !item) return commit({ ...current.current, rect: null, item: null, glide });\n    let session = current.current.session;\n    if (entering.current) { entering.current = false; session += 1; }\n    commit({ rect: rectOf(item, root), item, glide: glide && session === current.current.session, session });\n  }\n\n  const enabledItems = () => {\n    const root = container.current;\n    return root ? [...root.querySelectorAll<HTMLElement>(selector)].filter(item => !isItemDisabled(item)) : [];\n  };\n\n  // The lit item can move under a still highlight (a resize, content above it changing): follow it without travel.\n  const follow = useEffectEvent(() => { const { item } = current.current; if (item?.isConnected) light(item, false); });\n  useEffect(() => {\n    const root = container.current;\n    if (!root || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(() => follow());\n    observer.observe(root);\n    return () => observer.disconnect();\n  }, [container]);\n  useEffect(() => () => cancelAnimationFrame(frame.current), []);\n\n  const handlers = {\n    onMouseEnter: () => { entering.current = true; },\n    onMouseMove: (event: MouseEvent<T>) => {\n      if (!isOwn(event)) return;\n      pointer.current = true;\n      const { clientX, clientY } = event;\n      cancelAnimationFrame(frame.current);\n      frame.current = requestAnimationFrame(() => {\n        const over = disabled === \"clear\" ? document.elementFromPoint(clientX, clientY)?.closest<HTMLElement>(selector) : null;\n        light(over && isItemDisabled(over) ? null : pickNearest(enabledItems(), clientX, clientY, axis), true);\n      });\n    },\n    onMouseLeave: () => { cancelAnimationFrame(frame.current); entering.current = false; light(null, false); },\n    onKeyDownCapture: () => { pointer.current = false; },\n    onFocus: (event: FocusEvent<T>) => {\n      if (!followFocus || pointer.current || !isOwn(event)) return;\n      const item = event.target instanceof HTMLElement ? event.target.closest<HTMLElement>(selector) : null;\n      if (item && container.current?.contains(item) && !isItemDisabled(item)) light(item, false);\n    },\n    onBlur: (event: FocusEvent<T>) => {\n      if (!pointer.current && !event.currentTarget.contains(event.relatedTarget as Node | null)) light(null, false);\n    },\n    onClick: (event: MouseEvent<T>) => {\n      if (!gapClick || !isOwn(event)) return;\n      const target = event.target as Element;\n      if (!target.isConnected || target.closest(selector) || target.closest(CONTROL)) return;\n      const { item } = current.current;\n      if (item?.isConnected && !isItemDisabled(item)) forwardClick(item, event);\n    },\n  };\n\n  /** Clears the highlight at once, such as when a menu opens again. */\n  const reset = () => { cancelAnimationFrame(frame.current); entering.current = true; light(null, false); };\n\n  return { ...state, handlers, reset, light };\n}\n\nexport interface NearestItemOptions extends Omit<FluidHoverOptions, \"followFocus\"> {\n  /** Called with the nearest enabled item as the mouse moves over the container. */\n  onPick: (item: HTMLElement) => void;\n}\n\n/**\n * Fluid hover's picking without its highlight, for a list that already keeps its own active item and highlight (a listbox\n * with aria-activedescendant, a roving list): the mouse picks the nearest enabled item, gaps and padding included, and a\n * click in a gap goes to that item. Spread the result on the container.\n */\n// A hook only so callbacks that touch refs can be passed during render; it keeps no state.\nexport function useNearestItem<T extends HTMLElement>({ items: selector, axis = \"y\", isItemDisabled = defaultDisabled, gapClick = true, onPick }: NearestItemOptions) {\n  const nearest = (event: MouseEvent<T>) => {\n    if (!isOwn(event)) return null;\n    const items = [...event.currentTarget.querySelectorAll<HTMLElement>(selector)].filter(item => !isItemDisabled(item));\n    return pickNearest(items, event.clientX, event.clientY, axis);\n  };\n  return {\n    onPointerMove: (event: PointerEvent<T>) => { if (event.pointerType !== \"mouse\") return; const item = nearest(event); if (item) onPick(item); },\n    onClick: (event: MouseEvent<T>) => {\n      if (!gapClick) return;\n      const target = event.target as Element;\n      if (!target.isConnected || target.closest(selector) || target.closest(CONTROL)) return;\n      const item = nearest(event);\n      if (item) forwardClick(item, event);\n    },\n  };\n}\n\nconst sameRect = (a: FluidRect | null, b: FluidRect | null) =>\n  a === b || (!!a && !!b && a.top === b.top && a.left === b.left && a.width === b.width && a.height === b.height);\n\nexport interface FluidHoverHighlightProps {\n  /** The state from useFluidHover (or any { rect, glide, session }). */\n  hover: Pick<FluidHoverState, \"rect\" | \"glide\" | \"session\">;\n  /** Radius, fill, z-index. The container must be position: relative; the highlight is placed at its top-left corner. */\n  className?: string;\n  /** Extra attributes for styling, such as data-tone. */\n  tone?: string;\n}\n\n/** The one highlight a fluid hover set renders: it springs between items on transforms, and fades in and out. */\nexport function FluidHoverHighlight({ hover, className, tone }: FluidHoverHighlightProps) {\n  const reduced = useReducedMotion() ?? false;\n  const { rect, glide, session } = hover;\n  const place = rect ? { x: rect.left, y: rect.top, width: rect.width, height: rect.height } : undefined;\n  return (\n    <AnimatePresence initial={false}>\n      {place ? (\n        <motion.span key={session} className={className} data-tone={tone} aria-hidden=\"true\"\n          style={{ position: \"absolute\", top: 0, left: 0, pointerEvents: \"none\" }}\n          initial={{ opacity: 0, ...place }}\n          animate={{ opacity: 1, ...place }}\n          exit={{ opacity: 0, transition: motionTokens.spring.fast.exit }}\n          transition={{ default: glide && !reduced ? motionTokens.spring.fast : { duration: 0 }, opacity: { duration: motionTokens.duration.fast } }} />\n      ) : null}\n    </AnimatePresence>\n  );\n}\n"}],"docs":"Docs and live preview: https://ui.teamofsilicons.com/site-header","meta":{"tier":"free","kind":"block","docs":"https://ui.teamofsilicons.com/site-header","markdown":"https://ui.teamofsilicons.com/site-header.md","status":"stable"}}