// Sections for the RLC site (matching the original site's structure):
// About, Services, Experience (case studies), Expertise, Impact, Contact

const { useEffect, useRef, useState } = React;

// ───────────────────────────────────────────── Reveal-on-scroll
function useReveal() {
  const ref = useRef(null);
  const [visible, setVisible] = useState(false);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const obs = new IntersectionObserver(([e]) => {
      if (e.isIntersecting) {
        setVisible(true);
        obs.disconnect();
      }
    }, { threshold: 0.15, rootMargin: "0px 0px -10% 0px" });
    obs.observe(el);
    return () => obs.disconnect();
  }, []);
  return [ref, visible];
}

function Reveal({ children, delay = 0, motion = "medium", as: Tag = "div", style = {}, className }) {
  const [ref, visible] = useReveal();
  const enabled = motion !== "subtle" || true; // always on; intensity differs in transform
  const distance = motion === "rich" ? 32 : motion === "medium" ? 20 : 12;
  const dur = motion === "rich" ? 900 : motion === "medium" ? 700 : 500;
  return (
    <Tag
      ref={ref}
      className={className}
      style={{
        ...style,
        opacity: visible ? 1 : 0,
        transform: visible ? "translateY(0)" : `translateY(${distance}px)`,
        transition: `opacity ${dur}ms cubic-bezier(.2,.7,.2,1) ${delay}ms, transform ${dur}ms cubic-bezier(.2,.7,.2,1) ${delay}ms`,
      }}
    >
      {children}
    </Tag>
  );
}

// ───────────────────────────────────────────── Eyebrow
function Eyebrow({ children, color = "#0F8C6E" }) {
  return (
    <div style={{
      fontFamily: "Outfit, sans-serif",
      fontSize: 11,
      fontWeight: 600,
      letterSpacing: "3px",
      textTransform: "uppercase",
      color,
      marginBottom: 16,
      display: "flex",
      alignItems: "center",
      gap: 12,
    }}>
      <span style={{ width: 24, height: 1, background: color, opacity: 0.7 }} />
      {children}
    </div>
  );
}

// ───────────────────────────────────────────── Counter (counts up on view)
function Counter({ to, prefix = "", suffix = "", duration = 1600, motion = "medium" }) {
  const [ref, visible] = useReveal();
  const [val, setVal] = useState(0);
  useEffect(() => {
    if (!visible) return;
    if (motion === "subtle") { setVal(to); return; }
    const start = performance.now();
    let raf;
    const tick = (now) => {
      const t = Math.min(1, (now - start) / duration);
      const eased = 1 - Math.pow(1 - t, 3);
      setVal(to * eased);
      if (t < 1) raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, [visible, to, duration, motion]);
  const display = to >= 1000000
    ? `${(val / 1000000).toFixed(val < to ? 1 : 0)}M`
    : to >= 1000
    ? Math.round(val).toLocaleString()
    : Math.round(val).toString();
  return <span ref={ref}>{prefix}{display}{suffix}</span>;
}

// ───────────────────────────────────────────── About
function AboutSection({ density, motion }) {
  const pad = density === "compact" ? "80px 0" : density === "comfy" ? "160px 0" : "120px 0";
  return (
    <section id="about" style={{ background: "#ffffff", padding: pad }}>
      <div style={{ maxWidth: 1180, margin: "0 auto", padding: "0 48px", display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 80, alignItems: "start" }}>
        <Reveal motion={motion}>
          <Eyebrow>About</Eyebrow>
          <h2 style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 44, lineHeight: 1.05, letterSpacing: "-1px", color: "#0c1624", margin: 0 }}>
            A senior advisor who has been in the room.
          </h2>
        </Reveal>
        <Reveal motion={motion} delay={120}>
          <p style={{ fontFamily: "Outfit, sans-serif", fontSize: 19, lineHeight: 1.7, color: "#3a4a5c", margin: "8px 0 24px", textWrap: "pretty" }}>
            Rey López-Calderón, J.D., is the principal of RLC Development Solutions. For more than 25 years he has built, rebuilt, and grown nonprofits across the United States — reversing deficits, designing fundraising infrastructure, and coaching boards and executives through transitions.
          </p>
          <p style={{ fontFamily: "Outfit, sans-serif", fontSize: 19, lineHeight: 1.7, color: "#3a4a5c", margin: "0 0 32px", textWrap: "pretty" }}>
            His specialty is civic, charitable, and nonpartisan advocacy organizations. He has led national campaigns, founded several organizations from the ground up, and stewarded portfolios of six-figure donors and 100,000+ member bases.
          </p>
          <div style={{ display: "flex", gap: 32, paddingTop: 24, borderTop: "1px solid #e8eef4" }}>
            <div>
              <div style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 14, color: "#0c1624", letterSpacing: "0.05em" }}>EDUCATION</div>
              <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 15, color: "#5A6E82", marginTop: 4 }}>A.B., J.D., University of Chicago, DePaul College of Law</div>
            </div>
            <div>
              <div style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 14, color: "#0c1624", letterSpacing: "0.05em" }}>BASED IN</div>
              <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 15, color: "#5A6E82", marginTop: 4 }}>San Diego, CA · Serving nationally</div>
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

