/* Workfloor — Page sections (sections.jsx)
   Editorial layout, Podium-influenced rhythm, Workfloor brand
   ============================================================= */

const { useState, useEffect, useRef } = React;

/* ---------------- Reveal-on-scroll hook ---------------- */
const useReveal = () => {
  const ref = useRef(null);
  useEffect(() => {
    if (!ref.current) return;
    const obs = new IntersectionObserver(
      (ents) => ents.forEach((e) => {if (e.isIntersecting) {e.target.classList.add("in");obs.unobserve(e.target);}}),
      { threshold: 0.12, rootMargin: "0px 0px -60px 0px" }
    );
    obs.observe(ref.current);
    return () => obs.disconnect();
  }, []);
  return ref;
};

/* ---------------- NAV ---------------- */
const INDUSTRIES = [
  { label: "HVAC", href: "hvac.html" },
  { label: "Oil & Gas", href: "oil-and-gas.html" },
  { label: "Roofing", href: "roofing.html" },
  { label: "Electrical", href: "electrical.html" },
  { label: "Plumbing", href: "plumbing.html" },
  { label: "Painting", href: "painting.html" },
];

const ChevronDown = () => (
  <svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden>
    <polyline points="2,4 6,8 10,4" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

const ArrowRight = () => (
  <svg width="11" height="11" viewBox="0 0 12 12" fill="none" aria-hidden>
    <line x1="2" y1="6" x2="10" y2="6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
    <polyline points="7,3 10,6 7,9" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

const Nav = ({ onWatchDemo }) => {
  const [scrolled, setScrolled] = useState(false);
  const [openMenu, setOpenMenu] = useState(null);
  const navRef = useRef(null);

  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 12);
    window.addEventListener("scroll", onScroll);
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  useEffect(() => {
    if (!openMenu) return;
    const onKey = (e) => { if (e.key === "Escape") setOpenMenu(null); };
    const onClick = (e) => { if (navRef.current && !navRef.current.contains(e.target)) setOpenMenu(null); };
    document.addEventListener("keydown", onKey);
    document.addEventListener("mousedown", onClick);
    return () => { document.removeEventListener("keydown", onKey); document.removeEventListener("mousedown", onClick); };
  }, [openMenu]);

  const toggle = (menu) => setOpenMenu(openMenu === menu ? null : menu);

  const PANEL = {
    position: "absolute", top: "calc(100% + 10px)",
    background: "rgba(10,16,28,0.97)", backdropFilter: "blur(18px)",
    WebkitBackdropFilter: "blur(18px)",
    border: "1px solid rgba(255,255,255,0.09)",
    borderRadius: 14,
    boxShadow: "0 24px 56px rgba(0,0,0,0.55)",
    zIndex: 200,
    animation: "wf-dd-in 0.2s cubic-bezier(0.2,0.8,0.2,1) both"
  };

  const btnStyle = (active) => ({
    display: "inline-flex", alignItems: "center", gap: 6,
    fontSize: 13, color: active ? "#F5F3EE" : "#9AAABB",
    padding: "6px 14px", fontWeight: 500,
    borderRadius: 100, transition: "color 0.2s",
    background: "transparent", border: "none", cursor: "pointer",
    fontFamily: "var(--font-display)"
  });

  return (
    <header ref={navRef} style={{
      position: "fixed", top: 0, left: 0, right: 0, zIndex: 100,
      background: scrolled ? "rgba(6,13,22,0.78)" : "transparent",
      backdropFilter: scrolled ? "blur(14px)" : "none",
      borderBottom: scrolled ? "1px solid rgba(255,255,255,0.06)" : "1px solid transparent",
      transition: "all 0.3s ease"
    }}>
      <nav className="wf-container-wide wf-nav" style={{ display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px 0", position: "relative" }}>
        <a href="#top" style={{ display: "flex", alignItems: "center", gap: 9, textDecoration: "none" }}>
          <Mark size={22} />
          <span style={{ fontSize: 16, fontWeight: 700, color: "#F5F3EE", letterSpacing: "-0.02em", fontFamily: "var(--font-display)" }}>Workfloor</span>
        </a>

        <div className="wf-nav-links" style={{ display: "flex", gap: 2, alignItems: "center" }}>

          {/* Solutions dropdown */}
          <div style={{ position: "relative" }} onMouseLeave={() => setOpenMenu(null)}>
            <button style={btnStyle(openMenu === "solutions")}
              onMouseEnter={() => setOpenMenu("solutions")}
              aria-expanded={openMenu === "solutions"} aria-haspopup="true">
              Industry Solutions
              <span style={{ display: "flex", transition: "transform 0.22s", transform: openMenu === "solutions" ? "rotate(180deg)" : "none" }}><ChevronDown /></span>
            </button>
            {openMenu === "solutions" && (
              <div style={{ ...PANEL, left: 0, minWidth: 262, padding: "10px 8px" }}>

                {INDUSTRIES.map((ind) => (
                  <a key={ind.label} href={ind.href}
                    style={{ display: "flex", alignItems: "center", justifyContent: "space-between", padding: "11px 14px", borderRadius: 8, textDecoration: "none", color: "#c8c0b8", fontSize: 15, fontWeight: 500, fontFamily: "var(--font-display)", letterSpacing: "-0.01em", transition: "background 0.15s, color 0.15s" }}
                    onMouseEnter={(e) => { e.currentTarget.style.background = "rgba(255,255,255,0.07)"; e.currentTarget.style.color = "#F5F3EE"; }}
                    onMouseLeave={(e) => { e.currentTarget.style.background = "transparent"; e.currentTarget.style.color = "#c8c0b8"; }}
                    onClick={() => setOpenMenu(null)}>
                    {ind.label}
                    <span style={{ color: "#3d5268", flexShrink: 0 }}><ArrowRight /></span>
                  </a>
                ))}
              </div>
            )}
          </div>

          {/* Resources dropdown */}
          <div style={{ position: "relative" }} onMouseLeave={() => setOpenMenu(null)}>
            <button style={btnStyle(openMenu === "resources")}
              onMouseEnter={() => setOpenMenu("resources")}
              aria-expanded={openMenu === "resources"} aria-haspopup="true">
              Resources
              <span style={{ display: "flex", transition: "transform 0.22s", transform: openMenu === "resources" ? "rotate(180deg)" : "none" }}><ChevronDown /></span>
            </button>
            {openMenu === "resources" && (
              <div style={{ ...PANEL, left: 0, width: 320, padding: "10px 8px" }}>
                <div style={{ padding: "4px 12px 12px" }}>
                  <div style={{ fontSize: 10, fontWeight: 700, color: "#6A7D8E", letterSpacing: "0.14em", textTransform: "uppercase", fontFamily: "var(--font-display)", marginBottom: 6 }}>Learn</div>
                  {[
                    { label: "How it works", sub: "Three steps to a running system", href: "#how", icon: "clock" },
                  ].map((r) => (
                    <a key={r.label} href={r.href}
                      style={{ display: "flex", alignItems: "flex-start", gap: 12, padding: "10px 10px", borderRadius: 8, textDecoration: "none", transition: "background 0.15s" }}
                      onMouseEnter={(e) => e.currentTarget.style.background = "rgba(255,255,255,0.07)"}
                      onMouseLeave={(e) => e.currentTarget.style.background = "transparent"}
                      onClick={() => setOpenMenu(null)}>
                      <div style={{ width: 34, height: 34, borderRadius: 8, background: "rgba(232,147,74,0.12)", border: "1px solid rgba(232,147,74,0.2)", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }}>
                        {r.icon === "clock"
                          ? <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#E8934A" strokeWidth="2" strokeLinecap="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
                          : <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#E8934A" strokeWidth="2" strokeLinecap="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>}
                      </div>
                      <div>
                        <div style={{ fontSize: 14, fontWeight: 600, color: "#F5F3EE", fontFamily: "var(--font-display)", letterSpacing: "-0.01em", marginBottom: 2 }}>{r.label}</div>
                        <div style={{ fontSize: 12, color: "#6A7D8E", lineHeight: 1.4 }}>{r.sub}</div>
                      </div>
                    </a>
                  ))}
                </div>
                <div style={{ borderTop: "1px solid rgba(255,255,255,0.07)", padding: "10px 20px 8px", display: "flex", gap: 20 }}>
                  {[{ label: "Contact us", href: "contact.html" }, { label: "About", href: "about.html" }].map((r) => (
                    <a key={r.label} href={r.href}
                      style={{ fontSize: 12.5, color: "#9AAABB", textDecoration: "none", fontFamily: "var(--font-display)", fontWeight: 500, transition: "color 0.15s" }}
                      onMouseEnter={(e) => e.currentTarget.style.color = "#F5F3EE"}
                      onMouseLeave={(e) => e.currentTarget.style.color = "#9AAABB"}
                      onClick={() => setOpenMenu(null)}>
                      {r.label} →
                    </a>
                  ))}
                </div>
              </div>
            )}
          </div>

          {/* Static links */}
          {[
            { l: "Results", h: "#results" },
            { l: "FAQ", h: "#faq" },
            { l: "Contact", h: "contact.html" },
          ].map((item) => (
            <a key={item.l} href={item.h} className="wf-nav-link"
              style={{ fontSize: 13, color: "#9AAABB", padding: "6px 14px", textDecoration: "none", fontWeight: 500, borderRadius: 100, transition: "color 0.2s" }}
              onMouseEnter={(e) => e.target.style.color = "#F5F3EE"}
              onMouseLeave={(e) => e.target.style.color = "#9AAABB"}
              onClick={() => setOpenMenu(null)}>
              {item.l}
            </a>
          ))}

          <a href="contact.html" className="wf-pill wf-nav-cta" style={{ marginLeft: 12, padding: "9px 20px", fontSize: 13.5 }}>
            <svg width={10} height={10} viewBox="0 0 13 13" fill="#111E2E" aria-hidden><polygon points="2,1 12,6.5 2,12" /></svg>
            Watch a demo
          </a>
        </div>
      </nav>
    </header>);

};


/* ---------------- HERO — cinematic intro, then centered hero over video ---------------- */
const Hero = ({ headline, accentMix, onIntroChange }) => {
  // Parse headline: split off final clause as italic amber
  const [main, italic] = (() => {
    const parts = headline.split("|");
    if (parts.length === 2) return [parts[0].trim(), parts[1].trim()];
    return [headline, ""];
  })();

  // Intro state: "playing" → cinematic plays, only nav visible.
  // "done" → hero content revealed. Skipped if returning visitor.
  const seenIntro = (() => {
    try { return localStorage.getItem("wf-intro-seen") === "1"; } catch (e) { return false; }
  })();
  const [intro, setIntro] = useState(seenIntro ? "done" : "playing");
  const [muted, setMuted] = useState(true);
  const [loaded, setLoaded] = useState(false);
  const [soundPrompt, setSoundPrompt] = useState(false);
  const [isMobile, setIsMobile] = useState(false);
  const [videoEnded, setVideoEnded] = useState(false);
  const videoRef = useRef(null);
  const heroRef = useRef(null);
  const endedRef = useRef(false);

  const restartVideo = () => {
    const v = videoRef.current;
    if (!v) return;
    endedRef.current = false;
    setVideoEnded(false);
    // Return to the fresh-visit view: scroll to top so the headline hides
    // and the video plays full-screen with nothing over it.
    const root = document.scrollingElement || document.documentElement;
    if (root) root.scrollTop = 0;
    window.scrollTo(0, 0);
    setReveal(0);
    v.currentTime = 0;
    v.play().catch(() => {});
  };

  // Mobile detection — on phones we skip the heavy cinematic entirely and
  // show the static HVAC poster image instead.
  useEffect(() => {
    const mq = window.matchMedia("(max-width: 768px)");
    const update = () => setIsMobile(mq.matches);
    update();
    mq.addEventListener("change", update);
    return () => mq.removeEventListener("change", update);
  }, []);

  // On mobile, never run the cinematic intro — jump straight to hero content.
  useEffect(() => {
    if (isMobile && intro === "playing") finishIntroSilent();
  }, [isMobile]);

  // Notify parent (App) so it can hide page chrome / lock scroll during intro
  useEffect(() => { onIntroChange && onIntroChange(intro); }, [intro]);

  // 0..1 — how far the scroll-driven hero reveal has progressed.
  const [reveal, setReveal] = useState(0);

  const finishIntro = () => {
    setIntro("done");
    setSoundPrompt(false);
    try { localStorage.setItem("wf-intro-seen", "1"); } catch (e) {}
  };
  // Mobile / returning visitor: jump straight to the static hero.
  const finishIntroSilent = () => { setIntro("done"); setSoundPrompt(false); };

  // Lock scroll while the cinematic plays. The page sits at the top with only
  // the video + nav visible until the cinematic ends or the user skips.
  useEffect(() => {
    if (intro === "playing") {
      const prev = document.body.style.overflow;
      document.body.style.overflow = "hidden";
      window.scrollTo(0, 0);
      return () => { document.body.style.overflow = prev; };
    }
  }, [intro]);

  // Once the cinematic is done, the hero content is revealed by SCROLLING:
  // the headline, copy, and CTA rise up from the bottom and settle into place,
  // each tied directly to scroll position (not a one-shot toggle).
  useEffect(() => {
    if (intro !== "done" || isMobile) return;
    const onScroll = () => {
      const el = heroRef.current;
      if (!el) return;
      const vh = window.innerHeight;
      const dist = vh * 0.85;                 // scroll needed to fully reveal
      // Body is the scroll container (overflow-x:hidden), so window.scrollY
      // can be 0 — derive scroll from the section's position instead.
      const scrolled = Math.max(0, -el.getBoundingClientRect().top);
      const p = Math.max(0, Math.min(1, scrolled / dist));
      setReveal(p);
      // Pause the bg video once the hero has fully scrolled away.
      const v = videoRef.current;
      if (v) {
        const past = scrolled > vh * 1.05;
        // Never auto-resume a video that has finished its single play-through.
        if (past && !v.paused) v.pause();
        else if (!past && v.paused && !endedRef.current) v.play().catch(() => {});
      }
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, [intro, isMobile]);

  // Mobile: no scroll trick — content is shown immediately.
  useEffect(() => { if (isMobile) setReveal(1); }, [isMobile]);

  const toggleSound = () => {
    const v = videoRef.current;
    if (!v) return;
    const next = !muted;
    v.muted = next;
    setMuted(next);
    setSoundPrompt(false);
    if (!next) { v.play().catch(() => {}); }
  };

  const isPlaying = intro === "playing";
  const contentVisible = intro === "done";

  // Per-element reveal progress (staggered) + rise-from-bottom transform.
  const lp = (offset) => {
    if (isMobile) return 1;
    if (!contentVisible) return 0;
    const span = 1 - offset;
    return Math.max(0, Math.min(1, (reveal - offset) / span));
  };
  const rise = (offset, dist = 70) => {
    const p = lp(offset);
    return {
      opacity: p,
      transform: `translateY(${(1 - p) * dist}px)`,
      transition: "opacity 0.12s linear, transform 0.12s linear"
    };
  };

  // Show the big "turn on sound" prompt for the first few seconds of the cinematic
  useEffect(() => {
    if (isPlaying && !isMobile && muted) {
      setSoundPrompt(true);
      const t = setTimeout(() => setSoundPrompt(false), 6000);
      return () => clearTimeout(t);
    }
  }, [isPlaying, isMobile]);

  return (
    <section ref={heroRef} data-screen-label="01 Hero" id="top" style={{
      position: "relative",
      height: isMobile ? "auto" : (isPlaying ? "100vh" : "200vh"),
      minHeight: isMobile ? "100vh" : undefined,
      background: "#03070d",
      color: "#F5F3EE"
    }}>
      {/* Sticky stage: video + content stay pinned full-screen while the
          reveal plays out over the section's scroll runway. */}
      <div style={{
        position: isMobile ? "relative" : "sticky",
        top: 0,
        height: isMobile ? "auto" : "100vh",
        minHeight: isMobile ? "100vh" : undefined,
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        overflow: "hidden"
      }}>
      {/* Full-bleed cinematic / background video (desktop only) */}
      {!isMobile &&
        <video
          ref={videoRef}
          autoPlay
          muted={muted}
          loop={false}
          playsInline
          preload="auto"
          poster="marketing/assets/hero-poster.jpg"
          aria-hidden
          onLoadedData={() => setLoaded(true)}
          onEnded={() => {
            endedRef.current = true;
            setVideoEnded(true);
            const v = videoRef.current;
            if (v) { try { v.pause(); } catch (e) {} }
            if (isPlaying) finishIntro();
          }}
          style={{
            position: "absolute", inset: 0,
            width: "100%", height: "100%",
            objectFit: "cover",
            zIndex: 0,
            opacity: isPlaying ? 1 : 0.85,
            transition: "opacity 1s ease"
          }}>
          <source src="marketing/assets/hero-cinematic.mp4" type="video/mp4" />
        </video>
      }

      {/* Static HVAC poster background (mobile) */}
      {isMobile &&
        <div aria-hidden style={{
          position: "absolute", inset: 0, zIndex: 0,
          backgroundImage: "url('marketing/assets/hero-mobile.jpg')",
          backgroundSize: "cover",
          backgroundPosition: "center"
        }} />
      }

      {/* Loading shimmer — covers the black gap before the video first paints */}
      {!isMobile && !loaded &&
        <div aria-hidden style={{
          position: "absolute", inset: 0, zIndex: 1,
          backgroundImage: "url('marketing/assets/hero-poster.jpg')",
          backgroundSize: "cover", backgroundPosition: "center"
        }}>
          <div style={{
            position: "absolute", inset: 0,
            background: "linear-gradient(180deg, rgba(3,7,13,0.5), rgba(3,7,13,0.7))"
          }} />
          <div style={{
            position: "absolute", left: 0, right: 0, bottom: 48,
            display: "flex", justifyContent: "center", alignItems: "center", gap: 10
          }}>
            <span className="wf-load-dot" style={{ animationDelay: "0s" }} />
            <span className="wf-load-dot" style={{ animationDelay: "0.18s" }} />
            <span className="wf-load-dot" style={{ animationDelay: "0.36s" }} />
          </div>
        </div>
      }

      {/* Tint overlay — lighter during cinematic, full wash once hero is shown */}
      <div style={{
        position: "absolute", inset: 0, zIndex: 1, pointerEvents: "none",
        background: isPlaying
          ? "linear-gradient(180deg, rgba(3,7,13,0.35) 0%, rgba(3,7,13,0.05) 30%, rgba(3,7,13,0.45) 100%)"
          : "radial-gradient(ellipse 80% 70% at 50% 40%, rgba(6,13,22,0.35) 0%, rgba(3,7,13,0.78) 100%), linear-gradient(180deg, rgba(3,7,13,0.55) 0%, rgba(3,7,13,0.25) 35%, rgba(3,7,13,0.85) 100%)",
        transition: "background 1s ease"
      }} aria-hidden />

      {/* Drifting amber glow (hero only) */}
      <div className="wf-glow" style={{
        position: "absolute", zIndex: 1,
        width: 700, height: 700,
        background: `rgba(232,147,74,${0.10 * accentMix})`,
        top: "-15%", left: "50%", transform: "translateX(-50%)",
        pointerEvents: "none",
        opacity: isPlaying ? 0 : 1,
        transition: "opacity 1s ease"
      }} aria-hidden />

      {/* ===== BIG SOUND PROMPT (centered, first seconds of cinematic) ===== */}
      {isPlaying && soundPrompt && muted &&
        <button
          onClick={toggleSound}
          style={{
            position: "absolute", zIndex: 5,
            left: "50%", top: "50%", transform: "translate(-50%, -50%)",
            display: "flex", flexDirection: "column", alignItems: "center", gap: 16,
            background: "transparent", border: "none", cursor: "pointer",
            animation: "wf-sound-pop 0.6s cubic-bezier(0.2,0.8,0.2,1) both"
          }}>
          <span style={{
            width: 76, height: 76, borderRadius: "50%",
            background: "rgba(232,147,74,0.16)", backdropFilter: "blur(8px)",
            border: "1.5px solid rgba(232,147,74,0.6)",
            display: "flex", alignItems: "center", justifyContent: "center",
            boxShadow: "0 0 0 0 rgba(232,147,74,0.4)",
            animation: "wf-sound-ring 2s ease-out infinite"
          }}>
            <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="#F5F3EE" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" /><path d="M15.54 8.46a5 5 0 0 1 0 7.07" /><path d="M19.07 4.93a10 10 0 0 1 0 14.14" /></svg>
          </span>
          <span style={{
            color: "#F5F3EE", fontSize: 15, fontWeight: 600,
            fontFamily: "var(--font-display)", letterSpacing: "0.01em",
            textShadow: "0 2px 12px rgba(0,0,0,0.6)"
          }}>
            Turn on sound
          </span>
        </button>
      }

      {/* ===== CINEMATIC CONTROLS (only while playing) ===== */}
      {isPlaying &&
        <div style={{
          position: "absolute", zIndex: 4,
          left: 0, right: 0, bottom: 40,
          display: "flex", flexDirection: "column", alignItems: "center", gap: 18
        }}>
          {/* Sound toggle */}
          <button
            onClick={toggleSound}
            style={{
              display: "inline-flex", alignItems: "center", gap: 9,
              background: "rgba(3,7,13,0.5)", backdropFilter: "blur(10px)",
              border: "1px solid rgba(255,255,255,0.2)",
              color: "#F5F3EE", borderRadius: 100,
              padding: "9px 18px", fontSize: 13, cursor: "pointer",
              fontFamily: "var(--font-display)", fontWeight: 500,
              transition: "background 0.2s, border-color 0.2s"
            }}
            onMouseEnter={(e) => { e.currentTarget.style.background = "rgba(3,7,13,0.7)"; e.currentTarget.style.borderColor = "rgba(232,147,74,0.5)"; }}
            onMouseLeave={(e) => { e.currentTarget.style.background = "rgba(3,7,13,0.5)"; e.currentTarget.style.borderColor = "rgba(255,255,255,0.2)"; }}>
            {muted
              ? <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" /><line x1="23" y1="9" x2="17" y2="15" /><line x1="17" y1="9" x2="23" y2="15" /></svg>
              : <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" /><path d="M15.54 8.46a5 5 0 0 1 0 7.07" /><path d="M19.07 4.93a10 10 0 0 1 0 14.14" /></svg>}
            {muted ? "Tap for sound" : "Sound on"}
          </button>

          {/* Skip */}
          <button
            onClick={finishIntro}
            style={{
              display: "inline-flex", alignItems: "center", gap: 7,
              background: "transparent", border: "none",
              color: "rgba(245,243,238,0.6)", fontSize: 12.5, cursor: "pointer",
              fontFamily: "var(--font-display)", fontWeight: 500, letterSpacing: "0.04em",
              transition: "color 0.2s"
            }}
            onMouseEnter={(e) => e.currentTarget.style.color = "#F5F3EE"}
            onMouseLeave={(e) => e.currentTarget.style.color = "rgba(245,243,238,0.6)"}>
            Skip intro
            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polygon points="5 4 15 12 5 20 5 4" /><line x1="19" y1="5" x2="19" y2="19" /></svg>
          </button>
        </div>
      }

      {/* ===== HERO CONTENT (rises from the bottom, tied to scroll) ===== */}
      <div className="wf-container-wide" style={{
        position: "relative", zIndex: 2,
        textAlign: "center",
        padding: "0 24px",
        maxWidth: 760,
        opacity: contentVisible ? 1 : 0,
        pointerEvents: lp(0.24) > 0.5 ? "auto" : "none"
      }}>
        <p className="eyebrow" style={{ color: "#E8934A", marginBottom: 18, fontSize: 11, ...rise(0) }}>
          AI Operations for HVAC Contractors
        </p>
        <h1 className="wf-h1-fluid" style={{
          fontSize: "clamp(34px, 4.6vw, 58px)",
          color: "#F5F3EE",
          margin: "0 auto 18px",
          maxWidth: 680,
          fontFamily: "var(--font-display)",
          lineHeight: 1.05,
          letterSpacing: "-0.03em", fontWeight: "300",
          ...rise(0.1)
        }}>
          {main}
          {italic && <><br /><em style={{ color: "var(--wf-amber)", fontStyle: "italic", fontWeight: 600 }}>{italic}</em></>}
        </h1>
        <p style={{
          fontSize: "clamp(14px, 1.2vw, 16px)",
          color: "rgba(245,243,238,0.78)",
          lineHeight: 1.6,
          maxWidth: 520,
          margin: "0 auto 28px",
          fontFamily: "var(--font-body)",
          ...rise(0.2)
        }}>
          We map where your HVAC business is leaking revenue, and build the system that fixes and grows with your business.
        </p>
        <div style={{ display: "flex", justifyContent: "center", gap: 14, flexWrap: "wrap", ...rise(0.3) }}>
          <a href="#demo" className="wf-pill" style={{ padding: "13px 30px", fontSize: 14.5 }}>
            <svg width={12} height={12} viewBox="0 0 13 13" fill="#111E2E" aria-hidden><polygon points="2,1 12,6.5 2,12" /></svg>
            Get a demo
          </a>
          <a href="#voice" style={{
            display: "inline-flex", alignItems: "center", gap: 9,
            padding: "13px 26px", borderRadius: 100,
            background: "rgba(255,255,255,0.08)",
            border: "1px solid rgba(255,255,255,0.28)",
            color: "#F5F3EE", fontSize: 14.5, fontWeight: 600,
            fontFamily: "var(--font-display)", letterSpacing: "-0.01em",
            textDecoration: "none", backdropFilter: "blur(8px)",
            transition: "background 0.2s, border-color 0.2s"
          }}
            onMouseEnter={(e) => { e.currentTarget.style.background = "rgba(255,255,255,0.16)"; e.currentTarget.style.borderColor = "rgba(255,255,255,0.45)"; }}
            onMouseLeave={(e) => { e.currentTarget.style.background = "rgba(255,255,255,0.08)"; e.currentTarget.style.borderColor = "rgba(255,255,255,0.28)"; }}>
            Listen to a Voice AI call
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z" /></svg>
          </a>
        </div>
      </div>

      {/* ===== RESTART VIDEO (after the cinematic has finished) ===== */}
      {!isMobile && contentVisible && videoEnded &&
        <button
          onClick={restartVideo}
          style={{
            position: "absolute", zIndex: 4,
            right: 24, bottom: 24,
            display: "inline-flex", alignItems: "center", gap: 8,
            background: "rgba(3,7,13,0.5)", backdropFilter: "blur(10px)",
            border: "1px solid rgba(255,255,255,0.18)",
            color: "rgba(245,243,238,0.85)", borderRadius: 100,
            padding: "8px 16px", fontSize: 12.5, cursor: "pointer",
            fontFamily: "var(--font-display)", fontWeight: 500, letterSpacing: "0.01em",
            transition: "background 0.2s, border-color 0.2s, color 0.2s"
          }}
          onMouseEnter={(e) => { e.currentTarget.style.background = "rgba(3,7,13,0.72)"; e.currentTarget.style.borderColor = "rgba(232,147,74,0.5)"; e.currentTarget.style.color = "#F5F3EE"; }}
          onMouseLeave={(e) => { e.currentTarget.style.background = "rgba(3,7,13,0.5)"; e.currentTarget.style.borderColor = "rgba(255,255,255,0.18)"; e.currentTarget.style.color = "rgba(245,243,238,0.85)"; }}>
          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="23 4 23 10 17 10" /><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10" /></svg>
          Restart video
        </button>
      }

      {/* ===== SCROLL CUE — invites the scroll-reveal; click jumps to Built different ===== */}
      {!isPlaying &&
        <button
          onClick={() => { const t = document.getElementById("built"); if (t) window.scrollTo({ top: t.offsetTop, behavior: "smooth" }); }}
          aria-label="Scroll to next section"
          style={{
            position: "absolute", zIndex: 3,
            left: "50%", bottom: 72, transform: "translateX(-50%)",
            display: "flex", flexDirection: "column", alignItems: "center", gap: 8,
            background: "transparent", border: "none", cursor: "pointer",
            color: "rgba(245,243,238,0.62)",
            fontFamily: "var(--font-display)", fontWeight: 600,
            fontSize: 10.5, letterSpacing: "0.16em", textTransform: "uppercase",
            opacity: isMobile ? 1 : Math.max(0, 1 - reveal * 1.6),
            pointerEvents: (!isMobile && reveal > 0.55) ? "none" : "auto",
            transition: "opacity 0.2s linear"
          }}>
          <span>{(isMobile || reveal > 0.4) ? "Scroll" : "Scroll to explore"}</span>
          <span className="wf-scroll-cue" style={{ display: "flex" }}>
            <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="6 9 12 15 18 9" /></svg>
          </span>
        </button>
      }
      </div>
    </section>);

};


/* ---------------- LOGO STRIP — marquee ---------------- */
const LogoStrip = ({ light = false }) => {
  const items = ["ServiceTitan", "Jobber", "HouseCall Pro", "Twilio", "Zapier", "Calendly", "QuickBooks", "Slack", "Stripe"];
  const fg = light ? "#3d5268" : "#3d5268";
  const bg = light ? "#F5F2EE" : "#03070d";
  const lab = light ? "#9AAABB" : "#1e3045";
  const div = light ? "#9AAABB" : "#0f1e2e";
  return (
    <div style={{ background: bg, borderTop: "1px solid rgba(255,255,255,0.04)", borderBottom: "1px solid rgba(255,255,255,0.04)", padding: "28px 0", overflow: "hidden" }}>
      <div className="wf-container-wide" style={{ display: "flex", alignItems: "center", gap: 28 }}>
        <span style={{ fontSize: 10, color: lab, fontWeight: 700, letterSpacing: "0.18em", textTransform: "uppercase", flexShrink: 0, fontFamily: "var(--font-display)" }}>
          Connects to
        </span>
        <div className="wf-marquee" style={{ flex: 1, overflow: "hidden", maskImage: "linear-gradient(90deg, transparent 0, black 8%, black 92%, transparent 100%)" }}>
          <div className="wf-marquee-track">
            {[...items, ...items].map((name, i) =>
            <span key={i} style={{ display: "inline-flex", alignItems: "center", gap: 32, fontSize: 16, color: fg, fontWeight: 600, fontFamily: "var(--font-display)", letterSpacing: "-0.01em", whiteSpace: "nowrap" }}>
                {name}
                <span style={{ color: div, fontSize: 14 }}>◇</span>
              </span>
            )}
          </div>
        </div>
      </div>
    </div>);

};

/* ---------------- HOW IT WORKS — light, big numerals ---------------- */
const HowItWorks = () => {
  const ref = useReveal();
  const STEPS = [
  { n: "01", title: "We map your operation.", body: "30 minutes. We look at where calls, jobs, and revenue are slipping — which leads go unanswered, which slots go unfilled, which tasks eat your day. We tell you exactly what we'd build and what it would recover. If we're not the right fit, we'll say so." },
  { n: "02", title: "We build your system.", body: "We connect to your existing CRM — whatever you're already using — and build everything to your operation. Your service area, your pricing, how you handle customers. End-to-end tested before anything goes live. You approve the setup. Then it runs." },
  { n: "03", title: "It learns. You never fall behind.", body: "The system learns from your business over time — your call patterns, your peak seasons, what works in your market. Workfloor's team reviews performance every month. Month 3 runs sharper than month 1. You never manage it. You just see the results." }];

  return (
    <section id="how" data-screen-label="03 How it works" style={{ background: "var(--wf-warm-white)", position: "relative" }}>
      <div className="wf-container">
        <div ref={ref} className="wf-reveal" style={{ display: "grid", gridTemplateColumns: "0.9fr 1.1fr", gap: 64, alignItems: "start", marginBottom: 72 }}>
          <div>
            <p className="eyebrow">How it works</p>
            <h2 style={{ fontSize: "clamp(36px, 5vw, 56px)", margin: 0, lineHeight: 1.02, letterSpacing: "-0.03em", fontWeight: "500" }}>
              Three steps.<br />
              <span style={{ color: "var(--wf-amber)", fontStyle: "italic", fontWeight: 700 }}>One running system.</span>
            </h2>
          </div>
          <div style={{ paddingTop: 24 }}>
            <p style={{ fontSize: 18, color: "var(--wf-slate-400)", lineHeight: 1.65, margin: 0, maxWidth: 520 }}>Most contractors are running within a week of the discovery call. No software to learn, no dashboards to babysit. The system gets handed back to us. We run it, you see results.

            </p>
          </div>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 24 }}>
          {STEPS.map((step, i) =>
          <div key={step.n} className="wf-card-lift wf-reveal" style={{
            animationDelay: `${i * 0.1}s`,
            position: "relative",
            background: "#fff",
            border: "1px solid var(--wf-border-cream)",
            borderTop: "2px solid var(--wf-amber)",
            borderRadius: 12,
            padding: "44px 32px 36px",
            overflow: "hidden",
            boxShadow: "var(--wf-shadow-card)"
          }} ref={useReveal()}>
              <div style={{ position: "absolute", top: -18, right: 14, fontSize: 130, fontWeight: 800, color: "rgba(232,147,74,0.06)", lineHeight: 1, fontFamily: "var(--font-display)", letterSpacing: "-0.05em", opacity: "0.5" }}>{step.n}</div>
              <div style={{ fontSize: 11, color: "var(--wf-amber)", fontWeight: 700, letterSpacing: "0.18em", marginBottom: 20, fontFamily: "var(--font-display)" }}>STEP {step.n}</div>
              <h3 style={{ fontSize: 22, fontWeight: 700, marginBottom: 14, lineHeight: 1.2, letterSpacing: "-0.02em" }}>{step.title}</h3>
              <p style={{ fontSize: 14.5, color: "var(--wf-slate-400)", lineHeight: 1.7, margin: 0 }}>{step.body}</p>
            </div>
          )}
        </div>
      </div>
    </section>);

};

/* ---------------- STATS — editorial big numbers ---------------- */
const Stats = () => {
  const STATS = [
  { stat: "1 in 4", label: "Calls go unanswered", sub: "In the average HVAC shop. Owners guess 8%. The gap is what your competitor lives in." },
  { stat: "<60s", label: "System response time", sub: "Every missed contact gets a response. Day or night, on a job or off the clock." },
  { stat: "8×", label: "Conversion drops after 5 min", sub: "Leads go cold fast. The system fires before they dial the next number." },
  { stat: "292%", label: "After-hours booking lift", sub: "From 12/month to 47/month — documented in field deployments." },
  { stat: "78%", label: "Pick the first responder", sub: "Speed to lead is the only advantage that matters at 9pm." },
  { stat: "3 weeks", label: "Avg time to first results", sub: "The system starts working from day one. Most contractors see their first recovered lead in days." }];

  const ref = useReveal();
  return (
    <section id="stats" data-screen-label="05 Stats" style={{ background: "var(--wf-navy-deep)", color: "var(--wf-text-warm)", position: "relative", overflow: "hidden" }}>
      <div className="wf-grid-bg" style={{ position: "absolute", inset: 0, opacity: 0.4 }} />
      <div className="wf-container" style={{ position: "relative" }}>
        <div ref={ref} className="wf-reveal" style={{ marginBottom: 64, maxWidth: 760 }}>
          <p className="eyebrow">Real results · Real businesses</p>
          <h2 style={{ fontSize: "clamp(36px, 5vw, 56px)", color: "var(--wf-text-warm)", margin: 0, lineHeight: 1.04, letterSpacing: "-0.03em", fontWeight: "500" }}>
            The numbers behind <span style={{ color: "var(--wf-amber)", fontStyle: "italic" }}>every missed call.
            </span>
          </h2>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 1, background: "rgba(255,255,255,0.06)", borderRadius: 14, overflow: "hidden", border: "1px solid rgb(199, 167, 167)" }}>
          {STATS.map((card, i) => <div key={card.label} className="wf-reveal" ref={useReveal()} style={{
            background: "var(--wf-navy-deep)",
            padding: "44px 36px",
            position: "relative"
          }}>
              <div className="wf-bignum" style={{ fontSize: "clamp(48px, 5vw, 72px)", color: "var(--wf-amber)", marginBottom: 18, fontFamily: "\"system-ui\"", margin: "0px 0px 18px", borderStyle: "none", opacity: "0.7" }}>{card.stat}</div>
              <div style={{ fontSize: 15, color: "var(--wf-text-warm)", fontFamily: "var(--font-display)", fontWeight: 600, marginBottom: 10, letterSpacing: "-0.01em" }}>{card.label}</div>
              <p style={{ fontSize: 13, color: "var(--wf-slate-400)", lineHeight: 1.65, margin: 0 }}>{card.sub}</p>
            </div>
          )}
        </div>
        <p style={{ fontSize: 11, color: "var(--wf-slate-700)", textAlign: "center", marginTop: 32, letterSpacing: "0.05em" }}>
          Industry data from ACCA, Hatch, and documented field deployments.
        </p>
      </div>
    </section>);

};

/* ---------------- BUILT DIFFERENT — FAQ-style accordion + sticky mockup
   Two-column: left side is a vertical accordion (one open at a time),
   right side is a sticky mockup that swaps to match the open row.
   ---------------------------------------------------------------------- */
const BuiltDifferent = () => {
  const FEATURES = [
  {
    title: "Trained on your shop, not a template.",
    body: "Every system is built from your call patterns, your pricing, your service area. It runs the way you would — not the way a generic vendor thinks an HVAC shop should.",
    mockKey: "approval"
  },
  {
    title: "You don't manage it. We do.",
    body: "No dashboards to babysit. We run the system, tune it monthly, and update it as your operation changes. You see the results in a morning report.",
    mockKey: "morning"
  },
  {
    title: "Custom voice. Custom logic.",
    body: "It speaks the way you speak. It handles after-hours the way you'd handle after-hours. And it hands off to you the moment something needs your judgment.",
    mockKey: "missed"
  },
  {
    title: "Plugs into what you already run.",
    body: "ServiceTitan. Jobber. HouseCall Pro. Twilio. We connect to your existing CRM, dispatch, and phones — without forcing you to switch.",
    mockKey: "tracking"
  }];

  const [open, setOpen] = useState(0);
  const [progress, setProgress] = useState(0); // 0..1 progress through whole section
  const [isMobile, setIsMobile] = useState(false);
  const sectionRef = useRef(null);
  const userClickedRef = useRef(false);
  const userClickTimerRef = useRef(null);
  const lastChangeRef = useRef(0);
  const lastIdxRef = useRef(0);

  // Detect mobile — disables the scroll-cycle pattern entirely.
  useEffect(() => {
    const mq = window.matchMedia("(max-width: 980px)");
    const update = () => setIsMobile(mq.matches);
    update();
    mq.addEventListener("change", update);
    return () => mq.removeEventListener("change", update);
  }, []);

  // Per-card scroll "weight" — the last card gets HALF the runway of the
  // others so users can naturally scroll past once they've seen it.
  const WEIGHTS = FEATURES.map((_, i) => i === FEATURES.length - 1 ? 0.5 : 1);
  const TOTAL_W = WEIGHTS.reduce((a, b) => a + b, 0);
  const THRESHOLDS = (() => {
    const out = [];
    let acc = 0;
    for (let k = 0; k < WEIGHTS.length; k++) {
      out.push(acc / TOTAL_W);
      acc += WEIGHTS[k];
    }
    return out;
  })();

  // Scroll-driven (desktop only): derive active index + smooth progress from
  // how far we've scrolled THROUGH the section. After each transition, briefly
  // lock further changes so users can't blow through in one flick.
  useEffect(() => {
    if (isMobile) return;
    const onScroll = () => {
      if (userClickedRef.current) return;
      const el = sectionRef.current;
      if (!el) return;
      const rect = el.getBoundingClientRect();
      const vh = window.innerHeight;
      // Tiny lead-in (~10vh) — the section locks visually right when the
      // headline + cards layout is fully in view, then the cycle begins.
      const leadIn = vh * 0.1;
      const total = el.offsetHeight - vh - leadIn;
      if (total <= 0) return;
      const scrolled = Math.max(0, Math.min(total, -rect.top - leadIn));
      const p = scrolled / total;
      setProgress(p);
      // Find active card by walking the uneven thresholds.
      let idx = 0;
      for (let k = FEATURES.length - 1; k >= 0; k--) {
        if (p >= THRESHOLDS[k]) {idx = k;break;}
      }
      if (idx === lastIdxRef.current) return;
      const now = performance.now();
      if (now - lastChangeRef.current < 520) return;
      lastChangeRef.current = now;
      lastIdxRef.current = idx;
      setOpen(idx);
      if (history.replaceState) {
        history.replaceState(null, "", `#built-${idx + 1}`);
      }
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    window.addEventListener("resize", onScroll);
    return () => {
      window.removeEventListener("scroll", onScroll);
      window.removeEventListener("resize", onScroll);
    };
  }, [isMobile]);

  // Per-card progress (0..1 within that card's slice) — powers progress bars.
  const cardLocalProgress = (i) => {
    const start = THRESHOLDS[i];
    const end = i < FEATURES.length - 1 ? THRESHOLDS[i + 1] : 1;
    if (progress <= start) return 0;
    if (progress >= end) return 1;
    return (progress - start) / (end - start);
  };

  const onRowClick = (i) => {
    userClickedRef.current = true;
    lastIdxRef.current = i;
    lastChangeRef.current = performance.now();
    setOpen(i);
    if (history.replaceState) history.replaceState(null, "", `#built-${i + 1}`);
    const el = sectionRef.current;
    if (el && !isMobile) {
      const vh = window.innerHeight;
      const leadIn = vh * 0.1;
      const total = el.offsetHeight - vh - leadIn;
      // Use the same uneven thresholds so clicks match the scroll mapping.
      const sliceStart = THRESHOLDS[i];
      const sliceEnd = i < FEATURES.length - 1 ? THRESHOLDS[i + 1] : 1;
      const target = el.offsetTop + leadIn + total * ((sliceStart + sliceEnd) / 2);
      window.scrollTo({ top: target, behavior: "smooth" });
    }
    if (userClickTimerRef.current) clearTimeout(userClickTimerRef.current);
    userClickTimerRef.current = setTimeout(() => {userClickedRef.current = false;}, 1100);
  };

  /* ============== MOBILE: vertical stack of static cards — no scroll-cycle ============== */
  if (isMobile) {
    return (
      <section data-screen-label="04 Built different" id="built" style={{
        background: "var(--wf-navy-deep)",
        color: "var(--wf-text-warm)",
        position: "relative",
        overflow: "hidden",
        padding: "72px 0 96px"
      }}>
        <div className="wf-grid-bg" style={{ position: "absolute", inset: 0, opacity: 0.35, pointerEvents: "none" }} aria-hidden />
        <div className="wf-container" style={{ position: "relative" }}>
          <div style={{ textAlign: "center", marginBottom: 40, maxWidth: 560, margin: "0 auto 40px" }}>
            <p className="eyebrow">Built different</p>
            <h2 style={{ color: "var(--wf-text-warm)", margin: 0, lineHeight: 1.08, letterSpacing: "-0.03em", fontWeight: 500, fontSize: "clamp(28px, 7vw, 36px)" }}>
              AI made for all of HVAC <span style={{ color: "var(--wf-amber)", fontStyle: "italic" }}>is made for none.</span>
            </h2>
          </div>

          <div style={{ display: "flex", flexDirection: "column", gap: 32 }}>
            {FEATURES.map((f, i) => {
              const Mock = MOCKUPS[f.mockKey].Comp;
              return (
                <article key={f.title} id={`built-${i + 1}`} style={{
                  background: "linear-gradient(180deg, #0F1623 0%, #0B121C 100%)",
                  border: "1px solid rgba(255,255,255,0.06)",
                  borderRadius: 20,
                  padding: 24,
                  boxShadow: "0 12px 48px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03)"
                }}>
                  <div style={{
                    fontSize: 11, color: "#E8934A", fontWeight: 700, letterSpacing: "1.6px", textTransform: "uppercase",
                    fontFamily: "var(--font-display)", marginBottom: 12
                  }}>
                    Feature {String(i + 1).padStart(2, "0")}
                  </div>
                  <h3 style={{ fontSize: 22, fontWeight: 600, color: "#F5F3EE", margin: "0 0 12px", letterSpacing: "-0.015em", lineHeight: 1.25, fontFamily: "var(--font-display)" }}>
                    {f.title}
                  </h3>
                  <p style={{ fontSize: 14.5, color: "#9AAABB", lineHeight: 1.65, margin: "0 0 20px" }}>
                    {f.body}
                  </p>
                  <Mock />
                </article>);
            })}
          </div>
        </div>
      </section>);
  }

  /* ============== DESKTOP: scroll-locked stepper ============== */

  return (
    <section ref={sectionRef} data-screen-label="04 Built different" id="built" style={{
      background: "var(--wf-navy-deep)",
      color: "var(--wf-text-warm)",
      position: "relative",
      // Tall section gives us the scroll runway for the sticky stage inside
      // Section runway weighted by TOTAL_W so the last card needs less hold
      height: `${100 + 52 * TOTAL_W}vh`,
      padding: 0
    }}>
      <div className="wf-grid-bg" style={{ position: "absolute", inset: 0, opacity: 0.35, pointerEvents: "none" }} aria-hidden />
      <div className="wf-glow" style={{ position: "absolute", width: 700, height: 700, background: "rgba(232,147,74,0.05)", top: "-10%", left: "50%", transform: "translateX(-50%)", pointerEvents: "none" }} aria-hidden />

      {/* Sticky stage: stays locked in view as the user scrolls through the section */}
      <div style={{
        position: "sticky",
        top: 72,
        height: "calc(100vh - 72px)",
        display: "flex",
        flexDirection: "column",
        justifyContent: "flex-start",
        paddingTop: "4vh",
        paddingBottom: "0",
        marginTop: "0",
        marginBottom: "-80px",
        overflow: "hidden"
      }}>
        <div className="wf-container" style={{ position: "relative", width: "100%" }}>
          {/* Header */}
          <div style={{ textAlign: "center", marginBottom: 0, maxWidth: 760, margin: "0 auto 64px" }}>
            <p className="eyebrow" style={{ marginBottom: 2 }}>Built different</p>
            <h2 style={{ color: "var(--wf-text-warm)", margin: 0, lineHeight: 1.04, letterSpacing: "-0.03em", fontWeight: 500, fontSize: "44px" }}>
              AI made for all of HVAC <span style={{ color: "var(--wf-amber)", fontStyle: "italic" }}>is made for none.</span>
            </h2>
          </div>

          {/* Two-column: compact accordion + sticky mockup */}
          <div className="wf-built-grid" style={{
            display: "grid",
            gridTemplateColumns: "1fr 1fr",
            gap: 40,
            alignItems: "center"
          }}>
            {/* Left: compact accordion card */}
            <div style={{
              background: "linear-gradient(180deg, #0F1623 0%, #0B121C 100%)",
              border: "1px solid rgba(255,255,255,0.06)",
              borderRadius: 20,
              padding: "4px 28px",
              boxShadow: "0 12px 48px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03)"
            }}>
              {FEATURES.map((f, i) => {
                const isOpen = open === i;
                const isLast = i === FEATURES.length - 1;
                return (
                  <div
                    key={f.title}
                    style={{
                      borderBottom: isLast ? "none" : "1px solid rgba(255,255,255,0.06)",
                      position: "relative"
                    }}>
                    {/* Active progress bar across top of open row */}
                    {isOpen &&
                    <div style={{
                      position: "absolute", top: 0, left: 0, right: 0,
                      height: 2,
                      background: "rgba(232,147,74,0.12)",
                      overflow: "hidden"
                    }}>
                        <div style={{
                        width: `${cardLocalProgress(i) * 100}%`,
                        height: "100%",
                        background: "linear-gradient(90deg, var(--wf-amber), #F0A86A)",
                        transition: "width 0.08s linear"
                      }} />
                      </div>
                    }
                    <button
                      onClick={() => onRowClick(i)}
                      style={{
                        width: "100%",
                        display: "flex",
                        alignItems: "center",
                        justifyContent: "space-between",
                        textAlign: "left",
                        background: "transparent",
                        border: "none",
                        padding: "22px 0",
                        cursor: "pointer",
                        color: "inherit",
                        fontFamily: "var(--font-display)"
                      }}>
                      <span style={{
                        fontSize: 19,
                        fontWeight: 600,
                        color: isOpen ? "#F5F3EE" : "#c8c0b8",
                        letterSpacing: "-0.015em",
                        lineHeight: 1.35,
                        transition: "color 0.25s ease",
                        paddingRight: 16
                      }}>
                        {f.title}
                      </span>
                      <span style={{
                        width: 28, height: 28,
                        borderRadius: "50%",
                        border: `1px solid ${isOpen ? "var(--wf-amber)" : "rgba(255,255,255,0.18)"}`,
                        background: isOpen ? "var(--wf-amber)" : "transparent",
                        color: isOpen ? "var(--wf-navy-700)" : "#9AAABB",
                        display: "flex", alignItems: "center", justifyContent: "center",
                        flexShrink: 0,
                        transform: isOpen ? "rotate(45deg)" : "rotate(0deg)",
                        transition: "transform 0.3s ease, background 0.25s ease, border-color 0.25s ease, color 0.25s ease"
                      }}>
                        <svg width="12" height="12" viewBox="0 0 12 12" fill="none">
                          <line x1="6" y1="1.5" x2="6" y2="10.5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
                          <line x1="1.5" y1="6" x2="10.5" y2="6" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
                        </svg>
                      </span>
                    </button>
                    <div style={{
                      maxHeight: isOpen ? 220 : 0,
                      opacity: isOpen ? 1 : 0,
                      overflow: "hidden",
                      transition: "max-height 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.4s ease"
                    }}>
                      <p style={{
                        fontSize: 14.5,
                        color: "#9AAABB",
                        lineHeight: 1.65,
                        margin: "0 0 22px",
                        paddingRight: 32,
                        maxWidth: 520
                      }}>
                        {f.body}
                      </p>
                    </div>
                  </div>);
              })}
            </div>

            {/* Right: mockup card — cross-fades through states */}
            <div style={{
              background: "linear-gradient(180deg, #0F1623 0%, #0B121C 100%)",
              border: "1px solid rgba(255,255,255,0.06)",
              borderRadius: 20,
              padding: 16,
              boxShadow: "0 12px 48px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03)"
            }}>
              <div style={{ position: "relative", minHeight: 320 }}>
                {FEATURES.map((f, i) => {
                  const Mock = MOCKUPS[f.mockKey].Comp;
                  const isActive = open === i;
                  const isPrev = i < open;
                  return (
                    <div key={f.mockKey} style={{
                      position: i === 0 ? "relative" : "absolute",
                      top: 0, left: 0, right: 0,
                      opacity: isActive ? 1 : 0,
                      transform: isActive ?
                      "translateY(0) scale(1)" :
                      isPrev ?
                      "translateY(-16px) scale(0.98)" :
                      "translateY(16px) scale(0.98)",
                      transition: "opacity 0.6s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1)",
                      pointerEvents: isActive ? "auto" : "none",
                      filter: isActive ? "none" : "blur(2px)"
                    }}>
                      <Mock />
                    </div>);
                })}
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>);

};

/* ---------------- FEATURE DEEP DIVE — alternating layout ---------------- */
const FeatureDeepDive = () => {
  const FEATURES = [
  {
    eyebrow: "Always-on",
    title: <>Answers every lead within <span style={{ color: "var(--wf-amber)" }}>60 seconds.</span></>,
    body: "Calls and texts. Day, night, weekends, holidays. The system picks up, qualifies the lead, and books the right slot — without you noticing.",
    bullets: ["24/7 voice + SMS", "Triages by urgency", "Never sounds like a bot"],
    mockKey: "missed"
  },
  {
    eyebrow: "Self-healing schedule",
    title: <>Fills your cancellations <span style={{ color: "var(--wf-amber)" }}>from a waitlist.</span></>,
    body: "When a slot opens, the system fires through your waitlist in priority order. Most slots refill before you've heard about the cancellation.",
    bullets: ["Instant waitlist trigger", "Smart customer match", "Recovers $300–$500 per slot"],
    mockKey: "booking"
  },
  {
    eyebrow: "Owner-in-the-loop",
    title: <>Holds the <span style={{ color: "var(--wf-amber)" }}>high-stakes</span> calls for you.</>,
    body: "Quotes above your threshold, after-hours emergencies, anything unusual — held for your approval. One tap on your phone. Never goes off the rails.",
    bullets: ["Custom approval rules", "Mobile-first review", "Audit trail on every action"],
    mockKey: "approval"
  }];

  return (
    <section id="features" data-screen-label="06 Features" style={{ background: "var(--wf-warm-white)" }}>
      <div className="wf-container">
        <div className="wf-reveal" ref={useReveal()} style={{ textAlign: "center", marginBottom: 80, maxWidth: 720, margin: "0 auto 80px" }}>
          <p className="eyebrow">What the system does</p>
          <h2 style={{ fontSize: "clamp(36px, 5vw, 56px)", margin: 0, lineHeight: 1.04, letterSpacing: "-0.03em", fontWeight: "500" }}>
            Three jobs. Done <span style={{ color: "var(--wf-amber)", fontStyle: "italic" }}>relentlessly.</span>
          </h2>
        </div>
        <div style={{ display: "flex", flexDirection: "column", gap: 96 }}>
          {FEATURES.map((f, i) => {const Mock = MOCKUPS[f.mockKey].Comp;
            const reverse = i % 2 === 1;
            return (
              <div key={f.eyebrow} className="wf-reveal" ref={useReveal()} style={{
                display: "grid",
                gridTemplateColumns: "1fr 1fr",
                gap: 80,
                alignItems: "center",
                direction: reverse ? "rtl" : "ltr", margin: "50px 0px 0px", color: "rgb(65, 65, 65)"
              }}>
                <div style={{ direction: "ltr" }}>
                  <p className="eyebrow">{f.eyebrow}</p>
                  <h3 style={{ fontSize: "clamp(28px, 3.6vw, 42px)", margin: "0 0 20px", lineHeight: 1.1, letterSpacing: "-0.025em", maxWidth: 460 }}>{f.title}</h3>
                  <p style={{ fontSize: 16.5, color: "var(--wf-slate-400)", lineHeight: 1.7, margin: "0 0 28px", maxWidth: 460 }}>{f.body}</p>
                  <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 10 }}>
                    {f.bullets.map((b) =>
                    <li key={b} style={{ display: "flex", alignItems: "center", gap: 12, fontSize: 14.5, color: "var(--wf-navy-700)", fontFamily: "var(--font-display)", fontWeight: 500 }}>
                        <span style={{ width: 5, height: 5, borderRadius: "50%", background: "var(--wf-amber)", flexShrink: 0 }} />
                        {b}
                      </li>
                    )}
                  </ul>
                </div>
                <div style={{ direction: "ltr" }}><Mock /></div>
              </div>);

          })}
        </div>
      </div>
    </section>);

};

/* ---------------- MOCKUP GALLERY — tabbed switcher ---------------- */
const MockupGallery = () => {
  const [active, setActive] = useState("approval");
  const Mock = MOCKUPS[active].Comp;
  return (
    <section data-screen-label="07 Gallery" style={{ background: "var(--wf-navy-deep)", color: "var(--wf-text-warm)", position: "relative", overflow: "hidden" }}>
      <div className="wf-glow" style={{ width: 600, height: 600, background: "rgba(232,147,74,0.06)", top: "20%", left: "50%", transform: "translateX(-50%)" }} />
      <div className="wf-container" style={{ position: "relative" }}>
        <div className="wf-reveal" ref={useReveal()} style={{ textAlign: "center", marginBottom: 56, maxWidth: 720, margin: "0 auto 56px" }}>
          <p className="eyebrow">A look inside</p>
          <h2 style={{ fontSize: "clamp(32px, 4.5vw, 52px)", color: "var(--wf-text-warm)", margin: 0, lineHeight: 1.05, letterSpacing: "-0.03em", fontWeight: "500" }}>
            Five views. <span style={{ color: "var(--wf-amber)", fontStyle: "italic" }}>One system.</span>
          </h2>
          <p style={{ fontSize: 16, color: "var(--wf-slate-400)", marginTop: 18, maxWidth: 540, margin: "18px auto 0", lineHeight: 1.65 }}>You don't manage these screens. We do.
 They exist so you can see what the system is doing.
          </p>
        </div>

        <div style={{ display: "flex", gap: 6, justifyContent: "center", marginBottom: 36, flexWrap: "wrap" }}>
          {Object.entries(MOCKUPS).map(([k, v]) =>
          <button key={k} className={`wf-tab dark ${active === k ? "active" : ""}`} onClick={() => setActive(k)}>
              {v.label}
            </button>
          )}
        </div>

        <div style={{ maxWidth: 720, margin: "0 auto" }}>
          <div key={active} className="wf-rise"><Mock /></div>
          <p key={active + "-desc"} className="wf-rise" style={{ animationDelay: "0.1s", textAlign: "center", marginTop: 28, fontSize: 14.5, color: "var(--wf-slate-300)", maxWidth: 480, marginLeft: "auto", marginRight: "auto", lineHeight: 1.65 }}>
            {MOCKUPS[active].desc}
          </p>
        </div>
      </div>
    </section>);

};

/* ---------------- TESTIMONIALS — marquee cards (Podium-style) ---------------- */
const Testimonials = () => {
  const PREVIEWS = [
  { snippet: "Three weeks in and we'd already booked four jobs we would've missed entirely last quarter and never known it.", who: "Owner", where: "Cedar Rapids, IA", initials: "M.R." },
  { snippet: "The morning report is the best part. I know exactly what happened overnight without opening a thing.", who: "Owner", where: "Des Moines, IA", initials: "K.L." },
  { snippet: "Filled a same-day cancellation in four minutes. I wasn't even at my phone. That paid for the year.", who: "Ops Lead", where: "Quad Cities", initials: "J.A." }];

  return (
    <section id="results" data-screen-label="08 Results" style={{ background: "var(--wf-cream)", padding: "112px 0 96px", position: "relative", overflow: "hidden" }}>
      <div className="wf-container">
        <div className="wf-reveal" ref={useReveal()} style={{ maxWidth: 760, marginBottom: 48 }}>
          <p className="eyebrow">The results</p>
          <h2 style={{ fontSize: "clamp(34px, 5vw, 54px)", margin: 0, lineHeight: 1.05, letterSpacing: "-0.03em", maxWidth: 680, fontWeight: "500" }}>
            What contractors say once <span style={{ color: "var(--wf-amber)", fontStyle: "italic" }}>the phone stops ruling their day.</span>
          </h2>
          <p style={{ fontSize: 16, color: "var(--wf-slate-400)", marginTop: 20, lineHeight: 1.7, maxWidth: 580 }}>
            Our customers' numbers are their own — recovered jobs, after-hours bookings, hours handed back. We share the full stories, references, and the real figures directly with owners weighing it for their own shop.
          </p>
        </div>

        {/* Gated preview cards — blurred, "verified customer" chip, unlock on contact */}
        <div className="wf-reveal" ref={useReveal()} style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16, marginBottom: 48 }}>
          {PREVIEWS.map((p, i) =>
          <div key={i} style={{
            position: "relative",
            background: "#fff",
            border: "1px solid var(--wf-border-cream)",
            borderRadius: 14,
            padding: "26px 28px",
            boxShadow: "var(--wf-shadow-card)",
            overflow: "hidden",
            minHeight: 200,
            display: "flex", flexDirection: "column"
          }}>
            <div style={{ display: "inline-flex", alignItems: "center", gap: 7, alignSelf: "flex-start", background: "rgba(26,122,74,0.08)", border: "1px solid rgba(26,122,74,0.22)", borderRadius: 100, padding: "4px 11px", marginBottom: 16 }}>
              <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="#1A7A4A" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><polyline points="4 12 10 18 20 6" /></svg>
              <span style={{ fontSize: 10, color: "#1A7A4A", fontWeight: 700, letterSpacing: "0.08em", textTransform: "uppercase", fontFamily: "var(--font-display)" }}>Verified customer</span>
            </div>
            <p style={{ fontSize: 16, lineHeight: 1.55, margin: 0, color: "var(--wf-navy-700)", fontFamily: "var(--font-display)", fontWeight: 500, letterSpacing: "-0.01em" }}>
              "{p.snippet}"
            </p>
            <div style={{ display: "flex", alignItems: "center", gap: 12, marginTop: "auto", paddingTop: 18, borderTop: "1px solid var(--wf-border-cream)" }}>
              <div style={{ width: 36, height: 36, borderRadius: "50%", background: "var(--wf-amber)", color: "var(--wf-navy-700)", display: "flex", alignItems: "center", justifyContent: "center", fontSize: 12, fontWeight: 700, fontFamily: "var(--font-display)" }}>{p.initials}</div>
              <div>
                <div style={{ fontSize: 13, fontWeight: 600, color: "var(--wf-navy-700)", fontFamily: "var(--font-display)", filter: "blur(4.5px)", userSelect: "none" }}>{p.who} · Lindgren HVAC</div>
                <div style={{ fontSize: 11.5, color: "var(--wf-slate-400)", filter: "blur(4.5px)", userSelect: "none" }}>{p.where}</div>
              </div>
            </div>
          </div>
          )}
        </div>

        {/* Contact CTA */}
        <div className="wf-reveal" ref={useReveal()} style={{
          display: "flex", alignItems: "center", justifyContent: "space-between", gap: 32, flexWrap: "wrap",
          background: "var(--wf-navy-700)", borderRadius: 16, padding: "32px 40px"
        }}>
          <div>
            <h3 style={{ fontSize: 22, color: "var(--wf-text-warm)", margin: "0 0 6px", fontFamily: "var(--font-display)", fontWeight: 600, letterSpacing: "-0.01em" }}>
              See the full results and talk to a customer.
            </h3>
            <p style={{ fontSize: 14.5, color: "var(--wf-slate-300)", margin: 0, lineHeight: 1.6, maxWidth: 520 }}>
              We'll walk you through the real numbers and connect you with a shop running Workfloor so you can hear it firsthand.
            </p>
          </div>
          <a href="contact.html" className="wf-pill" style={{ flexShrink: 0, padding: "13px 28px", fontSize: 14.5 }}>
            Contact us →
          </a>
        </div>
      </div>
    </section>);

};

