// Page sections for Skillhub Builders
const { useState: useStateS, useEffect: useEffectS, useMemo: useMemoS, useRef: useRefS } = React;

// --- NAV ---
function Nav({ onOpenTweaks, hasTweaks }) {
  const [scrolled, setScrolled] = useStateS(false);
  useEffectS(() => {
    const on = () => setScrolled(window.scrollY > 8);
    on();
    window.addEventListener("scroll", on, { passive: true });
    return () => window.removeEventListener("scroll", on);
  }, []);
  return (
    <header style={{
      position: "sticky", top: 0, zIndex: 50,
      background: scrolled ? "color-mix(in oklab, var(--bg) 88%, transparent)" : "transparent",
      backdropFilter: scrolled ? "saturate(160%) blur(12px)" : "none",
      WebkitBackdropFilter: scrolled ? "saturate(160%) blur(12px)" : "none",
      borderBottom: `1px solid ${scrolled ? "var(--line)" : "transparent"}`,
      transition: "background 160ms, border-color 160ms"
    }}>
      <Container style={{ display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px clamp(20px, 4vw, 48px)" }}>
        <a href="#top" style={{ display: "inline-flex", alignItems: "center", gap: 10 }}>
          <Logo />
          <span style={{ fontFamily: "var(--mono)", fontSize: 13, fontWeight: 600, letterSpacing: "-0.01em" }}>
            skillhub<span style={{ color: "var(--accent)" }}>.builders</span>
          </span>
        </a>
        <nav className="nav-links" style={{ display: "flex", gap: 28 }}>
          {[["Services","#services"],["Process","#process"],["Pricing","#pricing"],["FAQ","#faq"]].map(([l,h]) => (
            <a key={h} href={h} className="mono" style={{ color: "var(--fg-2)" }}
               onMouseEnter={e => e.currentTarget.style.color = "var(--fg)"}
               onMouseLeave={e => e.currentTarget.style.color = "var(--fg-2)"}>{l}</a>
          ))}
        </nav>
        <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
          {hasTweaks && (
            <button onClick={onOpenTweaks} title="Open tweaks"
              style={{ display:"inline-flex", alignItems:"center", gap:6, padding:"6px 10px", border:"1px solid var(--line-strong)", borderRadius:999, fontFamily:"var(--mono)", fontSize:10, letterSpacing:"0.05em", textTransform:"uppercase", color:"var(--fg-2)" }}>
              <Dot /> tweaks
            </button>
          )}
          <Btn variant="ghost" size="sm" as="a" href="#contact" className="hide-mobile">Book a call</Btn>
          <Btn size="sm" as="a" href="#contact">Start a project <Arrow /></Btn>
        </div>
      </Container>
    </header>
  );
}

function Logo() {
  return (
    <svg width="22" height="22" viewBox="0 0 22 22" fill="none" aria-hidden>
      <rect x="1" y="1" width="20" height="20" rx="4" stroke="currentColor" strokeWidth="1.4" />
      <path d="M6 11h4M10 7v8M12 7h4v8" stroke="currentColor" strokeWidth="1.4" strokeLinecap="square" />
    </svg>
  );
}

// =========================================================
// HERO — 3 variants
// =========================================================
function Hero({ variant }) {
  if (variant === "statement") return <HeroStatement />;
  if (variant === "grid") return <HeroGrid />;
  return <HeroTerminal />;
}

function HeroTerminal() {
  const [step, setStep] = useStateS(0);
  useEffectS(() => { setStep(0); }, []);
  return (
    <section id="top" style={{ padding: "56px 0 24px", position: "relative" }}>
      <div className="grid-bg" style={{ position: "absolute", inset: 0, opacity: 0.5, maskImage: "linear-gradient(180deg, var(--bg) 10%, transparent 100%)", WebkitMaskImage: "linear-gradient(180deg, var(--bg) 10%, transparent 100%)", pointerEvents: "none" }} />
      <Container style={{ position: "relative" }}>
        <div className="resp-hero" style={{ display: "grid", gridTemplateColumns: "1.15fr 0.85fr", gap: 48, alignItems: "center" }}>
          <div>
            <Label style={{ color: "var(--accent)" }}>
              <Dot color="var(--accent)" /> &nbsp; Booking Q3 · 2 slots left
            </Label>
            <h1 style={{
              fontFamily: "var(--sans)", fontWeight: 600, letterSpacing: "-0.035em",
              fontSize: "clamp(44px, 6.2vw, 88px)", lineHeight: 0.98,
              margin: "22px 0 20px", textWrap: "balance"
            }}>
              We build your <span style={{ fontStyle: "italic", fontWeight: 400 }}>hub</span>.<br/>
              Then we keep it <span style={{ color: "var(--accent)" }}>humming</span>.
            </h1>
            <p style={{ fontSize: 19, lineHeight: 1.5, color: "var(--fg-2)", maxWidth: 540, margin: "0 0 28px", textWrap: "pretty" }}>
              A small shop for local businesses. We build your website, ship your mobile app,
              and run your socials so you can get back to the work you actually like.
            </p>
            <div style={{ display: "flex", gap: 10, flexWrap: "wrap" }}>
              <Btn as="a" href="#contact">Start a project <Arrow /></Btn>
              <Btn variant="ghost" as="a" href="#services">See services</Btn>
            </div>
            <div style={{ display: "flex", gap: 28, marginTop: 40, flexWrap: "wrap" }}>
              <Stat num="42" label="hubs shipped" />
              <Stat num="11d" label="avg build time" />
              <Stat num="99.98%" label="uptime SLA" />
              <Stat num="4.9★" label="client rating" />
            </div>
          </div>
          <Terminal title="skillhub@local:~/hub — bash">
            <TypedLine prompt="$" text="skillhub init --client 'acme-bakery'" delay={200} onDone={() => setStep(1)} />
            {step >= 1 && <div style={{ color: "var(--fg-3)", paddingLeft: 18 }}>→ scoping website, app, socials… ok</div>}
            {step >= 1 && <TypedLine prompt="$" text="skillhub build --stack website+app+social" delay={300} onDone={() => setStep(2)} />}
            {step >= 2 && (
              <div style={{ paddingLeft: 18, color: "var(--fg-2)" }}>
                <div><Dot color="var(--ok, var(--accent))" /> website  <span style={{ color:"var(--fg-3)" }}>deployed · skillhub.cloud/acme</span></div>
                <div><Dot color="var(--ok, var(--accent))" /> app      <span style={{ color:"var(--fg-3)" }}>submitted · ios + android</span></div>
                <div><Dot color="var(--ok, var(--accent))" /> social   <span style={{ color:"var(--fg-3)" }}>12 posts queued · ig, fb, tt</span></div>
              </div>
            )}
            {step >= 2 && <TypedLine prompt="$" text="skillhub maintain --addon 'website+app'" delay={200} onDone={() => setStep(3)} />}
            {step >= 3 && (
              <div style={{ paddingLeft: 18 }}>
                <div style={{ color: "var(--fg-3)" }}>→ monitoring on · monthly reports scheduled</div>
                <div style={{ marginTop: 10, color: "var(--accent)" }}>
                  ready. <span style={{ color: "var(--fg-3)" }}>uptime 100% · tickets 0 · next post in 2h 14m</span>
                </div>
              </div>
            )}
            {step >= 3 && <div style={{ marginTop: 6 }}><span style={{ color: "var(--fg-3)" }}>$</span> <span className="cursor" /></div>}
          </Terminal>
        </div>
      </Container>
    </section>
  );
}

function Stat({ num, label }) {
  return (
    <div>
      <div style={{ fontFamily: "var(--mono)", fontSize: 28, fontWeight: 500, letterSpacing: "-0.02em" }}>{num}</div>
      <div className="mono" style={{ marginTop: 4 }}>{label}</div>
    </div>
  );
}

function HeroStatement() {
  return (
    <section id="top" style={{ padding: "72px 0 40px", borderBottom: "1px solid var(--line)" }}>
      <Container>
        <div style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 32, alignItems: "end", marginBottom: 24 }}>
          <Label><Dot color="var(--accent)" pulse /> &nbsp;Est. 2025 · Austin, TX</Label>
          <div style={{ height: 1, background: "var(--line-strong)", marginBottom: 10 }} />
          <Label style={{ color: "var(--fg-3)" }}>Index / 01</Label>
        </div>
        <h1 className="statement-h1" style={{
          fontFamily: "var(--sans)", fontWeight: 500, letterSpacing: "-0.045em",
          fontSize: "clamp(56px, 10vw, 164px)", lineHeight: 0.92,
          margin: "12px 0 24px", textWrap: "balance"
        }}>
          A small <span style={{ fontStyle: "italic", fontWeight: 300 }}>agency</span> for<br/>
          local businesses that <br/>
          want to <span style={{ color: "var(--accent)" }}>stop worrying</span><br/>
          about the internet.
        </h1>
        <div className="resp-2col" style={{ display: "grid", gridTemplateColumns: "1.5fr 1fr", gap: 32, alignItems: "start", paddingTop: 18 }}>
          <p style={{ fontSize: 19, lineHeight: 1.5, color: "var(--fg-2)", maxWidth: 640, margin: 0, textWrap: "pretty" }}>
            We're Skillhub Builders. We build your hub — website, mobile app, socials —
            and we can maintain the whole thing as an add-on. One team, one number,
            no agencies-within-agencies.
          </p>
          <div style={{ display: "flex", flexDirection: "column", gap: 12, alignItems: "flex-start" }}>
            <Btn as="a" href="#contact">Start a project <Arrow /></Btn>
            <Btn variant="ghost" as="a" href="#process">How we work</Btn>
          </div>
        </div>
      </Container>
    </section>
  );
}

