{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "split-screen-hero",
  "title": "Split Screen Hero",
  "description": "A two-sided hero with a shared headline: two full-bleed photos meet at a seam, and the half under the pointer opens up to show its description and button. Stacks on phones.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/split-screen-hero/split-screen-hero.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 type SplitHeroTheme = \"dark\" | \"light\";\n\nexport interface SplitPanel {\n  eyebrow?: string;\n  title: string;\n  description?: string;\n  image: string;\n  alt?: string;\n  cta?: { label: string; href?: string; onClick?: () => void };\n}\n\nexport interface SplitScreenHeroProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: SplitHeroTheme;\n  /** The shared headline across both halves. */\n  title?: string;\n  left?: SplitPanel;\n  right?: SplitPanel;\n  /** Word in the badge on the seam. Pass an empty string to hide it. */\n  seamLabel?: string;\n  /** How far the seam can travel from the centre, in percent of the width. */\n  range?: number;\n  /** Height from tablet width up, in px. */\n  minHeight?: number;\n}\n\nconst PALETTES = {\n  dark: {\n    bg: \"#0A0A0A\",\n    text: \"#FFFFFF\",\n    sub: \"rgba(255,255,255,0.78)\",\n    scrim: \"10,10,10\",\n    line: \"rgba(255,255,255,0.55)\",\n    btn: \"#FFFFFF\",\n    btnText: \"#0A0A0A\",\n    badge: \"rgba(10,10,10,0.72)\",\n  },\n  light: {\n    bg: \"#FAF9F6\",\n    text: \"#14130F\",\n    sub: \"rgba(20,19,15,0.74)\",\n    scrim: \"250,249,246\",\n    line: \"rgba(20,19,15,0.45)\",\n    btn: \"#14130F\",\n    btnText: \"#FAF9F6\",\n    badge: \"rgba(250,249,246,0.86)\",\n  },\n};\n\nconst DEFAULT_LEFT: SplitPanel = {\n  eyebrow: \"12 bays, 40 boats\",\n  title: \"By sea\",\n  description:\n    \"Skippered gulets and day boats, stocked and ready at the marina.\",\n  image: \"/demo/pages/yacht-boat-rental/hero.webp\",\n  alt: \"Boats anchored in a turquoise bay, seen from above\",\n  cta: { label: \"See the boats\" },\n};\n\nconst DEFAULT_RIGHT: SplitPanel = {\n  eyebrow: \"9 routes, 3 regions\",\n  title: \"By land\",\n  description: \"Slow routes through valleys and old towns, with a local guide.\",\n  image: \"/demo/pages/travel-agency/hero.webp\",\n  alt: \"Hot air balloons over the rock valleys of Cappadocia at sunrise\",\n  cta: { label: \"See the routes\" },\n};\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction Panel({\n  panel,\n  side,\n  active,\n  pal,\n  onFocusCta,\n}: {\n  panel: SplitPanel;\n  side: \"left\" | \"right\";\n  active: boolean;\n  pal: (typeof PALETTES)[\"dark\"];\n  onFocusCta: () => void;\n}) {\n  const isLeft = side === \"left\";\n  const { cta } = panel;\n  const button =\n    \"inline-flex h-10 cursor-pointer items-center rounded-full px-5 text-[13.5px] font-semibold transition-opacity hover:opacity-85\";\n  return (\n    <div\n      className={cn(\n        \"relative min-h-[300px] overflow-hidden @[720px]:absolute @[720px]:inset-0 @[720px]:min-h-0\",\n        isLeft\n          ? \"min-h-[400px] @[720px]:z-10 @[720px]:[clip-path:inset(0_calc(100%-var(--seam))_0_0)]\"\n          : \"\",\n      )}\n    >\n      {/* eslint-disable-next-line @next/next/no-img-element */}\n      <img\n        src={panel.image}\n        alt={panel.alt ?? \"\"}\n        draggable={false}\n        className=\"absolute inset-0 size-full object-cover select-none\"\n        style={{\n          transform: `scale(1.08) translateX(calc(var(--shift) * ${isLeft ? 1 : -1}))`,\n        }}\n      />\n      <div\n        aria-hidden=\"true\"\n        className=\"absolute inset-0\"\n        style={{\n          background: `linear-gradient(to top, rgba(${pal.scrim},0.86) 0%, rgba(${pal.scrim},0.34) 34%, rgba(${pal.scrim},0) 58%)`,\n        }}\n      />\n      <div\n        className={cn(\n          \"absolute bottom-0 flex w-full flex-col p-6 @[720px]:w-[min(320px,31cqw)] @[720px]:p-10\",\n          isLeft ? \"left-0\" : \"right-0 @[720px]:items-end @[720px]:text-right\",\n        )}\n      >\n        {panel.eyebrow && (\n          <p\n            className=\"m-0 text-[12.5px] font-medium\"\n            style={{ color: pal.sub }}\n          >\n            {panel.eyebrow}\n          </p>\n        )}\n        <h2 className=\"m-0 mt-1.5 text-[34px] leading-none font-medium tracking-[-0.03em] @[720px]:text-[44px]\">\n          {panel.title}\n        </h2>\n        {panel.description && (\n          <div\n            data-on={active}\n            className=\"grid grid-rows-[1fr] transition-[grid-template-rows,opacity] duration-300 @[720px]:grid-rows-[0fr] @[720px]:opacity-0 @[720px]:data-[on=true]:grid-rows-[1fr] @[720px]:data-[on=true]:opacity-100\"\n          >\n            <p\n              className=\"m-0 min-h-0 overflow-hidden pt-3 text-[14px] leading-snug\"\n              style={{ color: pal.sub }}\n            >\n              {panel.description}\n            </p>\n          </div>\n        )}\n        {cta && (\n          <div className=\"mt-4\">\n            {cta.href ? (\n              <a\n                href={cta.href}\n                onFocus={onFocusCta}\n                className={cn(button, \"no-underline\")}\n                style={{ background: pal.btn, color: pal.btnText }}\n              >\n                {cta.label}\n              </a>\n            ) : (\n              <button\n                type=\"button\"\n                onClick={cta.onClick}\n                onFocus={onFocusCta}\n                className={button}\n                style={{ background: pal.btn, color: pal.btnText }}\n              >\n                {cta.label}\n              </button>\n            )}\n          </div>\n        )}\n      </div>\n    </div>\n  );\n}\n\nexport function SplitScreenHero({\n  theme = \"dark\",\n  title = \"Two ways to see the coast\",\n  left = DEFAULT_LEFT,\n  right = DEFAULT_RIGHT,\n  seamLabel = \"or\",\n  range = 15,\n  minHeight = 720,\n  className,\n  style,\n  onPointerMove,\n  onPointerLeave,\n  ...props\n}: SplitScreenHeroProps) {\n  const pal = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const target = React.useRef(50);\n  const current = React.useRef(50);\n  const raf = React.useRef(0);\n  const start = React.useRef<() => void>(() => {});\n  const [side, setSide] = React.useState<\"left\" | \"right\" | null>(null);\n\n  // The seam eases toward its target and writes straight to CSS variables, so nothing re-renders while it moves.\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    let prev = 0;\n    const write = () => {\n      el.style.setProperty(\"--seam\", `${current.current.toFixed(2)}%`);\n      el.style.setProperty(\n        \"--shift\",\n        `${((current.current - 50) * 0.35).toFixed(2)}px`,\n      );\n    };\n    const frame = (now: number) => {\n      const dt = Math.min(0.05, prev ? (now - prev) / 1000 : 1 / 60);\n      prev = now;\n      const next =\n        current.current +\n        (target.current - current.current) * (1 - Math.exp(-dt * 8));\n      const settled = Math.abs(target.current - next) < 0.02;\n      current.current = settled ? target.current : next;\n      write();\n      if (settled) {\n        raf.current = 0;\n        prev = 0;\n      } else raf.current = requestAnimationFrame(frame);\n    };\n    start.current = () => {\n      if (reduce) {\n        current.current = target.current;\n        write();\n      } else if (!raf.current) raf.current = requestAnimationFrame(frame);\n    };\n    return () => {\n      cancelAnimationFrame(raf.current);\n      raf.current = 0;\n    };\n  }, [reduce]);\n\n  const aim = (seam: number) => {\n    target.current = seam;\n    setSide(seam > 52 ? \"left\" : seam < 48 ? \"right\" : null);\n    start.current();\n  };\n\n  // The half under the pointer opens up, so the pointer never ends up chasing the seam.\n  const follow = (e: React.PointerEvent<HTMLElement>) => {\n    onPointerMove?.(e);\n    const r = e.currentTarget.getBoundingClientRect();\n    if (r.width < 720) return;\n    const x = (e.clientX - r.left) / r.width;\n    const pull = Math.max(-1, Math.min(1, (0.5 - x) * 3));\n    aim(50 + pull * range);\n  };\n\n  return (\n    <section\n      ref={rootRef}\n      onPointerMove={follow}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e);\n        aim(50);\n      }}\n      className={cn(\"@container relative w-full overflow-hidden\", className)}\n      style={\n        {\n          \"--seam\": \"50%\",\n          \"--shift\": \"0px\",\n          \"--h\": `${minHeight}px`,\n          background: pal.bg,\n          color: pal.text,\n          fontFamily: \"Inter, -apple-system, BlinkMacSystemFont, sans-serif\",\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <div className=\"relative isolate flex flex-col @[720px]:min-h-[var(--h)]\">\n        <Panel\n          panel={left}\n          side=\"left\"\n          active={side === \"left\"}\n          pal={pal}\n          onFocusCta={() => aim(50 + range)}\n        />\n        <Panel\n          panel={right}\n          side=\"right\"\n          active={side === \"right\"}\n          pal={pal}\n          onFocusCta={() => aim(50 - range)}\n        />\n\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-x-0 top-0 z-20 h-48\"\n          style={{\n            background: `linear-gradient(to bottom, rgba(${pal.scrim},0.62), rgba(${pal.scrim},0))`,\n          }}\n        />\n        <h1 className=\"pointer-events-none absolute inset-x-0 top-0 z-30 m-0 mx-auto max-w-[16ch] px-6 pt-8 text-center text-[36px] leading-[1.04] font-medium tracking-[-0.03em] @[720px]:max-w-[20ch] @[720px]:pt-11 @[720px]:text-[56px]\">\n          {title}\n        </h1>\n\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-y-0 z-20 hidden w-px @[720px]:block\"\n          style={{ left: \"var(--seam)\", background: pal.line }}\n        >\n          {seamLabel && (\n            <span\n              className=\"absolute top-1/2 left-1/2 grid size-11 -translate-x-1/2 -translate-y-1/2 place-items-center rounded-full text-[13px] font-medium backdrop-blur-md\"\n              style={{\n                background: pal.badge,\n                boxShadow: `0 0 0 1px ${pal.line}`,\n              }}\n            >\n              {seamLabel}\n            </span>\n          )}\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}