{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sticky-photo-backdrop-with-cards-passing-over","type":"registry:block","title":"Sticky Photo Backdrop With Cards Passing Over","description":"","dependencies":[],"files":[{"path":"components/we-inc/sticky-photo-backdrop-with-cards-passing-over.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\nconst ZOOM = 0.1; // how much the backdrop eases out (scale 1.1 -> 1.0) across the whole scroll\nconst WALKS = [\n  { day: \"Day one\", title: \"Harbour to the lighthouse\", text: \"A level start along the sea wall, then a gentle climb to the lamp room for the first long view of the bay.\", km: \"11 km\" },\n  { day: \"Day two\", title: \"The red cliffs\", text: \"The wildest stretch: open headland, a lot of sky, and a lunch stop above the cove where seals haul out.\", km: \"16 km\" },\n  { day: \"Day three\", title: \"Through the oak combe\", text: \"The path drops inland into shade, crosses two footbridges and climbs back out to a farm tea room.\", km: \"13 km\" },\n  { day: \"Day four\", title: \"Down to Pellow Sands\", text: \"An easy final morning that ends on a wide beach, with your bags already waiting at the station hotel.\", km: \"8 km\" },\n];\n\nexport default function StickyPhotoBackdropWithCardsPassingOver() {\n  const box = useRef<HTMLDivElement>(null);\n  const photo = useRef<HTMLImageElement>(null);\n\n  useEffect(() => {\n    const el = box.current;\n    if (!el) 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      el.classList.toggle(\"w6stk-moved\", el.scrollTop > 8);\n      if (reduce || !photo.current) return;\n      const m = el.scrollHeight - el.clientHeight;\n      const p = m ? el.scrollTop / m : 0;\n      photo.current.style.transform = `scale(${(1 + ZOOM * (1 - p)).toFixed(4)})`;\n    };\n    const req = () => {\n      if (on && !frame) frame = requestAnimationFrame(draw);\n    };\n    const io = new IntersectionObserver(([e]) => {\n      on = e.isIntersecting;\n      if (on) req();\n    });\n    io.observe(el);\n    el.addEventListener(\"scroll\", req, { passive: true });\n    req();\n    return () => {\n      cancelAnimationFrame(frame);\n      io.disconnect();\n      el.removeEventListener(\"scroll\", req);\n    };\n  }, []);\n\n  return (\n    <div ref={box} tabIndex={0} role=\"region\" aria-label=\"Fernmouth coast walk, scrollable preview\" className=\"w6stk relative h-[620px] overflow-y-auto overscroll-contain bg-[#0f1b2a] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#e9dcc4]\">\n      <style>{`\n        .w6stk-photo { transform: scale(1.1); transform-origin: 50% 40%; will-change: transform; }\n        .w6stk-hint { transition: opacity .5s ease; }\n        .w6stk-moved .w6stk-hint { opacity: 0; }\n        @media (prefers-reduced-motion: reduce) { .w6stk-photo { transform: none; will-change: auto; } }\n      `}</style>\n      <div className=\"sticky top-0 h-[620px] overflow-hidden\">\n        <img ref={photo} src=\"https://images.pexels.com/photos/7694094/pexels-photo-7694094.jpeg?auto=compress&cs=tinysrgb&w=1600\" alt=\"A rocky headland with dry grass and dark green trees above a wide grey sea under cloud\" width={1600} height={1280} className=\"w6stk-photo absolute inset-0 h-full w-full object-cover\" />\n        <div aria-hidden=\"true\" className=\"absolute inset-0 bg-gradient-to-b from-[#0f1b2a]/80 via-[#0f1b2a]/30 to-[#0f1b2a]/85\" />\n        <div className=\"relative px-6 pt-12 sm:px-12\">\n          <p className=\"text-xs font-semibold uppercase tracking-[0.26em] text-[#e9dcc4]\">Fernmouth Coast Walks</p>\n          <h2 className=\"mt-3 max-w-lg text-4xl font-semibold leading-tight text-white sm:text-5xl\">Four days on the south coast path</h2>\n          <p className=\"mt-4 max-w-sm text-base leading-relaxed text-[#dfe6ee]\">Self-guided, with bags carried between inns. The cliffs stay put while the days go by.</p>\n        </div>\n        <span className=\"w6stk-hint pointer-events-none absolute right-4 top-4 rounded-full bg-white/90 px-3 py-1.5 text-xs font-medium text-[#0f1b2a]\" aria-hidden=\"true\">Scroll inside</span>\n      </div>\n      <ol className=\"relative -mt-[620px] space-y-5 px-5 pb-16 pt-[360px] sm:ml-auto sm:max-w-md sm:px-10\">\n        {WALKS.map((w) => (\n          <li key={w.title} className=\"rounded-xl bg-[#f6f1e7] p-6 text-[#13202f] shadow-[0_24px_48px_-20px_rgba(0,0,0,0.6)]\">\n            <div className=\"flex items-baseline justify-between text-xs font-semibold uppercase tracking-[0.18em] text-[#5a6675]\">\n              <span>{w.day}</span>\n              <span>{w.km}</span>\n            </div>\n            <h3 className=\"mt-2 text-xl font-semibold\">{w.title}</h3>\n            <p className=\"mt-2 text-sm leading-relaxed text-[#3c4756]\">{w.text}</p>\n          </li>\n        ))}\n        <li>\n          <a href=\"#\" className=\"flex h-12 items-center justify-center rounded-xl bg-[#e9dcc4] text-sm font-semibold text-[#0f1b2a] transition hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-[#0f1b2a]\">Choose your start date</a>\n        </li>\n      </ol>\n    </div>\n  );\n}\n"}]}