function HeroGrid() {
  const modules = [
    { k: "WEB-01", t: "Website",    s: "live",      sub: "uptime 99.98%" },
    { k: "APP-02", t: "Mobile App", s: "shipped",   sub: "ios + android" },
    { k: "SOC-03", t: "Social",     s: "scheduled", sub: "12 posts / week" },
  ];
  return (
    <section id="top" style={{ padding: "48px 0 24px" }}>
      <Container>
        <div className="resp-hero" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 48, alignItems: "center", marginBottom: 32 }}>
          <div>
            <Label style={{ color: "var(--accent)" }}><Dot color="var(--accent)" pulse /> &nbsp;system online</Label>
            <h1 style={{
              fontFamily: "var(--sans)", fontWeight: 600, letterSpacing: "-0.035em",
              fontSize: "clamp(40px, 5.6vw, 76px)", lineHeight: 1.0,
              margin: "22px 0 16px", textWrap: "balance"
            }}>
              Your whole internet,<br/>on one dashboard.
            </h1>
            <p style={{ fontSize: 18, color: "var(--fg-2)", lineHeight: 1.5, maxWidth: 500, margin: "0 0 24px" }}>
              We run each piece as a module. Pick what you need, skip what you don't,
              and scale up when you grow.
            </p>
            <div style={{ display: "flex", gap: 10 }}>
              <Btn as="a" href="#pricing">See packages <Arrow /></Btn>
              <Btn variant="ghost" as="a" href="#services">Browse modules</Btn>
            </div>
          </div>
          <div className="resp-modules" style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 10 }}>
            {modules.map((m, i) => (
              <div key={i} style={{
                padding: 16, border: "1px solid var(--line-strong)", borderRadius: 8,
                background: "var(--surface)", position: "relative", minHeight: 120,
                display: "flex", flexDirection: "column", justifyContent: "space-between"
              }}>
                <div>
                  <Label style={{ color: "var(--fg-3)" }}>{m.k}</Label>
                  <div style={{ fontSize: 18, fontWeight: 500, marginTop: 6 }}>{m.t}</div>
                </div>
                <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
                  <Dot color="var(--accent)" pulse={i%2===0} />
                  <span className="mono" style={{ color: "var(--fg-2)" }}>{m.s}</span>
                </div>
                <div className="mono" style={{ position: "absolute", right: 12, top: 12, color: "var(--fg-3)" }}>
                  {String(i+1).padStart(2,"0")}
                </div>
                <div className="mono" style={{ marginTop: 6, color: "var(--fg-3)" }}>{m.sub}</div>
              </div>
            ))}
          </div>
        </div>
      </Container>
    </section>
  );
}