// ───────────────────────────────────────────── Services
const SERVICES = [
  {
    n: "01",
    title: "Fundraising Infrastructure",
    body: "CRM selection, gift processing, donor pipelines, and the operational backbone that turns one-time gifts into sustained revenue. We diagnose what's broken and rebuild it.",
    icon: "infra",
  },
  {
    n: "02",
    title: "Major Gifts Strategy",
    body: "Portfolio design, moves management, and direct coaching for executives meeting six- and seven-figure prospects. From discovery to close.",
    icon: "gifts",
  },
  {
    n: "03",
    title: "Strategic Planning",
    body: "Multi-year fundraising plans grounded in your theory of change. We facilitate boards and senior staff through priorities, capacity, and a real path to scale.",
    icon: "strategy",
  },
  {
    n: "04",
    title: "Leadership & Transitions",
    body: "Executive director searches, board restructuring, and interim development leadership during moments when the wrong hire could set you back two years.",
    icon: "leadership",
  },
  {
    n: "05",
    title: "Advocacy Counsel",
    body: "Specialized fundraising counsel for nonpartisan civic, democracy, and advocacy organizations — with a working knowledge of 501(c)(3) and (c)(4) coordination.",
    icon: "advocacy",
  },
  {
    n: "06",
    title: "Deficit Recovery",
    body: "When the budget breaks. Rapid assessment, donor outreach, expense rationalization, and a 90-day plan to stabilize and a 12-month plan to grow.",
    icon: "recovery",
  },
];

function ServiceIcon({ kind, color = "#0099ff" }) {
  const common = { width: 28, height: 28, viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: 1.6, strokeLinecap: "square", strokeLinejoin: "miter" };
  if (kind === "infra") return <svg {...common}><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/></svg>;
  if (kind === "gifts") return <svg {...common}><path d="M3 12h18M12 3v18M5 5l14 14M19 5L5 19"/></svg>;
  if (kind === "strategy") return <svg {...common}><path d="M3 20h18M6 20V10M12 20V4M18 20v-7"/></svg>;
  if (kind === "leadership") return <svg {...common}><circle cx="12" cy="8" r="3"/><path d="M5 21c0-3.5 3-6 7-6s7 2.5 7 6"/></svg>;
  if (kind === "advocacy") return <svg {...common}><path d="M3 12l9-9 9 9-9 9z"/><path d="M12 7v10"/></svg>;
  if (kind === "recovery") return <svg {...common}><path d="M3 17l6-6 4 4 8-8"/><path d="M14 7h7v7"/></svg>;
  return null;
}

