{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "portfolio-grid-block",
  "title": "Portfolio Grid Block",
  "description": "A portfolio grid with wide and tall tiles packed densely, a sliding category filter that reflows the grid, hover reveals with client and year, and a lightbox with details, next and previous, keyboard arrows and Escape.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/portfolio-grid-block/portfolio-grid-block.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, LayoutGroup, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\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 PortfolioItem {\n  id: string;\n  title: string;\n  category: string;\n  image: string;\n  client?: string;\n  year?: string;\n  description?: string;\n  /** wide spans two columns, tall spans two rows. */\n  size?: \"normal\" | \"wide\" | \"tall\";\n  href?: string;\n}\n\nexport interface PortfolioGridBlockProps {\n  eyebrow?: string;\n  title?: string;\n  description?: string;\n  items?: PortfolioItem[];\n  /** Show the category filter chips. */\n  filters?: boolean;\n  /** Open a lightbox with details and next/previous when an item is clicked. */\n  lightbox?: boolean;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.6)\", faint: \"rgba(245,244,241,0.38)\", border: \"rgba(255,255,255,0.1)\", chip: \"rgba(255,255,255,0.05)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", panel: \"#111111\", ring: \"rgba(245,244,241,0.6)\", scrim: \"rgba(0,0,0,0.82)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.6)\", faint: \"rgba(10,10,10,0.4)\", border: \"rgba(10,10,10,0.1)\", chip: \"rgba(10,10,10,0.04)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", panel: \"#FFFFFF\", ring: \"rgba(10,10,10,0.5)\", scrim: \"rgba(10,10,10,0.7)\" },\n};\n\nconst DEFAULT_ITEMS: PortfolioItem[] = [\n  { id: \"casa-lumen\", title: \"Casa Lumen\", category: \"Interiors\", image: \"/demo/1.webp\", client: \"Lumen Studio\", year: \"2026\", size: \"wide\", description: \"A quiet family house in plaster and oak, shot in the last hour of daylight.\" },\n  { id: \"run-season\", title: \"Run Season\", category: \"Campaigns\", image: \"/demo/29.webp\", client: \"Stride Co.\", year: \"2026\", size: \"tall\", description: \"Spring running campaign: one athlete, one white set, all motion.\" },\n  { id: \"studio-sessions\", title: \"Studio Sessions\", category: \"Portraits\", image: \"/demo/21.webp\", client: \"Editorial\", year: \"2025\", description: \"Natural-light portraits for a magazine series on new designers.\" },\n  { id: \"atelier-nord\", title: \"Atelier Nord\", category: \"Interiors\", image: \"/demo/6.webp\", client: \"Nord Atelier\", year: \"2025\", description: \"Dining room and stair hall for an architecture practice in Oslo.\" },\n  { id: \"equestrian\", title: \"Equestrian\", category: \"Campaigns\", image: \"/demo/26.webp\", client: \"Halden Riding\", year: \"2025\", size: \"wide\", description: \"Long exposures that keep the horse sharp and the world soft.\" },\n  { id: \"quiet-portraits\", title: \"Quiet Portraits\", category: \"Portraits\", image: \"/demo/22.webp\", year: \"2025\", size: \"tall\", description: \"A personal series about stillness, shot over one winter.\" },\n  { id: \"linen-house\", title: \"Linen House\", category: \"Interiors\", image: \"/demo/9.webp\", client: \"Norra\", year: \"2024\", description: \"A lookbook set where the room is as much the product as the clothes.\" },\n  { id: \"open-water\", title: \"Open Water\", category: \"Campaigns\", image: \"/demo/33.webp\", client: \"Tide Swim\", year: \"2024\", description: \"Swim campaign built from a single studio set and a lot of water.\" },\n  { id: \"velo\", title: \"Velo\", category: \"Campaigns\", image: \"/demo/34.webp\", client: \"Velo Club\", year: \"2024\", description: \"Panning shots at 1/15 s for a cycling club's season launch.\" },\n];\n\nfunction Lightbox({ items, index, onClose, onStep, p, reduce }: { items: PortfolioItem[]; index: number; onClose: () => void; onStep: (d: number) => void; p: (typeof PALETTES)[\"dark\"]; reduce: boolean }) {\n  const it = items[index];\n  const ref = React.useRef<HTMLDivElement>(null);\n  const titleId = React.useId();\n  const [dir, setDir] = React.useState(1);\n  React.useEffect(() => {\n    ref.current?.focus();\n    const prev = document.body.style.overflow;\n    document.body.style.overflow = \"hidden\";\n    const key = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") onClose();\n      if (e.key === \"ArrowRight\") {\n        setDir(1);\n        onStep(1);\n      }\n      if (e.key === \"ArrowLeft\") {\n        setDir(-1);\n        onStep(-1);\n      }\n    };\n    window.addEventListener(\"keydown\", key);\n    return () => {\n      document.body.style.overflow = prev;\n      window.removeEventListener(\"keydown\", key);\n    };\n  }, [onClose, onStep]);\n  const trap = (e: React.KeyboardEvent) => {\n    if (e.key !== \"Tab\" || !ref.current) return;\n    const els = [...ref.current.querySelectorAll<HTMLElement>(\"button, a[href]\")];\n    if (!els.length) return;\n    if (e.shiftKey && (document.activeElement === els[0] || document.activeElement === ref.current)) {\n      e.preventDefault();\n      els[els.length - 1].focus();\n    } else if (!e.shiftKey && document.activeElement === els[els.length - 1]) {\n      e.preventDefault();\n      els[0].focus();\n    }\n  };\n  const navBtn = \"flex h-10 w-10 cursor-pointer items-center justify-center rounded-full border text-[16px] outline-none focus-visible:ring-2\";\n  return (\n    <motion.div className=\"fixed inset-0 z-[100] flex items-center justify-center p-4 sm:p-8\" initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} exit={reduce ? undefined : { opacity: 0 }} style={{ background: p.scrim }} onClick={onClose} onKeyDown={trap}>\n      <div ref={ref} role=\"dialog\" aria-modal=\"true\" aria-labelledby={titleId} tabIndex={-1} onClick={(e) => e.stopPropagation()} className=\"relative grid max-h-full w-full max-w-5xl overflow-hidden rounded-2xl outline-none sm:grid-cols-[1.6fr_1fr]\" style={{ background: p.panel, color: p.text }}>\n        <div className=\"relative aspect-[4/3] overflow-hidden sm:aspect-auto sm:min-h-[460px]\" style={{ background: p.chip }}>\n          <AnimatePresence initial={false} custom={dir} mode=\"popLayout\">\n            <motion.img\n              key={it.id}\n              src={it.image}\n              alt={it.title}\n              className=\"absolute inset-0 h-full w-full object-cover\"\n              initial={reduce ? false : { opacity: 0, x: 40 * dir }}\n              animate={{ opacity: 1, x: 0 }}\n              exit={reduce ? undefined : { opacity: 0, x: -40 * dir }}\n              transition={{ duration: 0.35, ease: [0.2, 0.7, 0.2, 1] }}\n            />\n          </AnimatePresence>\n        </div>\n        <div className=\"flex flex-col p-6\">\n          <div className=\"flex items-center justify-between\">\n            <span className=\"text-[12.5px] tabular-nums\" style={{ color: p.faint }}>\n              {index + 1} / {items.length}\n            </span>\n            <button type=\"button\" onClick={onClose} aria-label=\"Close\" className={navBtn} style={{ borderColor: p.border, background: \"transparent\", color: p.text, [\"--tw-ring-color\" as string]: p.ring }}>\n              ×\n            </button>\n          </div>\n          <p className=\"m-0 mt-6 text-[12.5px] font-medium tracking-[0.1em] uppercase\" style={{ color: p.faint }}>\n            {it.category}\n          </p>\n          <h3 id={titleId} className=\"mt-2 mb-0 text-[26px] leading-[1.15] font-semibold tracking-[-0.02em]\">\n            {it.title}\n          </h3>\n          {it.description && (\n            <p className=\"m-0 mt-3 text-[15px] leading-[1.6]\" style={{ color: p.muted }}>\n              {it.description}\n            </p>\n          )}\n          <dl className=\"m-0 mt-6 grid grid-cols-2 gap-3 border-t pt-5 text-[13.5px]\" style={{ borderColor: p.border }}>\n            {it.client && (\n              <div>\n                <dt style={{ color: p.faint }}>Client</dt>\n                <dd className=\"m-0 mt-0.5\">{it.client}</dd>\n              </div>\n            )}\n            {it.year && (\n              <div>\n                <dt style={{ color: p.faint }}>Year</dt>\n                <dd className=\"m-0 mt-0.5 tabular-nums\">{it.year}</dd>\n              </div>\n            )}\n          </dl>\n          <div className=\"mt-auto flex items-center justify-between gap-3 pt-8\">\n            {it.href ? (\n              <a href={it.href} className=\"rounded text-[14px] font-medium underline-offset-4 outline-none hover:underline focus-visible:ring-2\" style={{ color: p.text, [\"--tw-ring-color\" as string]: p.ring }}>\n                View project →\n              </a>\n            ) : (\n              <span />\n            )}\n            <div className=\"flex gap-2\">\n              <button type=\"button\" onClick={() => {\n                  setDir(-1);\n                  onStep(-1);\n                }} aria-label=\"Previous project\" className={navBtn} style={{ borderColor: p.border, background: \"transparent\", color: p.text, [\"--tw-ring-color\" as string]: p.ring }}>\n                ←\n              </button>\n              <button type=\"button\" onClick={() => {\n                  setDir(1);\n                  onStep(1);\n                }} aria-label=\"Next project\" className={navBtn} style={{ borderColor: p.border, background: p.on, color: p.onText, [\"--tw-ring-color\" as string]: p.ring }}>\n                →\n              </button>\n            </div>\n          </div>\n        </div>\n      </div>\n    </motion.div>\n  );\n}\n\nexport function PortfolioGridBlock({\n  eyebrow = \"Selected work\",\n  title = \"Interiors, campaigns and portraits\",\n  description = \"A small studio for brands that care how things feel. Pick a category, or open any project for the details.\",\n  items = DEFAULT_ITEMS,\n  filters = true,\n  lightbox = true,\n  theme = \"dark\",\n  className,\n}: PortfolioGridBlockProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [cat, setCat] = React.useState(\"All\");\n  const [open, setOpen] = React.useState<number | null>(null);\n  const [mounted, setMounted] = React.useState(false);\n  const opener = React.useRef<HTMLElement | null>(null);\n  React.useEffect(() => {\n    const id = setTimeout(() => setMounted(true), 0);\n    return () => clearTimeout(id);\n  }, []);\n  const cats = [\"All\", ...Array.from(new Set(items.map((i) => i.category)))];\n  const list = items.filter((i) => cat === \"All\" || i.category === cat);\n  const close = React.useCallback(() => {\n    setOpen(null);\n    setTimeout(() => opener.current?.focus(), 0);\n  }, []);\n  const step = React.useCallback((d: number) => setOpen((o) => (o === null ? o : (o + d + list.length) % list.length)), [list.length]);\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.bg } as React.CSSProperties;\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-6xl px-6 py-20 @[640px]:py-24\">\n        <div className=\"flex flex-col gap-6 @[860px]:flex-row @[860px]:items-end @[860px]:justify-between\">\n          <div>\n            {eyebrow && <p className=\"m-0 text-[13px] font-medium tracking-[0.12em] uppercase\" style={{ color: p.faint }}>{eyebrow}</p>}\n            <h2 className=\"mt-3 mb-0 max-w-[18ch] text-[32px] leading-[1.1] font-semibold tracking-[-0.03em] @[640px]:text-[44px]\">{title}</h2>\n            {description && <p className=\"mt-4 mb-0 max-w-[480px] text-[16px] leading-[1.6]\" style={{ color: p.muted }}>{description}</p>}\n          </div>\n          {filters && cats.length > 2 && (\n            <div role=\"group\" aria-label=\"Filter projects\" className=\"-mx-6 flex gap-1 overflow-x-auto px-6 [scrollbar-width:none] @[860px]:mx-0 @[860px]:px-0 [&::-webkit-scrollbar]:hidden\">\n              <div className=\"flex shrink-0 rounded-full p-1\" style={{ background: p.chip }}>\n                {cats.map((c) => {\n                  const on = cat === c;\n                  return (\n                    <button key={c} type=\"button\" aria-pressed={on} onClick={() => setCat(c)} className=\"relative h-8 shrink-0 cursor-pointer rounded-full border-0 bg-transparent px-3.5 text-[13px] font-medium whitespace-nowrap outline-none focus-visible:ring-2\" style={{ color: on ? p.onText : p.muted, ...ring }}>\n                      {on && <motion.span layoutId={`${uid}-cat`} className=\"absolute inset-0 rounded-full\" style={{ background: p.on }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 420, damping: 34 }} />}\n                      <span className=\"relative\">{c}</span>\n                    </button>\n                  );\n                })}\n              </div>\n            </div>\n          )}\n        </div>\n\n        <LayoutGroup>\n          <ul className=\"m-0 mt-10 grid list-none auto-rows-[200px] grid-cols-1 gap-3 p-0 [grid-auto-flow:dense] @[560px]:grid-cols-2 @[560px]:auto-rows-[220px] @[900px]:grid-cols-3 @[900px]:auto-rows-[240px]\">\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              {list.map((it, i) => (\n                <motion.li\n                  key={it.id}\n                  layout={!reduce}\n                  initial={reduce ? false : { opacity: 0, scale: 0.96 }}\n                  animate={{ opacity: 1, scale: 1 }}\n                  exit={reduce ? undefined : { opacity: 0, scale: 0.96 }}\n                  transition={{ type: \"spring\", stiffness: 260, damping: 30 }}\n                  className={cn(it.size === \"wide\" && \"@[560px]:col-span-2\", it.size === \"tall\" && \"@[560px]:row-span-2\")}\n                >\n                  <button\n                    type=\"button\"\n                    onClick={(e) => {\n                      if (!lightbox) return;\n                      opener.current = e.currentTarget;\n                      setOpen(i);\n                    }}\n                    aria-haspopup={lightbox ? \"dialog\" : undefined}\n                    className=\"group relative block h-full w-full cursor-pointer overflow-hidden rounded-2xl border-0 p-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n                    style={{ background: p.chip, ...ring }}\n                  >\n                    {/* eslint-disable-next-line @next/next/no-img-element */}\n                    <img src={it.image} alt=\"\" loading=\"lazy\" className=\"absolute inset-0 h-full w-full object-cover transition-transform duration-700 ease-out group-hover:scale-[1.05]\" />\n                    <span aria-hidden=\"true\" className=\"absolute inset-0 bg-gradient-to-t from-black/75 via-black/10 to-transparent opacity-70 transition-opacity duration-300 group-hover:opacity-100 group-focus-visible:opacity-100\" />\n                    <span className=\"absolute inset-x-0 bottom-0 flex items-end justify-between gap-3 p-4 text-white @[640px]:p-5\">\n                      <span className=\"min-w-0\">\n                        <span className=\"block text-[11.5px] font-medium tracking-[0.1em] text-white/70 uppercase\">{it.category}</span>\n                        <span className=\"mt-1 block truncate text-[17px] font-semibold tracking-[-0.01em]\">{it.title}</span>\n                        <span className=\"block max-h-0 overflow-hidden text-[13px] text-white/75 transition-[max-height,margin] duration-300 group-hover:mt-1 group-hover:max-h-6 group-focus-visible:mt-1 group-focus-visible:max-h-6\">\n                          {[it.client, it.year].filter(Boolean).join(\" · \")}\n                        </span>\n                      </span>\n                      <span aria-hidden=\"true\" className=\"flex h-9 w-9 shrink-0 translate-y-2 items-center justify-center rounded-full bg-white text-[15px] text-black opacity-0 transition-all duration-300 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100\">\n                        ↗\n                      </span>\n                    </span>\n                  </button>\n                </motion.li>\n              ))}\n            </AnimatePresence>\n          </ul>\n        </LayoutGroup>\n      </div>\n      {mounted &&\n        createPortal(\n          <AnimatePresence>{open !== null && list[open] && <Lightbox key=\"lightbox\" items={list} index={open} onClose={close} onStep={step} p={p} reduce={reduce} />}</AnimatePresence>,\n          document.body,\n        )}\n    </section>\n  );\n}\n\nexport default PortfolioGridBlock;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}