{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"layered-mountain-landscape-hero-with-depth-parallax","type":"registry:block","title":"Layered Mountain Landscape Hero With Depth Parallax","description":"Free parallax scrolling hero with drawn mountain ridges that slide at different depths behind the headline. React and plain HTML, CSS and JS versions.","dependencies":[],"files":[{"path":"components/we-inc/layered-mountain-landscape-hero-with-depth-parallax.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\n// Each layer moves down by scroll * depth, so a higher depth reads as further away.\nconst LAYERS = [\n  { depth: 0.42, fill: \"#e8c39c\", d: \"M0 250 L110 205 L230 228 L370 150 L500 212 L640 168 L780 118 L930 190 L1060 146 L1210 214 L1330 172 L1440 198 V400 H0Z\" },\n  { depth: 0.3, fill: \"#c98f6e\", d: \"M0 292 L150 238 L300 276 L450 206 L620 268 L760 226 L910 286 L1080 216 L1250 270 L1440 236 V400 H0Z\" },\n  { depth: 0.18, fill: \"#8d5a49\", d: \"M0 330 C180 286 330 270 520 312 S850 356 1040 304 S1310 270 1440 314 V400 H0Z\" },\n];\nconst FRONT = \"M0 250 C220 196 470 222 720 240 S1180 204 1440 232 V400 H0Z\";\nconst NOTES = [\n  { title: \"Twelve rooms\", text: \"Every room faces the eastern ridge, so first light reaches the bed before the alarm does.\" },\n  { title: \"Marked trails\", text: \"Three loops leave from the porch, from a gentle valley walk to a full day on the high saddle.\" },\n  { title: \"A slow kitchen\", text: \"Breakfast runs until eleven and dinner is one long table, cooked from what the valley grows.\" },\n];\n\nexport default function LayeredMountainLandscapeHeroWithDepthParallax() {\n  const root = useRef<HTMLDivElement>(null);\n  const layers = useRef<(HTMLDivElement | null)[]>([]);\n\n  useEffect(() => {\n    const box = root.current;\n    if (!box) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let frame = 0;\n    let on = true;\n    const draw = () => {\n      frame = 0;\n      const s = box.scrollTop; // on page scroll use: Math.max(0, -hero.getBoundingClientRect().top)\n      box.classList.toggle(\"w6lnd-moved\", s > 8);\n      if (reduce) return;\n      layers.current.forEach((l) => {\n        if (l) l.style.transform = `translate3d(0,${(s * Number(l.dataset.depth)).toFixed(1)}px,0)`;\n      });\n    };\n    const req = () => {\n      if (on && !frame) frame = requestAnimationFrame(draw);\n    };\n    const io = new IntersectionObserver(([e]) => {\n      on = e.isIntersecting;\n      box.toggleAttribute(\"data-paused\", !on);\n      if (on) req();\n    });\n    io.observe(box);\n    box.addEventListener(\"scroll\", req, { passive: true });\n    return () => {\n      cancelAnimationFrame(frame);\n      io.disconnect();\n      box.removeEventListener(\"scroll\", req);\n    };\n  }, []);\n\n  let i = 0;\n  const layerRef = (n: HTMLDivElement | null) => {\n    if (n) layers.current[Number(n.dataset.i)] = n;\n  };\n\n  return (\n    <div\n      ref={root}\n      tabIndex={0}\n      role=\"region\"\n      aria-label=\"Haldor Ridge Lodge, scrollable preview\"\n      className=\"w6lnd relative h-[640px] overflow-y-auto overscroll-contain bg-[#21181a] text-[#2a1b19] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#8d5a49]\"\n    >\n      <style>{`\n        .w6lnd-layer { will-change: transform; }\n        .w6lnd-mist { animation: w6lnd-drift 26s ease-in-out infinite alternate; }\n        .w6lnd[data-paused] .w6lnd-mist { animation-play-state: paused; }\n        @keyframes w6lnd-drift { from { transform: translate3d(-4%,0,0); } to { transform: translate3d(4%,0,0); } }\n        .w6lnd-hint { transition: opacity .5s ease; }\n        .w6lnd-moved .w6lnd-hint { opacity: 0; }\n        @media (prefers-reduced-motion: reduce) { .w6lnd-mist { animation: none; } .w6lnd-layer { will-change: auto; } }\n      `}</style>\n      <header className=\"relative h-[640px] overflow-hidden bg-gradient-to-b from-[#f6e3c8] via-[#f2d3ae] to-[#eab98f]\">\n        <div ref={layerRef} data-i={i++} data-depth=\"0.55\" className=\"w6lnd-layer absolute left-[64%] top-[44%] -ml-16 h-32 w-32 rounded-full bg-[#fbeedb] shadow-[0_0_80px_30px_rgba(251,238,219,0.55)]\" aria-hidden=\"true\" />\n        <div className=\"w6lnd-hint pointer-events-none absolute right-4 top-4 z-30 rounded-full bg-[#2a1b19]/80 px-3 py-1.5 text-xs font-medium text-[#f6e3c8]\">Scroll inside</div>\n        <div ref={layerRef} data-i={i++} data-depth=\"0.35\" className=\"w6lnd-layer absolute inset-x-0 top-16 z-10 px-6 text-center\">\n          <p className=\"text-xs font-semibold uppercase tracking-[0.3em] text-[#6e3f30]\">Haldor Ridge Lodge</p>\n          <h1 className=\"mx-auto mt-4 max-w-3xl text-[clamp(36px,6.6vw,78px)] font-semibold leading-[1.02] tracking-[-0.02em]\">Wake up above the cloud line</h1>\n          <p className=\"mx-auto mt-4 max-w-md text-base leading-relaxed text-[#4a2c24]\">A small lodge at the head of the valley, with the ridge outside every window.</p>\n        </div>\n        {LAYERS.map((l) => (\n          <div key={l.depth} ref={layerRef} data-i={i++} data-depth={l.depth} aria-hidden=\"true\" className=\"w6lnd-layer absolute inset-x-0 bottom-0 z-20 h-[62%]\">\n            <svg viewBox=\"0 0 1440 400\" preserveAspectRatio=\"none\" className=\"h-full w-full\"><path d={l.d} fill={l.fill} /></svg>\n          </div>\n        ))}\n        <div aria-hidden=\"true\" className=\"w6lnd-mist absolute inset-x-[-10%] bottom-[16%] z-20 h-24 bg-gradient-to-b from-transparent via-[#f6e3c8]/40 to-transparent\" />\n        <div aria-hidden=\"true\" className=\"absolute inset-x-0 bottom-0 z-20 h-[30%]\">\n          <svg viewBox=\"0 0 1440 400\" preserveAspectRatio=\"none\" className=\"h-full w-full\"><path d={FRONT} fill=\"#21181a\" /></svg>\n        </div>\n        <div className=\"absolute inset-x-0 bottom-8 z-30 flex flex-wrap justify-center gap-3 px-6\">\n          <a href=\"#\" className=\"inline-flex h-12 items-center rounded-full bg-[#f6e3c8] px-6 text-sm font-semibold text-[#21181a] transition hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#f6e3c8] focus-visible:ring-offset-2 focus-visible:ring-offset-[#21181a]\">Check winter dates</a>\n          <a href=\"#\" className=\"inline-flex h-12 items-center rounded-full border border-[#f6e3c8]/50 px-6 text-sm font-semibold text-[#f6e3c8] transition hover:border-[#f6e3c8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#f6e3c8]\">See the trails</a>\n        </div>\n      </header>\n      <section className=\"px-6 pb-20 pt-10 text-[#f1dcc4] sm:px-10\">\n        <div className=\"mx-auto max-w-5xl\">\n          <h2 className=\"max-w-xl text-2xl font-semibold leading-snug sm:text-3xl\">Quiet rooms, early light and a porch that opens onto three trails.</h2>\n          <ul className=\"mt-10 grid gap-8 sm:grid-cols-3\">\n            {NOTES.map((n) => (\n              <li key={n.title} className=\"border-t border-[#f1dcc4]/25 pt-5\">\n                <h3 className=\"text-base font-semibold\">{n.title}</h3>\n                <p className=\"mt-2 text-sm leading-relaxed text-[#d9bfa6]\">{n.text}</p>\n              </li>\n            ))}\n          </ul>\n        </div>\n      </section>\n    </div>\n  );\n}\n"}]}