function ServicesSection({ density, motion, tealAccent }) {
  const pad = density === "compact" ? "80px 0" : density === "comfy" ? "160px 0" : "120px 0";
  return (
    <section id="services" style={{ background: "#F5F5F2", padding: pad }}>
      <div style={{ maxWidth: 1180, margin: "0 auto", padding: "0 48px" }}>
        <Reveal motion={motion}>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 1.6fr", gap: 80, alignItems: "end", marginBottom: 64 }}>
            <div>
              <Eyebrow>What we do</Eyebrow>
              <h2 style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 56, lineHeight: 1.02, letterSpacing: "-1.5px", color: "#0c1624", margin: 0 }}>
                Six things,<br/>done well.
              </h2>
            </div>
            <p style={{ fontFamily: "Outfit, sans-serif", fontSize: 19, lineHeight: 1.7, color: "#3a4a5c", margin: 0, textWrap: "pretty", paddingBottom: 8 }}>
              Engagements range from short diagnostics to multi-year retainers. We build it with you — and stay until it works.
            </p>
          </div>
        </Reveal>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 1, background: "#dde8f0", border: "1px solid #dde8f0" }}>
          {SERVICES.map((s, i) => (
            <Reveal key={s.n} motion={motion} delay={i * 80}>
              <div className="rlc-svc" style={{ background: "#ffffff", padding: "44px 36px", height: "100%", position: "relative", transition: "background 220ms ease" }}>
                <div style={{ position: "absolute", top: 0, left: 0, height: 3, width: tealAccent ? "100%" : 0, background: "#0F8C6E", transition: "width 320ms ease", opacity: 0 }} className="rlc-svc-bar" />
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", marginBottom: 24 }}>
                  <ServiceIcon kind={s.icon} color="#0099ff" />
                  <span style={{ fontFamily: "Outfit, sans-serif", fontSize: 12, fontWeight: 300, color: "#7a9bb5", letterSpacing: "0.1em" }}>{s.n}</span>
                </div>
                <h3 style={{ fontFamily: "Outfit, sans-serif", fontWeight: 600, fontSize: 22, lineHeight: 1.25, letterSpacing: "-0.5px", color: "#0c1624", margin: "0 0 12px" }}>{s.title}</h3>
                <p style={{ fontFamily: "Outfit, sans-serif", fontSize: 15, lineHeight: 1.65, color: "#5A6E82", margin: 0, textWrap: "pretty" }}>{s.body}</p>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
      <style>{`.rlc-svc:hover .rlc-svc-bar{opacity:1}`}</style>
    </section>
  );
}

// ───────────────────────────────────────────── Experience / Case Studies
const CASES = [
  {
    org: "Cal RCV",
    tag: "Fundraising & Strategy Consulting",
    body: "Developed a comprehensive, multi-year fundraising plan for the California Ranked-Choice Voting Institute, and supported board restructuring and executive director recruitment — helping position the organization for its next phase of growth.",
    metric: "Multi-year",
    metricLabel: "Fundraising plan",
  },
  {
    org: "More Equitable Democracy",
    tag: "2020–2025",
    body: "Grew More Equitable Democracy's annual budget from $300,000 to over $6 million through strategic fundraising counsel and donor development.",
    metric: "20×",
    metricLabel: "Budget growth",
  },
  {
    org: "Common Cause",
    tag: "National VP for Development",
    body: "Inherited a $2 million structural deficit upon taking over the Development Department. Reengineered fundraising operations, donor pipelines, and major-gift strategy — exiting the role with a $16 million surplus, while managing a portfolio of 150+ mid-level through six-figure donors and stewarding a membership base exceeding 100,000 supporters.",
    metric: "$16M",
    metricLabel: "Surplus (from $2M deficit)",
  },
  {
    org: "Alliance of the Southeast · Common Cause Illinois",
    tag: "Founder & Director",
    body: "Founded and led two organizations — Alliance of the Southeast in Chicago and Common Cause Illinois (reestablished) — staffing, fundraising, and building them into fully operational civic institutions.",
    metric: "2",
    metricLabel: "Organizations built",
  },
];

function ExperienceSection({ density, motion }) {
  const pad = density === "compact" ? "80px 0" : density === "comfy" ? "160px 0" : "120px 0";
  return (
    <section id="experience" style={{ background: "#0c1624", padding: pad, color: "#ffffff", position: "relative", overflow: "hidden" }}>
      <div style={{ maxWidth: 1180, margin: "0 auto", padding: "0 48px", position: "relative" }}>
        <Reveal motion={motion}>
          <Eyebrow color="#0F8C6E">Selected engagements</Eyebrow>
          <h2 style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 56, lineHeight: 1.02, letterSpacing: "-1.5px", color: "#ffffff", margin: "0 0 80px", maxWidth: 720 }}>
            Real organizations.<br/><span style={{ color: "#0099ff" }}>Real numbers.</span>
          </h2>
        </Reveal>
        <div style={{ display: "flex", flexDirection: "column", gap: 0 }}>
          {CASES.map((c, i) => (
            <Reveal key={i} motion={motion} delay={i * 100}>
              <article className="rlc-case" style={{
                display: "grid",
                gridTemplateColumns: "120px 1fr 280px",
                gap: 48,
                padding: "44px 0",
                borderBottom: "1px solid #1a3050",
                borderTop: i === 0 ? "1px solid #1a3050" : "none",
                alignItems: "start",
                transition: "padding 280ms ease",
              }}>
                <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 12, fontWeight: 300, color: "#7a9bb5", letterSpacing: "0.15em", paddingTop: 8 }}>0{i + 1} / 0{CASES.length}</div>
                <div>
                  <div style={{ fontFamily: "Outfit, sans-serif", fontWeight: 600, fontSize: 22, color: "#ffffff", letterSpacing: "-0.3px", marginBottom: 6 }}>{c.org}</div>
                  <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 11, fontWeight: 600, color: "#0F8C6E", letterSpacing: "3px", textTransform: "uppercase", marginBottom: 20 }}>{c.tag}</div>
                  <p style={{ fontFamily: "Outfit, sans-serif", fontSize: 17, lineHeight: 1.65, color: "#c9d6e3", margin: 0, maxWidth: 620, textWrap: "pretty" }}>{c.body}</p>
                </div>
                <div style={{ textAlign: "right" }}>
                  <div style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 56, lineHeight: 1, letterSpacing: "-2px", color: "#0099ff" }}>{c.metric}</div>
                  <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 12, color: "#7a9bb5", letterSpacing: "0.1em", marginTop: 8, textTransform: "uppercase" }}>{c.metricLabel}</div>
                </div>
              </article>
            </Reveal>
          ))}
        </div>
      </div>
      <style>{`.rlc-case:hover{background:linear-gradient(90deg, rgba(0,153,255,.04), transparent 40%);padding-left:16px !important;padding-right:16px !important}`}</style>
    </section>
  );
}

