// Services — editorial chapters, layered information.
// Borrows the Home page's calm rhythm, not Work's cinematic acts.

const { useState, useEffect, useRef, useMemo } = React;

const TWEAK_DEFAULTS = window.__TWEAKS__ || {};

// ============================================================
// HERO — declarative type, with a slow-zooming editorial photo strip
// running underneath the headline. Adds life without competing.
// ============================================================
function ServicesHero({ onInquire }) {
  // Slow horizontal pan of an image strip behind/below the headline
  const stripRef = useRef(null);
  const [scrollY, setScrollY] = useState(0);
  useEffect(() => {
    let raf;
    const on = () => {
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => setScrollY(window.scrollY));
    };
    window.addEventListener("scroll", on, { passive: true });
    return () => { window.removeEventListener("scroll", on); cancelAnimationFrame(raf); };
  }, []);

  const stripImgs = [
    "assets/work-clear-6.jpg",
    "assets/work-satin-2.png",
    "assets/work-clear-3.jpg",
    "assets/work-satin-1.png",
    "assets/work-clear-1.jpg",
  ];

  return (
    <section style={{
      paddingTop: 180, paddingBottom: 0,
      background: "var(--bone)",
      position: "relative",
      overflow: "hidden",
    }}>
      <div className="container" style={{ position: "relative", zIndex: 2 }}>
        <LineEyebrow style={{ marginBottom: 32 }}>
          M&amp;T · Services
        </LineEyebrow>
        {/* Brand color ribbon — quietly states the palette */}
        <Reveal delay={200}>
          <div style={{ display: "flex", gap: 0, marginBottom: 56, height: 6, width: 220 }}>
            <span style={{ flex: 1, background: "var(--maroon)" }}/>
            <span style={{ flex: 1, background: "var(--bronze)" }}/>
            <span style={{ flex: 1, background: "var(--ink)" }}/>
            <span style={{ flex: 1, background: "var(--bone-2)" }}/>
          </div>
        </Reveal>
        <h1 className="serif" style={{
          fontSize: "clamp(48px, 7.8vw, 132px)",
          lineHeight: 0.96,
          letterSpacing: "-0.025em",
          maxWidth: 1280,
          marginBottom: 56,
          textWrap: "balance",
        }}>
          <WordReveal text="The work is simple to explain." />
          <br/>
          <span style={{ color: "var(--maroon)", fontStyle: "italic" }}>
            <WordReveal text="The result is hard to believe." delay={400} />
          </span>
        </h1>
        <Reveal delay={900}>
          <div style={{
            maxWidth: 1280,
            paddingTop: 32,
            paddingBottom: 64,
            borderTop: "1px solid var(--line)",
          }}>
            <p style={{ fontSize: 18, lineHeight: 1.6, color: "var(--ink-2)", maxWidth: 480 }}>
              We protect natural stone — marble, quartzite, granite, limestone — from the things that ruin it: stains, etches, scratches, heat. Once it's on, you can't see it. You also can't undo what it prevents.
            </p>
          </div>
        </Reveal>
      </div>

      {/* Editorial image strip — panning slowly with scroll */}
      <Reveal delay={1100}>
        <div ref={stripRef} style={{
          position: "relative",
          height: "clamp(280px, 38vw, 560px)",
          overflow: "hidden",
          borderTop: "1px solid var(--line)",
          borderBottom: "1px solid var(--line)",
          background: "var(--ink)",
        }}>
          <div style={{
            position: "absolute", inset: 0,
            display: "flex", gap: 24, padding: 24,
            transform: `translate3d(${-scrollY * 0.18}px, 0, 0)`,
            willChange: "transform",
            width: "max-content",
          }}>
            {stripImgs.map((src, i) => (
              <div key={i} style={{
                width: "clamp(380px, 32vw, 520px)",
                height: "100%",
                overflow: "hidden",
                flexShrink: 0,
              }}>
                <img src={src} alt="" style={{
                  width: "100%", height: "100%", objectFit: "cover",
                  filter: "brightness(0.96)",
                }}/>
              </div>
            ))}
          </div>
          {/* Soft edge masks */}
          <div style={{
            position: "absolute", top: 0, bottom: 0, left: 0, width: 120,
            background: "linear-gradient(90deg, var(--bone), transparent)",
            pointerEvents: "none", zIndex: 2,
          }}/>
          <div style={{
            position: "absolute", top: 0, bottom: 0, right: 0, width: 120,
            background: "linear-gradient(-90deg, var(--bone), transparent)",
            pointerEvents: "none", zIndex: 2,
          }}/>
          {/* Inset caption */}
          <div className="mono" style={{
            position: "absolute", bottom: 24, left: 48,
            fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase",
            color: "rgba(245,242,237,0.7)",
            zIndex: 3,
            display: "flex", alignItems: "center", gap: 12,
          }}>
            <span style={{ display: "inline-block", width: 24, height: 1, background: "currentColor" }}/>
            Selected work · NY · NJ · PA
          </div>
        </div>
      </Reveal>
    </section>
  );
}

// ============================================================
// CHAPTER I — THE CATALOG
// 4-row table of all services with status pills. Honest, complete.
// ============================================================
// Big animated chapter number — counts up as it scrolls into view, then
// holds. Used at the top of each section's intro.
function ChapterNumber({ n, total = 6 }) {
  const [ref, shown] = useReveal({ threshold: 0.3 });
  const [count, setCount] = useState(0);
  useEffect(() => {
    if (!shown) return;
    let raf, start;
    const target = n;
    const dur = 800;
    const step = (t) => {
      if (!start) start = t;
      const p = Math.min(1, (t - start) / dur);
      const e = 1 - Math.pow(1 - p, 3);
      setCount(Math.round(e * target));
      if (p < 1) raf = requestAnimationFrame(step);
    };
    raf = requestAnimationFrame(step);
    return () => cancelAnimationFrame(raf);
  }, [shown, n]);
  return (
    <div ref={ref} className="serif" style={{
      fontSize: "clamp(140px, 18vw, 280px)",
      lineHeight: 0.85, letterSpacing: "-0.04em",
      color: "var(--maroon)",
      fontStyle: "italic",
      opacity: shown ? 0.18 : 0,
      transition: "opacity 1.2s ease",
      fontVariantNumeric: "tabular-nums",
      userSelect: "none",
      pointerEvents: "none",
    }}>
      {String(count).padStart(2, "0")}
    </div>
  );
}

