{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cinematic-stacked-gallery",
  "title": "Cinematic Stacked Gallery",
  "description": "A fullscreen hero gallery where inactive slides collapse into a stacked deck of thumbnails; clicking one crossfades it to full size with Ken Burns zoom, cursor parallax, and a title/description rail with CTA and prev/next controls.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/cinematic-stacked-gallery/cinematic-stacked-gallery.tsx",
      "content": "\"use client\";\n\nimport * as React from \"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 interface CinematicStackedGalleryItem {\n  image: string;\n  title: string;\n  description: string;\n  alt?: string;\n}\n\nexport interface CinematicStackedGalleryProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  items?: CinematicStackedGalleryItem[];\n  kenBurns?: boolean;\n  kenBurnsDuration?: number;\n  kenBurnsScale?: number;\n  parallax?: boolean;\n  parallaxStrength?: number;\n  depthBlur?: boolean;\n  kickerFontFamily?: string;\n  titleFontFamily?: string;\n  descriptionFontFamily?: string;\n  showCta?: boolean;\n  ctaLabel?: string;\n  ctaLink?: string;\n  ctaNewTab?: boolean;\n}\n\nconst DEFAULT_ITEMS: CinematicStackedGalleryItem[] = [\n  {\n    image: \"/demo/5.webp\",\n    title: \"Evening Stillness\",\n    description: \"As night settles in, he moves toward the light, a dark bedroom holding its quiet, waiting for rest.\",\n    alt: \"Man walking toward sheer curtains in a dark bedroom\",\n  },\n  {\n    image: \"/demo/6.webp\",\n    title: \"Passing Through\",\n    description: \"A quiet dining room opens onto a staircase, where morning light gathers behind sheer curtains and time seems to slow.\",\n    alt: \"Woman walking through a dining room toward a curtained doorway\",\n  },\n  {\n    image: \"/demo/7.webp\",\n    title: \"Stillness has a shape\",\n    description: \"Sheer fabric lifts in the light as she moves through the room, a moment suspended between motion and calm.\",\n    alt: \"Woman walking past a billowing sheer curtain\",\n  },\n  {\n    image: \"/demo/9.webp\",\n    title: \"Between Rooms\",\n    description: \"A figure crosses the light, unhurried, past a table set with quiet things, fruit, branch, and shadow.\",\n    alt: \"Man walking through a minimalist dining space\",\n  },\n  {\n    image: \"/demo/3.webp\",\n    title: \"Let It Move You\",\n    description: \"Pink light filters through soft fabric as she crosses the room, grace caught mid-motion in an ordinary moment.\",\n    alt: \"Woman walking beneath a pink sheer curtain\",\n  },\n];\n\n/**\n * CinematicStackedGallery — a fullscreen hero gallery where inactive slides\n * collapse into a stacked deck of thumbnails; clicking one crossfades it to\n * full size with Ken Burns zoom and cursor parallax.\n */\nexport function CinematicStackedGallery({\n  className,\n  items = DEFAULT_ITEMS,\n  kenBurns = true,\n  kenBurnsDuration = 18,\n  kenBurnsScale = 1.08,\n  parallax = true,\n  parallaxStrength = 18,\n  depthBlur = true,\n  kickerFontFamily = \"system-ui, -apple-system, sans-serif\",\n  titleFontFamily = \"system-ui, -apple-system, sans-serif\",\n  descriptionFontFamily = \"system-ui, -apple-system, sans-serif\",\n  showCta = true,\n  ctaLabel = \"Explore\",\n  ctaLink = \"#\",\n  ctaNewTab = false,\n  ...props\n}: CinematicStackedGalleryProps) {\n  const rawId = React.useId();\n  const scopeClass = \"csg-\" + rawId.replace(/[^a-zA-Z0-9]/g, \"\");\n\n  const safeItems = items?.length ? items : DEFAULT_ITEMS;\n  const total = safeItems.length;\n\n  const [activeIndex, setActiveIndex] = React.useState(0);\n  const [thumbOrder, setThumbOrder] = React.useState<number[]>(() => Array.from({ length: Math.max(total - 1, 0) }, (_, i) => i + 1));\n  const [mouse, setMouse] = React.useState({ x: 0, y: 0 });\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const [isVisible, setIsVisible] = React.useState(true);\n\n  React.useEffect(() => {\n    if (!rootRef.current) return;\n    const observer = new IntersectionObserver(([entry]) => setIsVisible(entry.isIntersecting), { threshold: 0 });\n    observer.observe(rootRef.current);\n    return () => observer.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    if (total < 2) {\n      setThumbOrder([]);\n      return;\n    }\n    setThumbOrder(\n      Array.from({ length: total - 1 }, (_, i) => (i >= activeIndex ? i + 1 : i)).filter((i) => i !== activeIndex && i < total)\n    );\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [total]);\n\n  const goTo = React.useCallback(\n    (newIndex: number) => {\n      if (newIndex === activeIndex || newIndex < 0 || newIndex >= total) return;\n      setThumbOrder((prev) => [...prev.filter((idx) => idx !== newIndex), activeIndex]);\n      setActiveIndex(newIndex);\n    },\n    [activeIndex, total]\n  );\n\n  const onMouseMove = React.useCallback(\n    (e: React.MouseEvent) => {\n      if (!parallax || !rootRef.current) return;\n      const rect = rootRef.current.getBoundingClientRect();\n      const x = (e.clientX - rect.left) / rect.width - 0.5;\n      const y = (e.clientY - rect.top) / rect.height - 0.5;\n      setMouse({ x, y });\n    },\n    [parallax]\n  );\n\n  const onMouseLeave = React.useCallback(() => setMouse({ x: 0, y: 0 }), []);\n\n  const parallaxX = parallax ? mouse.x * parallaxStrength : 0;\n  const parallaxY = parallax ? mouse.y * parallaxStrength : 0;\n\n  const onKeyDown = React.useCallback(\n    (e: React.KeyboardEvent) => {\n      if (e.key === \"ArrowRight\") {\n        e.preventDefault();\n        goTo(activeIndex + 1 < total ? activeIndex + 1 : 0);\n      } else if (e.key === \"ArrowLeft\") {\n        e.preventDefault();\n        goTo(activeIndex - 1 >= 0 ? activeIndex - 1 : total - 1);\n      }\n    },\n    [goTo, activeIndex, total]\n  );\n\n  return (\n    <div\n      ref={rootRef}\n      className={cn(scopeClass, \"relative h-full w-full overflow-hidden bg-[#0b0b0f] text-white\", className)}\n      data-paused={!isVisible}\n      onMouseMove={onMouseMove}\n      onMouseLeave={onMouseLeave}\n      onKeyDown={onKeyDown}\n      role=\"region\"\n      aria-roledescription=\"carousel\"\n      aria-label=\"Image gallery\"\n      tabIndex={0}\n      style={{ \"--kb-duration\": `${kenBurnsDuration}s`, \"--kb-scale\": kenBurnsScale, \"--depth-blur\": depthBlur ? \"2px\" : \"0px\" } as React.CSSProperties}\n      {...props}\n    >\n      <style>{`\n        .${scopeClass} {\n          --gs-scale: 0.11;\n          --gs-gap: 14px;\n          --gs-bottom: 28px;\n          --gs-duration: 0.85s;\n          --gs-ease: cubic-bezier(0.22, 1, 0.36, 1);\n          font-family: system-ui, -apple-system, sans-serif;\n          /* A size container: the stacked thumbnails are placed in cqw/cqh (the gallery's own box),\n             not vw/vh, which put them in the wrong spot whenever the gallery wasn't full-screen. */\n          container-type: size;\n        }\n        @container (max-width: 640px) {\n          .${scopeClass} .gs-track { --gs-scale: 0.16; --gs-gap: 10px; --gs-bottom: 20px; }\n        }\n        .${scopeClass} .gs-track { height: 100%; overflow: visible !important; position: relative; }\n        .${scopeClass} .gs-item { inset: 0 !important; margin: 0 !important; pointer-events: none !important; position: absolute !important; transform: none !important; width: auto !important; }\n        .${scopeClass} .gs-item[data-active=\"true\"] { z-index: 1 !important; }\n        .${scopeClass} .gs-item[data-active=\"false\"] { z-index: 10 !important; }\n        .${scopeClass} .gs-slide {\n          border-radius: 0; inset: 0; overflow: hidden; pointer-events: auto; position: absolute;\n          transform: translate(0, 0) scale(1);\n          transition: transform var(--gs-duration) var(--gs-ease), border-radius var(--gs-duration) var(--gs-ease), filter 0.35s ease;\n          will-change: transform, filter;\n        }\n        .${scopeClass} .gs-item[data-active=\"false\"] .gs-slide {\n          border-radius: 48px;\n          filter: brightness(0.62) blur(var(--depth-blur));\n          transform: translate(calc(var(--offset) * (var(--gs-scale) * 100cqw + var(--gs-gap))), calc((50cqh - var(--gs-scale) * 50cqh) - var(--gs-bottom))) scale(var(--gs-scale));\n        }\n        .${scopeClass} .gs-item[data-active=\"false\"] .gs-slide:hover { filter: brightness(1) blur(0); }\n        .${scopeClass} .gs-image-wrap { position: absolute; inset: -4%; width: 108%; height: 108%; transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1); will-change: transform; }\n        .${scopeClass} .gs-image { display: block; height: 100%; object-fit: cover; width: 100%; transform-origin: center center; }\n        .${scopeClass} .gs-item[data-active=\"true\"] .gs-image.gs-kenburns { animation: ${scopeClass}-kenburns var(--kb-duration) ease-in-out infinite alternate; }\n        @keyframes ${scopeClass}-kenburns {\n          from { transform: scale(1) translate(0%, 0%); }\n          to { transform: scale(var(--kb-scale)) translate(-1.2%, -0.8%); }\n        }\n        .${scopeClass} .gs-thumb-btn { appearance: none; background: none; border: 0; cursor: pointer; inset: 0; padding: 0; position: absolute; }\n        .${scopeClass} .gs-rail {\n          align-items: flex-start; background: linear-gradient(90deg, rgb(0 0 0 / 60%), transparent);\n          display: flex; flex-direction: column; gap: 1.75rem; inset: 0 auto 0 0;\n          justify-content: center; max-width: min(520px, 70%); padding: 0 3.5rem 0 3rem; pointer-events: none; position: absolute; z-index: 5;\n        }\n        @container (max-width: 640px) {\n          .${scopeClass} .gs-rail { max-width: 90%; padding: 0 1.5rem; }\n        }\n        .${scopeClass} .gs-content { animation: ${scopeClass}-content-in 0.65s var(--gs-ease) calc(var(--gs-duration) * 0.35) backwards; display: flex; flex-direction: column; gap: 0.85rem; }\n        @keyframes ${scopeClass}-content-in { from { opacity: 0; transform: translateY(22px); } }\n        .${scopeClass} .gs-kicker { margin: 0; opacity: 0.7; letter-spacing: 0.06em; font-size: 13px; line-height: 1.3; }\n        .${scopeClass} .gs-title { margin: 0; font-size: 40px; line-height: 1.05; }\n        .${scopeClass} .gs-description { color: rgb(255 255 255 / 85%); margin: 0; font-size: 16px; line-height: 1.6; }\n        .${scopeClass} .gs-controls { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; pointer-events: auto; }\n        .${scopeClass} .gs-nav-row { display: flex; gap: 0.75rem; align-items: center; }\n        .${scopeClass} .gs-nav {\n          align-items: center; appearance: none; backdrop-filter: blur(10px); background: rgb(255 255 255 / 10%);\n          border: 1px solid rgb(255 255 255 / 20%); border-radius: 50%; color: #fff; cursor: pointer; display: flex;\n          height: 3rem; justify-content: center; transition: background 0.2s, border-color 0.2s, opacity 0.2s, transform 0.15s; width: 3rem;\n        }\n        .${scopeClass} .gs-nav:hover:not(:disabled) { background: rgb(255 255 255 / 22%); border-color: rgb(255 255 255 / 40%); }\n        .${scopeClass} .gs-nav:active:not(:disabled) { transform: scale(0.94); }\n        .${scopeClass} .gs-nav:disabled { cursor: default; opacity: 0.35; }\n        .${scopeClass} .gs-cta {\n          align-items: center; appearance: none; backdrop-filter: blur(10px); background: rgb(255 255 255 / 12%);\n          border: 1px solid rgb(255 255 255 / 25%); border-radius: 999px; color: #fff; cursor: pointer; display: inline-flex;\n          font-size: 0.9rem; font-weight: 500; gap: 0.4rem; height: 3rem; letter-spacing: 0.02em; padding: 0 1.35rem;\n          text-decoration: none; transition: background 0.2s, border-color 0.2s, transform 0.15s; white-space: nowrap;\n        }\n        .${scopeClass} .gs-cta:hover { background: rgb(255 255 255 / 24%); border-color: rgb(255 255 255 / 45%); }\n        .${scopeClass} .gs-cta:active { transform: scale(0.97); }\n        .${scopeClass} .gs-sr-only { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }\n        @media (prefers-reduced-motion: reduce) {\n          .${scopeClass} .gs-slide { transition: none; }\n          .${scopeClass} .gs-content { animation: none; }\n          .${scopeClass} .gs-item[data-active=\"true\"] .gs-image.gs-kenburns { animation: none; }\n          .${scopeClass} .gs-image-wrap { transition: none; }\n        }\n        .${scopeClass}[data-paused=\"true\"] .gs-item[data-active=\"true\"] .gs-image.gs-kenburns { animation-play-state: paused; }\n      `}</style>\n\n      <div className=\"h-full w-full\">\n        <div className=\"gs-track\">\n          {safeItems.map((item, index) => {\n            const isActive = index === activeIndex;\n            const orderIdx = thumbOrder.indexOf(index);\n            const offset = orderIdx === -1 ? 0 : orderIdx - (thumbOrder.length - 1) / 2;\n\n            return (\n              <div\n                key={index}\n                className=\"gs-item\"\n                data-active={String(isActive)}\n                role=\"group\"\n                aria-roledescription=\"slide\"\n                aria-label={`${index + 1} of ${total}: ${item.title}`}\n              >\n                <div className=\"gs-slide\" style={{ \"--offset\": offset } as React.CSSProperties}>\n                  <div className=\"gs-image-wrap\" style={isActive ? { transform: `translate(${parallaxX}px, ${parallaxY}px)` } : undefined}>\n                    {/* eslint-disable-next-line @next/next/no-img-element */}\n                    <img\n                      src={item.image}\n                      alt={item.alt || item.title}\n                      className={`gs-image${isActive && kenBurns ? \" gs-kenburns\" : \"\"}`}\n                      draggable={false}\n                      loading={isActive ? \"eager\" : \"lazy\"}\n                      decoding=\"async\"\n                    />\n                  </div>\n                  {!isActive && (\n                    <button aria-label={`Go to slide ${index + 1}`} type=\"button\" className=\"gs-thumb-btn\" onClick={() => goTo(index)}>\n                      <span className=\"gs-sr-only\">Show {item.title}</span>\n                    </button>\n                  )}\n                </div>\n              </div>\n            );\n          })}\n        </div>\n\n        <ul className=\"gs-sr-only\">\n          {safeItems.map((item, index) => (\n            <li key={index}>\n              <strong>{item.title}</strong>: {item.description}\n            </li>\n          ))}\n        </ul>\n\n        <div className=\"gs-rail\">\n          <div className=\"gs-content\" key={activeIndex} aria-live=\"polite\" aria-atomic=\"true\">\n            <p className=\"gs-kicker\" style={{ fontFamily: kickerFontFamily }}>\n              {String(activeIndex + 1).padStart(2, \"0\")} / {String(total).padStart(2, \"0\")}\n            </p>\n            <h2 className=\"gs-title\" style={{ fontFamily: titleFontFamily }}>{safeItems[activeIndex]?.title}</h2>\n            <p className=\"gs-description\" style={{ fontFamily: descriptionFontFamily }}>{safeItems[activeIndex]?.description}</p>\n          </div>\n\n          <div className=\"gs-controls\">\n            {showCta && ctaLabel ? (\n              <a className=\"gs-cta\" href={ctaLink || \"#\"} target={ctaNewTab ? \"_blank\" : undefined} rel={ctaNewTab ? \"noopener noreferrer\" : undefined}>\n                {ctaLabel}\n              </a>\n            ) : null}\n\n            <div className=\"gs-nav-row\">\n              <button\n                type=\"button\"\n                className=\"gs-nav\"\n                onClick={() => goTo((activeIndex - 1 + total) % total)}\n                aria-label=\"Previous\"\n                disabled={total < 2}\n              >\n                <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                  <polyline points=\"15 18 9 12 15 6\" />\n                </svg>\n              </button>\n              <button\n                type=\"button\"\n                className=\"gs-nav\"\n                onClick={() => goTo((activeIndex + 1) % total)}\n                aria-label=\"Next\"\n                disabled={total < 2}\n              >\n                <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                  <polyline points=\"9 18 15 12 9 6\" />\n                </svg>\n              </button>\n            </div>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default CinematicStackedGallery;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}