// =========================================================
// SERVICES
// =========================================================
const SERVICES = [
  { id: "web",    code: "WEB",    t: "Website Design & Build",  b: "Fast, accessible sites that load in under a second and feel hand-built. Custom design, mobile-friendly, analytics wired in. Ongoing maintenance available as an add-on." },
  { id: "app",    code: "APP",    t: "Mobile App Development",  b: "iOS and Android apps built for your business — bookings, ordering, loyalty, whatever you need. We handle the app store submissions. Ongoing maintenance available as an add-on." },
  { id: "social", code: "SOCIAL", t: "Social Media Management", b: "Monthly content calendar, shot on-site, posted on IG, FB, TikTok. Real voice, not a bot. Scoped and priced around what your business actually needs." }
];

function Services() {
  return (
    <section id="services" style={{ padding: "96px 0 40px", borderTop: "1px solid var(--line)" }}>
      <Container>
        <div style={{ marginBottom: 40 }}>
          <SectionHead kicker="/services" title="Three services. One team." sub="Websites, mobile apps, and social media — that's it. Pick what you need and we'll take it from there." />
        </div>
        <div className="services-grid" style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0, border: "1px solid var(--line-strong)", borderRadius: 8, overflow: "hidden", background: "var(--surface)" }}>
          {SERVICES.map((s, i) => (
            <ServiceCell key={s.id} s={s} i={i} col={i % 3} row={Math.floor(i / 3)} total={SERVICES.length} />
          ))}
        </div>
      </Container>
    </section>
  );
}

