// ChaiShai marketing site — uses real app screenshots inside iPhone frames.

const { useState, useEffect, useRef } = React;

/* ============================================================
   useMobile — single source of truth for breakpoint behavior
   ============================================================ */
function useMobile(breakpoint = 820) {
  const [isMobile, setIsMobile] = useState(() =>
    typeof window !== "undefined" && window.matchMedia(`(max-width: ${breakpoint}px)`).matches
  );
  useEffect(() => {
    const mq = window.matchMedia(`(max-width: ${breakpoint}px)`);
    const onChange = e => setIsMobile(e.matches);
    setIsMobile(mq.matches);
    if (mq.addEventListener) mq.addEventListener("change", onChange);
    else mq.addListener(onChange);
    return () => {
      if (mq.removeEventListener) mq.removeEventListener("change", onChange);
      else mq.removeListener(onChange);
    };
  }, [breakpoint]);
  return isMobile;
}

/* ============================================================
   IPHONE SHELL — displays a real screenshot
   ============================================================ */
function IPhoneShell({ src, alt = "", scale = 1, className = "", showIsland = true }) {
  // base 360x780
  const W = 360, H = 780;
  return (
    <div className={`relative ${className}`} style={{ width: W * scale, height: H * scale }}>
      <div style={{
        position: "absolute", inset: 0,
        transform: `scale(${scale})`, transformOrigin: "top left",
        width: W, height: H,
      }}>
        {/* outer bezel */}
        <div style={{
          position: "absolute", inset: 0,
          borderRadius: 56,
          background: "linear-gradient(160deg, #2a2320 0%, #14100e 60%, #1c1714 100%)",
          padding: 5,
          boxShadow:
            "0 60px 90px -36px rgba(20,12,8,.50), 0 0 0 1px rgba(255,255,255,.04) inset, 0 1px 0 rgba(255,255,255,.06) inset",
        }}>
          {/* rim highlight */}
          <div style={{
            position: "absolute", inset: 1, borderRadius: 54,
            background: "linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,0) 12%, rgba(255,255,255,0) 88%, rgba(255,255,255,.04) 100%)",
            pointerEvents: "none",
          }} />
          {/* screen */}
          <div style={{
            position: "relative", height: "100%",
            borderRadius: 50, overflow: "hidden",
            background: "#1F1730",
          }}>
            {src ? (
              <img src={src} alt={alt} draggable={false} style={{
                position: "absolute", inset: 0,
                width: "100%", height: "100%",
                objectFit: "cover", objectPosition: "top center",
                userSelect: "none",
              }}/>
            ) : null}
            {/* dynamic island floating overlay */}
            {showIsland && (
              <div style={{
                position: "absolute", top: 11, left: "50%",
                transform: "translateX(-50%)",
                width: 116, height: 34,
                background: "#0a0a0a", borderRadius: 999,
                zIndex: 30,
                boxShadow: "0 0 0 2px rgba(0,0,0,.0)",
              }}/>
            )}
          </div>
        </div>
      </div>
    </div>
  );
}

/* ============================================================
   ICONS
   ============================================================ */
function ChaiCupIcon({ size = 16, color = "currentColor" }) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M5 10h11v6a3 3 0 0 1-3 3H8a3 3 0 0 1-3-3v-6z"/>
      <path d="M16 11h2a2 2 0 0 1 0 4h-2"/>
      <path d="M8 6c0-1 1-1 1-2s-1-1-1-2"/>
      <path d="M11 6c0-1 1-1 1-2s-1-1-1-2"/>
    </svg>
  );
}
function AppleGlyph({ size = 16, color = "currentColor" }) {
  return (
    <svg width={size * 0.88} height={size} viewBox="0 0 24 24" fill={color}>
      <path d="M17.5 12.5c0-2.7 2.2-4 2.3-4-1.2-1.8-3.2-2-3.9-2-1.6-.2-3.2.9-4 .9s-2.1-.9-3.5-.9c-1.8 0-3.5 1-4.4 2.7-1.9 3.3-.5 8.2 1.4 10.9.9 1.3 2 2.8 3.4 2.7 1.4-.1 1.9-.9 3.5-.9s2.1.9 3.5.9c1.4 0 2.4-1.3 3.3-2.7.7-1 1.2-2.1 1.6-3.2-2.6-1-3.2-3.6-3.2-4.4zM14.6 4.6c.8-.9 1.3-2.2 1.1-3.5-1.1.1-2.4.8-3.2 1.7-.7.8-1.4 2.1-1.2 3.4 1.2 0 2.5-.7 3.3-1.6z"/>
    </svg>
  );
}

/* ============================================================
   REVEAL ON SCROLL
   ============================================================ */
function Reveal({ children, className = "", stagger = false, as: As = "div", ...rest }) {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach(e => {
        if (e.isIntersecting) { el.classList.add("in"); io.unobserve(el); }
      });
    }, { threshold: 0.15, rootMargin: "0px 0px -8% 0px" });
    io.observe(el);
    return () => io.disconnect();
  }, []);
  return <As ref={ref} className={`${stagger ? "reveal-stagger" : "reveal"} ${className}`} {...rest}>{children}</As>;
}