// ───────────────────────────────────────────── Expertise (skills)
const EXPERTISE = [
  "Fundraising Infrastructure", "Major Gifts", "Monthly Sustainer Campaigns",
  "Board Development", "Executive Search", "Strategic Planning",
  "Direct Marketing", "Grant Strategy", "501(c)(3)/(c)(4) Coordination",
  "Coalition Building", "Planned Giving", "Deficit Turnaround",
];

function ExpertiseSection({ density, motion }) {
  const pad = density === "compact" ? "80px 0" : density === "comfy" ? "160px 0" : "120px 0";
  return (
    <section id="expertise" style={{ background: "#ffffff", padding: pad }}>
      <div style={{ maxWidth: 1180, margin: "0 auto", padding: "0 48px" }}>
        <Reveal motion={motion}>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 2fr", gap: 80, alignItems: "start" }}>
            <div>
              <Eyebrow>Expertise</Eyebrow>
              <h2 style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 44, lineHeight: 1.05, letterSpacing: "-1px", color: "#0c1624", margin: 0 }}>
                The full stack of nonprofit development.
              </h2>
            </div>
            <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "1px", background: "#dde8f0", border: "1px solid #dde8f0" }}>
              {EXPERTISE.map((e, i) => (
                <div key={e} style={{
                  background: "#ffffff",
                  padding: "24px 20px",
                  fontFamily: "Outfit, sans-serif",
                  fontSize: 15,
                  fontWeight: 500,
                  color: "#0c1624",
                  letterSpacing: "-0.2px",
                  display: "flex",
                  alignItems: "center",
                  gap: 12,
                }}>
                  <span style={{ fontFamily: "Outfit, sans-serif", fontSize: 11, fontWeight: 300, color: "#7a9bb5", letterSpacing: "0.1em" }}>{String(i + 1).padStart(2, "0")}</span>
                  {e}
                </div>
              ))}
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

// ───────────────────────────────────────────── Impact
function ImpactSection({ density, motion }) {
  const pad = density === "compact" ? "80px 0" : density === "comfy" ? "160px 0" : "120px 0";
  const stats = [
    { value: 25, suffix: "+", label: "Years building nonprofits" },
    { value: 6, prefix: "$", suffix: "M+", label: "Annual budget grown for one client" },
    { value: 16, prefix: "$", suffix: "M", label: "Surplus rebuilt from a $2M deficit" },
    { value: 150, suffix: "+", label: "Major-gift portfolio managed" },
  ];
  return (
    <section id="impact" style={{ background: "#F5F5F2", padding: pad }}>
      <div style={{ maxWidth: 1180, margin: "0 auto", padding: "0 48px" }}>
        <Reveal motion={motion}>
          <Eyebrow>By the numbers</Eyebrow>
          <h2 style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 44, lineHeight: 1.05, letterSpacing: "-1px", color: "#0c1624", margin: "0 0 64px", maxWidth: 720 }}>
            What 25 years of doing the work actually adds up to.
          </h2>
        </Reveal>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 24 }}>
          {stats.map((s, i) => (
            <Reveal key={i} motion={motion} delay={i * 100}>
              <div style={{ borderTop: "2px solid #0099ff", paddingTop: 24 }}>
                <div style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 64, lineHeight: 1, letterSpacing: "-2.5px", color: "#0c1624" }}>
                  <Counter to={s.value} prefix={s.prefix || ""} suffix={s.suffix || ""} motion={motion} />
                </div>
                <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 15, lineHeight: 1.4, color: "#5A6E82", marginTop: 16, textWrap: "pretty" }}>{s.label}</div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ───────────────────────────────────────────── Contact
