{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "top-destinations",
  "title": "Top Destinations",
  "author": "AlgorizeTech",
  "description": "A dual-row scroll-driven destination showcase with opposite-direction GSAP ScrollTrigger parallax travel, full-bleed photography, and interactive hover details.",
  "dependencies": [
    "gsap",
    "lucide-react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/TopDestinationsBlock.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport gsap from \"gsap\";\nimport { ScrollTrigger } from \"gsap/ScrollTrigger\";\nimport { ArrowUpRight, MapPin } from \"lucide-react\";\nimport React, { useEffect, useRef } from \"react\";\n\nif (typeof window !== \"undefined\") {\n  gsap.registerPlugin(ScrollTrigger);\n}\n\nexport interface DestinationItem {\n  id: string | number;\n  title: string;\n  country?: string;\n  placesCount?: number | string;\n  image: string;\n  tag?: string;\n  link?: string;\n}\n\nexport interface TopDestinationsProps\n  extends React.HTMLAttributes<HTMLElement> {\n  badgeText?: string;\n  badgeIcon?: React.ReactNode;\n  title?: string;\n  subtitle?: string;\n  /** Pass all items (automatically split evenly into 2 rows), or provide row1Items & row2Items directly */\n  items?: DestinationItem[];\n  row1Items?: DestinationItem[];\n  row2Items?: DestinationItem[];\n  /** Travel offset in px as the user scrolls past the section (default: 450) */\n  scrollOffset?: number;\n  /** Explicit scrolling container element or ref (essential for preview sandbox boxes) */\n  scrollerRef?: React.RefObject<HTMLElement | null>;\n  /** Callback fired when the Explore button on any card is clicked */\n  onExplore?: (item: DestinationItem) => void;\n}\n\nexport const DEFAULT_DESTINATIONS: DestinationItem[] = [\n  {\n    id: \"bali\",\n    title: \"Bali\",\n    country: \"Indonesia\",\n    placesCount: 38,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790158812/photo-1721335916916-37c319adce3a-1790158812206.jpg\",\n    tag: \"Tropical\",\n  },\n  {\n    id: \"kyoto\",\n    title: \"Kyoto\",\n    country: \"Japan\",\n    placesCount: 42,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790146211/photo-1441974231531-c6227db76b6e-1790146212212.jpg\",\n    tag: \"Historic\",\n  },\n  {\n    id: \"santorini\",\n    title: \"Santorini\",\n    country: \"Greece\",\n    placesCount: 26,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790166049/photo-1527004013197-933c4bb611b3-1790166052225.jpg\",\n    tag: \"Islands\",\n  },\n  {\n    id: \"amalfi\",\n    title: \"Amalfi Coast\",\n    country: \"Italy\",\n    placesCount: 31,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790158811/photo-1663428520845-056989f8a664-1790158812204.jpg\",\n    tag: \"Coastal\",\n  },\n  {\n    id: \"paris\",\n    title: \"Paris\",\n    country: \"France\",\n    placesCount: 54,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790146209/photo-1469474968028-56623f02e42e-1790146212205.jpg\",\n    tag: \"Romantic\",\n  },\n  {\n    id: \"new-york\",\n    title: \"New York\",\n    country: \"USA\",\n    placesCount: 68,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790145142/photo-1500530855697-b586d89ba3ee-1790145143493.jpg\",\n    tag: \"Metropolis\",\n  },\n  {\n    id: \"cape-town\",\n    title: \"Cape Town\",\n    country: \"South Africa\",\n    placesCount: 29,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790158812/photo-1695496896465-9e59091a8ed1-1790158812205.jpg\",\n    tag: \"Adventure\",\n  },\n  {\n    id: \"maui\",\n    title: \"Maui\",\n    country: \"Hawaii, USA\",\n    placesCount: 22,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790145140/photo-1426604966848-d7adac402bff-1790145143490.jpg\",\n    tag: \"Nature\",\n  },\n  {\n    id: \"swiss-alps\",\n    title: \"Swiss Alps\",\n    country: \"Switzerland\",\n    placesCount: 35,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790146210/photo-1506905925346-21bda4d32df4-1790146212208.jpg\",\n    tag: \"Alpine\",\n  },\n  {\n    id: \"dubai\",\n    title: \"Dubai\",\n    country: \"UAE\",\n    placesCount: 47,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790146211/photo-1519681393784-d120267933ba-1790146212210.jpg\",\n    tag: \"Luxury\",\n  },\n  {\n    id: \"banff\",\n    title: \"Banff\",\n    country: \"Canada\",\n    placesCount: 28,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790146210/photo-1506744038136-46273834b3fb-1790146212208.jpg\",\n    tag: \"Wilderness\",\n  },\n  {\n    id: \"reykjavik\",\n    title: \"Reykjavik\",\n    country: \"Iceland\",\n    placesCount: 25,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790158815/photo-1593378026483-2a1fd46a35bd-1790158812215.jpg\",\n    tag: \"Aurora\",\n  },\n  {\n    id: \"barcelona\",\n    title: \"Barcelona\",\n    country: \"Spain\",\n    placesCount: 44,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790158812/photo-1710762634126-4c0e8fba44d8-1790158812206.jpg\",\n    tag: \"Culture\",\n  },\n  {\n    id: \"tokyo\",\n    title: \"Tokyo\",\n    country: \"Japan\",\n    placesCount: 72,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1600,c_limit/v1790146209/photo-1470071459604-3b5ec3a7fe05-1790146212205.jpg\",\n    tag: \"Futuristic\",\n  },\n  {\n    id: \"sydney\",\n    title: \"Sydney\",\n    country: \"Australia\",\n    placesCount: 39,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790158811/photo-1682952986992-de7082fb213d-1790158812205.jpg\",\n    tag: \"Harbour\",\n  },\n  {\n    id: \"cairo\",\n    title: \"Cairo\",\n    country: \"Egypt\",\n    placesCount: 33,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1400,c_limit/v1790158809/photo-1628344253777-f73a64d8f983-1790158812202.jpg\",\n    tag: \"Ancient\",\n  },\n];\n\nexport function TopDestinationsCard({\n  item,\n  onExplore,\n}: {\n  item: DestinationItem;\n  onExplore?: (item: DestinationItem) => void;\n}) {\n  return (\n    <div\n      tabIndex={0}\n      role=\"button\"\n      onClick={() => onExplore?.(item)}\n      onKeyDown={(e) => {\n        if (e.key === \"Enter\" || e.key === \" \") {\n          e.preventDefault();\n          onExplore?.(item);\n        }\n      }}\n      className={cn(\n        \"relative shrink-0 w-[196px] h-[244px] sm:w-72 sm:h-84 md:w-80 md:h-96 lg:w-[330px] lg:h-[400px]\",\n        \"overflow-hidden rounded-2xl sm:rounded-3xl group cursor-pointer shadow-md select-none\",\n        \"border border-border/40 bg-muted/40 outline-none focus-visible:ring-2 focus-visible:ring-primary\",\n      )}\n    >\n      {/* Background Image */}\n      <img\n        src={item.image}\n        alt={item.title}\n        loading=\"lazy\"\n        draggable={false}\n        className=\"w-full h-full object-cover transition-transform duration-700 ease-out group-hover:scale-110 group-focus-visible:scale-110 will-change-transform\"\n      />\n\n      {/* Persistent Dark Gradient Shadow (stays visible on hover too) */}\n      <div\n        className=\"absolute inset-0 pointer-events-none transition-opacity duration-500\"\n        style={{\n          background:\n            \"linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.38) 50%, rgba(0,0,0,0.12) 100%)\",\n        }}\n      />\n\n      {/* Rotated Country/City Title (Visible by default, fades out on hover) */}\n      <span\n        aria-hidden=\"true\"\n        className={cn(\n          \"absolute bottom-4 left-6 sm:bottom-6 sm:left-8 -rotate-90 origin-left\",\n          \"text-white text-base sm:text-2xl font-bold tracking-wider uppercase whitespace-nowrap\",\n          \"drop-shadow-[0_2px_8px_rgba(0,0,0,0.8)] pointer-events-none\",\n          \"transition-all duration-500 opacity-100 group-hover:opacity-0 group-focus-visible:opacity-0 group-hover:-translate-y-4\",\n        )}\n      >\n        {item.title}\n      </span>\n\n      {/* Hover Overlay with Bordered Box — keeps blackish backdrop */}\n      <div\n        className=\"absolute inset-0 z-10 opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 transition-opacity duration-500 p-3 sm:p-5 flex items-end\"\n        style={{ backgroundColor: \"rgba(0, 0, 0, 0.56)\" }}\n      >\n        <div className=\"w-full h-full border border-white/25 rounded-xl sm:rounded-2xl p-3.5 sm:p-6 flex flex-col justify-between backdrop-blur-[2px] transition-transform duration-500 transform translate-y-3 group-hover:translate-y-0 group-focus-visible:translate-y-0\">\n          {/* Top metadata */}\n          <div className=\"flex justify-between items-center gap-2\">\n            {item.tag && (\n              <span className=\"text-[9px] sm:text-[10px] font-semibold tracking-widest uppercase px-2 sm:px-2.5 py-0.5 sm:py-1 rounded-full bg-white/15 text-white/90 border border-white/20 truncate\">\n                {item.tag}\n              </span>\n            )}\n            <span className=\"text-[10px] sm:text-[11px] text-white/70 font-mono ml-auto truncate\">\n              {item.country || \"Explore\"}\n            </span>\n          </div>\n\n          {/* Center Title and Places info */}\n          <div className=\"my-auto text-center py-1 sm:py-2\">\n            <h3 className=\"text-white font-bold text-lg sm:text-3xl tracking-tight leading-tight\">\n              {item.title}\n            </h3>\n            {item.placesCount && (\n              <p className=\"text-white/75 text-[11px] sm:text-sm mt-1 sm:mt-1.5 font-medium\">\n                {item.placesCount} Places to visit\n              </p>\n            )}\n          </div>\n\n          {/* Bottom Explore CTA Button */}\n          <button\n            type=\"button\"\n            onClick={(e) => {\n              e.stopPropagation();\n              onExplore?.(item);\n            }}\n            className=\"text-white text-xs sm:text-sm font-semibold cursor-pointer inline-flex items-center gap-1 sm:gap-1.5 mx-auto hover:text-primary hover:underline underline-offset-4 transition-colors group/btn\"\n          >\n            <span>Explore</span>\n            <ArrowUpRight className=\"w-3.5 h-3.5 sm:w-4 sm:h-4 transition-transform duration-300 group-hover/btn:translate-x-0.5 group-hover/btn:-translate-y-0.5\" />\n          </button>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport function TopDestinations({\n  badgeText = \"Top Destinations\",\n  badgeIcon = <MapPin className=\"w-4 h-4 text-primary\" />,\n  title = \"Top Destinations\",\n  subtitle = \"Experience our Instagram moments, where we share team activities, product stories, and memorable events that showcase our brand's journey and community connections.\",\n  items,\n  row1Items,\n  row2Items,\n  scrollOffset = 450,\n  scrollerRef,\n  onExplore,\n  className,\n  ...props\n}: TopDestinationsProps) {\n  const containerRef = useRef<HTMLElement>(null);\n  const row1Ref = useRef<HTMLDivElement>(null);\n  const row2Ref = useRef<HTMLDivElement>(null);\n\n  // Divide items into 2 rows if explicit rows are not supplied\n  const effectiveItems = items || DEFAULT_DESTINATIONS;\n  const half = Math.ceil(effectiveItems.length / 2);\n  const r1 = row1Items || effectiveItems.slice(0, half);\n  const r2 = row2Items || effectiveItems.slice(half);\n  const displayRow1 = r1.length > 0 && r1.length < 10 ? [...r1, ...r1] : r1;\n  const displayRow2 = r2.length > 0 && r2.length < 10 ? [...r2, ...r2] : r2;\n\n  useEffect(() => {\n    const container = containerRef.current;\n    const row1 = row1Ref.current;\n    const row2 = row2Ref.current;\n    if (!container || !row1 || !row2) return;\n\n    if (\n      typeof window !== \"undefined\" &&\n      window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches\n    ) {\n      return;\n    }\n\n    // Resolve scrolling container (scrollerRef > nearest scrollable ancestor > window)\n    const doc = container.ownerDocument;\n    const win = doc.defaultView ?? window;\n    let scrollerEl: Element | Window = win;\n\n    if (scrollerRef?.current) {\n      scrollerEl = scrollerRef.current;\n    } else {\n      let parent = container.parentElement;\n      while (parent && parent !== doc.documentElement) {\n        const style = win.getComputedStyle(parent);\n        if (\n          /(auto|scroll|overlay)/.test(style.overflowY) &&\n          parent.scrollHeight > parent.clientHeight\n        ) {\n          scrollerEl = parent;\n          break;\n        }\n        parent = parent.parentElement;\n      }\n    }\n\n    const containerWidth = container.clientWidth || 1024;\n    const effectiveOffset =\n      containerWidth < 640\n        ? Math.min(scrollOffset, Math.max(120, Math.round(containerWidth * 0.42)))\n        : scrollOffset;\n\n    const ctx = gsap.context(() => {\n      // Row 1: starts shifted right, scrubs towards left\n      gsap.fromTo(\n        row1,\n        { x: effectiveOffset },\n        {\n          x: -effectiveOffset,\n          ease: \"none\",\n          scrollTrigger: {\n            trigger: container,\n            scroller: scrollerEl,\n            start: \"top bottom\",\n            end: \"bottom top\",\n            scrub: 1.2,\n            invalidateOnRefresh: true,\n          },\n        },\n      );\n\n      // Row 2: starts shifted left, scrubs towards right\n      gsap.fromTo(\n        row2,\n        { x: -effectiveOffset },\n        {\n          x: effectiveOffset,\n          ease: \"none\",\n          scrollTrigger: {\n            trigger: container,\n            scroller: scrollerEl,\n            start: \"top bottom\",\n            end: \"bottom top\",\n            scrub: 1.2,\n            invalidateOnRefresh: true,\n          },\n        },\n      );\n    }, container);\n\n    return () => {\n      ctx.revert();\n    };\n  }, [scrollOffset, scrollerRef]);\n\n  return (\n    <section\n      ref={containerRef}\n      className={cn(\n        \"w-full pt-8 pb-14 sm:pt-16 sm:pb-28 lg:pt-20 lg:pb-32 bg-background overflow-hidden relative select-none\",\n        className,\n      )}\n      {...props}\n    >\n      {/* Section Header */}\n      <div className=\"container mx-auto px-4 text-center mb-7 sm:mb-14 lg:mb-16\">\n        {badgeText && (\n          <div className=\"inline-flex items-center gap-2.5 sm:gap-3 relative mb-2.5 sm:mb-3\">\n            <span className=\"w-8 sm:w-12 h-0.5 bg-gradient-to-r from-transparent to-primary\" />\n            <span className=\"w-8 h-8 sm:w-9 sm:h-9 rounded-full bg-primary/10 flex items-center justify-center text-primary shadow-xs\">\n              {badgeIcon}\n            </span>\n            <span className=\"w-8 sm:w-12 h-0.5 bg-gradient-to-l from-transparent to-primary\" />\n          </div>\n        )}\n\n        {title && (\n          <h2 className=\"text-2xl sm:text-4xl lg:text-5xl font-bold tracking-tight text-foreground\">\n            {title}\n          </h2>\n        )}\n\n        {subtitle && (\n          <p className=\"w-full text-xs sm:text-base max-w-md sm:max-w-none md:w-[62%] lg:w-[48%] mx-auto mt-2.5 sm:mt-3.5 px-1 sm:px-0 text-muted-foreground leading-relaxed text-pretty\">\n            {subtitle}\n          </p>\n        )}\n      </div>\n\n      {/* 2-Row Parallax Dual Scroll Container */}\n      <div className=\"flex flex-col gap-4 sm:gap-8 lg:gap-10 overflow-hidden w-full\">\n        {/* Row 1 (Travels Left) */}\n        <div className=\"w-full flex justify-center\">\n          <div\n            ref={row1Ref}\n            className=\"flex gap-3 sm:gap-6 will-change-transform\"\n          >\n            {displayRow1.map((item, idx) => (\n              <TopDestinationsCard\n                key={`row1-${item.id}-${idx}`}\n                item={item}\n                onExplore={onExplore}\n              />\n            ))}\n          </div>\n        </div>\n\n        {/* Row 2 (Travels Right) */}\n        <div className=\"w-full flex justify-center\">\n          <div\n            ref={row2Ref}\n            className=\"flex gap-3 sm:gap-6 will-change-transform\"\n          >\n            {displayRow2.map((item, idx) => (\n              <TopDestinationsCard\n                key={`row2-${item.id}-${idx}`}\n                item={item}\n                onExplore={onExplore}\n              />\n            ))}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/custom/blocks/TopDestinationsBlock.tsx"
    }
  ],
  "docs": "Named exports: TopDestinations, TopDestinationsCard, DEFAULT_DESTINATIONS (plus DestinationItem type). Accepts items array or row1Items/row2Items, scrollOffset, and scrollerRef.",
  "categories": [
    "marketing",
    "data-display",
    "scroll"
  ],
  "type": "registry:component"
}