function ServiceCell({ s, i, col, row, total }) {
  const [hover, setHover] = useStateS(false);
  const rowsTotal = Math.ceil(total / 3);
  const borderRight = col < 2 ? "1px solid var(--line-strong)" : "none";
  const borderBottom = row < rowsTotal - 1 ? "1px solid var(--line-strong)" : "none";
  return (
    <div className="service-cell" onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}
      style={{
        padding: "28px 26px 26px", position: "relative", minHeight: 200,
        borderRight, borderBottom,
        background: hover ? "var(--accent-soft)" : "transparent",
        transition: "background 160ms"
      }}>
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 20 }}>
        <Label style={{ color: "var(--accent)" }}>{s.code}</Label>
        <Label style={{ color: "var(--fg-3)" }}>0{i + 1}</Label>
      </div>
      <h3 style={{ fontSize: 22, fontWeight: 500, letterSpacing: "-0.015em", margin: "0 0 10px" }}>{s.t}</h3>
      <p style={{ color: "var(--fg-2)", fontSize: 14.5, lineHeight: 1.55, margin: 0 }}>{s.b}</p>
      <div style={{
        position: "absolute", right: 20, bottom: 18, color: "var(--fg-3)",
        transform: hover ? "translateX(0)" : "translateX(-4px)",
        opacity: hover ? 1 : 0.4, transition: "all 200ms"
      }}>
        <Arrow dir="upRight" />
      </div>
    </div>
  );
}

// =========================================================
// PROCESS
// =========================================================
function Process() {
  const steps = [
    { n: "01", t: "Fill the request form", d: "Tell us about your business and what you need through the form below. We reply within one business day.", meta: "Week 0" },
    { n: "02", t: "Scope & quote", d: "Fixed scope, fixed fee. Maintenance add-ons and social media are scoped here too. No surprises on the invoice.", meta: "Week 0–1" },
    { n: "03", t: "Build",        d: "Your website or app takes shape. You get a staging link on day 3 and we iterate in the open.", meta: "Week 1–2" },
    { n: "04", t: "Launch & maintain", d: "We flip the switch. If you've added maintenance, we take it from there — monitoring, updates, the works.", meta: "Week 2 → ∞" }
  ];
  return (
    <section id="process" style={{ padding: "96px 0", borderTop: "1px solid var(--line)" }}>
      <Container>
        <SectionHead kicker="/process" title="Four steps. Two weeks. Then we stay." sub="Most clients are live inside two weeks. After launch, we keep running things — you don't have to hire another agency." />
        <div className="process-grid" style={{ marginTop: 56, display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 0, borderTop: "1px solid var(--line-strong)" }}>
          {steps.map((s, i) => (
            <div key={i} className="process-step" style={{
              padding: "26px 24px 32px",
              borderRight: i < 3 ? "1px solid var(--line)" : "none",
              position: "relative"
            }}>
              <div style={{ display: "flex", justifyContent: "space-between", marginBottom: 18 }}>
                <Label style={{ color: "var(--accent)", fontSize: 14, fontWeight: 500 }}>{s.n}</Label>
                <Label style={{ color: "var(--fg-3)" }}>{s.meta}</Label>
              </div>
              <h3 style={{ fontSize: 22, fontWeight: 500, letterSpacing: "-0.015em", margin: "0 0 10px" }}>{s.t}</h3>
              <p style={{ color: "var(--fg-2)", fontSize: 14.5, lineHeight: 1.55, margin: 0 }}>{s.d}</p>
            </div>
          ))}
        </div>
      </Container>
    </section>
  );
}