/* ---------------- FAQ ---------------- */
const FAQ = () => {
  const [open, setOpen] = useState(0);
  const Q = [
  { q: "Do I need to learn new software?", a: "No. We connect to your existing CRM — ServiceTitan, Jobber, HouseCall Pro, whatever you're already running. The system lives in the background. You get a morning report, an approval ping when something needs you, and that's it." },
  { q: "Will my customers know they're talking to AI?", a: "It doesn't sound like a bot, and it doesn't pretend to be a human either. It introduces itself as your after-hours line. Every interaction is logged and reviewable. We tune the voice and tone to match how you'd actually talk." },
  { q: "What if I want to take a call myself?", a: "You always can. The system hands off cleanly the moment you pick up. It also holds anything outside your approval thresholds — high-dollar quotes, unusual requests — so you decide the high-stakes stuff." },
  { q: "How much does it cost?", a: "Scoped on the discovery call. We don't publish pricing because we don't sell a package — every system is built to your operation. Most contractors recover the cost in the first 60 days from after-hours and waitlist alone." },
  { q: "How long does setup take?", a: "Within a month you will have leads being handled 24/7. The discovery call is week zero. Build and test happens in week one and two. You approve, then we flip it on. Most contractors see their first recovered lead in days." },
  { q: "What if it's not a fit?", a: "We'll tell you on the discovery call. If we can't find at least three concrete revenue gaps to fix, we'll say so. There's no obligation after the call." }];

  return (
    <section id="faq" data-screen-label="10 FAQ" style={{ background: "var(--wf-warm-white)" }}>
      <div className="wf-container" style={{ textAlign: "center" }}>
        <div className="wf-reveal" ref={useReveal()} style={{ display: "grid", gridTemplateColumns: "0.85fr 1.15fr", gap: 80, alignItems: "start" }}>
          <div style={{ position: "sticky", top: 100 }}>
            <p className="eyebrow">Common questions</p>
            <h2 style={{ fontSize: "clamp(32px, 4.4vw, 48px)", margin: 0, lineHeight: 1.05, letterSpacing: "-0.03em", fontWeight: "500" }}>
              Things <span style={{ color: "var(--wf-amber)", fontStyle: "italic", fontSize: "43px" }}>contractors ask</span> before signing.
            </h2>
            <p style={{ fontSize: 15, color: "var(--wf-slate-400)", marginTop: 24, lineHeight: 1.7 }}>
              Don't see yours? Email <a href="mailto:contact@getworkfloor.com" style={{ color: "var(--wf-amber)", textDecoration: "none", fontWeight: 600 }}>contact@getworkfloor.com</a> — usually a same-day reply.
            </p>
          </div>
          <div>
            {Q.map((item, i) =>
            <div key={i} className={`wf-faq-item ${open === i ? "open" : ""}`}>
                <button onClick={() => setOpen(open === i ? -1 : i)}>
                  <span>{item.q}</span>
                  <span className="plus">
                    <svg width={12} height={12} viewBox="0 0 12 12" fill="none">
                      <line x1="6" y1="1" x2="6" y2="11" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
                      <line x1="1" y1="6" x2="11" y2="6" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
                    </svg>
                  </span>
                </button>
                <div className="answer"><div className="answer-inner">{item.a}</div></div>
              </div>
            )}
          </div>
        </div>
      </div>
    </section>);

};

