{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hero-scroll-depth",
  "type": "registry:component",
  "title": "Hero Scroll Depth",
  "description": "A dusk mountain scene in five layers, sky, far ridge, dolomite towers, wooded hills and foreground pines, with the headline tucked between them. Scrolling pushes the camera in and each layer moves at its own depth.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hero",
    "hero",
    "scroll",
    "parallax",
    "depth",
    "outdoor",
    "travel"
  ],
  "docs": "https://hyperblur.dev/effects/hero-scroll-depth",
  "files": [
    {
      "path": "registry/hyperblur/hero-scroll-depth.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hero-scroll-depth.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HeroScrollDepthLink {\n  label: string;\n  href: string;\n}\n\nexport interface HeroScrollDepthProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  brand?: string;\n  eyebrow?: string;\n  title?: string;\n  summary?: string;\n  stats?: { value: string; label: string }[];\n  cta?: HeroScrollDepthLink | null;\n  accent?: string;\n  progress?: number;\n  autoPlay?: boolean;\n  duration?: number;\n  length?: number;\n  height?: string;\n  headingAs?: \"h1\" | \"h2\";\n}\n\nconst defaultStats = [\n  { value: \"7\", label: \"days\" },\n  { value: \"6\", label: \"mountain huts\" },\n  { value: \"82 km\", label: \"Alta Via 1\" },\n];\n\nconst pines = (x0: number, base: number, count: number, size: number, seed: number) => {\n  let d = \"\";\n  for (let i = 0; i < count; i++) {\n    let h = Math.imul((i + seed) * 374761393, 668265263) >>> 0;\n    h = (h ^ (h >>> 13)) >>> 0;\n    const s = size * (0.7 + ((h % 1000) / 1000) * 0.6);\n    const x = x0 + i * size * 0.55 + ((h >>> 10) % 20) - 10;\n    const top = base - s * 2.4;\n    d += `M${x.toFixed(1)} ${top.toFixed(1)}L${(x + s * 0.5).toFixed(1)} ${(base - s * 1.5).toFixed(1)}L${(x + s * 0.28).toFixed(1)} ${(base - s * 1.5).toFixed(1)}L${(x + s * 0.75).toFixed(1)} ${(base - s * 0.6).toFixed(1)}L${(x + s * 0.12).toFixed(1)} ${(base - s * 0.6).toFixed(1)}L${(x + s * 0.12).toFixed(1)} ${base}L${(x - s * 0.12).toFixed(1)} ${base}L${(x - s * 0.12).toFixed(1)} ${(base - s * 0.6).toFixed(1)}L${(x - s * 0.75).toFixed(1)} ${(base - s * 0.6).toFixed(1)}L${(x - s * 0.28).toFixed(1)} ${(base - s * 1.5).toFixed(1)}L${(x - s * 0.5).toFixed(1)} ${(base - s * 1.5).toFixed(1)}Z`;\n  }\n  return d;\n};\n\nconst farPeaks = \"M0 700V420L80 380L150 400L240 330L310 372L390 318L470 360L560 300L640 352L720 326L800 368L880 312L960 356L1050 330L1130 372L1200 350V700Z\";\nconst midPeaks =\n  \"M0 700V470L60 452L110 380L130 386L160 300L178 310L196 268L214 318L240 330L290 420L360 440L420 360L436 366L458 286L474 296L490 250L506 282L530 300L560 380L640 430L720 400L760 330L778 336L800 262L818 272L838 236L854 270L880 300L930 410L1000 440L1060 380L1090 330L1110 340L1140 300L1170 380L1200 400V700Z\";\nconst hills = \"M0 700V520C120 490 220 500 320 520C430 540 520 500 640 494C760 488 860 520 980 512C1080 506 1150 490 1200 496V700Z\";\nconst hillTrees = pines(-10, 528, 38, 34, 3);\nconst frontLeft = pines(-60, 720, 6, 150, 11);\nconst frontRight = pines(960, 720, 6, 150, 23);\n\nconst css = `\n.hb-va12 {\n  --hb-va12-accent: #ffb37a;\n  --hb-va12-p: 0;\n  --hb-va12-o: 0;\n  position: relative;\n  width: 100%;\n  height: var(--hb-va12-h);\n  color: #fff;\n  font-family: inherit;\n  background: #0f1022;\n}\n.hb-va12[data-pinned=\"true\"] { height: calc(var(--hb-va12-h) * var(--hb-va12-len)); }\n.hb-va12 *, .hb-va12 *::before, .hb-va12 *::after { box-sizing: border-box; }\n.hb-va12-stage {\n  position: sticky;\n  top: 0;\n  height: var(--hb-va12-h);\n  overflow: hidden;\n  container-type: size;\n  isolation: isolate;\n}\n.hb-va12-layer {\n  position: absolute;\n  inset: 0;\n  width: 100%;\n  height: 100%;\n  transform-origin: 50% 100%;\n  transform: translateY(calc(var(--hb-va12-p) * var(--hb-va12-ty))) scale(calc(1 + var(--hb-va12-p) * var(--hb-va12-z)));\n  will-change: transform;\n  pointer-events: none;\n}\n.hb-va12-sky {\n  background:\n    radial-gradient(9cqw 9cqw at 62% 52%, #fff2d8, color-mix(in srgb, var(--hb-va12-accent) 80%, #fff) 30%, transparent 62%),\n    radial-gradient(60% 40% at 62% 58%, color-mix(in srgb, var(--hb-va12-accent) 55%, transparent), transparent 70%),\n    linear-gradient(180deg, #14173a 0%, #2b2d63 30%, #8a5a8a 52%, #f0a674 66%, #f6c79a 74%);\n}\n.hb-va12-fog {\n  position: absolute;\n  inset: 52% -10% 18%;\n  background: linear-gradient(180deg, transparent, rgba(255, 226, 214, 0.32) 50%, transparent);\n  filter: blur(8px);\n  transform: translateX(calc(var(--hb-va12-p) * -6cqw));\n  pointer-events: none;\n}\n.hb-va12-copy {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  padding-top: 36cqh;\n  text-align: center;\n  transform: translateY(calc(var(--hb-va12-p) * -16cqh)) scale(calc(1 + var(--hb-va12-p) * 0.18));\n  opacity: calc(1 - var(--hb-va12-p) * 0.6);\n  will-change: transform;\n}\n.hb-va12-eyebrow {\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(10px, 1.15cqw, 13px);\n  letter-spacing: 0.24em;\n  text-transform: uppercase;\n  color: rgba(255, 240, 225, 0.8);\n}\n.hb-va12-title {\n  margin: 0.25em 0 0;\n  font-family: var(--font-grotesk, var(--font-sans, system-ui));\n  font-size: clamp(3rem, 15cqw, 14rem);\n  font-weight: 700;\n  line-height: 0.85;\n  letter-spacing: -0.06em;\n  color: #fff7ee;\n  text-shadow: 0 10px 50px rgba(40, 20, 60, 0.35);\n}\n.hb-va12-bar {\n  position: absolute;\n  inset: 0 0 auto;\n  z-index: 6;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  padding: 3.6cqh 4cqw;\n  font-size: clamp(11px, 1.3cqw, 14px);\n}\n.hb-va12-brand { display: inline-flex; align-items: center; gap: 0.5em; font-weight: 700; letter-spacing: -0.01em; }\n.hb-va12-brand svg { width: 1.3em; height: 1.3em; }\n.hb-va12-nav { display: flex; gap: 1.6em; color: rgba(255, 255, 255, 0.72); }\n.hb-va12-final {\n  position: absolute;\n  inset: auto 4cqw 6cqh;\n  z-index: 6;\n  display: flex;\n  align-items: flex-end;\n  justify-content: space-between;\n  gap: 2rem;\n  opacity: var(--hb-va12-o);\n  transform: translateY(calc((1 - var(--hb-va12-o)) * 24px));\n  pointer-events: none;\n}\n.hb-va12[data-final=\"true\"] .hb-va12-final { pointer-events: auto; }\n.hb-va12-summary {\n  max-width: 30ch;\n  margin: 0;\n  font-size: clamp(13px, 1.8cqw, 20px);\n  font-weight: 500;\n  line-height: 1.35;\n  letter-spacing: -0.015em;\n}\n.hb-va12-stats { display: flex; gap: 2.4cqw; margin-top: 1em; }\n.hb-va12-stats div { font-size: clamp(10px, 1.15cqw, 13px); color: rgba(255, 255, 255, 0.6); }\n.hb-va12-stats b { display: block; font-size: 1.7em; font-weight: 600; letter-spacing: -0.03em; color: #fff; }\n.hb-va12-cta {\n  display: inline-flex;\n  align-items: center;\n  gap: 0.6em;\n  padding: 0.8em 1.4em;\n  border-radius: 999px;\n  background: var(--hb-va12-accent);\n  color: #2a1406;\n  font-size: clamp(12px, 1.4cqw, 15px);\n  font-weight: 700;\n  text-decoration: none;\n  white-space: nowrap;\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 14px 34px -12px var(--hb-va12-accent);\n  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), filter 0.3s ease;\n}\n.hb-va12-cta:hover { transform: translateY(-1px); filter: brightness(1.06); }\n.hb-va12-cta:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }\n@media (max-width: 640px) {\n  .hb-va12-nav { display: none; }\n  .hb-va12-final { flex-direction: column; align-items: flex-start; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-va12-cta { transition: none; }\n}\n`;\n\nfunction findScroller(el: HTMLElement): HTMLElement | null {\n  let node = el.parentElement;\n  while (node && node !== document.body && node !== document.documentElement) {\n    const oy = getComputedStyle(node).overflowY;\n    if ((oy === \"auto\" || oy === \"scroll\" || oy === \"overlay\") && node.scrollHeight > node.clientHeight + 1) return node;\n    node = node.parentElement;\n  }\n  return null;\n}\n\nfunction ease(x: number) {\n  return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\n\nfunction clamp01(x: number) {\n  return Math.min(1, Math.max(0, x));\n}\n\nfunction loopAt(ms: number, duration: number) {\n  const d = Math.max(1, duration) * 1000;\n  const back = d * 0.7;\n  const hold = 1400;\n  const t = ms % (d + hold + back + 700);\n  if (t < d) return ease(t / d);\n  if (t < d + hold) return 1;\n  if (t < d + hold + back) return 1 - ease((t - d - hold) / back);\n  return 0;\n}\n\nfunction useScrollProgress(\n  ref: React.RefObject<HTMLElement | null>,\n  apply: (p: number) => void,\n  progress: number | undefined,\n  autoPlay: boolean,\n  duration: number,\n) {\n  const applyRef = React.useRef(apply);\n  React.useLayoutEffect(() => {\n    applyRef.current = apply;\n  });\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const run = (p: number) => applyRef.current(clamp01(p));\n    if (typeof progress === \"number\") {\n      run(progress);\n      return;\n    }\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      run(1);\n      return;\n    }\n    let raf = 0;\n    if (autoPlay) {\n      let visible = true;\n      let last = 0;\n      let t = 0;\n      const io = new IntersectionObserver((entries) => {\n        visible = entries[0]?.isIntersecting ?? true;\n      });\n      io.observe(el);\n      const loop = (now: number) => {\n        const dt = last ? Math.min(64, now - last) : 0;\n        last = now;\n        if (visible) {\n          t += dt;\n          run(loopAt(t, duration));\n        }\n        raf = requestAnimationFrame(loop);\n      };\n      raf = requestAnimationFrame(loop);\n      return () => {\n        cancelAnimationFrame(raf);\n        io.disconnect();\n      };\n    }\n    const sc = findScroller(el);\n    const measure = () => {\n      raf = 0;\n      const r = el.getBoundingClientRect();\n      const top = sc ? r.top - sc.getBoundingClientRect().top : r.top;\n      const vh = sc ? sc.clientHeight : window.innerHeight;\n      const span = r.height - vh;\n      run(span > 1 ? -top / span : (vh - top) / (vh + r.height));\n    };\n    const onScroll = () => {\n      if (!raf) raf = requestAnimationFrame(measure);\n    };\n    measure();\n    const target: HTMLElement | Window = sc ?? window;\n    target.addEventListener(\"scroll\", onScroll, { passive: true });\n    window.addEventListener(\"resize\", onScroll);\n    return () => {\n      cancelAnimationFrame(raf);\n      target.removeEventListener(\"scroll\", onScroll);\n      window.removeEventListener(\"resize\", onScroll);\n    };\n  }, [ref, progress, autoPlay, duration]);\n}\n\nfunction layerStyle(ty: string, z: number): React.CSSProperties {\n  return { \"--hb-va12-ty\": ty, \"--hb-va12-z\": z } as React.CSSProperties;\n}\n\nexport function HeroScrollDepth({\n  brand = \"Trailhead\",\n  eyebrow = \"Hut-to-hut trekking · Dolomites\",\n  title = \"Go higher\",\n  summary = \"A guided week on the Alta Via 1, from Lago di Braies to Belluno, sleeping in mountain huts every night.\",\n  stats = defaultStats,\n  cta = { label: \"Plan your trek\", href: \"#\" },\n  accent = \"#ffb37a\",\n  progress,\n  autoPlay = false,\n  duration = 6,\n  length = 3,\n  height = \"100vh\",\n  headingAs = \"h1\",\n  className,\n  style,\n  ...rest\n}: HeroScrollDepthProps) {\n  const ref = React.useRef<HTMLElement>(null);\n  const uid = React.useId().replace(/[^a-zA-Z0-9]/g, \"\");\n  const Heading = headingAs;\n  const pinned = progress === undefined && !autoPlay;\n\n  useScrollProgress(\n    ref,\n    (p) => {\n      const el = ref.current;\n      if (!el) return;\n      el.style.setProperty(\"--hb-va12-p\", ease(clamp01(p / 0.85)).toFixed(4));\n      const o = ease(clamp01((p - 0.66) / 0.28));\n      el.style.setProperty(\"--hb-va12-o\", o.toFixed(4));\n      el.dataset.final = o > 0.5 ? \"true\" : \"false\";\n    },\n    progress,\n    autoPlay,\n    duration,\n  );\n\n  return (\n    <section\n      ref={ref}\n      className={[\"hb-va12\", className].filter(Boolean).join(\" \")}\n      data-pinned={pinned ? \"true\" : \"false\"}\n      style={{ \"--hb-va12-accent\": accent, \"--hb-va12-h\": height, \"--hb-va12-len\": length, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-hero-scroll-depth\" precedence=\"default\">{css}</style>\n      <div className=\"hb-va12-stage\">\n        <div className=\"hb-va12-layer hb-va12-sky\" style={layerStyle(\"-3cqh\", 0.04)} aria-hidden=\"true\" />\n        <svg className=\"hb-va12-layer\" style={layerStyle(\"-2cqh\", 0.1)} viewBox=\"0 0 1200 700\" preserveAspectRatio=\"xMidYMax slice\" aria-hidden=\"true\">\n          <path d={farPeaks} fill=\"#9a8db3\" opacity=\"0.75\" />\n        </svg>\n        <svg className=\"hb-va12-layer\" style={layerStyle(\"0cqh\", 0.22)} viewBox=\"0 0 1200 700\" preserveAspectRatio=\"xMidYMax slice\" aria-hidden=\"true\">\n          <defs>\n            <linearGradient id={`${uid}m`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n              <stop offset=\"0\" stopColor=\"#6c5f91\" />\n              <stop offset=\"0.6\" stopColor=\"#3f3a6a\" />\n            </linearGradient>\n          </defs>\n          <path d={midPeaks} fill={`url(#${uid}m)`} />\n          <path d=\"M196 268L214 318L200 312L190 290Z M490 250L506 282L494 280L484 262Z M838 236L854 270L842 266L832 250Z\" fill=\"#f6c79a\" opacity=\"0.55\" />\n        </svg>\n        <div className=\"hb-va12-copy\">\n          <span className=\"hb-va12-eyebrow\">{eyebrow}</span>\n          <Heading className=\"hb-va12-title\">{title}</Heading>\n        </div>\n        <div className=\"hb-va12-fog\" aria-hidden=\"true\" />\n        <svg className=\"hb-va12-layer\" style={layerStyle(\"6cqh\", 0.55)} viewBox=\"0 0 1200 700\" preserveAspectRatio=\"xMidYMax slice\" aria-hidden=\"true\">\n          <path d={hills} fill=\"#26264a\" />\n          <path d={hillTrees} fill=\"#1c1c3a\" />\n          <rect x=\"0\" y=\"560\" width=\"1200\" height=\"140\" fill=\"#1c1c3a\" />\n        </svg>\n        <svg className=\"hb-va12-layer\" style={layerStyle(\"26cqh\", 1.5)} viewBox=\"0 0 1200 700\" preserveAspectRatio=\"xMidYMax slice\" aria-hidden=\"true\">\n          <path d={frontLeft} fill=\"#0c0d1c\" />\n          <path d={frontRight} fill=\"#0c0d1c\" />\n          <path d=\"M0 700V660C200 640 400 650 600 668C800 650 1000 640 1200 660V700Z\" fill=\"#0c0d1c\" />\n        </svg>\n        <div className=\"hb-va12-bar\">\n          <span className=\"hb-va12-brand\">\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M2 20L9 8l4 6 3-4 6 10z\" />\n            </svg>\n            {brand}\n          </span>\n          <span className=\"hb-va12-nav\" aria-hidden=\"true\">\n            <span>Treks</span>\n            <span>Huts</span>\n            <span>Guides</span>\n          </span>\n        </div>\n        <div className=\"hb-va12-final\">\n          <div>\n            {summary ? <p className=\"hb-va12-summary\">{summary}</p> : null}\n            {stats.length ? (\n              <div className=\"hb-va12-stats\">\n                {stats.map((s) => (\n                  <div key={s.label}>\n                    <b>{s.value}</b>\n                    {s.label}\n                  </div>\n                ))}\n              </div>\n            ) : null}\n          </div>\n          {cta ? (\n            <a className=\"hb-va12-cta\" href={cta.href}>\n              {cta.label}\n            </a>\n          ) : null}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}