{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "portfolio-showcase",
  "title": "Portfolio Showcase",
  "author": "AlgorizeTech",
  "description": "An infinite continuous 2D draggable masonry canvas with momentum physics, smooth camera glide, and interactive project modal for creative portfolios.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://avaraui.com/r/button.json",
    "https://avaraui.com/r/modal.json",
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/PortfolioShowcaseBlock.tsx",
      "content": "\"use client\";\n\nimport React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { Mail, ArrowUpRight } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport Button from \"./Button\";\nimport { Modal } from \"./ModalBlock\";\n\nexport interface PortfolioItem {\n  /** Project title */\n  title: string;\n  /** High-resolution project image URL */\n  image: string;\n  /** Project slug or unique identifier */\n  slug?: string;\n  /** Category or discipline (e.g. 'Brand Identity', 'Web Design', 'Mobile App') */\n  category?: string;\n  /** Comprehensive project description */\n  description?: string;\n  /** Client or organization name */\n  client?: string;\n  /** Year of creation or delivery */\n  year?: string;\n  /** Optional live URL or case study link */\n  href?: string;\n  /** Tags or keywords */\n  tags?: string[];\n  /** Detailed specifications or deliverables */\n  specs?: Record<string, string>;\n  /** Optional custom card height in px (will be clamped between 180 and 340) */\n  height?: number;\n}\n\nexport interface PortfolioShowcaseProps extends Omit<React.HTMLAttributes<HTMLElement>, \"onFocus\"> {\n  /** Visual presentation mode. Defaults to 'masonry-portfolio'. */\n  variant?: \"masonry-portfolio\" | \"fullscreen\";\n  /** The portfolio project cards shown on the canvas. */\n  items?: PortfolioItem[];\n  /** Staggered columns in one tile. Defaults to 4. */\n  columns?: number;\n  /** Gap between cards in pixels in all directions. Defaults to 16. */\n  gap?: number;\n  /** Vertical stagger offset between alternate columns. Defaults to 72. */\n  stagger?: number;\n  /** Controls automatic auto-scroll. Set to true (default) for continuous smooth 2D gliding, or false to hold still. */\n  interval?: boolean | number;\n  /** Interval time in ms when configured. Defaults to 5500. */\n  intervalTime?: number;\n  /** Sequence ordering: 'serial' or 'shuffle'. */\n  order?: \"serial\" | \"shuffle\";\n  /** Camera zoom / card scale multiplier on desktop. Defaults to 1. */\n  zoom?: number;\n  /** Camera zoom on mobile / small screens (<=640px). Defaults to 0.5. */\n  mobileZoom?: number;\n  /** Intro animation duration in ms. Defaults to 0 for instant start. */\n  intro?: number;\n  /** Whether the user can drag and pan the wall infinitely in all 4 directions with inertia. Defaults to true. */\n  draggable?: boolean;\n  /** Ambient continuous auto-scroll velocity { x, y } or boolean. Defaults to { x: -0.35, y: -0.18 } when interval=true. */\n  drift?: boolean | { x?: number; y?: number };\n  /** Opacity of resting cards. Defaults to 1. */\n  cardDim?: number;\n  /** Whether center card is highlighted. Defaults to false. */\n  highlightFocus?: boolean;\n  /** Whether cards render with elevated drop shadows. Defaults to true. */\n  cardShadow?: boolean;\n  /** Whether clicking a portfolio item opens the interactive details modal. Defaults to true. */\n  itemModal?: boolean;\n  /** Callback fired when an item is clicked. */\n  onItemClick?: (item: PortfolioItem, index: number) => void;\n  /** Callback fired when center card changes. */\n  onFocus?: (index: number) => void;\n  /** Optional custom CTA button text in the details modal */\n  ctaLabel?: string;\n  /** Optional custom CTA button link in the details modal */\n  ctaHref?: string;\n  /** Custom cursor badge label shown on card hover. Defaults to \"View Details\". */\n  cursorBadgeLabel?: string;\n  /** Whether to show the custom orange cursor with badge on card hover. Defaults to true. */\n  showCursorBadge?: boolean;\n}\n\n// ------------------------------------------\n// Geometry: Original card dimensions (384px wide × 285px high) preserved from previous commit\n// ------------------------------------------\nconst CARD_W = 384;\nconst GAP_DEFAULT = 16;\nconst STAGGER_DEFAULT = 72;\nconst CARD_BORDER = 1;\nconst CARD_PAD = 6;\nconst CAPTION_H = 16;\nconst FRAME_W = CARD_W - (CARD_BORDER + CARD_PAD) * 2; // 370px\nconst FRAME_RATIO = 493 / 332; // ~1.485\nconst FRAME_H = Math.round(FRAME_W / FRAME_RATIO); // 249px\nconst CARD_H = CARD_BORDER + CARD_PAD + CAPTION_H + CARD_PAD + FRAME_H + CARD_PAD + CARD_BORDER; // 285px\nconst CENTER_TILE = \"0,0\";\n\ninterface PlacedCard extends PortfolioItem {\n  left: number;\n  top: number;\n  cardH: number;\n  frameH: number;\n}\n\nfunction layoutCards(\n  items: PortfolioItem[],\n  columns: number,\n  gap: number = GAP_DEFAULT,\n  stagger: number = STAGGER_DEFAULT,\n) {\n  const colW = CARD_W + gap;\n  // Pad items so that every column has the exact same number of cards, avoiding empty trailing gaps\n  const remainder = items.length % columns;\n  const fullItems =\n    remainder === 0 || items.length === 0\n      ? items\n      : items.concat(items.slice(0, columns - remainder));\n\n  const rowsPerCol = Math.ceil(fullItems.length / columns);\n  // Masonry column offsets: creates an organic staggered wall without identical row lines\n  const pattern = [0, 1, 0.42, 1.25, 0.65, 1.1, 0.25, 0.85];\n  const colOffsets = Array.from({ length: columns }, (_, c) =>\n    stagger > 0 ? Math.round((pattern[c % pattern.length] ?? 0) * stagger) : 0,\n  );\n\n  const bottoms = [...colOffsets];\n  const placed: PlacedCard[] = fullItems.map((item, i) => {\n    const c = i % columns;\n    const card: PlacedCard = {\n      ...item,\n      left: c * colW,\n      top: bottoms[c],\n      cardH: CARD_H,\n      frameH: FRAME_H,\n    };\n    bottoms[c] += CARD_H + gap;\n    return card;\n  });\n\n  // Vertical repeat period MUST be exactly rowsPerCol * (CARD_H + gap).\n  // Because card.top = colOffsets[c] + r * (CARD_H + gap),\n  // (card.top + height) - (lastCard.top + CARD_H) = gap (strictly 16px) across infinite tile repeats for EVERY column!\n  const height = rowsPerCol * (CARD_H + gap);\n  const width = columns * colW;\n\n  return { placed, width, height };\n}\n\nconst prefersReducedMotion = () =>\n  typeof window !== \"undefined\" && window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;\n\n// ------------------------------------------\n// Individual Portfolio Card (Memoized)\n// ------------------------------------------\nconst ShowcaseCard = React.memo(function ShowcaseCard({\n  card,\n  left,\n  top,\n  copy,\n  cardDim = 1,\n  cardShadow = true,\n}: {\n  card: PlacedCard;\n  left: number;\n  top: number;\n  copy: boolean;\n  cardDim?: number;\n  cardShadow?: boolean;\n}) {\n  return (\n    <figure\n      aria-hidden={copy || undefined}\n      data-card\n      data-card-x={left}\n      data-card-y={top}\n      className={cn(\n        \"absolute flex flex-col gap-1.5 overflow-hidden rounded-2xl border border-foreground/12 p-2 transition-[opacity,transform,filter,box-shadow] duration-500 ease-out select-none will-change-transform cursor-none\",\n        cardShadow ? \"bg-card shadow-xl shadow-black/20 dark:shadow-black/55\" : \"bg-muted\",\n      )}\n      style={{\n        left,\n        top,\n        width: CARD_W,\n        height: card.cardH,\n        opacity: cardDim,\n      }}\n    >\n      <figcaption\n        className={cn(\n          \"flex h-4 shrink-0 items-center px-1 font-mono text-[9px] leading-none select-none transition-colors duration-500\",\n          cardShadow ? \"font-semibold text-foreground\" : \"text-muted-foreground\",\n        )}\n      >\n        {card.title}\n      </figcaption>\n      <div\n        className=\"relative min-h-0 flex-1 overflow-hidden rounded-lg border border-foreground/10 bg-card select-none\"\n        style={{ height: card.frameH }}\n      >\n        <img\n          src={card.image}\n          alt=\"\"\n          width={FRAME_W}\n          height={card.frameH}\n          decoding=\"async\"\n          draggable={false}\n          className=\"absolute inset-0 h-full w-full object-cover object-top select-none pointer-events-none\"\n        />\n      </div>\n    </figure>\n  );\n});\n\n// ------------------------------------------\n// Default Showcase Projects\n// ------------------------------------------\nexport const DEFAULT_PORTFOLIO_ITEMS: PortfolioItem[] = [\n  {\n    slug: \"fintech-aura\",\n    title: \"Aura Fintech Banking\",\n    category: \"Mobile App & Design System\",\n    client: \"Aura Global Financial\",\n    year: \"2026\",\n    description: \"An ultra-modern mobile banking experience and comprehensive design system with real-time liquidity visualization, biometric security flows, and seamless multi-currency settlements.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516057/bento-showcase-1790516064489.jpg\",\n    tags: [\"Mobile\", \"Fintech\", \"Design System\"],\n  },\n  {\n    slug: \"minimal-studio\",\n    title: \"Studio Arch Minimal\",\n    category: \"Architecture & Editorial\",\n    client: \"Atelier Architekten\",\n    year: \"2026\",\n    description: \"Monolithic editorial portfolio website for an international architectural studio, combining high-resolution spatial photography with smooth inertial gallery physics.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516057/collage-hero-1790516064493.jpg\",\n    tags: [\"Architecture\", \"Editorial\", \"Web Design\"],\n  },\n  {\n    slug: \"lumina-health\",\n    title: \"Lumina Telehealth AI\",\n    category: \"Healthcare & AI Assistant\",\n    client: \"Lumina Care Systems\",\n    year: \"2025\",\n    description: \"Intelligent diagnostic consultation and care booking workflow connecting patients to certified specialists with encrypted medical records and interactive appointment timeline.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516057/book-appointment-1790516064490.jpg\",\n    tags: [\"AI\", \"Healthcare\", \"Web App\"],\n  },\n  {\n    slug: \"atelier-fashion\",\n    title: \"Maison Haute Couture\",\n    category: \"Luxury Fashion & Ecommerce\",\n    client: \"Maison Parisienne\",\n    year: \"2026\",\n    description: \"Sensory runway collection showcase and high-converting ecommerce storefront with fluid magnetic carousels, lookbook moodboards, and bespoke checkout ergonomics.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516058/fashion-hero-1790516064495.jpg\",\n    tags: [\"Fashion\", \"Ecommerce\", \"Creative\"],\n  },\n  {\n    slug: \"cloud-metrics\",\n    title: \"Pulse Cloud Observability\",\n    category: \"Developer Tools & SaaS\",\n    client: \"Pulse Metrics Inc\",\n    year: \"2025\",\n    description: \"Zero-latency Kubernetes cluster monitoring dashboard with live metrics telemetry, interactive topological dependency graphs, and predictive incident management.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516056/data-flow-1790516064493.jpg\",\n    tags: [\"SaaS\", \"Dashboard\", \"DevTools\"],\n  },\n  {\n    slug: \"sound-craft\",\n    title: \"Sonic Spatial Experience\",\n    category: \"Interactive Audio & WebGL\",\n    client: \"Sonic Labs Zurich\",\n    year: \"2026\",\n    description: \"Immersive three-dimensional audio-reactive web landscape transforming organic sound frequencies into dynamic procedural light wave sculptures in real-time.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516057/hero-1790516064495.jpg\",\n    tags: [\"WebGL\", \"Audio\", \"Interactive\"],\n  },\n  {\n    slug: \"strata-billing\",\n    title: \"Strata Revenue Infrastructure\",\n    category: \"Fintech & Invoicing\",\n    client: \"Strata Global Pay\",\n    year: \"2026\",\n    description: \"Enterprise billing automation engine featuring dynamic pricing matrices, localized VAT compliance, automated reconciliation, and beautiful customer invoices.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516058/pricing-1790516064500.jpg\",\n    tags: [\"Enterprise\", \"Billing\", \"Product\"],\n  },\n  {\n    slug: \"honeycomb-grid\",\n    title: \"Hive Neural Collaboration\",\n    category: \"Productivity & Workspace\",\n    client: \"Hive Technologies\",\n    year: \"2025\",\n    description: \"Hexagonal interconnected canvas for modern product teams, mapping user research insights, interface wireframes, and design components onto a shared spatial board.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516059/honeycomb-hero-1790516064497.jpg\",\n    tags: [\"Collaboration\", \"Workspace\", \"Canvas\"],\n  },\n  {\n    slug: \"chrono-schedule\",\n    title: \"Chrono Calendar Intelligence\",\n    category: \"Time Management & UI\",\n    client: \"Chrono Labs\",\n    year: \"2026\",\n    description: \"Time-zone agnostic smart scheduling assistant with fluid calendar heatmaps, recurring event sync, and focus-time protection algorithms.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516057/calendar-1790516064491.jpg\",\n    tags: [\"Productivity\", \"Calendar\", \"UI Design\"],\n  },\n  {\n    slug: \"orbit-gallery\",\n    title: \"Orbital Digital Museum\",\n    category: \"Cultural Arts & Exhibition\",\n    client: \"Modern Art Foundation\",\n    year: \"2026\",\n    description: \"Circular spatial gallery presenting curated contemporary digital artwork, sculpture archives, and generative generative art with gyroscopic navigation.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516058/orbit-gallery-1790516064499.jpg\",\n    tags: [\"Museum\", \"Arts\", \"3D Gallery\"],\n  },\n  {\n    slug: \"verve-commerce\",\n    title: \"Verve Artisan Goods\",\n    category: \"Brand & Direct-to-Consumer\",\n    client: \"Verve Roasters\",\n    year: \"2025\",\n    description: \"Direct-to-consumer artisanal coffee subscription portal with roast date tracking, origin stories, and interactive tasting notes flavor profile matching.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516058/product-details-1790516064500.jpg\",\n    tags: [\"Ecommerce\", \"Branding\", \"D2C\"],\n  },\n  {\n    slug: \"nexus-analytics\",\n    title: \"Nexus Global Ledger\",\n    category: \"Big Data & Visualization\",\n    client: \"Nexus Capital\",\n    year: \"2026\",\n    description: \"High-density data grid platform capable of streaming hundreds of thousands of ledger records per second with GPU-accelerated filtering and pivot charting.\",\n    image: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516056/data-grid-1790516064494.jpg\",\n    tags: [\"Big Data\", \"Fintech\", \"Analytics\"],\n  },\n];\n\n// ------------------------------------------\n// PortfolioShowcase Component\n// ------------------------------------------\nexport const PortfolioShowcase = forwardRef<HTMLElement, PortfolioShowcaseProps>(\n  (\n    {\n      variant = \"masonry-portfolio\",\n      items = DEFAULT_PORTFOLIO_ITEMS,\n      columns = 4,\n      gap = GAP_DEFAULT,\n      stagger = STAGGER_DEFAULT,\n      interval = true,\n      intervalTime = 5500,\n      order = \"shuffle\",\n      zoom = 0.55,\n      mobileZoom = 0.42,\n      intro = 0,\n      draggable = true,\n      drift,\n      cardDim = 1,\n      highlightFocus = false,\n      cardShadow = true,\n      itemModal = true,\n      onItemClick,\n      onFocus,\n      ctaLabel = \"View Case Study\",\n      ctaHref = \"#\",\n      cursorBadgeLabel = \"View Details\",\n      showCursorBadge = true,\n      className,\n      ...props\n    },\n    ref,\n  ) => {\n    const [selectedItem, setSelectedItem] = useState<PortfolioItem | null>(null);\n    const [tiles, setTiles] = useState(CENTER_TILE);\n    const [isDragging, setIsDragging] = useState(false);\n    const [onScreen, setOnScreen] = useState(true);\n    const [isHoveringCard, setIsHoveringCard] = useState(false);\n    const isHoveringCardRef = useRef(false);\n    const customCursorRef = useRef<HTMLDivElement | null>(null);\n\n    const wrapRef = useRef<HTMLDivElement | null>(null);\n    const canvasRef = useRef<HTMLDivElement | null>(null);\n    const cameraRef = useRef({ x: 0, y: 0, s: zoom });\n    const tilesRef = useRef(CENTER_TILE);\n    const momentumAnimRef = useRef<number | null>(null);\n    const driftAnimRef = useRef<number | null>(null);\n\n    // Drag / Pan interaction state\n    const dragRef = useRef({\n      active: false,\n      startX: 0,\n      startY: 0,\n      lastX: 0,\n      lastY: 0,\n      camStartX: 0,\n      camStartY: 0,\n      lastTime: 0,\n      vx: 0,\n      vy: 0,\n      moved: false,\n    });\n\n    // Layout memoization\n    const { placed, width, height } = useMemo(\n      () => layoutCards(items, columns, gap, stagger),\n      [items, columns, gap, stagger],\n    );\n    const placedRef = useRef(placed);\n    placedRef.current = placed;\n\n    const tileRef = useRef({ width, height });\n    tileRef.current = { width, height };\n\n    // Auto-scroll drift animation: when interval is enabled (true or >0), activate the continuous\n    // smooth auto-scrolling glide { x: -0.35, y: -0.18 } restored from the original fullscreen wall variant.\n    // Pauses cleanly when the project inspection modal is open.\n    const isIntervalActive = typeof interval === \"boolean\" ? interval : interval > 0;\n    const resolvedDrift =\n      selectedItem !== null\n        ? false\n        : drift !== undefined\n          ? drift\n          : isIntervalActive\n            ? { x: -0.35, y: -0.18 }\n            : false;\n\n    // Viewport tile culling for infinite 2D canvas wrapping\n    const cull = useCallback(() => {\n      const wrap = wrapRef.current;\n      if (!wrap) return;\n      const { x, y, s } = cameraRef.current;\n      const { width: tw, height: th } = tileRef.current;\n      if (!tw || !th) return;\n\n      const w = wrap.clientWidth;\n      const h = wrap.clientHeight;\n      if (!w || !h) return;\n\n      const margin = CARD_W;\n      const minX = -x / s - margin;\n      const maxX = (w - x) / s + margin;\n      const minY = -y / s - margin;\n      const maxY = (h - y) / s + margin;\n\n      const minDx = Math.floor(minX / tw);\n      const maxDx = Math.floor(maxX / tw);\n      const minDy = Math.floor(minY / th);\n      const maxDy = Math.floor(maxY / th);\n\n      const keep: string[] = [];\n      for (let dy = minDy; dy <= maxDy; dy++) {\n        for (let dx = minDx; dx <= maxDx; dx++) {\n          keep.push(`${dx},${dy}`);\n        }\n      }\n\n      const key = keep.join(\"|\") || CENTER_TILE;\n      if (key !== tilesRef.current) {\n        tilesRef.current = key;\n        setTiles(key);\n      }\n    }, []);\n\n    // Track whether camera has been initialized\n    const initializedRef = useRef(false);\n\n    // Ambient 60fps auto-scroll glide\n    const startAmbientDrift = useCallback(() => {\n      if (!resolvedDrift || prefersReducedMotion()) return;\n      if (momentumAnimRef.current) return;\n      if (driftAnimRef.current) cancelAnimationFrame(driftAnimRef.current);\n\n      const dx = typeof resolvedDrift === \"object\" ? (resolvedDrift.x ?? -0.35) : -0.35;\n      const dy = typeof resolvedDrift === \"object\" ? (resolvedDrift.y ?? -0.18) : -0.18;\n\n      const tickDrift = () => {\n        if (dragRef.current.active) {\n          driftAnimRef.current = null;\n          return;\n        }\n        cameraRef.current.x += dx;\n        cameraRef.current.y += dy;\n        const el = canvasRef.current;\n        if (el) {\n          el.style.translate = `${cameraRef.current.x}px ${cameraRef.current.y}px`;\n        }\n        cull();\n        driftAnimRef.current = requestAnimationFrame(tickDrift);\n      };\n      driftAnimRef.current = requestAnimationFrame(tickDrift);\n    }, [resolvedDrift, cull]);\n\n    // Reactively start or stop drift when resolvedDrift or onScreen changes\n    useEffect(() => {\n      if (resolvedDrift && onScreen) {\n        if (!dragRef.current.active && !momentumAnimRef.current) {\n          startAmbientDrift();\n        }\n      } else {\n        if (driftAnimRef.current) {\n          cancelAnimationFrame(driftAnimRef.current);\n          driftAnimRef.current = null;\n        }\n      }\n      return () => {\n        if (driftAnimRef.current) {\n          cancelAnimationFrame(driftAnimRef.current);\n          driftAnimRef.current = null;\n        }\n      };\n    }, [resolvedDrift, onScreen, startAmbientDrift]);\n\n    // Initial scale & center positioning - only happens ONCE, never resets during scroll/drag\n    useLayoutEffect(() => {\n      const wrap = wrapRef.current;\n      if (!wrap) return;\n\n      const W = wrap.clientWidth;\n      const s = W <= 640 && mobileZoom !== undefined ? mobileZoom : zoom;\n      cameraRef.current.s = s;\n\n      if (!initializedRef.current) {\n        initializedRef.current = true;\n        // Center initial canvas position on first mount\n        const cx = width / 2;\n        const cy = height / 2;\n        cameraRef.current.x = W * 0.5 - s * cx;\n        cameraRef.current.y = wrap.clientHeight * 0.5 - s * cy;\n      }\n\n      const el = canvasRef.current;\n      if (el) {\n        el.style.translate = `${cameraRef.current.x}px ${cameraRef.current.y}px`;\n        el.style.scale = String(s);\n        el.style.opacity = \"1\";\n      }\n      cull();\n\n      if (resolvedDrift && !dragRef.current.active && !momentumAnimRef.current) {\n        startAmbientDrift();\n      }\n\n      const handleResize = () => {\n        const currentWrap = wrapRef.current;\n        if (!currentWrap) return;\n        const currentW = currentWrap.clientWidth;\n        const newS = currentW <= 640 && mobileZoom !== undefined ? mobileZoom : zoom;\n        cameraRef.current.s = newS;\n        if (canvasRef.current) {\n          canvasRef.current.style.scale = String(newS);\n        }\n        cull();\n      };\n\n      const ro = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(handleResize);\n      ro?.observe(wrap);\n\n      return () => {\n        ro?.disconnect();\n      };\n    }, [width, height, zoom, mobileZoom, cull, resolvedDrift, startAmbientDrift]);\n\n\n    const handlePointerDown = useCallback(\n      (e: React.PointerEvent<HTMLDivElement>) => {\n        if (!draggable || e.button !== 0) return;\n        if (momentumAnimRef.current) {\n          cancelAnimationFrame(momentumAnimRef.current);\n          momentumAnimRef.current = null;\n        }\n        if (driftAnimRef.current) {\n          cancelAnimationFrame(driftAnimRef.current);\n          driftAnimRef.current = null;\n        }\n\n        if (isHoveringCardRef.current) {\n          isHoveringCardRef.current = false;\n          setIsHoveringCard(false);\n        }\n\n        const d = dragRef.current;\n        d.active = true;\n        d.startX = e.clientX;\n        d.startY = e.clientY;\n        d.lastX = e.clientX;\n        d.lastY = e.clientY;\n        d.camStartX = cameraRef.current.x;\n        d.camStartY = cameraRef.current.y;\n        d.lastTime = performance.now();\n        d.vx = 0;\n        d.vy = 0;\n        d.moved = false;\n\n        setIsDragging(true);\n        try {\n          (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n        } catch {}\n      },\n      [draggable],\n    );\n\n    const handlePointerMove = useCallback(\n      (e: React.PointerEvent<HTMLDivElement>) => {\n        // Track custom cursor position and card hover state on desktop\n        if (showCursorBadge && e.pointerType !== \"touch\" && customCursorRef.current && wrapRef.current) {\n          const rect = wrapRef.current.getBoundingClientRect();\n          const x = e.clientX - rect.left;\n          const y = e.clientY - rect.top;\n          customCursorRef.current.style.transform = `translate3d(${x}px, ${y}px, 0)`;\n\n          const target = e.target as HTMLElement | null;\n          const isOverCard = Boolean(target?.closest?.(\"[data-card]\"));\n          if (isOverCard !== isHoveringCardRef.current) {\n            isHoveringCardRef.current = isOverCard;\n            setIsHoveringCard(isOverCard);\n          }\n        }\n\n        const d = dragRef.current;\n        if (!d.active) return;\n\n        const deltaX = e.clientX - d.startX;\n        const deltaY = e.clientY - d.startY;\n        if (!d.moved && Math.hypot(deltaX, deltaY) > 4) {\n          d.moved = true;\n          if (isHoveringCardRef.current) {\n            isHoveringCardRef.current = false;\n            setIsHoveringCard(false);\n          }\n        }\n\n        const now = performance.now();\n        const dt = Math.max(1, now - d.lastTime);\n        const stepX = e.clientX - d.lastX;\n        const stepY = e.clientY - d.lastY;\n\n        d.vx = (stepX / dt) * 16.67;\n        d.vy = (stepY / dt) * 16.67;\n        d.lastX = e.clientX;\n        d.lastY = e.clientY;\n        d.lastTime = now;\n\n        cameraRef.current.x = d.camStartX + deltaX;\n        cameraRef.current.y = d.camStartY + deltaY;\n\n        const el = canvasRef.current;\n        if (el) {\n          el.style.translate = `${cameraRef.current.x}px ${cameraRef.current.y}px`;\n        }\n        cull();\n      },\n      [cull, showCursorBadge],\n    );\n\n    const handleCardSelection = useCallback(\n      (portfolioItem: PortfolioItem, index: number) => {\n        onItemClick?.(portfolioItem, index);\n        if (itemModal) {\n          setSelectedItem(portfolioItem);\n        }\n      },\n      [itemModal, onItemClick],\n    );\n\n    const handlePointerUp = useCallback(\n      (e: React.PointerEvent<HTMLDivElement>) => {\n        const d = dragRef.current;\n        if (!d.active) return;\n        d.active = false;\n        setIsDragging(false);\n\n        try {\n          (e.currentTarget as HTMLElement).releasePointerCapture(e.pointerId);\n        } catch {}\n\n        // Click / tap item inspection\n        if (!d.moved) {\n          const wrap = wrapRef.current;\n          if (wrap) {\n            const rect = wrap.getBoundingClientRect();\n            const clickX = e.clientX - rect.left;\n            const clickY = e.clientY - rect.top;\n            const { x, y, s } = cameraRef.current;\n            const canvasX = (clickX - x) / s;\n            const canvasY = (clickY - y) / s;\n            const tw = tileRef.current.width;\n            const th = tileRef.current.height;\n            const baseDx = Math.floor(canvasX / tw);\n            const baseDy = Math.floor(canvasY / th);\n            const placedList = placedRef.current;\n            let clickedIndex = -1;\n\n            for (let cdy = baseDy - 1; cdy <= baseDy + 1; cdy++) {\n              for (let cdx = baseDx - 1; cdx <= baseDx + 1; cdx++) {\n                const offsetX = cdx * tw;\n                const offsetY = cdy * th;\n                for (let i = 0; i < placedList.length; i++) {\n                  const c = placedList[i];\n                  const left = c.left + offsetX;\n                  const top = c.top + offsetY;\n                  if (\n                    canvasX >= left &&\n                    canvasX <= left + CARD_W &&\n                    canvasY >= top &&\n                    canvasY <= top + (c.cardH ?? CARD_H)\n                  ) {\n                    clickedIndex = items.length > 0 ? i % items.length : i;\n                    break;\n                  }\n                }\n                if (clickedIndex >= 0) break;\n              }\n              if (clickedIndex >= 0) break;\n            }\n\n            if (clickedIndex >= 0) {\n              const rawItem = items[clickedIndex] ?? placedList[clickedIndex];\n              handleCardSelection(rawItem, clickedIndex);\n            }\n          }\n        }\n\n        // Kinetic inertial momentum physics\n        const maxV = 28;\n        let vx = Math.max(-maxV, Math.min(maxV, d.vx || 0));\n        let vy = Math.max(-maxV, Math.min(maxV, d.vy || 0));\n\n        const tickMomentum = () => {\n          if (Math.abs(vx) < 0.15 && Math.abs(vy) < 0.15) {\n            momentumAnimRef.current = null;\n            if (resolvedDrift) startAmbientDrift();\n            return;\n          }\n\n          cameraRef.current.x += vx;\n          cameraRef.current.y += vy;\n          vx *= 0.93;\n          vy *= 0.93;\n\n          const el = canvasRef.current;\n          if (el) {\n            el.style.translate = `${cameraRef.current.x}px ${cameraRef.current.y}px`;\n          }\n          cull();\n          momentumAnimRef.current = requestAnimationFrame(tickMomentum);\n        };\n\n        if (Math.hypot(vx, vy) > 0.5) {\n          momentumAnimRef.current = requestAnimationFrame(tickMomentum);\n        } else if (resolvedDrift) {\n          startAmbientDrift();\n        }\n      },\n      [cull, resolvedDrift, startAmbientDrift, handleCardSelection, items],\n    );\n\n    // Visibility & screen intersection observers to preserve performance\n    useEffect(() => {\n      const onVisibility = () => {\n        const isHidden = document.hidden;\n        if (isHidden) {\n          if (driftAnimRef.current) cancelAnimationFrame(driftAnimRef.current);\n        } else if (resolvedDrift) {\n          startAmbientDrift();\n        }\n      };\n      document.addEventListener(\"visibilitychange\", onVisibility);\n      return () => document.removeEventListener(\"visibilitychange\", onVisibility);\n    }, [resolvedDrift, startAmbientDrift]);\n\n    useEffect(() => {\n      const el = wrapRef.current;\n      if (!el || typeof IntersectionObserver === \"undefined\") return;\n      const io = new IntersectionObserver(\n        (entries) => {\n          const visible = entries.some((e) => e.isIntersecting);\n          setOnScreen(visible);\n          if (visible && resolvedDrift) {\n            startAmbientDrift();\n          } else if (driftAnimRef.current) {\n            cancelAnimationFrame(driftAnimRef.current);\n          }\n        },\n        { threshold: 0.15 },\n      );\n      io.observe(el);\n      return () => io.disconnect();\n    }, [resolvedDrift, startAmbientDrift]);\n\n    // Visible tile offsets\n    const offsets = useMemo(\n      () =>\n        tiles.split(\"|\").map((t: string) => {\n          const [dx, dy] = t.split(\",\").map(Number);\n          return { dx, dy };\n        }),\n      [tiles],\n    );\n\n    // Cards grid rendering\n    const cards = useMemo(\n      () =>\n        offsets.map(({ dx, dy }: { dx: number; dy: number }) => {\n          const copy = dx !== 0 || dy !== 0;\n          return placed.map((card, i) => {\n            const key = `${dx},${dy},${i}`;\n            return (\n              <ShowcaseCard\n                key={key}\n                card={card}\n                left={card.left + dx * width}\n                top={card.top + dy * height}\n                copy={copy}\n                cardDim={cardDim}\n                cardShadow={cardShadow}\n              />\n            );\n          });\n        }),\n      [offsets, placed, width, height, cardDim, cardShadow],\n    );\n\n    const activeProject = selectedItem ?? items[0];\n\n    return (\n      <>\n        <section\n          ref={ref}\n          className={cn(\n            \"relative w-full h-[520px] sm:h-[640px] lg:h-[760px] overflow-hidden bg-background text-foreground select-none\",\n            className,\n          )}\n          {...props}\n        >\n          {/* Multi-tiered 3D convex dome cushion underneath the cards in center */}\n          <div\n            className=\"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center z-0\"\n            aria-hidden\n          >\n            {/* Ambient diffuse primary aura around the base */}\n            <div\n              className=\"absolute w-[980px] max-w-[96vw] h-[640px] rounded-full blur-3xl opacity-75 dark:opacity-45\"\n              style={{\n                background:\n                  \"radial-gradient(ellipse at 50% 50%, color-mix(in oklab, var(--primary) 22%, transparent) 0%, color-mix(in oklab, var(--primary) 8%, transparent) 55%, transparent 75%)\",\n              }}\n            />\n\n            {/* Base Tier 1: Outer mound rim with 3D elevation shadow */}\n            <div\n              className=\"absolute w-[880px] max-w-[94vw] h-[550px] rounded-full border border-foreground/[0.08] dark:border-white/[0.09] shadow-[0_30px_70px_-15px_rgba(0,0,0,0.14),inset_0_1px_2px_rgba(255,255,255,0.7)] dark:shadow-[0_30px_80px_-15px_rgba(0,0,0,0.65),inset_0_1px_2px_rgba(255,255,255,0.15)]\"\n              style={{\n                background:\n                  \"radial-gradient(ellipse at 50% 40%, color-mix(in oklab, var(--card) 92%, white) 0%, color-mix(in oklab, var(--card) 65%, var(--background)) 55%, color-mix(in oklab, var(--background) 90%, transparent) 85%, transparent 100%)\",\n              }}\n            />\n\n            {/* Mid Tier 2: Rising dome slope ring */}\n            <div\n              className=\"absolute w-[640px] max-w-[80vw] h-[400px] rounded-full border border-foreground/[0.10] dark:border-white/[0.12] shadow-[0_20px_50px_-10px_rgba(0,0,0,0.16),inset_0_2px_4px_rgba(255,255,255,0.85)] dark:shadow-[0_20px_50px_-10px_rgba(0,0,0,0.7),inset_0_2px_4px_rgba(255,255,255,0.2)]\"\n              style={{\n                background:\n                  \"radial-gradient(ellipse at 50% 36%, color-mix(in oklab, var(--card) 98%, white) 0%, color-mix(in oklab, var(--card) 80%, white) 45%, color-mix(in oklab, var(--primary) 12%, transparent) 80%, transparent 100%)\",\n              }}\n            />\n\n            {/* Apex Tier 3: Center crest / peak */}\n            <div\n              className=\"absolute w-[400px] max-w-[58vw] h-[250px] rounded-full border border-foreground/[0.12] dark:border-white/[0.16] shadow-[0_14px_35px_-6px_rgba(0,0,0,0.18),inset_0_2px_6px_rgba(255,255,255,0.95)] dark:shadow-[0_14px_35px_-6px_rgba(0,0,0,0.75),inset_0_2px_6px_rgba(255,255,255,0.25)]\"\n              style={{\n                background:\n                  \"radial-gradient(ellipse at 50% 30%, color-mix(in oklab, var(--card) 99%, white) 0%, color-mix(in oklab, var(--card) 88%, white) 50%, color-mix(in oklab, var(--primary) 18%, transparent) 85%, transparent 100%)\",\n              }}\n            />\n\n            {/* Specular light glint at top-center of the dome peak */}\n            <div\n              className=\"absolute -translate-y-8 w-[220px] h-[95px] rounded-full blur-md opacity-80 dark:opacity-40\"\n              style={{\n                background:\n                  \"radial-gradient(ellipse at 50% 50%, rgba(255,255,255,0.95) 0%, color-mix(in oklab, var(--primary) 30%, white) 45%, transparent 75%)\",\n              }}\n            />\n          </div>\n\n          {/* Self-contained 2D Infinite Canvas */}\n          <div\n            ref={wrapRef}\n            onPointerDown={handlePointerDown}\n            onPointerMove={handlePointerMove}\n            onPointerUp={handlePointerUp}\n            onPointerCancel={handlePointerUp}\n            onPointerLeave={() => {\n              if (isHoveringCardRef.current) {\n                isHoveringCardRef.current = false;\n                setIsHoveringCard(false);\n              }\n            }}\n            className={cn(\n              \"relative z-10 size-full overflow-hidden select-none touch-none [mask-image:radial-gradient(ellipse_78%_68%_at_50%_50%,black_45%,rgba(0,0,0,0.85)_75%,transparent_100%)]\",\n              draggable && (isDragging ? \"cursor-grabbing\" : \"cursor-grab\"),\n            )}\n          >\n            <div\n              ref={canvasRef}\n              className=\"absolute left-0 top-0 will-change-transform origin-top-left\"\n              style={{ width, height, opacity: 0 }}\n            >\n              {cards}\n            </div>\n\n            {/* Custom Theme-Aware Mouse Pointer with \"View Details\" Badge */}\n            {showCursorBadge && (\n              <div\n                ref={customCursorRef}\n                aria-hidden=\"true\"\n                className={cn(\n                  \"pointer-events-none absolute left-0 top-0 z-40 transition-opacity duration-150 ease-out select-none will-change-transform flex items-start\",\n                  isHoveringCard && !isDragging && !selectedItem\n                    ? \"opacity-100 scale-100\"\n                    : \"opacity-0 scale-95 pointer-events-none\",\n                )}\n                style={{\n                  transform: \"translate3d(-9999px, -9999px, 0)\",\n                }}\n              >\n                {/* Mouse Cursor Arrow matching Theme Color */}\n                <svg\n                  width=\"18\"\n                  height=\"18\"\n                  viewBox=\"0 0 20 20\"\n                  fill=\"none\"\n                  xmlns=\"http://www.w3.org/2000/svg\"\n                  className=\"shrink-0 text-primary drop-shadow-[0_1px_2px_rgba(0,0,0,0.3)]\"\n                >\n                  <path\n                    d=\"M0 0L7.07 17.97L9.58 10.58L16.97 8.07L0 0Z\"\n                    fill=\"currentColor\"\n                  />\n                </svg>\n\n                {/* Pill Badge matching Theme Color */}\n                <div className=\"bg-primary text-primary-foreground text-[12px] font-bold px-2.5 py-1 rounded-[8px] shadow-[0_2px_10px_color-mix(in_oklab,var(--primary)_35%,transparent)] whitespace-nowrap leading-none tracking-wide -ml-1 mt-2.5 select-none\">\n                  {cursorBadgeLabel}\n                </div>\n              </div>\n            )}\n          </div>\n\n          {/* 4-sided smooth perimeter vignette */}\n          <div className=\"pointer-events-none absolute inset-x-0 top-0 h-28 sm:h-40 bg-gradient-to-b from-background via-background/85 to-transparent z-20\" aria-hidden />\n          <div className=\"pointer-events-none absolute inset-x-0 bottom-0 h-28 sm:h-40 bg-gradient-to-t from-background via-background/85 to-transparent z-20\" aria-hidden />\n          <div className=\"pointer-events-none absolute inset-y-0 left-0 w-24 sm:w-40 bg-gradient-to-r from-background via-background/85 to-transparent z-20\" aria-hidden />\n          <div className=\"pointer-events-none absolute inset-y-0 right-0 w-24 sm:w-40 bg-gradient-to-l from-background via-background/85 to-transparent z-20\" aria-hidden />\n        </section>\n\n        {/* Interactive Portfolio Details Modal: Full-screen visual showcase with ribbon-like frosted blur */}\n        {itemModal && (\n          <Modal\n            isOpen={Boolean(selectedItem)}\n            onClose={() => setSelectedItem(null)}\n            variant=\"custom\"\n            overlayClassName=\"bg-black/60 backdrop-blur-xl transition-all duration-300\"\n            contentClassName=\"max-w-5xl w-[94vw] sm:w-[88vw] md:w-[82vw] p-0 overflow-y-auto md:overflow-hidden bg-card border border-foreground/15 dark:border-white/10 rounded-2xl sm:rounded-3xl shadow-2xl max-h-[90vh] md:max-h-[85vh] flex flex-col relative\"\n            ariaLabel={activeProject ? `${activeProject.title} Showcase` : \"Portfolio Project\"}\n          >\n            {activeProject && (\n              <div className=\"relative w-full flex flex-col md:block overflow-hidden bg-card select-none\">\n                {/* Complete Project Image: 100% visible with zero zooming or clipping */}\n                <div className=\"relative w-full overflow-hidden flex items-center justify-center bg-card\">\n                  <img\n                    src={activeProject.image}\n                    alt={activeProject.title}\n                    className=\"w-full h-auto max-h-[50vh] sm:max-h-[60vh] md:max-h-[82vh] object-contain block select-none pointer-events-none\"\n                  />\n                </div>\n\n                {/* Info & Action Controls: In-flow below image on mobile (not absolute), floating frosted ribbon pill on desktop (md:) */}\n                <div className=\"relative md:absolute md:inset-x-6 md:bottom-6 z-20 flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3 sm:gap-4 p-4 sm:p-5 md:py-3.5 md:px-5 border-t md:border border-foreground/10 md:border-foreground/15 dark:border-white/10 md:dark:border-white/15 bg-card/95 md:bg-white/75 md:dark:bg-[#131316]/75 md:backdrop-blur-md md:rounded-2xl\">\n                  <div className=\"space-y-1 md:space-y-0.5 max-w-xl\">\n                    <h2 className=\"text-base sm:text-lg md:text-xl font-bold tracking-tight text-foreground\">\n                      {activeProject.title}\n                    </h2>\n                    {activeProject.category && (\n                      <p className=\"text-xs sm:text-sm font-medium text-muted-foreground\">\n                        {activeProject.category}\n                      </p>\n                    )}\n                    {activeProject.description && (\n                      <p className=\"text-xs sm:text-sm text-muted-foreground/90 leading-relaxed pt-1 md:hidden\">\n                        {activeProject.description}\n                      </p>\n                    )}\n                  </div>\n\n                  <div className=\"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 sm:gap-2.5 w-full md:w-auto shrink-0 pt-1 md:pt-0 [&>div]:w-full sm:[&>div]:w-auto [&>div>button]:w-full sm:[&>div>button]:w-auto [&>button]:w-full sm:[&>button]:w-auto\">\n                    <Button\n                      variant=\"default\"\n                      size=\"default\"\n                      onClick={(e) => {\n                        e.preventDefault();\n                        if (activeProject.href && activeProject.href !== \"#\") {\n                          window.open(activeProject.href, \"_blank\", \"noopener,noreferrer\");\n                        }\n                      }}\n                      iconRight={<ArrowUpRight size={15} />}\n                      className=\"w-full sm:w-auto font-medium\"\n                    >\n                      {ctaLabel}\n                    </Button>\n\n                    <Button\n                      variant=\"outline\"\n                      size=\"default\"\n                      onClick={(e) => {\n                        e.preventDefault();\n                      }}\n                      iconLeft={<Mail size={15} />}\n                      className=\"w-full sm:w-auto font-medium\"\n                    >\n                      Contact\n                    </Button>\n                  </div>\n                </div>\n              </div>\n            )}\n          </Modal>\n        )}\n      </>\n    );\n  },\n);\n\nPortfolioShowcase.displayName = \"PortfolioShowcase\";\n",
      "type": "registry:component",
      "target": "components/custom/blocks/PortfolioShowcaseBlock.tsx"
    }
  ],
  "docs": "Named export: PortfolioShowcase (plus PortfolioItem type). Renders an edge-to-edge infinite masonry canvas with 4-directional kinetic drag, auto-glide camera, and full-details modal.",
  "categories": [
    "media",
    "marketing"
  ],
  "type": "registry:component"
}