// =========================================================
// PRICING
// =========================================================
const PRICING_COPY = {
  friendly: {
    title: "Simple, flat pricing.",
    sub: "One flat fee to build. Ongoing maintenance is an optional add-on. Social media is priced around what you actually need.",
    plans: [
      { name: "Website",      price: "$200", priceLabel: "one-time", addon: "Ongoing maintenance available as an add-on", pitch: "A fast, modern website for your business.", features: ["Custom design", "Mobile-friendly", "Contact form", "Analytics set up", "You own everything"] },
      { name: "Mobile App",   price: "$500", priceLabel: "one-time", addon: "Ongoing maintenance available as an add-on", pitch: "An iOS and Android app for your business.", features: ["iOS + Android", "App store submission", "Push notifications", "Analytics set up", "You own everything"] },
      { name: "Social Media", price: "Custom", priceLabel: "based on your needs", addon: null, pitch: "Social media management, scoped to fit you.", features: ["Content calendar", "Posting on IG, FB, TikTok", "Real voice, not a bot", "Monthly report", "Scoped on the intro call"] }
    ]
  },
  direct: {
    title: "Three services. Three prices.",
    sub: "Websites are $200. Mobile apps are $500. Maintenance is an optional add-on for both. Social media is quoted per client.",
    plans: [
      { name: "Website",      price: "$200", priceLabel: "one-time", addon: "Maintenance add-on available", pitch: "Built fast. You own it.", features: ["Custom design", "Mobile-friendly", "Contact form", "Analytics", "Full ownership"] },
      { name: "Mobile App",   price: "$500", priceLabel: "one-time", addon: "Maintenance add-on available", pitch: "iOS + Android, submitted for you.", features: ["iOS + Android", "Store submission", "Push notifications", "Analytics", "Full ownership"] },
      { name: "Social Media", price: "Custom", priceLabel: "quoted per client", addon: null, pitch: "Tell us what you need. We'll quote it.", features: ["Content calendar", "IG, FB, TikTok", "Human-written posts", "Monthly report", "Scoped to your needs"] }
    ]
  },
  playful: {
    title: "Pick your thing. Or all three.",
    sub: "A website for $200, an app for $500, and social media tuned to whatever your business needs.",
    plans: [
      { name: "Website",      price: "$200", priceLabel: "one-time", addon: "Want us to keep it humming? Add maintenance.", pitch: "You want to look sharp online without the agency price tag.", features: ["Custom design", "Looks great on phones", "Contact form", "Analytics wired in", "It's yours, forever"] },
      { name: "Mobile App",   price: "$500", priceLabel: "one-time", addon: "Want us to keep it humming? Add maintenance.", pitch: "Your business, in your customers' pockets.", features: ["iOS + Android", "We handle the app stores", "Push notifications", "Analytics wired in", "It's yours, forever"] },
      { name: "Social Media", price: "Custom", priceLabel: "tuned to you", addon: null, pitch: "Tired of doing socials at 11pm? Hand it to us.", features: ["Content calendar", "IG, FB, TikTok", "Real voice, not a bot", "Monthly report", "We scope it together"] }
    ]
  }
};

function Pricing({ copy }) {
  const data = PRICING_COPY[copy] || PRICING_COPY.friendly;
  return (
    <section id="pricing" style={{ padding: "96px 0", borderTop: "1px solid var(--line)", background: "var(--surface)" }}>
      <Container>
        <SectionHead align="center" kicker="/pricing" title={data.title} sub={data.sub} />
        <div className="pricing-grid" style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16, marginTop: 56 }}>
          {data.plans.map((p, i) => (
            <PricingCard key={i} plan={p} index={i} featured={i === 1} />
          ))}
        </div>
        <div style={{ textAlign: "center", marginTop: 28, color: "var(--fg-3)" }} className="mono">
          no contracts · maintenance add-ons optional · you own everything
        </div>
      </Container>
    </section>
  );
}