/* ============================================================
   NAV
   ============================================================ */
function Nav() {
  const isMobile = useMobile();
  return (
    <header className="nav-blur fixed top-0 left-0 right-0 z-50">
      <div className="mx-auto" style={{ maxWidth: 1100, padding: isMobile ? "0 18px" : "0 28px", height: 48, display: "flex", alignItems: "center", justifyContent: "space-between" }}>
        <a href="#" style={{ display: "flex", alignItems: "center", gap: 9 }}>
          <span style={{ fontSize: 17, fontWeight: 700, letterSpacing: -0.02, color: "var(--color-ink)" }}>Chai Shai</span>
        </a>
        <nav style={{ display: "flex", gap: isMobile ? 16 : 28, fontSize: isMobile ? 12.5 : 13.5, color: "color-mix(in srgb, var(--color-ink) 70%, transparent)" }}>
          {[
            { t: "The app",       href: "#top" },
            { t: "How it works",  href: "#features" },
            { t: "Pricing",       href: "#pricing" },
            { t: "Support",       href: "mailto:support@chaishaiapp.com" },
          ].map(({ t, href }) => (
            <a key={t} href={href}
              style={{ transition: "color .2s", whiteSpace: "nowrap" }}
              onMouseEnter={e=>e.currentTarget.style.color="var(--color-ink)"}
              onMouseLeave={e=>e.currentTarget.style.color="color-mix(in srgb, var(--color-ink) 70%, transparent)"}
            >{t}</a>
          ))}
        </nav>
        <span/>
      </div>
    </header>
  );
}

function BrandMark({ size = 24 }) {
  // gradient pink→coral circle with cup
  return (
    <div style={{
      width: size, height: size, borderRadius: 999,
      background: "linear-gradient(135deg, var(--color-pink) 0%, var(--color-coral) 100%)",
      display: "grid", placeItems: "center",
      boxShadow: "0 4px 10px -2px rgba(233,69,96,.4)",
    }}>
      <ChaiCupIcon size={size * 0.6} color="white"/>
    </div>
  );
}

/* ============================================================
   HERO
   ============================================================ */
function Hero() {
  const isMobile = useMobile();
  return (
    <section style={{ position: "relative", paddingTop: isMobile ? 92 : 116, paddingBottom: 24, overflow: "hidden" }}>
      <div aria-hidden style={{
        position: "absolute", inset: 0, pointerEvents: "none",
        background:
          "radial-gradient(ellipse 70% 50% at 50% -10%, rgba(233,69,96,.14), transparent 60%), " +
          "radial-gradient(ellipse 40% 30% at 90% 10%, rgba(245,138,109,.10), transparent 70%)",
      }}/>

      <div className="mx-auto" style={{ maxWidth: 1100, padding: isMobile ? "0 22px" : "0 28px", position: "relative" }}>
        <Reveal>
          <h1 className="display-lg" style={{
            textAlign: "center",
            fontSize: "clamp(48px, 7.6vw, 108px)",
            marginTop: 14,
            color: "var(--color-ink)",
          }}>
            Your story starts<br/>
            <span className="grad-text">over a cup of chai.</span>
          </h1>
        </Reveal>
        <Reveal>
          <p className="body-prose" style={{ maxWidth: 660, margin: "22px auto 0", textAlign: "center" }}>
            Swipe less. Sit across from more. A match score, the days they’re free, and one tap to say <b>Let’s Chai</b>—the rest happens at a real table.
          </p>
        </Reveal>
        <Reveal>
          <div style={{ display: "flex", flexWrap: "wrap", justifyContent: "center", alignItems: "center", gap: 22, marginTop: 32 }}>
            <span className="btn-primary" aria-disabled="true" style={{ cursor: "default", opacity: 0.85 }}>
              <span style={{ marginRight: 8, display: "inline-flex" }}><AppleGlyph size={16} color="currentColor"/></span>
              Launching Soon
            </span>
            <a href="#features" className="btn-ghost">See how it works <span className="arr">›</span></a>
          </div>
        </Reveal>

      </div>
    </section>
  );
}

function Heart() {
  return (
    <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 21s-7-4.6-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 11c0 5.4-7 10-7 10z"/></svg>
  );
}

