{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"big-headline-hero-with-stats-row","type":"registry:block","title":"Big Headline Hero with Stats Row","description":"Hero with a huge headline over a rooftop photo and a stats row whose numbers roll like meter drums. Copy the React and Tailwind code or HTML free.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/big-headline-hero-with-stats-row.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { motion, useReducedMotion } from \"framer-motion\";\n\n/** One photograph: a tiled roof with a row of panels, and a lot of open evening sky for the headline. */\nconst PHOTO = \"https://images.unsplash.com/photo-1761158495585-eac721decf1b?auto=format&fit=crop&w=1600&q=80\";\nconst PHOTO_ALT = \"An orange tiled roof with a row of solar panels along its lower edge, under a wide pale evening sky crossed by overhead wires\";\n\nconst firm = {\n  name: \"Sunward\",\n  trade: \"Rooftop solar, fitted by our own crews\",\n  eyebrow: \"Surveys booking for spring\",\n  headline: [\"Run the meter\", \"backwards.\"],\n  copy: \"We survey, fit and look after solar panels and batteries for ordinary houses. One fixed price, one crew from scaffold to switch-on, and a meter that starts counting the other way.\",\n};\n\nconst links = [\"How it works\", \"Batteries\", \"Our roofs\", \"Prices\"];\n\n/** The stats row. Each `value` is shown on rolling meter drums. */\nconst stats = [\n  { label: \"Roofs fitted since 2011\", value: \"2,418\", prefix: \"\", unit: \"\" },\n  { label: \"Typical first-year saving\", value: \"840\", prefix: \"£\", unit: \"\" },\n  { label: \"Panel and workmanship cover\", value: \"25\", prefix: \"\", unit: \"yrs\" },\n];\n\n/** The live stat: tenths of a kilowatt hour sent back to the grid today. It keeps counting while you watch. */\nconst LIVE_START = 317642;\nconst LIVE_LABEL = \"kWh sent back to the grid today\";\n\nconst DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n\nfunction Drum({ digit, delay, red, still }: { digit: number; delay: number; red?: boolean; still: boolean }) {\n  return (\n    <span className={`relative inline-block h-[1.18em] w-[0.74em] overflow-hidden rounded-[0.09em] ${red ? \"bg-[#b93a12] text-[#fff3e2]\" : \"bg-[#efe7d8] text-[#1b1814]\"}`}>\n      <motion.span\n        className=\"absolute inset-x-0 top-0 flex flex-col\"\n        initial={still ? false : { y: \"0%\" }}\n        animate={{ y: `-${digit * 10}%` }}\n        transition={still ? { duration: 0 } : { type: \"spring\", stiffness: 60, damping: 14, mass: 1, delay }}\n      >\n        {DIGITS.map((d) => (\n          <span key={d} className=\"flex h-[1.18em] items-center justify-center leading-none\">\n            {d}\n          </span>\n        ))}\n      </motion.span>\n      {/* Shading that makes the flat strip of numerals read as a turning drum. */}\n      <span className=\"pointer-events-none absolute inset-0 bg-gradient-to-b from-black/45 via-transparent to-black/50\" />\n      <span className=\"pointer-events-none absolute inset-x-0 top-1/2 h-px bg-black/10\" />\n    </span>\n  );\n}\n\n/** A row of drums for a string such as \"2,418\". Commas stay still; digits roll. */\nfunction Meter({ text, redLast, baseDelay, still }: { text: string; redLast?: boolean; baseDelay: number; still: boolean }) {\n  const chars = text.split(\"\");\n  const lastDigit = chars.length - 1;\n  return (\n    <span className=\"inline-flex items-center gap-[0.07em] rounded-[0.16em] bg-[#0c0a08] p-[0.12em] font-mono font-semibold tabular-nums shadow-[inset_0_2px_6px_rgba(0,0,0,0.9),0_1px_0_rgba(255,255,255,0.08)]\" aria-hidden=\"true\">\n      {chars.map((c, i) =>\n        /\\d/.test(c) ? (\n          <Drum key={i} digit={Number(c)} delay={baseDelay + (chars.length - i) * 0.05} red={redLast && i === lastDigit} still={still} />\n        ) : (\n          <span key={i} className=\"self-end pb-[0.08em] text-[0.7em] text-[#efe7d8]/70\">\n            {c}\n          </span>\n        ),\n      )}\n    </span>\n  );\n}\n\nfunction formatTenths(n: number) {\n  const whole = Math.floor(n / 10).toLocaleString(\"en-US\");\n  return `${whole}${n % 10}`;\n}\n\nexport default function BigHeadlineHeroWithStatsRow() {\n  const reduce = useReducedMotion();\n  const still = Boolean(reduce);\n  const root = useRef<HTMLElement>(null);\n  const [live, setLive] = useState(true);\n  const [tenths, setTenths] = useState(LIVE_START);\n\n  useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const io = new IntersectionObserver(([entry]) => setLive(entry.isIntersecting));\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  // The live meter: a few tenths of a unit every second or so, only while the hero is on screen.\n  useEffect(() => {\n    if (still || !live) return;\n    const id = window.setInterval(() => setTenths((t) => t + 1 + Math.floor(Math.random() * 3)), 1100);\n    return () => window.clearInterval(id);\n  }, [still, live]);\n\n  const rise = (delay: number) =>\n    still ? {} : { initial: { opacity: 0, y: 28 }, animate: { opacity: 1, y: 0 }, transition: { type: \"spring\" as const, stiffness: 70, damping: 17, delay } };\n\n  return (\n    <section ref={root} data-live={live} className=\"stats-meter-hero relative isolate overflow-hidden bg-[#14110e] text-[#1b1814]\">\n      <style>{`\n        @keyframes stats-meter-hero-sun { 0% { transform: translate3d(-30%, 18%, 0); opacity: 0.5; } 50% { transform: translate3d(35%, -8%, 0); opacity: 0.95; } 100% { transform: translate3d(100%, 18%, 0); opacity: 0.5; } }\n        @keyframes stats-meter-hero-disc { from { transform: translate3d(130px, 0, 0); } to { transform: translate3d(-14px, 0, 0); } }\n        @keyframes stats-meter-hero-settle { from { transform: scale(1.1); } to { transform: scale(1.02); } }\n        .stats-meter-hero-photo { animation: stats-meter-hero-settle 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }\n        .stats-meter-hero-sun { animation: stats-meter-hero-sun 24s ease-in-out infinite; }\n        .stats-meter-hero-disc { animation: stats-meter-hero-disc 2.6s linear infinite; }\n        .stats-meter-hero[data-live=\"false\"] * { animation-play-state: paused !important; }\n        @media (prefers-reduced-motion: reduce) {\n          .stats-meter-hero-photo { animation: none; transform: scale(1.02); }\n          .stats-meter-hero-sun { animation: none; transform: translate3d(35%, -8%, 0); }\n          .stats-meter-hero-disc { animation: none; transform: translate3d(58px, 0, 0); }\n        }\n      `}</style>\n\n      <div className=\"relative\">\n        {/* The photograph and the big headline. */}\n        <div className=\"relative h-[560px] overflow-hidden bg-[#d6cfbf] sm:h-[620px] lg:h-[660px]\">\n          <img src={PHOTO} alt={PHOTO_ALT} width={1600} height={1067} loading=\"lazy\" className=\"stats-meter-hero-photo absolute inset-0 h-full w-full origin-bottom-right object-cover object-[78%_100%]\" />\n          {/* Low sun travelling across the sky. */}\n          <div className=\"pointer-events-none absolute inset-0 overflow-hidden mix-blend-soft-light\" aria-hidden=\"true\">\n            <div className=\"stats-meter-hero-sun absolute -top-1/4 left-0 h-[130%] w-1/2 rounded-full bg-[radial-gradient(closest-side,rgba(255,214,150,0.95),rgba(255,190,120,0.4)_45%,transparent_72%)]\" />\n          </div>\n          <div className=\"pointer-events-none absolute inset-x-0 top-0 h-2/3 bg-gradient-to-b from-[#f4ecdd]/75 via-[#f4ecdd]/30 to-transparent\" aria-hidden=\"true\" />\n          <div className=\"pointer-events-none absolute inset-y-0 left-0 hidden w-1/2 bg-gradient-to-r from-[#f1e8d8]/70 to-transparent lg:block\" aria-hidden=\"true\" />\n          <div className=\"pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-t from-[#14110e] to-transparent\" aria-hidden=\"true\" />\n\n          <div className=\"relative mx-auto flex h-full max-w-7xl flex-col px-5 pt-5 sm:px-8\">\n            <nav aria-label=\"Main\" className=\"flex items-center justify-between gap-4\">\n              <a href=\"#\" className=\"flex items-center gap-2.5 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1b1814] focus-visible:ring-offset-2 focus-visible:ring-offset-[#f1e8d8]\">\n                <svg viewBox=\"0 0 24 24\" className=\"h-6 w-6 text-[#b93a12]\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                  <path d=\"M4 17a8 8 0 0 1 16 0\" />\n                  <path d=\"M2 21h20M12 3v2.500M4.500 7.500l1.800 1.800M19.500 7.500l-1.800 1.800\" />\n                </svg>\n                <span className=\"text-lg font-semibold tracking-tight\">{firm.name}</span>\n                <span className=\"hidden border-l border-[#1b1814]/30 pl-2.5 text-xs font-medium text-[#1b1814]/80 sm:inline\">{firm.trade}</span>\n              </a>\n              <ul className=\"hidden items-center gap-7 text-sm font-medium lg:flex\">\n                {links.map((link) => (\n                  <li key={link}>\n                    <a href=\"#\" className=\"rounded-sm py-2 underline-offset-8 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1b1814]\">\n                      {link}\n                    </a>\n                  </li>\n                ))}\n              </ul>\n              <a href=\"#\" className=\"flex h-10 items-center rounded-full border border-[#1b1814]/25 bg-[#f7f1e6]/70 px-4 text-sm font-semibold backdrop-blur-md transition-colors hover:bg-[#f7f1e6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1b1814]\">\n                0161 555 0142\n              </a>\n            </nav>\n\n            <div className=\"mt-10 sm:mt-14\">\n              <motion.p {...rise(0.05)} className=\"flex items-center gap-3 text-[11px] font-semibold uppercase tracking-[0.28em] text-[#1b1814]/85\">\n                <span className=\"h-px w-10 bg-[#b93a12]\" aria-hidden=\"true\" />\n                {firm.eyebrow}\n              </motion.p>\n              <h1 className=\"mt-5 text-[clamp(3.3rem,10.2vw,9.25rem)] font-semibold leading-[1.02] tracking-[-0.06em] sm:leading-[0.84]\">\n                <motion.span {...rise(0.12)} className=\"block\">\n                  {firm.headline[0]}\n                </motion.span>\n                <motion.span {...rise(0.24)} className=\"block font-serif font-normal italic tracking-[-0.045em] text-[#b93a12]\">\n                  {firm.headline[1]}\n                </motion.span>\n              </h1>\n            </div>\n          </div>\n        </div>\n\n        {/* The pitch: over the photo on wide screens, on the dark band on phones. */}\n        <motion.div {...rise(0.4)} className=\"mx-auto max-w-7xl px-5 pb-2 pt-6 text-[#efe7d8] sm:px-8 lg:absolute lg:inset-x-0 lg:bottom-12 lg:pb-0 lg:pt-0 lg:text-[#1b1814]\">\n          <div className=\"max-w-xl\">\n            <p className=\"max-w-md text-[15px] leading-relaxed lg:font-medium\">{firm.copy}</p>\n            <div className=\"mt-5 flex flex-wrap items-center gap-x-5 gap-y-3\">\n              <a href=\"#\" className=\"group flex h-12 items-center gap-3 rounded-full bg-[#b93a12] pl-5 pr-2 text-sm font-semibold text-white shadow-[0_14px_30px_-12px_rgba(185,58,18,0.9)] transition-transform hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#b93a12] focus-visible:ring-offset-2 focus-visible:ring-offset-[#14110e] lg:focus-visible:ring-offset-[#efe7d8]\">\n                Book a free roof survey\n                <span className=\"flex h-8 w-8 items-center justify-center rounded-full bg-white text-[#b93a12] transition-transform group-hover:translate-x-0.5\">\n                  <svg viewBox=\"0 0 20 20\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"M4 10h12M11 5l5 5-5 5\" />\n                  </svg>\n                </span>\n              </a>\n              <a href=\"#\" className=\"flex h-12 items-center rounded-sm text-sm font-semibold underline decoration-[#b93a12] decoration-2 underline-offset-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-current\">\n                See a real bill, before and after\n              </a>\n            </div>\n          </div>\n        </motion.div>\n      </div>\n\n      {/* The stats row, set as four meter windows. */}\n      <div className=\"relative border-t border-white/10 bg-[#14110e] text-[#efe7d8]\">\n        <dl className=\"mx-auto grid max-w-7xl grid-cols-3 gap-x-3 gap-y-8 px-5 py-8 sm:px-8 sm:gap-x-6 lg:grid-cols-[1fr_1fr_1fr_1.5fr] lg:gap-x-10 lg:py-10\">\n          {stats.map((s, i) => (\n            <div key={s.label} className=\"flex flex-col-reverse justify-end gap-3 lg:border-r lg:border-white/10 lg:pr-8\">\n              <dt className=\"text-[13px] leading-snug text-[#efe7d8]/80\">{s.label}</dt>\n              <dd className=\"flex items-end gap-1.5 text-[clamp(1.5rem,3.6vw,2.9rem)] sm:gap-2 leading-none\">\n                <span className=\"sr-only\">\n                  {s.prefix}\n                  {s.value} {s.unit}\n                </span>\n                {s.prefix ? (\n                  <span className=\"pb-[0.14em] text-[0.7em] font-semibold text-[#efe7d8]/80\" aria-hidden=\"true\">\n                    {s.prefix}\n                  </span>\n                ) : null}\n                <Meter text={s.value} baseDelay={0.35 + i * 0.12} still={still} />\n                {s.unit ? (\n                  <span className=\"pb-[0.2em] text-sm font-semibold text-[#efe7d8]/80\" aria-hidden=\"true\">\n                    {s.unit}\n                  </span>\n                ) : null}\n              </dd>\n            </div>\n          ))}\n          <div className=\"col-span-3 flex flex-col-reverse justify-end gap-3 lg:col-span-1\">\n            <dt className=\"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-[13px] leading-snug text-[#efe7d8]/80\">\n              <span className=\"flex items-center gap-2\">\n                <span className=\"h-1.5 w-1.5 rounded-full bg-[#ff7a45]\" aria-hidden=\"true\" />\n                {LIVE_LABEL}\n              </span>\n              {/* The spinning disc of an old electricity meter, with its mark travelling the wrong way. */}\n              <span className=\"relative block h-[7px] w-[120px] overflow-hidden rounded-full bg-[linear-gradient(180deg,#5d564c,#cfc6b6_45%,#6b6358)] shadow-[inset_0_1px_1px_rgba(0,0,0,0.6)]\" aria-hidden=\"true\">\n                <span className=\"stats-meter-hero-disc absolute left-0 top-0 h-full w-2.5 bg-[#b93a12]\" />\n              </span>\n            </dt>\n            <dd className=\"text-[clamp(1.7rem,3.6vw,2.9rem)] leading-none\">\n              <span className=\"sr-only\">About {Math.floor(LIVE_START / 10).toLocaleString(\"en-US\")} and rising</span>\n              <Meter text={formatTenths(tenths)} redLast baseDelay={0.2} still={still} />\n            </dd>\n          </div>\n        </dl>\n      </div>\n    </section>\n  );\n}\n"}]}