function PricingCard({ plan, index, featured }) {
  return (
    <div style={{
      border: `1px solid ${featured ? "var(--fg)" : "var(--line-strong)"}`,
      background: featured ? "var(--fg)" : "var(--bg)",
      color: featured ? "var(--bg)" : "var(--fg)",
      borderRadius: 10, padding: "32px 28px 28px", position: "relative",
      transition: "transform 160ms", display: "flex", flexDirection: "column", gap: 18
    }}>
      {featured && (
        <span style={{
          position: "absolute", top: -10, left: 24, padding: "3px 8px",
          background: "var(--accent)", color: "var(--accent-fg)",
          fontFamily: "var(--mono)", fontSize: 10, letterSpacing: "0.08em",
          textTransform: "uppercase", borderRadius: 4
        }}>most picked</span>
      )}
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline" }}>
        <h3 style={{ fontSize: 22, fontWeight: 500, letterSpacing: "-0.01em", margin: 0 }}>{plan.name}</h3>
        <Label style={{ color: featured ? "color-mix(in oklab, var(--bg) 60%, var(--fg))" : "var(--fg-3)" }}>
          0{index + 1}
        </Label>
      </div>
      <p style={{ fontSize: 14.5, lineHeight: 1.5, margin: 0, color: featured ? "color-mix(in oklab, var(--bg) 70%, var(--fg))" : "var(--fg-2)" }}>{plan.pitch}</p>
      <div style={{ borderTop: `1px solid ${featured ? "color-mix(in oklab, var(--bg) 25%, transparent)" : "var(--line)"}`, paddingTop: 18 }}>
        <div style={{ fontFamily: "var(--mono)", fontSize: 30, fontWeight: 500, letterSpacing: "-0.02em" }}>{plan.price}</div>
        <Label style={{ color: featured ? "color-mix(in oklab, var(--bg) 60%, var(--fg))" : "var(--fg-3)" }}>{plan.priceLabel}</Label>
        {plan.addon && (
          <div style={{ marginTop: 10, fontSize: 13.5, lineHeight: 1.45, color: featured ? "color-mix(in oklab, var(--bg) 65%, var(--fg))" : "var(--fg-2)" }}>
            + {plan.addon}
          </div>
        )}
      </div>
      <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 10 }}>
        {plan.features.map((f, i) => (
          <li key={i} style={{ display: "flex", alignItems: "flex-start", gap: 10, fontSize: 14.5, lineHeight: 1.45 }}>
            <span style={{ fontFamily: "var(--mono)", color: featured ? "color-mix(in oklab, var(--bg) 50%, var(--fg))" : "var(--fg-3)", fontSize: 11, marginTop: 4, minWidth: 18 }}>{String(i+1).padStart(2,"0")}</span>
            <span>{f}</span>
          </li>
        ))}
      </ul>
      <Btn
        variant={featured ? "soft" : "ghost"}
        as="a"
        href="#contact"
        style={featured ? { background: "var(--bg)", color: "var(--fg)", borderColor: "transparent", marginTop: "auto" } : { marginTop: "auto" }}>
        Choose {plan.name} <Arrow />
      </Btn>
    </div>
  );
}

// =========================================================
// FAQ
// =========================================================
function FAQ() {
  const items = [
    { q: "Who owns the website, app, and accounts?", a: "You do. Always. We set everything up in your name and hand you admin access on day one. If you ever leave us, you walk away with the whole hub." },
    { q: "Do I have to commit to a long contract?", a: "No. The maintenance add-on is month-to-month, and social media is scoped to what you need. Cancel anytime." },
    { q: "What if I already have a website I like?", a: "Great. We'll audit what you have and fold it into a maintenance add-on, or quote social media on its own." },
    { q: "How fast can we launch?", a: "Websites are typically live in 10–14 business days from signed scope. Apps take a bit longer with store review. We don't drag it out." },
    { q: "Do you work with businesses outside the US?", a: "Yes, if you're okay with Central Time. We've worked with clients in Canada, the UK, and Mexico." },
    { q: "What does the maintenance add-on cover?", a: "Hosting, monitoring, backups, security patches, and small edits. Available for both websites and mobile apps. Bigger changes are quoted separately but usually take a day." }
  ];
  return (
    <section id="faq" style={{ padding: "96px 0", borderTop: "1px solid var(--line)" }}>
      <Container>
        <div className="resp-2col" style={{ display: "grid", gridTemplateColumns: "0.9fr 1.4fr", gap: 56 }}>
          <div className="faq-side" style={{ position: "sticky", top: 100, alignSelf: "start" }}>
            <SectionHead kicker="/faq" title="Questions we get, honestly answered." sub="If yours isn't here, send us a note through the form below and we'll answer in a day." />
            <div style={{ marginTop: 24 }}>
              <Btn as="a" href="#contact" variant="ghost">Ask us something <Arrow /></Btn>
            </div>
          </div>
          <Accordion items={items} />
        </div>
      </Container>
    </section>
  );
}

