// sections-top.jsx — Nav, Hero, Marquee, Problem, Fix

/* ── Nav ─────────────────────────────────────────────────────── */
function Nav() {
  const [scrolled, setScrolled] = React.useState(false);
  const [open, setOpen] = React.useState(false);
  React.useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 30);
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  const items = [
    { l: "Services", h: "#services" },
    { l: "Process",  h: "#process" },
    { l: "Work",     h: "#results" },
    { l: "Pricing",  h: "#pricing" },
    { l: "FAQ",      h: "#faq" },
  ];
  const go = (h) => {
    setOpen(false);
    const el = document.querySelector(h);
    if (!el) return;
    const top = el.getBoundingClientRect().top + window.pageYOffset - 70; // offset for fixed nav
    window.scrollTo({ top, behavior: "smooth" });
  };
  return (
    <nav style={{
      position: "fixed", top: 0, left: 0, right: 0, zIndex: 50,
      transition: "all 300ms ease",
      background: scrolled ? "rgba(11,11,12,0.75)" : "transparent",
      backdropFilter: scrolled ? "blur(14px) saturate(140%)" : "none",
      borderBottom: scrolled ? "1px solid var(--border)" : "1px solid transparent",
    }}>
      <div className="container" style={{
        display: "flex", alignItems: "center", justifyContent: "space-between",
        height: 72,
      }}>
        <a href="#" style={{ display: "flex", alignItems: "center", gap: 12 }}>
          <img src="assets/yukaa-logo.png" alt="Yukaa Media" style={{
            height: 36, width: "auto",
            filter: "drop-shadow(0 0 16px rgba(43,163,232,0.35))",
          }} />
          <span style={{
            fontFamily: "var(--font-display)",
            fontWeight: 600, fontSize: 17,
            letterSpacing: "-0.02em",
          }}>Yukaa Media</span>
        </a>

        <div className="nav-desktop" style={{ display: "flex", alignItems: "center", gap: 4 }}>
          {items.map((it) => (
            <button key={it.h} onClick={() => go(it.h)} style={{
              padding: "10px 14px",
              fontSize: 14,
              color: "var(--fg-mute)",
              transition: "color 200ms",
              fontWeight: 400,
            }} onMouseEnter={(e) => e.currentTarget.style.color = "var(--fg)"}
               onMouseLeave={(e) => e.currentTarget.style.color = "var(--fg-mute)"}>
              {it.l}
            </button>
          ))}
        </div>

        <div className="nav-cta" style={{ display: "flex", alignItems: "center", gap: 12 }}>
          <a href={CALENDLY_URL} target="_blank" rel="noopener noreferrer" className="btn btn--primary" style={{ padding: "10px 18px", fontSize: 14 }}>
            Book a call <span className="arr"><Icon.arrUR /></span>
          </a>
          <button className="nav-burger" onClick={() => setOpen(!open)} style={{
            display: "none", padding: 8, color: "var(--fg)",
          }} aria-label="Menu">
            {open ? <Icon.close /> : <Icon.menu />}
          </button>
        </div>
      </div>

      {open && (
        <div style={{
          background: "var(--bg-2)",
          borderTop: "1px solid var(--border)",
          padding: "8px 0 16px",
        }}>
          <div className="container" style={{ display: "flex", flexDirection: "column", gap: 2 }}>
            {items.map((it) => (
              <button key={it.h} onClick={() => go(it.h)} style={{
                textAlign: "left",
                padding: "14px 12px",
                fontSize: 16,
                color: "var(--fg)",
                borderBottom: "1px solid var(--border)",
              }}>{it.l}</button>
            ))}
          </div>
        </div>
      )}

      <style>{`
        @media (max-width: 860px) {
          .nav-desktop { display: none !important; }
          .nav-burger  { display: inline-flex !important; }
        }
      `}</style>
    </nav>
  );
}