function ContactSection({ density, motion }) {
  const pad = density === "compact" ? "80px 0" : density === "comfy" ? "160px 0" : "120px 0";
  const [submitted, setSubmitted] = useState(false);
  const [submitting, setSubmitting] = useState(false);
  const [error, setError] = useState(false);
  const formRef = useRef(null);

  async function handleSubmit(e) {
    e.preventDefault();
    if (submitting || submitted) return;
    setError(false);
    setSubmitting(true);
    const form = e.currentTarget;
    const data = new FormData(form);
    try {
      const res = await fetch("https://formspree.io/f/xlgalrwk", {
        method: "POST",
        headers: { "Accept": "application/json" },
        body: data,
      });
      if (res.ok) {
        setSubmitted(true);
        form.reset();
      } else {
        setError(true);
      }
    } catch {
      setError(true);
    } finally {
      setSubmitting(false);
    }
  }

  return (
    <section id="contact" style={{ background: "#0c1624", padding: pad, position: "relative", overflow: "hidden" }}>
      {/* Ghost mark in background */}
      <div style={{ position: "absolute", right: -120, top: "50%", transform: "translateY(-50%)", opacity: 0.06, pointerEvents: "none" }}>
        <RLCMark size={520} variant="white" />
      </div>
      <div style={{ maxWidth: 1180, margin: "0 auto", padding: "0 48px", position: "relative", display: "grid", gridTemplateColumns: "1fr 1fr", gap: 80 }}>
        <Reveal motion={motion}>
          <Eyebrow color="#0F8C6E">Let's talk</Eyebrow>
          <h2 style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 64, lineHeight: 1, letterSpacing: "-2px", color: "#ffffff", margin: "0 0 32px" }}>
            Ready to grow your mission?
          </h2>
          <p style={{ fontFamily: "Outfit, sans-serif", fontSize: 19, lineHeight: 1.7, color: "#7a9bb5", margin: "0 0 40px", maxWidth: 480, textWrap: "pretty" }}>
            Tell me about the organization and where you're stuck. Most engagements start with a 45-minute call — no pitch deck, no charge.
          </p>
          <div style={{ display: "flex", flexDirection: "column", gap: 20, fontFamily: "Outfit, sans-serif" }}>
            <a href="mailto:rey@rlcdevelopment.com" style={{ color: "#ffffff", fontSize: 17, textDecoration: "none", borderBottom: "1px solid #0F8C6E", paddingBottom: 4, alignSelf: "flex-start" }}>rey@rlcdevelopment.com</a>
            <a href="tel:+16197864838" style={{ color: "#ffffff", fontSize: 17, textDecoration: "none", borderBottom: "1px solid #0F8C6E", paddingBottom: 4, alignSelf: "flex-start" }}>(619) 786-4838</a>
            <a href="https://www.linkedin.com/in/rey-david-lopez-calderon-jd-1396343/" style={{ color: "#0099ff", fontSize: 15, textDecoration: "none", display: "inline-flex", alignItems: "center", gap: 8, alignSelf: "flex-start" }}>
              <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20.45 20.45h-3.55v-5.57c0-1.33-.02-3.04-1.85-3.04-1.85 0-2.14 1.45-2.14 2.94v5.67H9.36V9h3.41v1.56h.05c.47-.9 1.64-1.85 3.37-1.85 3.6 0 4.27 2.37 4.27 5.46v6.28zM5.34 7.43a2.06 2.06 0 1 1 0-4.13 2.06 2.06 0 0 1 0 4.13zM7.12 20.45H3.56V9h3.56v11.45zM22.22 0H1.77C.79 0 0 .77 0 1.72v20.56C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.72V1.72C24 .77 23.2 0 22.22 0z"/></svg>
              LinkedIn →
            </a>
          </div>
        </Reveal>
        <Reveal motion={motion} delay={120}>
          <form ref={formRef} action="https://formspree.io/f/xlgalrwk" method="POST" onSubmit={handleSubmit} style={{ display: "flex", flexDirection: "column", gap: 20 }}>
            <FormField label="Name" name="name" />
            <FormField label="Organization" name="org" />
            <FormField label="Email" name="email" type="email" />
            <FormField label="What are you working on?" name="msg" textarea />
            <button type="submit" disabled={submitting || submitted} style={{
              background: submitted ? "#0F8C6E" : "#0099ff",
              color: "#ffffff",
              fontFamily: "Outfit, sans-serif",
              fontWeight: 600,
              fontSize: 14,
              letterSpacing: "0.15em",
              textTransform: "uppercase",
              padding: "20px 32px",
              border: 0,
              borderRadius: 0,
              cursor: submitting || submitted ? "default" : "pointer",
              marginTop: 8,
              transition: "background 200ms ease, transform 200ms ease",
            }} onMouseEnter={(e) => { if (submitted || submitting) return; e.currentTarget.style.background = "#33adff"; e.currentTarget.style.transform = "translateY(-2px)"; }} onMouseLeave={(e) => { if (submitted) return; e.currentTarget.style.background = "#0099ff"; e.currentTarget.style.transform = "translateY(0)"; }}>
              {submitted ? "Sent — I'll be in touch ✓" : submitting ? "Sending…" : "Send →"}
            </button>
            {error && (
              <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 14, color: "#ff8888", marginTop: 4 }}>
                Something went wrong. Email <a href="mailto:rey@rlcdevelopment.com" style={{ color: "#ffffff" }}>rey@rlcdevelopment.com</a> directly.
              </div>
            )}
          </form>
        </Reveal>
      </div>
    </section>
  );
}