// =========================================================
// CONTACT
// =========================================================
function Contact() {
  const [form, setForm] = useStateS({ name: "", email: "", business: "", budget: "website", message: "" });
  const [errs, setErrs] = useStateS({});
  const [status, setStatus] = useStateS("idle");
  const validate = () => {
    const e = {};
    if (!form.name.trim()) e.name = "Tell us what to call you";
    if (!/^\S+@\S+\.\S+$/.test(form.email)) e.email = "Need a valid email";
    if (!form.business.trim()) e.business = "What do you do?";
    return e;
  };
  const submit = (e) => {
    e.preventDefault();
    const er = validate();
    setErrs(er);
    if (Object.keys(er).length) return;
    setStatus("sending");
    setTimeout(() => setStatus("sent"), 900);
  };
  return (
    <section id="contact" style={{ padding: "96px 0", borderTop: "1px solid var(--line)", background: "var(--surface)" }}>
      <Container>
        <div className="resp-2col" style={{ display: "grid", gridTemplateColumns: "1fr 1.3fr", gap: 64, alignItems: "start" }}>
          <div>
            <Label style={{ color: "var(--accent)" }}><Dot color="var(--accent)" pulse /> &nbsp;accepting clients</Label>
            <h2 style={{ fontFamily: "var(--sans)", fontWeight: 600, letterSpacing: "-0.03em", fontSize: "clamp(36px, 4.4vw, 56px)", lineHeight: 1.02, margin: "20px 0 16px", textWrap: "balance" }}>
              Let's scope your hub.
            </h2>
            <p style={{ color: "var(--fg-2)", fontSize: 17, lineHeight: 1.5, maxWidth: 420, margin: "0 0 32px" }}>
              Fill this out and we'll reply within one business day with a 30-minute intro call. No pitch deck, no sales rep.
            </p>
            <dl style={{ margin: 0, display: "grid", gridTemplateColumns: "auto 1fr", gap: "10px 18px", fontSize: 14.5 }}>
              <dt className="mono">phone</dt>     <dd style={{ margin: 0 }}>(512) 710-6259</dd>
              <dt className="mono">address</dt>   <dd style={{ margin: 0 }}>Austin, Texas</dd>
              <dt className="mono">instagram</dt> <dd style={{ margin: 0 }}><a href="https://www.instagram.com/skillhub.builders/" target="_blank" rel="noopener noreferrer" style={{ textDecoration: "underline", textUnderlineOffset: 3 }}>@skillhub.builders</a></dd>
            </dl>
          </div>
          <form onSubmit={submit} style={{
            border: "1px solid var(--line-strong)", borderRadius: 10, padding: 24,
            background: "var(--bg)", display: "grid", gap: 14
          }}>
            <Field label="Your name" err={errs.name}>
              <input value={form.name} onChange={e=>setForm({...form, name: e.target.value})} placeholder="Sam Ortega" style={inputStyle} />
            </Field>
            <div className="resp-form-row" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14 }}>
              <Field label="Email" err={errs.email}>
                <input value={form.email} onChange={e=>setForm({...form, email: e.target.value})} placeholder="sam@bakery.com" style={inputStyle} />
              </Field>
              <Field label="Business" err={errs.business}>
                <input value={form.business} onChange={e=>setForm({...form, business: e.target.value})} placeholder="Acme Bakery" style={inputStyle} />
              </Field>
            </div>
            <Field label="What do you need?">
              <div style={{ display: "grid", gridTemplateColumns: "repeat(3,1fr)", gap: 8 }}>
                {[["website","Website"],["app","Mobile App"],["social","Social"]].map(([v, l]) => (
                  <button type="button" key={v} onClick={() => setForm({...form, budget: v})}
                    style={{
                      padding: "10px 12px", borderRadius: 6, fontFamily: "var(--mono)",
                      fontSize: 11, letterSpacing: "0.05em", textTransform: "uppercase",
                      border: `1px solid ${form.budget===v ? "var(--fg)" : "var(--line-strong)"}`,
                      background: form.budget===v ? "var(--fg)" : "transparent",
                      color: form.budget===v ? "var(--bg)" : "var(--fg-2)"
                    }}>{l}</button>
                ))}
              </div>
            </Field>
            <Field label="Tell us more">
              <textarea value={form.message} onChange={e=>setForm({...form, message: e.target.value})} rows={4}
                placeholder="A rough sketch is fine. A list of URLs you like is better." style={{...inputStyle, resize: "vertical", fontFamily: "var(--sans)"}} />
            </Field>
            <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", marginTop: 6 }}>
              <span className="mono" style={{ color: "var(--fg-3)" }}>
                {status === "sent" ? "✓ received — check your inbox" : status === "sending" ? "sending…" : "1-business-day reply"}
              </span>
              <Btn as="button" disabled={status !== "idle"} style={{ opacity: status !== "idle" ? 0.6 : 1 }}>
                {status === "sent" ? "Sent" : status === "sending" ? "Sending…" : "Send request"} <Arrow />
              </Btn>
            </div>
          </form>
        </div>
      </Container>
    </section>
  );
}
const inputStyle = {
  width: "100%", padding: "12px 14px", border: "1px solid var(--line-strong)",
  borderRadius: 6, background: "var(--surface)", color: "var(--fg)",
  fontFamily: "var(--sans)", fontSize: 15, outline: "none"
};
function Field({ label, err, children }) {
  return (
    <label style={{ display: "grid", gap: 6 }}>
      <span className="mono" style={{ color: err ? "var(--warn)" : "var(--fg-2)" }}>
        {label}{err ? ` — ${err}` : ""}
      </span>
      {children}
    </label>
  );
}