// ============================================================
// CHAPTER BAND — colored interlude between sections
// ============================================================
function ChapterBand({ kicker, line, accent = "var(--bronze)" }) {
  return (
    <section style={{
      background: "var(--maroon)",
      color: "var(--bone)",
      padding: "80px 0",
      position: "relative",
      overflow: "hidden",
    }}>
      <div aria-hidden="true" style={{
        position: "absolute", inset: 0,
        background: "radial-gradient(ellipse at 20% 50%, rgba(232,212,168,0.14), transparent 55%)",
        pointerEvents: "none",
      }}/>
      <div className="container" style={{ position: "relative" }}>
        <div style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 56, alignItems: "center" }} className="cb-grid">
          <div className="mono" style={{
            fontSize: 11, letterSpacing: "0.24em", textTransform: "uppercase",
            color: accent, whiteSpace: "nowrap",
            display: "inline-flex", alignItems: "center", gap: 14,
          }}>
            <span style={{ width: 28, height: 1, background: "currentColor", display: "inline-block" }}/>
            {kicker}
          </div>
          <p className="serif" style={{
            fontSize: "clamp(24px, 2.6vw, 38px)",
            lineHeight: 1.22, letterSpacing: "-0.015em",
            margin: 0,
            color: "var(--bone)",
            textWrap: "pretty",
          }}>
            {line}
          </p>
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){ .cb-grid{ grid-template-columns: 1fr !important; gap: 16px !important; } }
      `}</style>
    </section>
  );
}

// ============================================================
// CHAPTER I — THE CATALOG (editorial spread)
// Two flagship product cards as large media-led panels, side-by-side.
// "On the way" treated as a quieter annex underneath.
// ============================================================
function Catalog({ onInquire, showFuture = true }) {
  const flagships = [
    {
      no: "01",
      name: "Clear",
      product: "StoneGuard®",
      finish: "Polished · Glossy",
      tag: "For polished stone",
      desc: "A virtually invisible film for polished marble — stain-proof, etch-proof, heat-resistant. Marble looks identical, just stops getting ruined.",
      poster: "assets/work-clear-6.jpg",
      // Drop your install footage in here when ready — the <video> tag will use it
      // and gracefully fall back to the poster image until then.
      videoSrc: null,
      pull: "Matched to polished stone.",
      stats: [
        ["Stain",   "Proof"],
        ["Etch",    "Proof"],
        ["Heat",    "420°F"],
        ["Warranty","Lifetime"],
      ],
    },
    {
      no: "02",
      name: "Satin",
      product: "StoneGuard®",
      finish: "Honed · Matte",
      tag: "For honed stone",
      desc: "Engineered for honed stone. Protects the full surface, preserves the tactile softness, and adds depth that brings out the stone's natural color.",
      poster: "assets/work-satin-2.png",
      videoSrc: null,
      pull: "Matched to honed stone.",
      stats: [
        ["Stain",   "Proof"],
        ["Etch",    "Proof"],
        ["Heat",    "420°F"],
        ["Warranty","Lifetime"],
      ],
    },
  ];

  // Mirrors the mobile services page's "On the way" section — keep in sync.
  const upcoming = [
    {
      name: "Restoration Service",
      desc: "Full marble polishing and etch repair as a standalone service — for clients who don't yet want a film, but need their stone brought back.",
      status: "Q3 2026",
    },
  ];

  return (
    <section style={{ padding: "140px 0 120px", background: "var(--cream)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        {/* Section header — quieter, single column, lets the cards breathe */}
        <div style={{ position: "relative", marginBottom: 72 }}>
          <div style={{ position: "absolute", right: -20, top: -80, zIndex: 0 }} className="chapter-num-abs">
            <ChapterNumber n={1} />
          </div>
          <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-end", gap: 48, position: "relative", zIndex: 1, flexWrap: "wrap" }}>
            <div>
              <LineEyebrow style={{ marginBottom: 28 }}>I / The Catalog</LineEyebrow>
              <h2 className="serif" style={{ fontSize: "clamp(40px, 5vw, 76px)", lineHeight: 1.0, letterSpacing: "-0.022em", maxWidth: 880, marginBottom: 0 }}>
                Two services we offer today. <em style={{ color: "var(--maroon)" }}>One more on the way.</em>
              </h2>
            </div>
            <p style={{ fontSize: 15, lineHeight: 1.55, color: "var(--ink-2)", maxWidth: 320, fontStyle: "italic" }}>
              We only sell what we'd put in our own kitchens. If something isn't ready, we say so.
            </p>
          </div>
        </div>

        {/* Flagship pair */}
        <div style={{
          display: "grid", gridTemplateColumns: "1fr 1fr", gap: 28,
          marginBottom: 56,
        }} className="cat-pair">
          {flagships.map((f, i) => (
            <Reveal key={f.no} delay={i * 100}>
              <CatalogCard f={f} onInquire={onInquire} />
            </Reveal>
          ))}
        </div>

        {/* "On the way" — quiet annex */}
        {showFuture && (
          <Reveal delay={200}>
            <div style={{
              borderTop: "1px solid var(--line)",
              paddingTop: 36,
            }}>
              <div className="mono" style={{
                fontSize: 10, letterSpacing: "0.24em", textTransform: "uppercase",
                color: "var(--mute)", marginBottom: 28,
                display: "inline-flex", alignItems: "center", gap: 12,
              }}>
                <span style={{ display: "inline-block", width: 22, height: 1, background: "currentColor", opacity: 0.6 }}/>
                On the way
              </div>
              <div style={{ display: "grid", gap: 20 }} className="cat-upcoming">
                {upcoming.map((u) => (
                  <div key={u.name} style={{
                    border: "1px dashed var(--line)",
                    background: "var(--bone)",
                    padding: "28px 32px",
                    display: "flex", justifyContent: "space-between",
                    alignItems: "flex-start", gap: 28, flexWrap: "wrap",
                  }}>
                    <div>
                      <div className="mono" style={{
                        fontSize: 10, letterSpacing: "0.2em", textTransform: "uppercase",
                        color: "var(--mute)", marginBottom: 12,
                      }}>
                        Coming soon
                      </div>
                      <h4 className="serif" style={{ fontSize: 26, letterSpacing: "-0.015em", lineHeight: 1.15, marginBottom: 8 }}>
                        {u.name}
                      </h4>
                      <p style={{ fontSize: 14, lineHeight: 1.55, color: "var(--ink-2)", maxWidth: 560, marginBottom: 0 }}>
                        {u.desc}
                      </p>
                    </div>
                    <span className="mono" style={{
                      fontSize: 10, letterSpacing: "0.2em", textTransform: "uppercase",
                      padding: "5px 10px", whiteSpace: "nowrap",
                      background: "var(--bronze)", color: "var(--ink)",
                    }}>
                      {u.status}
                    </span>
                  </div>
                ))}
              </div>
            </div>
          </Reveal>
        )}
      </div>
      <style>{`
        @media (max-width: 980px){
          .cat-pair{ grid-template-columns: 1fr !important; }
          .chapter-num-abs{ display: none; }
        }
      `}</style>
    </section>
  );
}

// --- One flagship product card ---
function CatalogCard({ f, onInquire }) {
  const [hover, setHover] = useState(false);
  const videoRef = useRef(null);
  const hasVideo = !!f.videoSrc;

  // Auto-play / pause the install video on hover (when one is supplied).
  useEffect(() => {
    const v = videoRef.current;
    if (!v) return;
    if (hover) v.play?.().catch(() => {});
    else { v.pause?.(); v.currentTime = 0; }
  }, [hover]);

  return (
    <article
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{
        background: "var(--bone)",
        border: "1px solid var(--line)",
        display: "flex", flexDirection: "column",
        height: "100%",
        position: "relative",
        transform: hover ? "translateY(-4px)" : "translateY(0)",
        boxShadow: hover
          ? "0 30px 60px -25px rgba(20,16,12,0.22), 0 8px 18px -10px rgba(20,16,12,0.12)"
          : "0 1px 0 rgba(0,0,0,0)",
        transition: "transform 500ms cubic-bezier(.2,.7,.2,1), box-shadow 500ms cubic-bezier(.2,.7,.2,1)",
      }}
    >
      {/* Media — image now, drop-in slot for install video */}
      <div style={{
        position: "relative",
        aspectRatio: "5/4",
        overflow: "hidden",
        background: "var(--ink)",
      }}>
        <img src={f.poster} alt={`${f.product} ${f.name}`} style={{
          position: "absolute", inset: 0,
          width: "100%", height: "100%", objectFit: "cover", display: "block",
          transform: hover ? "scale(1.04)" : "scale(1)",
          filter: hover ? "brightness(0.92)" : "brightness(1)",
          transition: "transform 1200ms cubic-bezier(.2,.7,.2,1), filter 600ms ease",
        }}/>
        {hasVideo && (
          <video
            ref={videoRef}
            src={f.videoSrc}
            poster={f.poster}
            muted playsInline preload="metadata" loop
            style={{
              position: "absolute", inset: 0,
              width: "100%", height: "100%", objectFit: "cover",
              opacity: hover ? 1 : 0,
              transition: "opacity 380ms ease",
              pointerEvents: "none",
            }}
          />
        )}

        {/* Top-left chip: number + finish */}
        <div className="mono" style={{
          position: "absolute", top: 20, left: 20,
          fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase",
          color: "var(--bone)",
          padding: "8px 12px",
          background: "rgba(10,9,8,0.55)",
          backdropFilter: "blur(6px)",
          display: "inline-flex", alignItems: "center", gap: 10,
        }}>
          <span style={{ color: "var(--bronze)" }}>{f.no}</span>
          <span style={{ width: 1, height: 10, background: "rgba(245,242,237,0.4)" }}/>
          {f.finish}
        </div>

        {/* Bottom-left pull line — large serif over media */}
        <div className="serif" style={{
          position: "absolute", left: 24, bottom: 22, right: 24,
          fontSize: "clamp(20px, 1.9vw, 28px)",
          letterSpacing: "-0.015em",
          lineHeight: 1.1,
          color: "var(--bone)",
          textShadow: "0 2px 18px rgba(0,0,0,0.45)",
        }}>
          <em>"{f.pull}"</em>
        </div>

        {/* Watch-install affordance — only visible if videoSrc present */}
        {hasVideo && (
          <div className="mono" style={{
            position: "absolute", top: 20, right: 20,
            fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase",
            color: "var(--bone)",
            padding: "8px 12px",
            background: "rgba(10,9,8,0.55)",
            backdropFilter: "blur(6px)",
            display: "inline-flex", alignItems: "center", gap: 10,
            opacity: hover ? 0 : 1,
            transition: "opacity 220ms ease",
          }}>
            <span style={{ width: 6, height: 6, borderRadius: 99, background: "#E8D4A8" }}/>
            Hover · Install footage
          </div>
        )}
      </div>

      {/* Body */}
      <div style={{ padding: "36px 36px 36px", display: "flex", flexDirection: "column", flex: 1 }}>
        <div className="mono" style={{ fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--mute)", marginBottom: 12 }}>
          {f.tag}
        </div>
        <h3 className="serif" style={{
          fontSize: "clamp(34px, 3.2vw, 48px)",
          letterSpacing: "-0.022em", lineHeight: 1.0,
          marginBottom: 18,
        }}>
          {f.product} <em style={{ color: "var(--maroon)" }}>{f.name}</em>
        </h3>
        <p style={{ fontSize: 16, lineHeight: 1.6, color: "var(--ink-2)", marginBottom: 28, maxWidth: 480 }}>
          {f.desc}
        </p>

        {/* Stats strip */}
        <div style={{
          display: "grid", gridTemplateColumns: "repeat(4, 1fr)",
          borderTop: "1px solid var(--line)",
          borderBottom: "1px solid var(--line)",
          marginBottom: 28,
        }}>
          {f.stats.map(([k, v], j) => (
            <div key={j} style={{
              padding: "16px 0",
              borderRight: j < f.stats.length - 1 ? "1px solid var(--line)" : "none",
              textAlign: j === 0 ? "left" : "left",
              paddingLeft: j === 0 ? 0 : 14,
            }}>
              <div className="mono" style={{
                fontSize: 9, letterSpacing: "0.2em", textTransform: "uppercase",
                color: "var(--mute)", marginBottom: 6,
              }}>{k}</div>
              <div className="serif" style={{ fontSize: 18, letterSpacing: "-0.01em", color: "var(--ink)" }}>{v}</div>
            </div>
          ))}
        </div>

        {/* CTA row */}
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", gap: 20, marginTop: "auto" }}>
          <button
            onClick={onInquire}
            className="mono"
            style={{
              fontSize: 11, letterSpacing: "0.2em", textTransform: "uppercase",
              color: hover ? "var(--maroon)" : "var(--ink)",
              background: "transparent",
              border: 0,
              borderBottom: hover ? "1px solid var(--maroon)" : "1px solid var(--ink)",
              padding: "6px 0",
              cursor: "pointer",
              transition: "color 280ms ease, border-color 280ms ease",
            }}
          >
            Get a quote for {f.name} &nbsp;→
          </button>
          <a
            href={`#what-it-is`}
            className="mono"
            style={{
              fontSize: 10, letterSpacing: "0.2em", textTransform: "uppercase",
              color: "var(--mute)",
              textDecoration: "none",
            }}
          >
            Spec ↓
          </a>
        </div>
      </div>
    </article>
  );
}