function FormField({ label, name, type = "text", textarea }) {
  const [focused, setFocused] = useState(false);
  const [value, setValue] = useState("");
  const Tag = textarea ? "textarea" : "input";
  return (
    <label style={{ display: "block", position: "relative", paddingTop: 18 }}>
      <span style={{
        position: "absolute",
        left: 0,
        top: focused || value ? 0 : 32,
        fontFamily: "Outfit, sans-serif",
        fontSize: focused || value ? 11 : 15,
        fontWeight: focused || value ? 600 : 400,
        letterSpacing: focused || value ? "0.15em" : "0",
        textTransform: focused || value ? "uppercase" : "none",
        color: focused ? "#0099ff" : "#7a9bb5",
        transition: "all 200ms ease",
        pointerEvents: "none",
      }}>{label}</span>
      <Tag
        type={type}
        name={name}
        value={value}
        onChange={(e) => setValue(e.target.value)}
        onFocus={() => setFocused(true)}
        onBlur={() => setFocused(false)}
        rows={textarea ? 4 : undefined}
        style={{
          width: "100%",
          background: "transparent",
          border: 0,
          borderBottom: `1px solid ${focused ? "#0099ff" : "#1a3050"}`,
          color: "#ffffff",
          fontFamily: "Outfit, sans-serif",
          fontSize: 17,
          padding: "10px 0",
          outline: "none",
          resize: textarea ? "vertical" : undefined,
          transition: "border-color 200ms ease",
        }}
      />
    </label>
  );
}

// ───────────────────────────────────────────── Footer
function Footer() {
  return (
    <footer style={{ background: "#0c1624", borderTop: "1px solid #1a3050", padding: "48px 0", color: "#2a5070" }}>
      <div style={{ maxWidth: 1180, margin: "0 auto", padding: "0 48px", display: "flex", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 24 }}>
        <a href="#" style={{ display: "inline-flex", alignItems: "center", gap: 14, textDecoration: "none" }}>
          <RLCMark size={36} variant="dark" />
          <div style={{ lineHeight: 1, display: "flex", flexDirection: "column", gap: 4 }}>
            <span style={{ fontFamily: "Outfit, sans-serif", fontWeight: 700, fontSize: 14, letterSpacing: "0.32em", color: "#0099ff" }}>RLC</span>
            <span style={{ fontFamily: "Outfit, sans-serif", fontWeight: 400, fontSize: 9, letterSpacing: "0.22em", color: "#5a7088", textTransform: "uppercase" }}>Development Solutions</span>
          </div>
        </a>
        <div style={{ fontFamily: "Outfit, sans-serif", fontSize: 13, color: "#2a5070", letterSpacing: "0.05em" }}>
          © 2026 RLC Development Solutions · Chicago, IL
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, {
  Reveal, Eyebrow, Counter,
  AboutSection, ServicesSection, ExperienceSection, ExpertiseSection, ImpactSection, ContactSection, Footer,
});