// =========================================================
// FOOTER
// =========================================================
function Footer() {
  return (
    <footer style={{ borderTop: "1px solid var(--line-strong)", padding: "40px 0 28px", background: "var(--bg)" }}>
      <Container>
        <div className="footer-grid" style={{ display: "grid", gridTemplateColumns: "1.5fr 1fr 1fr 1fr", gap: 40, marginBottom: 40 }}>
          <div>
            <a href="#top" style={{ display: "inline-flex", alignItems: "center", gap: 10 }}>
              <Logo />
              <span style={{ fontFamily: "var(--mono)", fontSize: 14, fontWeight: 600 }}>skillhub.builders</span>
            </a>
            <p style={{ color: "var(--fg-2)", fontSize: 14, lineHeight: 1.5, margin: "14px 0 0", maxWidth: 320 }}>
              We build your hub with our skills.<br/>A small client-services agency for local businesses.
            </p>
          </div>
          <FooterCol title="Services" items={[
            { label: "Website", href: "#services" },
            { label: "Mobile App", href: "#services" },
            { label: "Social Media", href: "#services" },
            { label: "Maintenance add-on", href: "#pricing" }
          ]} />
          <FooterCol title="Studio" items={[
            { label: "About", href: "#top" },
            { label: "Pricing", href: "#pricing" },
            { label: "FAQ", href: "#faq" }
          ]} />
          <FooterCol title="Contact" items={[
            { label: "(512) 710-6259", href: "tel:+15127106259" },
            { label: "Austin, Texas" },
            { label: "Instagram", href: "https://www.instagram.com/skillhub.builders/" }
          ]} />
        </div>
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", borderTop: "1px solid var(--line)", paddingTop: 18, flexWrap: "wrap", gap: 10 }}>
          <span className="mono" style={{ color: "var(--fg-3)" }}>© 2026 skillhub builders, llc · all systems nominal</span>
          <span className="mono" style={{ color: "var(--fg-3)" }}>v1.0.0 · last deploy 4m ago</span>
        </div>
      </Container>
    </footer>
  );
}
function FooterCol({ title, items }) {
  return (
    <div>
      <Label style={{ color: "var(--fg-3)", marginBottom: 14 }}>{title}</Label>
      <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 10 }}>
        {items.map(({ label, href }, i) => (
          <li key={i}>
            {href ? (
              <a href={href} target={href.startsWith("http") ? "_blank" : undefined} rel={href.startsWith("http") ? "noopener noreferrer" : undefined} style={{ fontSize: 14.5, color: "var(--fg)" }}>{label}</a>
            ) : (
              <span style={{ fontSize: 14.5, color: "var(--fg)" }}>{label}</span>
            )}
          </li>
        ))}
      </ul>
    </div>
  );
}

Object.assign(window, { Nav, Hero, Services, Process, Pricing, FAQ, Contact, Footer, PRICING_COPY });