function FloatingChip({ children, side = "left", top = "30%", delay = 0 }) {
  const ref = useRef(null);
  useEffect(() => {
    const t = setTimeout(() => ref.current?.classList.add("in"), delay);
    return () => clearTimeout(t);
  }, [delay]);
  const horizontal = side === "left" ? { left: "calc(50% - 280px)" } : { right: "calc(50% - 280px)" };
  return (
    <div ref={ref} className="float-chip" style={{
      position: "absolute", top, ...horizontal,
      padding: "9px 14px",
      borderRadius: 999,
      background: "rgba(255,255,255,.85)",
      backdropFilter: "saturate(180%) blur(14px)",
      WebkitBackdropFilter: "saturate(180%) blur(14px)",
      border: "1px solid rgba(20,12,8,.06)",
      boxShadow: "0 12px 28px -10px rgba(20,12,8,.18)",
      fontSize: 12.5, fontWeight: 500, letterSpacing: -0.005,
      color: "var(--color-ink)",
      display: "flex", alignItems: "center",
      whiteSpace: "nowrap",
      transform: side === "left" ? "translateX(-12px)" : "translateX(12px)",
      opacity: 0,
      transition: "opacity .9s cubic-bezier(.16,.84,.3,1), transform .9s cubic-bezier(.16,.84,.3,1)",
    }}>
      {children}
      <style>{`.float-chip.in { opacity: 1 !important; transform: translateX(0) !important; }`}</style>
    </div>
  );
}

/* ============================================================
   HIGHLIGHTS
   ============================================================ */
function Highlights() {
  const items = [
    { kicker: "01", stat: "Meet, don’t just match.", label: "A path to chai, not another lost thread." },
    { kicker: "02", stat: "Resonant introductions.", label: "Profiles shaped by values and how you love." },
    { kicker: "03", stat: "Room to be yourself.", label: "Privacy and respect built into every step." },
  ];
  return (
    <section style={{ padding: "80px 0", borderTop: "1px solid var(--color-hairline)", borderBottom: "1px solid var(--color-hairline)" }}>
      <div className="mx-auto" style={{ maxWidth: 1100, padding: "0 28px" }}>
        <Reveal stagger as="div" style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 40 }}>
          {items.map((h) => (
            <div key={h.kicker} style={{ padding: "8px 0 8px 22px", borderLeft: "1px solid var(--color-hairline)" }}>
              <div className="num-tabular" style={{ fontSize: 12, fontWeight: 600, color: "var(--color-pink)", letterSpacing: 0.5 }}>{h.kicker}</div>
              <div className="display" style={{ fontSize: 28, marginTop: 12, color: "var(--color-ink)", letterSpacing: -0.02 }}>{h.stat}</div>
              <p style={{ marginTop: 10, fontSize: 15, lineHeight: 1.5, color: "color-mix(in srgb, var(--color-ink) 65%, transparent)" }}>{h.label}</p>
            </div>
          ))}
        </Reveal>
      </div>
    </section>
  );
}

/* ============================================================
   PINNED SCROLL SHOWCASE
   ============================================================ */