// ============================================================
// CHAPTER II — THE COMPARISON
// Drag-slider revealing Clear vs Satin on real photography.
// ============================================================
function Comparison() {
  const [pos, setPos] = useState(50); // 0-100, slider position from left
  const ref = useRef(null);
  const draggingRef = useRef(false);

  const updateFromClientX = (clientX) => {
    const el = ref.current; if (!el) return;
    const r = el.getBoundingClientRect();
    const p = ((clientX - r.left) / r.width) * 100;
    setPos(Math.max(0, Math.min(100, p)));
  };

  const onPointerDown = (e) => {
    draggingRef.current = true;
    e.currentTarget.setPointerCapture?.(e.pointerId);
    updateFromClientX(e.clientX);
  };
  const onPointerMove = (e) => {
    if (!draggingRef.current) return;
    updateFromClientX(e.clientX);
  };
  const onPointerUp = (e) => {
    draggingRef.current = false;
    e.currentTarget.releasePointerCapture?.(e.pointerId);
  };

  return (
    <section style={{ padding: "140px 0 140px", background: "var(--bone)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        <div style={{ position: "relative", marginBottom: 64 }}>
          <div style={{ position: "absolute", left: -20, top: -80, zIndex: 0 }} className="chapter-num-abs">
            <ChapterNumber n={2} />
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 2fr", gap: 80, position: "relative", zIndex: 1 }} className="cmp-head">
            <LineEyebrow>II / Clear vs Satin</LineEyebrow>
            <div>
              <h2 className="serif" style={{ fontSize: "clamp(36px, 4.6vw, 64px)", lineHeight: 1.04, letterSpacing: "-0.02em", maxWidth: 760, marginBottom: 24 }}>
                The right finish is the one your stone <em style={{ color: "var(--maroon)" }}>already wears.</em>
              </h2>
              <p style={{ fontSize: 17, lineHeight: 1.6, color: "var(--ink-2)", maxWidth: 600 }}>
                Drag to see the difference. Clear preserves a polished, glossy surface. Satin matches honed and matte stone exactly. Same protection, same warranty, applied differently.
              </p>
            </div>
          </div>
        </div>

        <Reveal>
          <div
            ref={ref}
            onPointerDown={onPointerDown}
            onPointerMove={onPointerMove}
            onPointerUp={onPointerUp}
            onPointerCancel={onPointerUp}
            style={{
              position: "relative",
              width: "100%",
              aspectRatio: "16/9",
              overflow: "hidden",
              cursor: "ew-resize",
              userSelect: "none",
              touchAction: "none",
              background: "var(--ink)",
              boxShadow: "0 30px 60px -20px rgba(10,9,8,0.3)",
            }}
          >
            {/* Right side — Satin (full image, beneath) */}
            <img src="assets/work-satin-2.png" alt="Honed marble — Satin"
              draggable={false}
              style={{
                position: "absolute", inset: 0,
                width: "100%", height: "100%", objectFit: "cover",
                pointerEvents: "none",
              }}/>
            {/* Left side — Clear (clipped) */}
            <div style={{
              position: "absolute", inset: 0,
              clipPath: `polygon(0 0, ${pos}% 0, ${pos}% 100%, 0 100%)`,
              willChange: "clip-path",
            }}>
              <img src="assets/work-clear-6.jpg" alt="Polished marble — Clear"
                draggable={false}
                style={{
                  position: "absolute", inset: 0,
                  width: "100%", height: "100%", objectFit: "cover",
                  pointerEvents: "none",
                }}/>
            </div>

            {/* Labels */}
            <div className="mono" style={{
              position: "absolute", top: 24, left: 28,
              fontSize: 10, letterSpacing: "0.24em", textTransform: "uppercase",
              color: "var(--bone)",
              padding: "8px 14px",
              background: "rgba(10,9,8,0.6)",
              backdropFilter: "blur(6px)",
              opacity: pos > 8 ? 1 : 0,
              transition: "opacity .3s",
            }}>
              <span style={{ color: "var(--bronze)" }}>●</span> &nbsp;Clear · Polished
            </div>
            <div className="mono" style={{
              position: "absolute", top: 24, right: 28,
              fontSize: 10, letterSpacing: "0.24em", textTransform: "uppercase",
              color: "var(--bone)",
              padding: "8px 14px",
              background: "rgba(10,9,8,0.6)",
              backdropFilter: "blur(6px)",
              opacity: pos < 92 ? 1 : 0,
              transition: "opacity .3s",
            }}>
              Satin · Honed&nbsp; <span style={{ color: "var(--bronze)" }}>●</span>
            </div>

            {/* Divider line + handle */}
            <div style={{
              position: "absolute", top: 0, bottom: 0,
              left: `${pos}%`,
              width: 1,
              background: "var(--bone)",
              transform: "translateX(-0.5px)",
              pointerEvents: "none",
            }}/>
            <div style={{
              position: "absolute", top: "50%",
              left: `${pos}%`,
              transform: "translate(-50%, -50%)",
              width: 56, height: 56,
              borderRadius: 99,
              background: "var(--bone)",
              display: "grid", placeItems: "center",
              boxShadow: "0 10px 30px -8px rgba(10,9,8,0.4)",
              pointerEvents: "none",
              animation: "cmp-pulse 2.4s ease-in-out infinite",
            }}>
              <svg width="20" height="14" viewBox="0 0 20 14" fill="none">
                <path d="M6 1L1 7l5 6M14 1l5 6-5 6" stroke="var(--ink)" strokeWidth="1.4" fill="none"/>
              </svg>
            </div>
            <style>{`
              @keyframes cmp-pulse {
                0%, 100% { box-shadow: 0 10px 30px -8px rgba(10,9,8,0.4), 0 0 0 0 rgba(245,242,237,0.4); }
                50% { box-shadow: 0 10px 30px -8px rgba(10,9,8,0.4), 0 0 0 14px rgba(245,242,237,0); }
              }
            `}</style>
            {/* Hint label — fades on first interaction */}
            <div className="mono" style={{
              position: "absolute", left: "50%", bottom: 32,
              transform: "translateX(-50%)",
              fontSize: 10, letterSpacing: "0.24em", textTransform: "uppercase",
              color: "var(--bone)",
              padding: "8px 14px",
              background: "rgba(10,9,8,0.5)",
              backdropFilter: "blur(6px)",
              opacity: pos > 30 && pos < 70 ? 1 : 0,
              transition: "opacity .4s",
              pointerEvents: "none",
            }}>
              ← &nbsp; Drag to compare &nbsp; →
            </div>
          </div>
        </Reveal>

        {/* Spec rows beneath */}
        <div style={{
          display: "grid", gridTemplateColumns: "1fr 1fr",
          gap: 0,
          marginTop: 56,
          border: "1px solid var(--line)",
        }} className="cmp-specs">
          {[
            { label: "Best for",       a: "Polished stone",               b: "Matte stone" },
            { label: "Visibility",     a: "Effectively invisible",        b: "Matched to honed surface" },
            { label: "Stain resistance", a: "Yes",                         b: "Yes" },
            { label: "Etch resistance",  a: "Yes",                         b: "Yes" },
            { label: "Heat tolerance", a: "Up to 420°F",                  b: "Up to 420°F" },
            { label: "UV stability",   a: "Stable, non-yellowing",        b: "Stable, non-yellowing" },
            { label: "Warranty",       a: "Lifetime",                     b: "Lifetime" },
            { label: "Removable",      a: "Yes — no residue",             b: "Yes — no residue" },
            { label: "Install time",   a: "One day",                      b: "One day" },
          ].map((s, i) => (
            <React.Fragment key={i}>
              <div style={{
                padding: "20px 24px",
                borderRight: "1px solid var(--line)",
                borderBottom: i < 8 ? "1px solid var(--line)" : "none",
                fontSize: 14,
                display: "flex", alignItems: "baseline", gap: 16,
              }}>
                <span className="mono" style={{
                  fontSize: 10, letterSpacing: "0.18em", textTransform: "uppercase",
                  color: "var(--mute)", minWidth: 130, flexShrink: 0,
                }}>{s.label}</span>
                <span style={{ color: "var(--ink)" }}>{s.a}</span>
              </div>
              <div style={{
                padding: "20px 24px",
                borderBottom: i < 8 ? "1px solid var(--line)" : "none",
                fontSize: 14,
                color: "var(--ink)",
              }}>
                {s.b}
              </div>
            </React.Fragment>
          ))}
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){
          .cmp-head{ grid-template-columns: 1fr !important; gap: 32px !important; }
          .cmp-specs{ grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

// Editorial diagram: a stack showing stone → film → wear with scale.
function FilmDiagram() {
  const [ref, shown] = useReveal({ threshold: 0.3 });
  return (
    <div ref={ref} style={{
      marginBottom: 100,
      padding: "56px 48px",
      background: "var(--bone)",
      border: "1px solid var(--line)",
      display: "grid",
      gridTemplateColumns: "1.2fr 1fr",
      gap: 64, alignItems: "center",
    }} className="film-diag">
      <div>
        <div className="mono" style={{ fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--mute)", marginBottom: 32 }}>
          Cross‑section · Actual scale exaggerated 20×
        </div>
        {/* Layer structure mirrors the mobile FilmDiagramMobile — keep in sync. */}
        <svg viewBox="0 0 760 240" style={{ width: "100%", height: "auto", display: "block" }}>
          {[110, 260, 410].map((x, i) => (
            <g key={i} opacity={shown ? 0.7 : 0} style={{ transition: `opacity 800ms ease ${300 + i * 80}ms` }}>
              <line x1={x} y1="14" x2={x} y2="52" stroke="var(--maroon)" strokeWidth="1"/>
              <path d={`M ${x - 4} 48 L ${x} 54 L ${x + 4} 48`} fill="none" stroke="var(--maroon)" strokeWidth="1"/>
            </g>
          ))}
          <text x="260" y="34" textAnchor="middle" style={{ fontFamily: "'JetBrains Mono', monospace", fontSize: 10, letterSpacing: "0.18em", fill: "var(--mute)" }}>
            STAINS · ETCHES · SCRATCHES · HEAT
          </text>
          {/* Nano ceramic wear coat */}
          <rect x="40" y="64" width="520" height="8" fill="#fff" opacity={shown ? 0.9 : 0} style={{ transition: "opacity 900ms ease 400ms" }}/>
          {/* Film core */}
          <rect x="40" y="72" width="520" height="16" fill="#E8D4A8" opacity={shown ? 0.6 : 0} style={{ transition: "opacity 900ms ease 500ms" }}/>
          {/* Adhesive */}
          <rect x="40" y="88" width="520" height="8" fill="#C9A961" opacity={shown ? 0.45 : 0} style={{ transition: "opacity 900ms ease 600ms" }}/>
          {/* Stone slab */}
          <rect x="40" y="96" width="520" height="110"
            fill="var(--bone-2)" stroke="var(--ink)" strokeWidth="1"
            opacity={shown ? 1 : 0}
            style={{ transition: "opacity 900ms ease 100ms" }}/>
          <path d="M 60 124 Q 180 114 280 144 T 540 134" fill="none" stroke="var(--mute)" strokeWidth="0.6" opacity={shown ? 0.5 : 0} style={{ transition: "opacity 1200ms ease 700ms" }}/>
          <path d="M 60 164 Q 200 154 320 179 T 540 169" fill="none" stroke="var(--mute)" strokeWidth="0.6" opacity={shown ? 0.4 : 0} style={{ transition: "opacity 1200ms ease 900ms" }}/>
          <text x="300" y="160" textAnchor="middle" style={{ fontFamily: "'Instrument Serif', serif", fontSize: 15, fontStyle: "italic", fill: "var(--ink-2)", opacity: shown ? 1 : 0, transition: "opacity 1200ms ease 800ms" }}>
            your stone
          </text>
          {/* Layer callouts, right side */}
          <g opacity={shown ? 1 : 0} style={{ transition: "opacity 900ms ease 700ms" }}>
            <line x1="565" y1="68" x2="578" y2="68" stroke="var(--maroon)" strokeWidth="0.6"/>
            <text x="583" y="71" style={{ fontFamily: "'JetBrains Mono', monospace", fontSize: 9, letterSpacing: "0.1em", fill: "var(--maroon)" }}>NANO CERAMIC · 1 mil</text>
            <line x1="565" y1="80" x2="578" y2="80" stroke="var(--ink)" strokeWidth="0.6"/>
            <text x="583" y="83" style={{ fontFamily: "'JetBrains Mono', monospace", fontSize: 9, letterSpacing: "0.1em", fill: "var(--ink)" }}>FILM · 5 mil</text>
            <line x1="565" y1="92" x2="578" y2="92" stroke="var(--mute)" strokeWidth="0.6"/>
            <text x="583" y="95" style={{ fontFamily: "'JetBrains Mono', monospace", fontSize: 9, letterSpacing: "0.1em", fill: "var(--mute)" }}>ADHESIVE</text>
          </g>
        </svg>
      </div>
      <div>
        <h3 className="serif" style={{ fontSize: 32, letterSpacing: "-0.015em", lineHeight: 1.1, marginBottom: 20 }}>
          The film is the surface that takes the abuse.
        </h3>
        <p style={{ fontSize: 16, lineHeight: 1.65, color: "var(--ink-2)", maxWidth: 440, marginBottom: 32 }}>
          Roughly the thickness of a human hair: a nano ceramic wear coat over a 5 mil film, bonded with a breathable adhesive. Your countertop never sees the wine, the oil, the knife.
        </p>
        <div style={{ display: "flex", gap: 32, flexWrap: "wrap" }}>
          <div>
            <div className="serif" style={{ fontSize: 40, color: "var(--maroon)", lineHeight: 1 }}>5<span style={{ fontSize: 20 }}>mil</span></div>
            <div className="mono" style={{ fontSize: 10, letterSpacing: "0.18em", color: "var(--mute)", textTransform: "uppercase", marginTop: 8 }}>Film thickness</div>
          </div>
          <div>
            <div className="serif" style={{ fontSize: 40, color: "var(--maroon)", lineHeight: 1 }}>420<span style={{ fontSize: 20 }}>°F</span></div>
            <div className="mono" style={{ fontSize: 10, letterSpacing: "0.18em", color: "var(--mute)", textTransform: "uppercase", marginTop: 8 }}>Heat tolerance</div>
          </div>
          <div>
            <div className="serif" style={{ fontSize: 40, color: "var(--maroon)", lineHeight: 1 }}>UV<span style={{ fontSize: 20 }}>-stable</span></div>
            <div className="mono" style={{ fontSize: 10, letterSpacing: "0.18em", color: "var(--mute)", textTransform: "uppercase", marginTop: 8 }}>Non-yellowing</div>
          </div>
        </div>
        <a href="assets/stoneguard-patent-US9980567.pdf" target="_blank" rel="noopener" className="mono" style={{
          display: "inline-flex", alignItems: "center", gap: 10,
          marginTop: 32, paddingBottom: 3,
          fontSize: 10, letterSpacing: "0.2em", textTransform: "uppercase",
          color: "var(--ink)", borderBottom: "1px solid var(--line)",
        }}>
          Protected by U.S. Patent 9,980,567 · View the patent
          <svg width="11" height="11" viewBox="0 0 14 14" fill="none"><path d="M1 7h12m0 0L7 1m6 6L7 13" stroke="currentColor" strokeWidth="1.2"/></svg>
        </a>
      </div>
      <style>{`
        @media (max-width: 860px){ .film-diag{ grid-template-columns: 1fr !important; gap: 32px !important; padding: 32px !important; } }
      `}</style>
    </div>
  );
}

// ============================================================
// CHAPTER III — WHAT IT ACTUALLY IS
// Educational, layered. Default short. Expandable spec disclosures.
// ============================================================
function WhatItIs() {
  const facts = [
    {
      q: "What is StoneGuard?",
      a: "A precision-engineered protective film, hand-applied to your stone. Roughly the thickness of a human hair. It bonds to the surface and acts as the wear layer — taking the rings, the scratches, the etches, instead of your stone.",
      spec: [
        ["Material",           "Multi-layer urethane film"],
        ["Thickness",          "0.5 mil"],
        ["Bond type",          "Pressure-activated adhesive, residue-free removal"],
        ["Cure time",          "24 hours after install"],
      ],
    },
    {
      q: "What does it actually stop?",
      a: "Stains from wine, oil, coffee, citrus. Etches from acidic foods on marble. Scratches from cutting, sliding pans, dropped utensils. Heat up to 420°F. The film is the surface that takes the abuse — your stone never sees it.",
      spec: [
        ["Stains",             "Sealed top layer is non-porous"],
        ["Etches",             "Acid-resistant"],
        ["Scratches",          "Self-healing surface to a depth"],
        ["Heat",               "Tested to 420°F continuous"],
      ],
    },
    {
      q: "Will I see it?",
      a: "No. Clear is optically matched to polished stone — most clients can't find the edge after install. Satin is engineered to match honed and matte finishes exactly. We hand-trim every edge to disappear into the stone's existing seams.",
      spec: [
        ["Optical clarity",    "Clear, UV-stable, non-yellowing"],
        ["Surface match",      "Polished or honed"],
        ["Edge treatment",     "Hand-trimmed, no visible seam"],
      ],
    },
    {
      q: "Can it be removed?",
      a: "Yes, cleanly, by us. The adhesive is engineered for a residue-free release. Selling the home, renovating, changing your mind — the stone underneath is exactly as it was the day we installed.",
      spec: [
        ["Removal",            "Professional, residue-free"],
        ["Stone condition",    "Unchanged from pre-install"],
        ["Re-installation",    "Possible after cleaning"],
      ],
    },
  ];

  return (
    <section style={{ padding: "140px 0 140px", background: "var(--cream)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        <div style={{ position: "relative", marginBottom: 80 }}>
          <div style={{ position: "absolute", right: -20, top: -80, zIndex: 0 }} className="chapter-num-abs">
            <ChapterNumber n={3} />
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 2fr", gap: 80, position: "relative", zIndex: 1 }} className="wii-head">
            <LineEyebrow>III / What it actually is</LineEyebrow>
            <h2 className="serif" style={{ fontSize: "clamp(36px, 4.6vw, 64px)", lineHeight: 1.04, letterSpacing: "-0.02em", maxWidth: 800 }}>
              A film thinner than a human hair, doing the job of a coaster, a cutting board, and a trivet — <em style={{ color: "var(--maroon)" }}>permanently.</em>
            </h2>
          </div>
        </div>

        {/* Editorial "thin as a hair" diagram — simple, animated */}
        <Reveal>
          <FilmDiagram />
        </Reveal>

        <div>
          {facts.map((f, i) => <FactRow key={i} fact={f} index={i} />)}
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){ .wii-head{ grid-template-columns: 1fr !important; gap: 32px !important; } }
      `}</style>
    </section>
  );
}

function FactRow({ fact, index }) {
  const [open, setOpen] = useState(false);
  return (
    <Reveal delay={index * 60}>
      <div style={{ borderTop: "1px solid var(--line)", borderBottom: index === 3 ? "1px solid var(--line)" : "none" }}>
        <div style={{
          display: "grid", gridTemplateColumns: "80px 1fr 1fr 140px",
          gap: 32, alignItems: "start",
          padding: "36px 0",
        }} className="fact-row">
          <div className="mono" style={{ fontSize: 11, letterSpacing: "0.22em", color: "var(--mute)" }}>
            {String(index + 1).padStart(2, "0")}
          </div>
          <h3 className="serif" style={{ fontSize: 26, letterSpacing: "-0.015em", lineHeight: 1.15, maxWidth: 380 }}>
            {fact.q}
          </h3>
          <p style={{ fontSize: 16, lineHeight: 1.6, color: "var(--ink-2)", maxWidth: 560 }}>
            {fact.a}
          </p>
          <button onClick={() => setOpen(!open)} className="mono" style={{
            fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase",
            color: "var(--ink)", background: "transparent", border: 0,
            cursor: "pointer", justifySelf: "end",
            display: "inline-flex", alignItems: "center", gap: 8,
            padding: "8px 0",
          }}>
            {open ? "Hide spec" : "See the spec"}
            <span style={{
              display: "inline-block",
              transform: open ? "rotate(45deg)" : "rotate(0)",
              transition: "transform .3s ease",
            }}>+</span>
          </button>
        </div>
        <div style={{
          maxHeight: open ? 400 : 0,
          overflow: "hidden",
          transition: "max-height .5s cubic-bezier(.2,.7,.2,1)",
        }}>
          <div style={{
            padding: "0 0 36px 112px",
            display: "grid",
            gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))",
            gap: 24,
          }} className="fact-spec">
            {fact.spec.map(([k, v], j) => (
              <div key={j} style={{ borderLeft: "1px solid var(--maroon)", paddingLeft: 16 }}>
                <div className="mono" style={{
                  fontSize: 10, letterSpacing: "0.18em", textTransform: "uppercase",
                  color: "var(--mute)", marginBottom: 6,
                }}>{k}</div>
                <div style={{ fontSize: 14, color: "var(--ink)", lineHeight: 1.4 }}>{v}</div>
              </div>
            ))}
          </div>
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){
          .fact-row{ grid-template-columns: 1fr !important; gap: 12px !important; }
          .fact-spec{ padding-left: 0 !important; }
        }
      `}</style>
    </Reveal>
  );
}

// ============================================================
// CHAPTER IV — WHY US (no photos, type-driven)
// ============================================================
function WhyUs({ dark = true }) {
  const pillars = [
    {
      h: "We only do this.",
      p: "Surface protection is the entire business. Not a tile shop, not a fabricator, not a side service. Specialists, not generalists.",
    },
    {
      h: "Certified by the manufacturer.",
      p: "We're a Certified StoneGuard® installer. That's a relationship the brand only extends to teams whose work they'll stand behind.",
    },
    {
      h: "Lifetime warranty, in writing.",
      p: "If the film fails, we're back. No subcontractor lottery. No expiration date. The same two installers who applied it answer the call.",
    },
    {
      h: "Five stars, every review.",
      p: "Five-star average across Google and Houzz. Thousands of homes. Read them all if you'd like — they're on the home page.",
    },
  ];
  return (
    <section style={{ padding: "160px 0 160px", background: dark ? "var(--ink)" : "var(--bone)", color: dark ? "var(--bone)" : "var(--ink)" }}>
      <div className="container">
        <div style={{ marginBottom: 100 }}>
          <div className="mono" style={{
            fontSize: 11, letterSpacing: "0.24em", textTransform: "uppercase",
            color: dark ? "rgba(245,242,237,0.5)" : "var(--mute)", marginBottom: 32,
            display: "inline-flex", alignItems: "center", gap: 12,
          }}>
            <span style={{ display: "inline-block", width: 28, height: 1, background: "currentColor" }}/>
            IV / Why us
          </div>
          <h2 className="serif" style={{
            fontSize: "clamp(48px, 7vw, 112px)",
            lineHeight: 0.98, letterSpacing: "-0.025em",
            maxWidth: 1200,
          }}>
            There are other installers. <em style={{ color: "var(--bronze)" }}>This is what makes us different.</em>
          </h2>
        </div>

        <div style={{
          display: "grid", gridTemplateColumns: "repeat(2, 1fr)",
          gap: 0,
          borderTop: dark ? "1px solid rgba(245,242,237,0.18)" : "1px solid var(--line)",
        }} className="why-grid">
          {pillars.map((p, i) => (
            <Reveal key={i} delay={i * 80}>
              <div style={{
                padding: "48px 48px 56px 0",
                borderBottom: dark ? "1px solid rgba(245,242,237,0.18)" : "1px solid var(--line)",
                borderRight: i % 2 === 0 ? (dark ? "1px solid rgba(245,242,237,0.18)" : "1px solid var(--line)") : "none",
                paddingLeft: i % 2 === 1 ? 48 : 0,
                minHeight: 220,
              }} className="why-cell">
                <div className="mono" style={{
                  fontSize: 10, letterSpacing: "0.22em",
                  color: "var(--bronze)", marginBottom: 24,
                }}>0{i + 1}</div>
                <h3 className="serif" style={{ fontSize: 36, letterSpacing: "-0.02em", lineHeight: 1.1, marginBottom: 20 }}>
                  {p.h}
                </h3>
                <p style={{ fontSize: 16, lineHeight: 1.6, color: dark ? "rgba(245,242,237,0.75)" : "var(--ink-2)", maxWidth: 480 }}>
                  {p.p}
                </p>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){
          .why-grid{ grid-template-columns: 1fr !important; }
          .why-cell{ padding: 36px 0 !important; border-right: none !important; }
        }
      `}</style>
    </section>
  );
}

// ============================================================
// CHAPTER V — THE PROCESS
// 6 real steps, editorial, numbered. No animation gymnastics.
// ============================================================
function Process() {
  const steps = [
    {
      no: "01", t: "You find us.",
      d: "Most clients arrive through social, a referral, or a fabricator who's seen our work. You submit an inquiry form — it takes about a minute.",
      side: "DAY 0",
    },
    {
      no: "02", t: "We measure your stone.",
      d: "Either your fabricator already has the templates, or you measure your countertops yourself with a tape — we'll walk you through it. Photos help.",
      side: "DAY 1–2",
    },
    {
      no: "03", t: "You send the template.",
      d: "Hand-drawn on graph paper, a fabricator spec sheet, or photos with measurements. Whatever format works — we'll convert it on our end.",
      side: "DAY 2",
    },
    {
      no: "04", t: "We send the quote.",
      d: "An itemized quote based on the exact square footage, the finish, and the edge profile. Fixed price. No surprises later.",
      side: "DAY 3",
    },
    {
      no: "05", t: "We schedule and install.",
      d: "Two installers, one day, your kitchen. We template on-site, prep the surface, lay the film, hand-trim every edge, and cure it. You can use the counters that night.",
      side: "INSTALL DAY",
    },
    {
      no: "06", t: "You forget it's there.",
      d: "By the next morning, the film has fully cured and disappeared into the stone. You'll never think about coasters again. We'll check in at six months and a year.",
      side: "FOREVER",
    },
  ];

  return (
    <section style={{ padding: "140px 0 140px", background: "var(--cream)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        <div style={{ position: "relative", marginBottom: 100 }}>
          <div style={{ position: "absolute", left: -20, top: -80, zIndex: 0 }} className="chapter-num-abs">
            <ChapterNumber n={5} />
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 2fr", gap: 80, position: "relative", zIndex: 1 }} className="proc-head">
            <LineEyebrow>V / The Process</LineEyebrow>
            <div>
              <h2 className="serif" style={{ fontSize: "clamp(36px, 4.6vw, 64px)", lineHeight: 1.04, letterSpacing: "-0.02em", maxWidth: 800, marginBottom: 24 }}>
                Six steps from <em style={{ color: "var(--maroon)" }}>"I'm worried"</em> to <em style={{ color: "var(--maroon)" }}>"I forgot it was there."</em>
              </h2>
              <p style={{ fontSize: 17, lineHeight: 1.6, color: "var(--ink-2)", maxWidth: 600 }}>
                The whole arc usually takes a week. The install itself is a single day.
              </p>
            </div>
          </div>
        </div>

        <div style={{ position: "relative" }}>
          {/* Vertical line behind numbers */}
          <div style={{
            position: "absolute", left: 47, top: 0, bottom: 0,
            width: 1, background: "var(--line)",
          }} className="proc-line"/>

          {steps.map((s, i) => (
            <Reveal key={i} delay={i * 60}>
              <div style={{
                display: "grid",
                gridTemplateColumns: "96px 1fr 1.6fr 100px",
                gap: 32,
                padding: "44px 0",
                borderBottom: i < 5 ? "1px solid var(--line)" : "none",
                alignItems: "start",
                position: "relative",
              }} className="proc-row">
                <div style={{
                  width: 64, height: 64, borderRadius: 99,
                  background: "var(--maroon)",
                  border: "1px solid var(--maroon)",
                  boxShadow: "0 0 0 4px var(--bone), 0 0 0 5px rgba(107,20,22,0.18)",
                  display: "grid", placeItems: "center",
                  position: "relative", zIndex: 1,
                }}>
                  <span className="mono" style={{ fontSize: 13, letterSpacing: "0.1em", color: "var(--bronze)", fontWeight: 500 }}>
                    {s.no}
                  </span>
                </div>
                <h3 className="serif" style={{ fontSize: 28, letterSpacing: "-0.015em", lineHeight: 1.15, paddingTop: 16 }}>
                  {s.t}
                </h3>
                <p style={{ fontSize: 16, lineHeight: 1.65, color: "var(--ink-2)", paddingTop: 18, maxWidth: 560 }}>
                  {s.d}
                </p>
                <div className="mono" style={{
                  fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase",
                  color: "var(--maroon)", paddingTop: 22, justifySelf: "end",
                }}>
                  {s.side}
                </div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){
          .proc-head{ grid-template-columns: 1fr !important; gap: 32px !important; }
          .proc-row{ grid-template-columns: 64px 1fr !important; }
          .proc-row > p, .proc-row > .mono:last-child{ grid-column: 2 / 3; }
          .proc-line{ display: none; }
        }
      `}</style>
    </section>
  );
}

// ============================================================
// CHAPTER VI — FAQ (layered)
// ============================================================
function FAQ() {
  const items = [
    { q: "How long does it last?",
      a: "The film carries a lifetime warranty against failure. In normal use, we expect it to outlast the kitchen it's installed in. If anything ever does go wrong, we replace it." },
    { q: "Can I cut directly on it?",
      a: "We don't recommend it — it's protection, not a cutting board. The film resists scratches, but a sharp blade with pressure can still mark the surface. Use a board." },
    { q: "What about hot pots?",
      a: "Up to 420°F continuous. A pan straight off the burner is fine. A cast-iron pot pulled from the oven sitting overnight is not. Use a trivet for the extreme cases." },
    { q: "Will it yellow?",
      a: "No. The films we use are UV-stable and non-yellowing — that was a problem with earlier generations of surface films. The modern formulation we install holds its color." },
    { q: "Does it work on quartz, quartzite, granite?",
      a: "Yes. We've installed on every major countertop material — marble, quartzite, granite, limestone, soapstone, and engineered quartz. The product is the same; the prep changes slightly." },
    { q: "What if I'm renovating later?",
      a: "We remove it, no residue, no damage to the stone. Or you can leave it and let the next owner decide." },
    { q: "Do you do bathrooms? Tables? Backsplashes?",
      a: "Yes, yes, and yes. Anywhere there's natural stone or quartz that you'd like to keep looking new. Vanities, dining tables, coffee tables, shower curbs, fireplace surrounds — the same protection." },
  ];
  return (
    <section style={{ padding: "140px 0 140px", background: "var(--cream)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        <div style={{ position: "relative", marginBottom: 64 }}>
          <div style={{ position: "absolute", right: -20, top: -80, zIndex: 0 }} className="chapter-num-abs">
            <ChapterNumber n={6} />
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 2fr", gap: 80, position: "relative", zIndex: 1 }} className="faq-head">
            <LineEyebrow>VI / Common Questions</LineEyebrow>
            <h2 className="serif" style={{ fontSize: "clamp(36px, 4.6vw, 64px)", lineHeight: 1.04, letterSpacing: "-0.02em", maxWidth: 700 }}>
              The questions we hear most often.
            </h2>
          </div>
        </div>
        <div style={{ borderTop: "1px solid var(--line)" }}>
          {items.map((it, i) => <FAQRow key={i} item={it} index={i} last={i === items.length - 1} />)}
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){ .faq-head{ grid-template-columns: 1fr !important; gap: 32px !important; } }
      `}</style>
    </section>
  );
}

function FAQRow({ item, index, last }) {
  const [open, setOpen] = useState(false);
  return (
    <div style={{ borderBottom: "1px solid var(--line)" }}>
      <button onClick={() => setOpen(!open)} style={{
        width: "100%", textAlign: "left",
        display: "grid", gridTemplateColumns: "80px 1fr 40px",
        gap: 32, padding: "32px 0",
        background: "transparent", border: 0, cursor: "pointer",
        color: "var(--ink)",
      }} className="faq-row">
        <span className="mono" style={{ fontSize: 11, letterSpacing: "0.22em", color: "var(--mute)" }}>
          {String(index + 1).padStart(2, "0")}
        </span>
        <span className="serif" style={{ fontSize: 24, letterSpacing: "-0.015em", lineHeight: 1.2 }}>
          {item.q}
        </span>
        <span style={{
          fontSize: 24, lineHeight: 1, color: "var(--maroon)", justifySelf: "end",
          transform: open ? "rotate(45deg)" : "rotate(0)",
          transition: "transform .3s ease",
        }}>+</span>
      </button>
      <div style={{
        maxHeight: open ? 300 : 0,
        overflow: "hidden",
        transition: "max-height .5s cubic-bezier(.2,.7,.2,1)",
      }}>
        <div style={{
          padding: "0 0 32px 112px",
          fontSize: 16, lineHeight: 1.65, color: "var(--ink-2)",
          maxWidth: 720,
        }} className="faq-ans">
          {item.a}
        </div>
      </div>
      <style>{`
        @media (max-width: 860px){
          .faq-row{ grid-template-columns: 1fr 40px !important; gap: 16px !important; }
          .faq-row > .mono:first-child{ display: none; }
          .faq-ans{ padding-left: 0 !important; }
        }
      `}</style>
    </div>
  );
}

// ============================================================
// FINAL CTA — quiet, in-voice
// ============================================================
function FinalCTA({ onInquire }) {
  return (
    <section style={{
      padding: "180px 0 200px",
      background: "var(--maroon)",
      color: "var(--bone)",
      position: "relative",
      overflow: "hidden",
    }}>
      {/* soft grain / radial warmth */}
      <div aria-hidden="true" style={{
        position: "absolute", inset: 0,
        background: "radial-gradient(ellipse at 30% 0%, rgba(232,212,168,0.18), transparent 55%), radial-gradient(ellipse at 80% 100%, rgba(10,9,8,0.45), transparent 60%)",
        pointerEvents: "none",
      }}/>
      <div className="container" style={{ textAlign: "center", position: "relative" }}>
        <Reveal>
          <div className="mono" style={{
            fontSize: 11, letterSpacing: "0.24em", textTransform: "uppercase",
            color: "var(--bronze)", marginBottom: 40,
            display: "inline-flex", alignItems: "center", gap: 14,
          }}>
            <span style={{ display: "inline-block", width: 28, height: 1, background: "currentColor", opacity: 0.7 }}/>
            Ready when you are
            <span style={{ display: "inline-block", width: 28, height: 1, background: "currentColor", opacity: 0.7 }}/>
          </div>
          <h2 className="serif" style={{
            fontSize: "clamp(48px, 7.4vw, 124px)",
            lineHeight: 0.98, letterSpacing: "-0.025em",
            maxWidth: 1300, margin: "0 auto 48px",
            textWrap: "balance",
            color: "var(--bone)",
          }}>
            Stone is beautiful. <em style={{ color: "var(--bronze)" }}>Let's keep it that way.</em>
          </h2>
          <p style={{
            fontSize: 18, lineHeight: 1.55, color: "rgba(245,242,237,0.78)",
            maxWidth: 560, margin: "0 auto 56px",
          }}>
            Tell us about your stone and we'll send back a custom protection plan and quote. All free within the next 24 hours.
          </p>
          <div style={{ display: "inline-flex", gap: 16, flexWrap: "wrap", justifyContent: "center" }}>
            <button onClick={onInquire} className="btn" style={{
              background: "var(--bronze)",
              color: "var(--ink)",
            }}
              onMouseEnter={(e) => { e.currentTarget.style.background = "var(--bone)"; }}
              onMouseLeave={(e) => { e.currentTarget.style.background = "var(--bronze)"; }}
            >
              Get My Stone Protected
              <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
                <path d="M1 7h12m0 0L7 1m6 6L7 13" stroke="currentColor" strokeWidth="1.3"/>
              </svg>
            </button>
            <a href="work.html" className="btn" style={{
              border: "1px solid rgba(245,242,237,0.4)",
              color: "var(--bone)",
              background: "transparent",
            }}
              onMouseEnter={(e) => { e.currentTarget.style.borderColor = "var(--bone)"; }}
              onMouseLeave={(e) => { e.currentTarget.style.borderColor = "rgba(245,242,237,0.4)"; }}
            >See the work</a>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

// ============================================================
// FOOTER (minimal)
// ============================================================
function Footer() {
  return (
    <footer style={{ padding: "60px 0 60px", borderTop: "1px solid var(--line)", background: "var(--bone)" }}>
      <div className="container" style={{
        display: "flex", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 24,
      }}>
        <div className="serif" style={{ fontSize: 18, letterSpacing: "-0.01em" }}>
          M<span style={{ fontSize: 13, verticalAlign: "super", margin: "0 2px" }}>&amp;</span>T Surface Protectors
        </div>
        <div className="mono" style={{ fontSize: 11, letterSpacing: "0.18em", textTransform: "uppercase", color: "var(--mute)" }}>
          © 2026 · NY · NJ · PA
        </div>
      </div>
    </footer>
  );
}

// ============================================================
// PAGE
// ============================================================
function ServicesPage() {
  const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);
  const onInquire = () => {
    window.location.href = "index.html#inquire";
  };
  return (
    <>
      <style>{`
        :root { --accent: ${t.heroAccent === "bronze" ? "#9C7A3F" : t.heroAccent === "ink" ? "#141412" : "#6B1416"}; }
      `}</style>
      <Nav onInquire={onInquire} />
      <main>
        <ServicesHero onInquire={onInquire} />
        <Catalog onInquire={onInquire} showFuture={t.showFuture} />
        <ChapterBand
          kicker="A note on finish"
          line={<><em>"The right product matched to the right stone."</em>&nbsp; The line that decides whether the protection feels invisible — or invisible-but-wrong.</>}
        />
        <Comparison />
        <WhatItIs />
        <ChapterBand
          kicker="Our standard"
          line={<>Surface protection is the entire business — <em style={{ color: "var(--bronze)" }}>not a side service.</em> What that buys you, in writing, on the next screen.</>}
          accent="var(--bronze)"
        />
        <WhyUs dark={t.darkWhyUs} />
        <Process />
        <FAQ />
      </main>
      <Footer />
      <TweaksPanel title="Tweaks">
        <TweakSection label="Hero" />
        <TweakRadio label="Accent color" value={t.heroAccent}
          options={["maroon", "bronze", "ink"]}
          onChange={(v) => setTweak("heroAccent", v)} />
        <TweakSection label="Catalog" />
        <TweakToggle label="Show future services" value={t.showFuture}
          onChange={(v) => setTweak("showFuture", v)} />
        <TweakSection label="Why Us" />
        <TweakToggle label="Dark background" value={t.darkWhyUs}
          onChange={(v) => setTweak("darkWhyUs", v)} />
      </TweaksPanel>
    </>
  );
}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<ServicesPage />);