/* ---------------- BOOK CALL ---------------- */
const BookCallSection = () => {
  const [form, setForm] = useState({ business: "", name: "", email: "", phone: "", crm: "" });
  const [submitted, setSubmitted] = useState(false);
  const [errors, setErrors] = useState({});
  const inputStyle = { width: "100%", padding: "13px 16px", background: "#fff", border: "2px solid var(--wf-border-cream)", borderRadius: 8, fontSize: 14.5, color: "var(--wf-navy-700)", outline: "none", boxSizing: "border-box", fontFamily: "var(--font-body)", transition: "border-color 0.2s" };
  const labelStyle = { display: "block", fontSize: 13, fontWeight: 600, color: "var(--wf-navy-700)", marginBottom: 8, fontFamily: "var(--font-display)" };

  const handle = (e) => {e.preventDefault();
    const errs = {};
    ["business", "name", "email", "phone", "crm"].forEach((k) => {if (!form[k]) errs[k] = true;});
    if (form.email && !form.email.includes("@")) errs.email = true;
    setErrors(errs);
    if (Object.keys(errs).length === 0) setSubmitted(true);
  };

  const onChange = (k, v) => {setForm({ ...form, [k]: v });if (errors[k]) setErrors({ ...errors, [k]: false });};

  return (
    <section id="demo" data-screen-label="11 Book call" style={{ background: "var(--wf-cream)" }}>
      <div className="wf-container">
        <div className="wf-reveal" ref={useReveal()} style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 80, alignItems: "start" }}>
          <div style={{ paddingTop: 16 }}>
            <p className="eyebrow">Book a discovery call</p>
            <h2 style={{ fontSize: "clamp(32px, 4.4vw, 48px)", margin: 0, lineHeight: 1.05, letterSpacing: "-0.03em", fontWeight: "500" }}>
              30 minutes. <span style={{ color: "var(--wf-amber)", fontStyle: "italic" }}>Honest map</span> of your operation.
            </h2>
            <p style={{ fontSize: 16, color: "var(--wf-slate-400)", lineHeight: 1.7, marginTop: 24, marginBottom: 36, maxWidth: 460 }}>
              We'll map your operation, identify where AI makes the most sense, and walk you through exactly what we'd build. You'll leave with a clear picture — whether we work together or not.
            </p>
            <div style={{ display: "flex", flexDirection: "column", gap: 18 }}>
              {[
              { n: "1", t: "We review your business before the call." },
              { n: "2", t: "30-minute discovery — we map your operation." },
              { n: "3", t: "Proposal in your inbox within 24 hours." }].
              map((s) =>
              <div key={s.n} style={{ display: "flex", gap: 16, alignItems: "flex-start" }}>
                  <div style={{ width: 30, height: 30, borderRadius: "50%", background: "rgba(232,147,74,0.12)", border: "1px solid rgba(232,147,74,0.3)", color: "var(--wf-amber)", fontSize: 12, fontWeight: 700, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, fontFamily: "var(--font-display)" }}>{s.n}</div>
                  <span style={{ fontSize: 15, color: "var(--wf-navy-700)", lineHeight: 1.5, paddingTop: 5, fontFamily: "var(--font-display)", fontWeight: 500 }}>{s.t}</span>
                </div>
              )}
            </div>
            <div style={{ marginTop: 40, padding: "20px 24px", background: "#fff", border: "1px solid var(--wf-border-cream)", borderRadius: 12 }}>
              <div className="eyebrow" style={{ marginBottom: 8 }}>The Discovery Guarantee</div>
              <p style={{ fontSize: 13.5, color: "var(--wf-slate-400)", lineHeight: 1.65, margin: 0 }}>
                In 30 minutes, we'll map exactly where your business is losing revenue. If we can't find at least three concrete gaps, we'll say so. No obligation after the call.
              </p>
            </div>
          </div>

          {submitted ?
          <div style={{ background: "#fff", border: "1px solid var(--wf-border-cream)", borderRadius: 14, padding: 56, boxShadow: "var(--wf-shadow-form)", textAlign: "center" }}>
              <div style={{ width: 56, height: 56, borderRadius: "50%", background: "rgba(74,222,128,0.12)", border: "1px solid rgba(74,222,128,0.3)", margin: "0 auto 24px", display: "flex", alignItems: "center", justifyContent: "center" }}>
                <svg width={26} height={26} viewBox="0 0 24 24" fill="none" stroke="#1A7A4A" strokeWidth="2.5" strokeLinecap="round"><polyline points="4,12 10,18 20,6" /></svg>
              </div>
              <h3 style={{ fontSize: 24, fontWeight: 700, marginBottom: 12, letterSpacing: "-0.02em" }}>Got it. Talk soon.</h3>
              <p style={{ fontSize: 15, color: "var(--wf-slate-400)", lineHeight: 1.6, margin: 0 }}>We'll review your business and email back within 4 hours (weekdays) with two times that work.</p>
            </div> :

          <form onSubmit={handle} style={{ background: "#fff", border: "1px solid var(--wf-border-cream)", borderRadius: 14, padding: 36, boxShadow: "var(--wf-shadow-form)" }}>
              {[
            { k: "business", l: "Business name", ph: "Smith's HVAC", t: "text" },
            { k: "name", l: "Your name", ph: "John Smith", t: "text" }].
            map((f) =>
            <div key={f.k} style={{ marginBottom: 18 }}>
                  <label style={labelStyle}>{f.l} <span style={{ color: "var(--wf-red)" }}>*</span></label>
                  <input style={{ ...inputStyle, borderColor: errors[f.k] ? "var(--wf-red)" : "var(--wf-border-cream)" }} placeholder={f.ph} value={form[f.k]} onChange={(e) => onChange(f.k, e.target.value)} onFocus={(e) => e.target.style.borderColor = "var(--wf-amber)"} onBlur={(e) => e.target.style.borderColor = errors[f.k] ? "var(--wf-red)" : "var(--wf-border-cream)"} />
                </div>
            )}
              <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14, marginBottom: 18 }}>
                <div>
                  <label style={labelStyle}>Email <span style={{ color: "var(--wf-red)" }}>*</span></label>
                  <input style={{ ...inputStyle, borderColor: errors.email ? "var(--wf-red)" : "var(--wf-border-cream)" }} type="email" placeholder="john@example.com" value={form.email} onChange={(e) => onChange("email", e.target.value)} onFocus={(e) => e.target.style.borderColor = "var(--wf-amber)"} onBlur={(e) => e.target.style.borderColor = errors.email ? "var(--wf-red)" : "var(--wf-border-cream)"} />
                </div>
                <div>
                  <label style={labelStyle}>Phone <span style={{ color: "var(--wf-red)" }}>*</span></label>
                  <input style={{ ...inputStyle, borderColor: errors.phone ? "var(--wf-red)" : "var(--wf-border-cream)" }} type="tel" placeholder="(555) 123-4567" value={form.phone} onChange={(e) => onChange("phone", e.target.value)} onFocus={(e) => e.target.style.borderColor = "var(--wf-amber)"} onBlur={(e) => e.target.style.borderColor = errors.phone ? "var(--wf-red)" : "var(--wf-border-cream)"} />
                </div>
              </div>
              <div style={{ marginBottom: 28 }}>
                <label style={labelStyle}>Scheduling software <span style={{ color: "var(--wf-red)" }}>*</span></label>
                <p style={{ fontSize: 12, color: "var(--wf-slate-300)", margin: "0 0 8px" }}>So we can confirm how we'd connect before we talk.</p>
                <select style={{ ...inputStyle, borderColor: errors.crm ? "var(--wf-red)" : "var(--wf-border-cream)" }} value={form.crm} onChange={(e) => onChange("crm", e.target.value)}>
                  <option value="">Select…</option>
                  <option>ServiceTitan</option><option>Jobber</option><option>HouseCall Pro</option>
                  <option>FieldEdge</option><option>Other / not sure</option>
                </select>
              </div>
              <button type="submit" className="wf-pill" style={{ width: "100%", justifyContent: "center", padding: "15px 32px" }}>Book a discovery call →

            </button>
              <p style={{ fontSize: 11.5, color: "var(--wf-slate-300)", marginTop: 14, textAlign: "center" }}>We respond within 4 hours, weekdays.</p>
            </form>
          }
        </div>
      </div>
    </section>);

};