function PinnedShowcase() {
  const sectionRef = useRef(null);
  const [activeIdx, setActiveIdx] = useState(0);
  const isMobile = useMobile();
  const features = [
    {
      eyebrow: "Discovery",
      title: "Built to decide.",
      body: "Every profile is big, bold, and beautifully clean. A real percentage Match, the days they’re free for chai, and the interests you share—everything you need to choose. Let’s Chai, or pass. No retries.",
      bullets: [
        "Big, bold profiles",
        "Percentage Match · Days available · Shared interests",
        "Chai or pass. No undo.",
      ],
      src: "uploads/Discovery.PNG",
    },
    {
      eyebrow: "Matches",
      title: "Your yeses, together.",
      body: "When you both tap Let’s Chai, you match. Matches lives in one calm list—your people, ready when you are, with a gentle Meet-or-Lose timer keeping the spark from going stale.",
      bullets: [
        "Mutual Let’s Chai = a match",
        "One list, no clutter",
        "A timer that respects the moment",
      ],
      src: "uploads/matches.PNG",
    },
    {
      eyebrow: "Chats",
      title: "Every chat, on the clock.",
      body: "Your conversations live in one clean, beautifully organized inbox. Each thread carries the time you have left before the match expires—so you always know what to open first, and when to make the plan.",
      bullets: [
        "Organized and beautifully clean",
        "Time remaining on every match",
        "Always know what’s next",
      ],
      src: "uploads/chats.PNG",
    },
    {
      eyebrow: "Ghost Court",
      title: "Closure, by design.",
      body: "When a chat goes quiet, Ghost Court privately asks the other person what happened—and shares their answer with you. One tap to file. One time per chat. Never public. Never scored. Just a kinder way to ask.",
      bullets: [
        "One-tap to file",
        "Private and one-time",
        "Never public, never scored",
      ],
      src: "uploads/Ghost_Court.PNG",
    },
    {
      eyebrow: "Verdict",
      title: "Their answer, on a card.",
      body: "They have 72 hours to reply. Their words come back to you on a single verdict card. If they don’t reply, the silence itself becomes the answer—and you get to move on with grace.",
      bullets: [
        "72-hour response window",
        "Their words, your closure",
        "Closure either way",
      ],
      src: "uploads/Ghost_Court_Verdict.PNG",
    },
    {
      eyebrow: "Meet or Lose",
      title: "Seven days to chai.",
      body: "Every match comes with a seven-day countdown—by design. Long enough for a real conversation. Short enough to keep things from drifting into forever-chat. Make a plan, or set the slot free for someone who will.",
      bullets: [
        "7-day countdown on every match",
        "Long enough for a real conversation",
        "Short enough to stay honest",
      ],
      src: "uploads/Expired_chat.PNG",
    },
    {
      eyebrow: "Chai Dates",
      title: "From spark to plan.",
      body: "Pick a time you’re both free. Pick a café near you both. Confirm in a tap. The date lands on your Chai Dates so you arrive with butterflies, not doubt.",
      bullets: [
        "Times you’re both free",
        "Cafés near you both",
        "Confirm in a tap",
      ],
      src: "uploads/calendar.png",
    },
  ];

  useEffect(() => {
    if (isMobile) return;            // mobile uses a stacked layout — no scroll tracking
    const section = sectionRef.current;
    if (!section) return;
    const onScroll = () => {
      const rect = section.getBoundingClientRect();
      const total = section.offsetHeight - window.innerHeight;
      const progress = Math.min(1, Math.max(0, -rect.top / total));
      const idx = Math.min(features.length - 1, Math.floor(progress * features.length));
      setActiveIdx(idx);
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, [isMobile]);

  /* -------- Mobile layout: single column, phone inline with each step -------- */
  if (isMobile) {
    return (
      <section id="features" ref={sectionRef} style={{ position: "relative", padding: "24px 0 40px", scrollMarginTop: 60 }}>
        <div className="mx-auto" style={{ maxWidth: 560, padding: "0 22px", display: "flex", flexDirection: "column", gap: 80 }}>
          {features.map((f, i) => (
            <Reveal key={i}>
              <div style={{ display: "flex", flexDirection: "column", alignItems: "center", textAlign: "center" }}>
                <div style={{ position: "relative", marginBottom: 28 }}>
                  <div aria-hidden style={{
                    position: "absolute", inset: -28, borderRadius: 999,
                    background: "radial-gradient(ellipse, rgba(233,69,96,.16), transparent 65%)",
                    filter: "blur(28px)", zIndex: -1,
                  }}/>
                  <IPhoneShell src={f.src} alt={f.eyebrow} scale={0.68}/>
                </div>
                <h3 className="display" style={{ fontSize: "clamp(34px, 8vw, 44px)", color: "var(--color-ink)" }}>{f.title}</h3>
                <p className="body-prose" style={{ marginTop: 14, fontSize: 17 }}>{f.body}</p>
                <ul style={{ marginTop: 22, display: "flex", flexDirection: "column", gap: 12, textAlign: "left", alignSelf: "stretch" }}>
                  {f.bullets.map(b => (
                    <li key={b} style={{ display: "flex", alignItems: "flex-start", gap: 12, fontSize: 16, lineHeight: 1.45, color: "color-mix(in srgb, var(--color-ink) 82%, transparent)" }}>
                      <span style={{
                        width: 22, height: 22, borderRadius: 999,
                        background: "linear-gradient(135deg, var(--color-pink), var(--color-coral))",
                        color: "white",
                        display: "grid", placeItems: "center", flexShrink: 0, marginTop: 2,
                        boxShadow: "0 4px 8px -2px rgba(233,69,96,.4)",
                      }}>
                        <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3"><path d="M5 12l5 5L20 7"/></svg>
                      </span>
                      <span>{b}</span>
                    </li>
                  ))}
                </ul>
              </div>
            </Reveal>
          ))}
        </div>
      </section>
    );
  }

  /* -------- Desktop layout: sticky phone, scroll-tied step changes -------- */
  return (
    <section id="features" ref={sectionRef} style={{ position: "relative", padding: "0", scrollMarginTop: 60 }}>
      <div style={{ position: "relative" }}>
        <div className="mx-auto" style={{ maxWidth: 1100, padding: "0 28px", display: "grid", gridTemplateColumns: "1fr 1fr", gap: 80, alignItems: "start" }}>
          {/* sticky iPhone */}
          <div style={{ position: "sticky", top: 80, height: "calc(100vh - 120px)", display: "flex", alignItems: "center", justifyContent: "center" }}>
            <div style={{ position: "relative" }}>
              <div aria-hidden style={{
                position: "absolute", inset: -50, borderRadius: 999,
                background: "radial-gradient(ellipse, rgba(233,69,96,.18), transparent 65%)",
                filter: "blur(34px)", zIndex: -1,
              }}/>
              <div style={{ position: "relative", width: 360 * 0.85, height: 780 * 0.85 }}>
                {features.map((f, i) => (
                  <div key={f.src} style={{
                    position: "absolute", inset: 0,
                    opacity: i === activeIdx ? 1 : 0,
                    transform: i === activeIdx ? "translateY(0) scale(1)" : i < activeIdx ? "translateY(-18px) scale(0.97)" : "translateY(18px) scale(0.97)",
                    transition: "opacity .7s cubic-bezier(.16,.84,.3,1), transform .7s cubic-bezier(.16,.84,.3,1)",
                    pointerEvents: i === activeIdx ? "auto" : "none",
                  }}>
                    <IPhoneShell src={f.src} alt={f.eyebrow} scale={0.85}/>
                  </div>
                ))}
              </div>
            </div>
          </div>

          {/* steps */}
          <div style={{ display: "flex", flexDirection: "column" }}>
            {features.map((f, i) => (
              <div key={i} style={{
                minHeight: "100vh",
                display: "flex", flexDirection: "column", justifyContent: "center",
                paddingBottom: 40,
              }}>
                <div style={{
                  opacity: i === activeIdx ? 1 : 0.28,
                  transform: i === activeIdx ? "translateY(0)" : "translateY(8px)",
                  transition: "opacity .6s ease, transform .6s ease",
                }}>
                  <h3 className="display" style={{ fontSize: "clamp(48px, 5.2vw, 72px)", color: "var(--color-ink)" }}>{f.title}</h3>
                  <p className="body-prose" style={{ marginTop: 24, fontSize: 22 }}>{f.body}</p>
                  <ul style={{ marginTop: 30, display: "flex", flexDirection: "column", gap: 14 }}>
                    {f.bullets.map(b => (
                      <li key={b} style={{ display: "flex", alignItems: "flex-start", gap: 14, fontSize: 18, lineHeight: 1.45, color: "color-mix(in srgb, var(--color-ink) 82%, transparent)" }}>
                        <span style={{
                          width: 24, height: 24, borderRadius: 999,
                          background: "linear-gradient(135deg, var(--color-pink), var(--color-coral))",
                          color: "white",
                          display: "grid", placeItems: "center", flexShrink: 0, marginTop: 3,
                          boxShadow: "0 4px 8px -2px rgba(233,69,96,.4)",
                        }}>
                          <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3"><path d="M5 12l5 5L20 7"/></svg>
                        </span>
                        <span>{b}</span>
                      </li>
                    ))}
                  </ul>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

/* ============================================================
   ONBOARDING BAND (dark, with hero login screen)
   ============================================================ */
function OnboardingBand() {
  return (
    <section style={{ padding: "140px 0", background: "var(--color-navy)", color: "var(--color-ink)", position: "relative", overflow: "hidden" }}>
      <div aria-hidden style={{
        position: "absolute", inset: 0,
        background: "radial-gradient(ellipse 50% 40% at 25% 50%, rgba(233,69,96,.18), transparent 70%)",
      }}/>
      <div className="mx-auto" style={{ maxWidth: 1100, padding: "0 28px", display: "grid", gridTemplateColumns: "1.05fr 1fr", gap: 80, alignItems: "center", position: "relative" }}>
        <div>
          <Reveal>
            <p className="eyebrow" style={{ color: "var(--color-coral)" }}>Getting started</p>
          </Reveal>
          <Reveal>
            <h2 className="display" style={{ fontSize: "clamp(40px, 5.4vw, 68px)", marginTop: 14, color: "white" }}>
              When the vibe is right,<br/>you just <span className="grad-text">know</span>.
            </h2>
          </Reveal>
          <Reveal>
            <p className="body-prose" style={{ marginTop: 20, color: "rgba(246,241,234,.65)" }}>
              Sign up in a tap. Tell us how you love, what a great first meeting looks like, and a few things you’re into. We’ll bring you people worth your time.
            </p>
          </Reveal>
          <Reveal stagger as="div" style={{ marginTop: 36, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16 }}>
            {[
              { n: "30s", l: "to create your profile" },
              { n: "3 prompts", l: "that actually go deep" },
              { n: "Zero", l: "ads in your feed, ever" },
            ].map(s => (
              <div key={s.n} style={{
                padding: "18px 18px",
                borderRadius: 18,
                background: "rgba(255,255,255,.05)",
                border: "1px solid rgba(255,255,255,.08)",
              }}>
                <div className="display" style={{ fontSize: 26, color: "white" }}>{s.n}</div>
                <div style={{ marginTop: 4, fontSize: 13, color: "rgba(246,241,234,.55)" }}>{s.l}</div>
              </div>
            ))}
          </Reveal>
          <Reveal>
            <div style={{ display: "flex", gap: 14, marginTop: 36 }}>
              <a href="#download" className="btn-primary" style={{ background: "white", color: "var(--color-navy)" }}>
                <span style={{ marginRight: 8, display: "inline-flex" }}><AppleGlyph size={16} color="currentColor"/></span>
                Continue with Apple
              </a>
              <a href="#" className="btn-ghost" style={{ color: "var(--color-coral)" }}>Use phone instead <span className="arr">›</span></a>
            </div>
          </Reveal>
        </div>
        <Reveal>
          <div style={{ position: "relative", display: "flex", justifyContent: "center" }}>
            <div aria-hidden style={{
              position: "absolute", inset: -30, borderRadius: 999,
              background: "radial-gradient(ellipse, rgba(233,69,96,.28), transparent 70%)",
              filter: "blur(40px)", zIndex: 0,
            }}/>
            <div style={{ position: "relative", zIndex: 1 }}>
              <IPhoneShell src="assets/screen-hero.png" alt="Sign up to ChaiShai" scale={0.78}/>
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

/* ============================================================
   PERKS GRID
   ============================================================ */
function PerksGrid() {
  const isMobile = useMobile();
  const perks = [
    { t: "Bold by design.",          d: "Beautifully clean, beautifully bold. The app gets out of your way so you can show up as yourself.", k: "bold" },
    { t: "7 days. Make them count.", d: "Every match carries a seven-day timer—by design. Long enough for a real conversation. Short enough to stay honest.", k: "clock" },
    { t: "Plans, in the chat.",      d: "Pick a time, pick a café, confirm—without ever leaving the conversation.", k: "schedule" },
    { t: "Ghosting, with a reply.",  d: "Ghost Court privately asks the other side what happened. One tap. One time per chat.", k: "ghost" },
    { t: "A calendar made for chai.",d: "Every confirmed date lands in the app. No more juggling your iPhone calendar.", k: "calendar" },
    { t: "Verified. For free.",      d: "Identity verification is built in, and it doesn’t cost a thing. Show up sure.", k: "verify" },
  ];
  const icon = (k) => {
    const stroke = { fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round" };
    switch (k) {
      case "bold":     return <svg width="22" height="22" viewBox="0 0 24 24" {...stroke}><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/><circle cx="12" cy="12" r="3.5"/></svg>;
      case "clock":    return <svg width="22" height="22" viewBox="0 0 24 24" {...stroke}><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>;
      case "schedule": return <svg width="22" height="22" viewBox="0 0 24 24" {...stroke}><path d="M4 6h16v11a2 2 0 0 1-2 2H8l-4 3z"/><path d="M8 11h8M8 14h5"/></svg>;
      case "ghost":    return <svg width="22" height="22" viewBox="0 0 24 24" {...stroke}><path d="M5 11a7 7 0 0 1 14 0v9l-2.5-1.5L14 20l-2-1.5L10 20l-2.5-1.5L5 20z"/><circle cx="9.5" cy="11" r="1" fill="currentColor" stroke="none"/><circle cx="14.5" cy="11" r="1" fill="currentColor" stroke="none"/></svg>;
      case "calendar": return <svg width="22" height="22" viewBox="0 0 24 24" {...stroke}><rect x="3.5" y="5" width="17" height="15" rx="2"/><path d="M3.5 10h17M8 3.5v3M16 3.5v3"/></svg>;
      case "verify":   return <svg width="22" height="22" viewBox="0 0 24 24" {...stroke}><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z"/><path d="M9 12l2 2 4-4"/></svg>;
      default: return null;
    }
  };
  return (
    <section style={{ padding: isMobile ? "80px 0" : "140px 0" }}>
      <div className="mx-auto" style={{ maxWidth: 1100, padding: isMobile ? "0 22px" : "0 28px" }}>
        <Reveal>
          <h2 className="display" style={{ fontSize: "clamp(36px, 7vw, 64px)", maxWidth: 780, color: "var(--color-ink)" }}>
            Good vibes, better matches,<br/><span className="grad-text">best chai.</span>
          </h2>
        </Reveal>
        <Reveal stagger as="div" style={{ marginTop: isMobile ? 40 : 56, display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(3, 1fr)", gap: isMobile ? 12 : 16 }}>
          {perks.map((p) => (
            <div key={p.t} className="perk-card">
              <div className="perk-icon">{icon(p.k)}</div>
              <div style={{ fontSize: 19, fontWeight: 600, letterSpacing: -0.018, color: "var(--color-ink)" }}>{p.t}</div>
              <p style={{ marginTop: 8, fontSize: 15, lineHeight: 1.5, color: "color-mix(in srgb, var(--color-ink) 62%, transparent)" }}>{p.d}</p>
            </div>
          ))}
        </Reveal>
      </div>
    </section>
  );
}

/* ============================================================
   STORIES BAND
   ============================================================ */
function StoriesBand() {
  return (
    <section style={{ padding: "20px 0 140px" }}>
      <div className="mx-auto" style={{ maxWidth: 1100, padding: "0 28px" }}>
        <Reveal>
          <div style={{
            position: "relative", overflow: "hidden",
            borderRadius: 32,
            padding: "80px 60px",
            background: "linear-gradient(135deg, var(--color-pink) 0%, var(--color-coral) 100%)",
            color: "white",
          }}>
            <div aria-hidden style={{
              position: "absolute", inset: 0,
              background: "radial-gradient(ellipse 60% 60% at 80% 20%, rgba(255,255,255,.18), transparent 60%)",
            }}/>
            <div style={{ position: "relative", maxWidth: 720 }}>
              <p className="eyebrow" style={{ color: "rgba(255,255,255,.85)" }}>Stories worth telling</p>
              <h2 className="display" style={{ fontSize: "clamp(36px, 4.8vw, 56px)", marginTop: 12, color: "white" }}>
                The best chapters start with the first sip.
              </h2>
              <p style={{ marginTop: 16, fontSize: 18, lineHeight: 1.55, color: "rgba(255,255,255,.9)" }}>
                The second cup, the long walk after, the “see you Friday.” When you find yours, we’d love to celebrate you — and inspire the next brave hello.
              </p>
              <div style={{ display: "flex", gap: 14, marginTop: 30 }}>
                <a href="#" className="btn-primary" style={{ background: "white", color: "#241A33" }}>Share your story</a>
                <a href="#" className="btn-ghost" style={{ color: "white" }}>Get on the updates list <span className="arr">›</span></a>
              </div>
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

/* ============================================================
   DOWNLOAD BAND
   ============================================================ */
function DownloadBand() {
  const isMobile = useMobile();
  return (
    <section id="download" style={{ padding: isMobile ? "80px 0 90px" : "120px 0 140px", position: "relative", overflow: "hidden", borderTop: "1px solid var(--color-hairline)" }}>
      <div aria-hidden style={{
        position: "absolute", inset: 0,
        background: "radial-gradient(ellipse 60% 40% at 50% 50%, rgba(233,69,96,.14), transparent 70%)",
      }}/>
      <div className="mx-auto" style={{ maxWidth: 900, padding: isMobile ? "0 22px" : "0 28px", textAlign: "center", position: "relative" }}>
        <Reveal>
          <h2 className="display" style={{ fontSize: "clamp(36px, 8.5vw, 84px)", color: "var(--color-ink)" }}>
            Your next chai date is one tap away.
          </h2>
        </Reveal>
      </div>
    </section>
  );
}

/* ============================================================
   FOOTER
   ============================================================ */
function Footer() {
  return (
    <footer style={{ borderTop: "1px solid var(--color-hairline)", padding: "42px 0", fontSize: 12, color: "color-mix(in srgb, var(--color-ink) 55%, transparent)" }}>
      <div className="mx-auto" style={{ maxWidth: 1100, padding: "0 28px", display: "flex", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 16 }}>
        <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
          <span>© 2026 Chai Shai. Made warm.</span>
        </div>
        <div style={{ display: "flex", gap: 22 }}>
          {[
            { t: "Privacy", href: "legal?doc=privacy" },
            { t: "Terms",   href: "legal?doc=terms"   },
            { t: "support@chaishaiapp.com", href: "mailto:support@chaishaiapp.com" },
          ].map(({ t, href }) => (
            <a key={t} href={href}
              onMouseEnter={e=>e.currentTarget.style.color="var(--color-ink)"}
              onMouseLeave={e=>e.currentTarget.style.color="inherit"}
              style={{ transition:"color .2s" }}>{t}</a>
          ))}
        </div>
      </div>
    </footer>
  );
}

/* ============================================================
   PRICING — one price, every feature, no tiers
   ============================================================ */
function PriceCard({ name, term, was, savings, after, featured = false }) {
  return (
    <div style={{
      position: "relative",
      padding: "36px 28px 30px",
      borderRadius: 24,
      background: featured
        ? "linear-gradient(170deg, color-mix(in srgb, var(--color-pink) 9%, var(--color-cream)) 0%, var(--color-cream) 72%)"
        : "var(--color-cream)",
      border: featured
        ? "1.5px solid color-mix(in srgb, var(--color-pink) 48%, transparent)"
        : "1px solid var(--color-hairline)",
      boxShadow: featured
        ? "0 26px 52px -26px rgba(233,69,96,.34)"
        : "0 12px 28px -22px rgba(26,20,18,.20)",
      textAlign: "center",
      display: "flex", flexDirection: "column", alignItems: "center",
    }}>
      {featured && (
        <div style={{
          position: "absolute", top: -13, left: "50%", transform: "translateX(-50%)",
          padding: "6px 16px", borderRadius: 999,
          background: "linear-gradient(135deg, var(--color-pink), var(--color-coral))",
          color: "white", fontSize: 11, fontWeight: 700, letterSpacing: 0.3,
          whiteSpace: "nowrap",
          boxShadow: "0 8px 18px -6px rgba(233,69,96,.5)",
        }}>Best value</div>
      )}

      <div style={{ fontSize: 21, fontWeight: 700, letterSpacing: -0.02, color: "var(--color-ink)" }}>{name}</div>
      <div style={{ marginTop: 4, fontSize: 13.5, color: "color-mix(in srgb, var(--color-ink) 55%, transparent)" }}>{term}</div>

      <div style={{ display: "flex", alignItems: "baseline", justifyContent: "center", gap: 13, marginTop: 22 }}>
        <span className="num-tabular" style={{
          fontSize: 27, fontWeight: 600,
          color: "color-mix(in srgb, var(--color-ink) 40%, transparent)",
          textDecoration: "line-through",
          textDecorationColor: "var(--color-pink)",
          textDecorationThickness: "2px",
        }}>{was}</span>
        <span className="grad-text display" style={{ fontSize: 52, lineHeight: 1 }}>Free</span>
      </div>

      <div style={{
        marginTop: 16,
        display: "inline-flex", alignItems: "center", gap: 7,
        padding: "7px 14px", borderRadius: 999,
        background: "color-mix(in srgb, var(--color-coral) 16%, transparent)",
        border: "1px solid color-mix(in srgb, var(--color-coral) 34%, transparent)",
        fontSize: 11.5, fontWeight: 600, letterSpacing: 0.2,
        color: "var(--color-pink-dark)",
        textTransform: "uppercase",
      }}>
        <span style={{ width: 7, height: 7, borderRadius: 999, background: "linear-gradient(135deg, var(--color-pink), var(--color-coral))" }}/>
        Launch promo — limited
      </div>

      {savings && (
        <div style={{ marginTop: 14, fontSize: 14, fontWeight: 600, color: "var(--color-pink)" }}>{savings}</div>
      )}

      <div style={{ marginTop: savings ? 8 : 14, fontSize: 12.5, color: "color-mix(in srgb, var(--color-ink) 46%, transparent)" }}>{after}</div>
    </div>
  );
}

function Pricing() {
  const isMobile = useMobile();
  return (
    <section id="pricing" style={{
      padding: isMobile ? "80px 0" : "140px 0",
      borderTop: "1px solid var(--color-hairline)",
      scrollMarginTop: 60,
      position: "relative", overflow: "hidden",
    }}>
      <div aria-hidden style={{
        position: "absolute", inset: 0, pointerEvents: "none",
        background: "radial-gradient(ellipse 55% 42% at 50% 0%, rgba(233,69,96,.10), transparent 66%)",
      }}/>
      <div className="mx-auto" style={{ maxWidth: 1100, padding: isMobile ? "0 22px" : "0 28px", position: "relative" }}>

        <Reveal>
          <h2 className="display" style={{
            fontSize: "clamp(36px, 6vw, 64px)",
            textAlign: "center", color: "var(--color-ink)",
          }}>
            One price. <span className="grad-text">Every feature.</span><br/>No tiers.
          </h2>
        </Reveal>
        <Reveal>
          <p className="body-prose" style={{ maxWidth: 600, margin: "20px auto 0", textAlign: "center" }}>
            No Plus, no Premium, no Gold. No paywalled swipes, no boosts to buy. One membership unlocks everything Chai Shai does — the same for everyone.
          </p>
        </Reveal>

        <Reveal stagger as="div" style={{
          marginTop: isMobile ? 48 : 66,
          marginLeft: "auto", marginRight: "auto", maxWidth: 720,
          display: "grid",
          gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr",
          gap: isMobile ? 30 : 20,
        }}>
          <PriceCard
            name="Monthly"
            term="Billed every month"
            was="$29.99"
            after="$29.99/mo once launch promo ends"
          />
          <PriceCard
            featured
            name="6 Months"
            term="Billed every 6 months"
            was="$119.99"
            savings="$20/mo · Save 33% vs monthly"
            after="$119.99 / 6 mo once launch promo ends"
          />
        </Reveal>

        <Reveal>
          <div style={{
            marginTop: isMobile ? 36 : 48,
            marginLeft: "auto", marginRight: "auto", maxWidth: 720,
            padding: isMobile ? "30px 24px" : "36px 44px",
            borderRadius: 24,
            background: "var(--color-cream)",
            border: "1px solid var(--color-hairline)",
            textAlign: "center",
          }}>
            <div className="display" style={{ fontSize: isMobile ? 25 : 30, color: "var(--color-ink)", letterSpacing: -0.02 }}>
              Everything included. <span className="grad-text">No tiers, ever.</span>
            </div>
            <p style={{
              maxWidth: 540, margin: "12px auto 0",
              fontSize: 15, lineHeight: 1.55,
              color: "color-mix(in srgb, var(--color-ink) 62%, transparent)",
            }}>
              No special features locked behind an upgrade. Every member gets the full Chai Shai experience — and every feature we ship next — at no extra cost.
            </p>
            <div style={{ marginTop: 24, display: "flex", flexWrap: "wrap", justifyContent: "center", gap: 9 }}>
              {[
                "Ghost Court", "Chai Dates", "7-day Meet-or-Lose timer",
                "Identity verification", "In-app date calendar", "Match scoring",
                "All future updates",
              ].map(c => (
                <span key={c} style={{
                  fontSize: 12.5, fontWeight: 500,
                  padding: "8px 14px", borderRadius: 999,
                  background: "var(--color-sand)",
                  border: "1px solid var(--color-hairline)",
                  color: "color-mix(in srgb, var(--color-ink) 72%, transparent)",
                }}>{c}</span>
              ))}
            </div>
          </div>
        </Reveal>

      </div>
    </section>
  );
}

/* ============================================================
   APP
   ============================================================ */
function App() {
  return (
    <>
      <Nav />
      <main>
        <Hero />
        <PinnedShowcase />
        <PerksGrid />
        <Pricing />
        <DownloadBand />
      </main>
      <Footer />
    </>
  );
}

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