/* ── Hero ────────────────────────────────────────────────────── */
function Hero() {
  return (
    <section style={{ position: "relative", padding: "180px 0 80px", overflow: "hidden" }}>
      <div className="grid-bg"></div>
      <div className="noise"></div>

      {/* glow */}
      <div aria-hidden style={{
        position: "absolute",
        bottom: "-30%", left: "50%", transform: "translateX(-50%)",
        width: 900, height: 900, borderRadius: "50%",
        background: "radial-gradient(circle at center, rgba(43,163,232,0.22) 0%, transparent 60%)",
        filter: "blur(60px)",
        pointerEvents: "none",
      }}></div>

      <div className="container" style={{ position: "relative", zIndex: 2 }}>
        <Reveal>
          <Pill>Trusted by 90+ service businesses</Pill>
        </Reveal>

          <Reveal>
            <h1 className="display h1" style={{ marginTop: 28, maxWidth: "13ch" }}>
              Websites that turn <span className="serif-it accent-gradient">visitors</span><br />
              into <span className="serif-it">leads.</span>
            </h1>
          </Reveal>

        <div style={{
          marginTop: 36,
          display: "grid",
          gridTemplateColumns: "minmax(0, 1fr) auto",
          gap: 32,
          alignItems: "end",
        }} className="hero-grid">
          <Reveal delay={200}>
            <p className="lead" style={{ maxWidth: "44ch" }}>
              We design sales-focused websites for service businesses — built to capture leads, book calls, and grow your revenue. Launched in 1–2 weeks.
            </p>

            <div style={{ display: "flex", flexWrap: "wrap", gap: 12, marginTop: 28 }}>
              <PrimaryButton large>Book a free 15-min call</PrimaryButton>
              <GhostButton large href="#results" onClick={(e) => {
                e?.preventDefault?.();
                const el = document.querySelector("#results");
                if (!el) return;
                const top = el.getBoundingClientRect().top + window.pageYOffset - 70;
                window.scrollTo({ top, behavior: "smooth" });
              }}>
                See real results
              </GhostButton>
            </div>

            <p className="mono dim" style={{ fontSize: 12, marginTop: 18, letterSpacing: "0.04em" }}>
              ◇ No pressure, just clarity.
            </p>
          </Reveal>

          <Reveal delay={300}>
            <div className="hero-stats" style={{
              display: "grid",
              gridTemplateColumns: "1fr",
              gap: 0,
              border: "1px solid var(--border)",
              borderRadius: "var(--r-lg)",
              padding: 4,
              background: "var(--bg-2)",
              minWidth: 240,
            }}>
              {[
                { v: 90, s: "+", l: "Businesses served" },
                { v: 1.5, s: "wk", l: "Average turnaround" },
                { v: 14, s: "+", l: "5★ Google reviews / client" },
              ].map((st, i) => (
                <div key={i} style={{
                  padding: "18px 18px",
                  borderBottom: i < 2 ? "1px solid var(--border)" : "none",
                  display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: 16,
                }}>
                  <span className="display" style={{ fontSize: 34, fontWeight: 600 }}>
                    <CountUp end={st.v} suffix={st.s} />
                  </span>
                  <span className="mono" style={{ fontSize: 10.5, color: "var(--fg-mute)", textTransform: "uppercase", letterSpacing: "0.1em", textAlign: "right", maxWidth: 140 }}>
                    {st.l}
                  </span>
                </div>
              ))}
            </div>
          </Reveal>
        </div>

      </div>

      <style>{`
        @media (max-width: 860px) {
          .hero-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

/* ── Marquee ─────────────────────────────────────────────────── */
function Marquee() {
  const items = [
    "Home improvement", "Mortgage & finance", "Healthcare", "Construction",
    "Consulting", "Professional services", "Wellness", "Home improvement",
    "Mortgage & finance", "Healthcare", "Construction", "Consulting",
    "Professional services", "Wellness",
  ];
  return (
    <div className="marquee">
      <div className="marquee__track">
        {items.concat(items).map((t, i) => (
          <span key={i} className="marquee__item">
            <Icon.star className="star" />
            {t}
          </span>
        ))}
      </div>
    </div>
  );
}

/* ── Problem ─────────────────────────────────────────────────── */
function ProblemSection() {
  const items = [
    { n: "01", t: "Visitors leave in seconds", d: "No clear message. No direction. People land on your site, get confused, and bounce — straight to a competitor who made it easier." },
    { n: "02", t: "Your phone isn't ringing", d: "Traffic means nothing if nobody contacts you. No forms filled. No calls booked. Your website is a digital brochure collecting dust." },
    { n: "03", t: "You can't tell what's working", d: "No tracking. No data. You're spending money on a website with zero visibility into what's generating business and what's wasting it." },
  ];
  return (
    <section className="section section--alt">
      <div className="container">
        <div style={{ display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1.4fr)", gap: 64, alignItems: "start" }} className="two-col">
          <div>
            <Reveal><Eyebrow>The problem</Eyebrow></Reveal>
            <Reveal delay={80}>
              <h2 className="display h2" style={{ marginTop: 20 }}>
                Your site looks fine.<br />
                <span className="serif-it" style={{ color: "var(--fg-mute)" }}>It's just not</span><br />
                <span className="serif-it">bringing in business.</span>
              </h2>
            </Reveal>
          </div>

          <div>
            <Reveal>
              <p className="lead">You paid for a website. It's live. It looks decent. Here's what's actually happening behind the scenes:</p>
            </Reveal>
            <div style={{ marginTop: 40, display: "flex", flexDirection: "column" }}>
              {items.map((it, i) => (
                <Reveal key={i} delay={i * 100}>
                  <div style={{
                    display: "grid",
                    gridTemplateColumns: "60px 1fr",
                    gap: 20,
                    padding: "28px 0",
                    borderTop: "1px solid var(--border)",
                  }}>
                    <span className="mono" style={{ color: "var(--fg-dim)", fontSize: 13, letterSpacing: "0.04em" }}>{it.n}</span>
                    <div>
                      <h3 className="display" style={{ fontSize: 24, fontWeight: 500, letterSpacing: "-0.02em", marginBottom: 8 }}>{it.t}</h3>
                      <p className="mute" style={{ fontSize: 15, lineHeight: 1.55, maxWidth: "52ch" }}>{it.d}</p>
                    </div>
                  </div>
                </Reveal>
              ))}
              <div style={{ borderTop: "1px solid var(--border)" }}></div>
            </div>
            <Reveal delay={300}>
              <p style={{ marginTop: 36, fontSize: 18, fontWeight: 500, letterSpacing: "-0.01em" }}>
                If any of this sounds familiar, the problem isn't your business —{" "}
                <span className="serif-it text-accent" style={{ fontSize: 22 }}>it's your website.</span>
              </p>
            </Reveal>
          </div>
        </div>
      </div>

      <style>{`
        @media (max-width: 860px) {
          .two-col { grid-template-columns: 1fr !important; gap: 32px !important; }
        }
      `}</style>
    </section>
  );
}

/* ── Fix ─────────────────────────────────────────────────────── */
function FixSection() {
  const items = [
    { i: "→", t: "Clear, sales-focused messaging", d: "Every page guides visitors toward one action: contacting you. No jargon. No confusion. Just a clear path from visitor to lead." },
    { i: "✦", t: "Built to capture leads", d: "Strategic calls-to-action, appointment booking, and lead forms placed exactly where they convert — not where they look pretty." },
    { i: "◆", t: "Tracking & analytics from day one", d: "Google Analytics, conversion tracking, and performance data built in from launch. You'll know what's working and what needs to change." },
  ];
  return (
    <section className="section">
      <div className="container">
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "end", flexWrap: "wrap", gap: 24, marginBottom: 64 }}>
          <Reveal>
            <Eyebrow>The fix</Eyebrow>
            <h2 className="display h2" style={{ marginTop: 20, maxWidth: 16 + "ch" }}>
              Your website should<br />
              work as hard <span className="serif-it">as you do.</span>
            </h2>
          </Reveal>
          <Reveal delay={120}>
            <p className="lead" style={{ maxWidth: "36ch" }}>
              We don't just make websites look good. We make them bring in business. Three ingredients, none optional.
            </p>
          </Reveal>
        </div>

        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
          gap: 16,
        }} className="fix-grid">
          {items.map((it, i) => (
            <Reveal key={i} delay={i * 90}>
              <div className="card" style={{ padding: 28, height: "100%" }}>
                <div style={{
                  width: 48, height: 48,
                  border: "1px solid var(--border-2)",
                  borderRadius: "50%",
                  display: "grid", placeItems: "center",
                  marginBottom: 24,
                  fontFamily: "var(--font-serif)",
                  fontStyle: "italic",
                  fontSize: 22,
                  color: "var(--accent)",
                }}>{it.i}</div>
                <h3 className="display" style={{ fontSize: 22, fontWeight: 500, letterSpacing: "-0.02em", marginBottom: 12 }}>{it.t}</h3>
                <p className="mute" style={{ fontSize: 14.5, lineHeight: 1.55 }}>{it.d}</p>
              </div>
            </Reveal>
          ))}
        </div>
      </div>

      <style>{`
        @media (max-width: 860px) {
          .fix-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

Object.assign(window, { Nav, Hero, Marquee, ProblemSection, FixSection });