/* ---------------- CTA BANNER ---------------- */
const CTABanner = () =>
<section data-screen-label="12 CTA" style={{ background: "var(--wf-navy-darkest)", borderTop: "1px solid rgba(255,255,255,0.04)", borderBottom: "1px solid rgba(255,255,255,0.04)", padding: "112px 0", position: "relative", overflow: "hidden" }}>
    <div className="wf-glow" style={{ width: 800, height: 400, background: "rgba(232,147,74,0.04)", left: "50%", top: "50%", transform: "translate(-50%, -50%)" }} />
    <div className="wf-container" style={{ position: "relative", textAlign: "center", maxWidth: 820 }}>
      <h2 style={{ fontSize: "clamp(28px, 4vw, 44px)", lineHeight: 1.18, marginBottom: 36, letterSpacing: "-0.02em", margin: "0 0 36px", fontWeight: "700", color: "rgb(245, 243, 238)" }}>
        Other AI tools give you a dashboard. <span style={{ color: "var(--wf-amber)" }}>We give you your mornings back.</span>
      </h2>
      <a href="#demo" className="wf-pill ghost">Show me how →</a>
    </div>
  </section>;

/* ---------------- FOOTER ---------------- */
const Footer = () =>
<footer data-screen-label="13 Footer" style={{ background: "var(--wf-navy-darkest)" }}>
    <div className="wf-container" style={{ padding: "56px 0 32px" }}>
      <div style={{ display: "grid", gridTemplateColumns: "1.3fr 1fr 1fr 1fr", gap: 48, marginBottom: 56 }}>
        <div>
          <div style={{ display: "flex", alignItems: "center", gap: 10, marginBottom: 16 }}>
            <Mark size={20} />
            <span style={{ fontSize: 16, color: "var(--wf-text-warm)", fontWeight: 700, fontFamily: "var(--font-display)", letterSpacing: "-0.01em" }}>Workfloor</span>
          </div>
          <p style={{ fontSize: 13, color: "var(--wf-slate-400)", lineHeight: 1.7, maxWidth: 260, margin: 0 }}>
            AI operations for HVAC contractors.<br />Cedar Rapids, IA · Built for trade.<br />contact@getworkfloor.com
          </p>
        </div>
        {[
      { label: "Product", links: [{ l: "How it works", h: "#how" }, { l: "Results", h: "#results" }, { l: "FAQ", h: "#faq" }] },
      { label: "Company", links: [{ l: "About", h: "about.html" }, { l: "Discovery call", h: "#demo" }, { l: "Contact", h: "mailto:contact@getworkfloor.com" }] },
      { label: "Legal", links: [{ l: "Privacy", h: "privacy.html" }, { l: "Terms", h: "terms.html" }, { l: "Data handling", h: "data-handling.html" }] }].
      map((col) =>
      <div key={col.label}>
            <div style={{ fontSize: 11, color: "var(--wf-amber)", fontWeight: 700, letterSpacing: "0.16em", textTransform: "uppercase", marginBottom: 18, fontFamily: "var(--font-display)" }}>{col.label}</div>
            <div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
              {col.links.map((item) =>
          <a key={item.l} href={item.h} style={{ fontSize: 13, color: "var(--wf-slate-400)", textDecoration: "none", fontFamily: "var(--font-display)", fontWeight: 500, transition: "color 0.2s" }}
          onMouseEnter={(e) => e.target.style.color = "#F5F3EE"}
          onMouseLeave={(e) => e.target.style.color = "#6A7D8E"}>
                  {item.l}
                </a>
          )}
            </div>
          </div>
      )}
      </div>
      <div style={{ borderTop: "1px solid rgba(255,255,255,0.06)", paddingTop: 24, display: "flex", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 16 }}>
        <span style={{ fontSize: 12, color: "var(--wf-slate-700)" }}>© 2026 Workfloor. All rights reserved.</span>
        <span style={{ fontSize: 11, color: "var(--wf-slate-700)", fontFamily: "var(--font-mono)", letterSpacing: "0.05em" }}>getworkfloor.com</span>
      </div>
    </div>
  </footer>;


Object.assign(window, { Nav, Hero, LogoStrip, HowItWorks, BuiltDifferent, Stats, FeatureDeepDive, MockupGallery, Testimonials, FAQ, BookCallSection, CTABanner, Footer });