// js/sections.jsx — Nav, Hero, Band, About, Experience
const { useState: useSt, useEffect: useEf, useRef: useRf } = React;
const D = window.SHAMA;

/* ───────────────────────── Nav ───────────────────────── */
function Nav() {
  const [solid, setSolid] = useSt(false);
  useEf(() => {
    const on = () => setSolid(window.scrollY > 40);
    on(); addEventListener("scroll", on, { passive: true });
    return () => removeEventListener("scroll", on);
  }, []);
  const links = [["Work", "#work"], ["Experience", "#experience"], ["About", "#about"], ["Contact", "#contact"]];
  return (
    <header style={{
      position: "fixed", top: 0, left: 0, right: 0, zIndex: 200,
      transition: "background .4s, border-color .4s, backdrop-filter .4s",
      background: solid ? "rgba(7,11,18,0.6)" : "transparent",
      backdropFilter: solid ? "blur(16px)" : "none", WebkitBackdropFilter: solid ? "blur(16px)" : "none",
      borderBottom: `1px solid ${solid ? "var(--stroke)" : "transparent"}`,
    }}>
      <div className="wrap" style={{ display: "flex", alignItems: "center", justifyContent: "space-between", height: 74 }}>
        <a href="#top" data-cursor style={{ display: "flex", alignItems: "center", gap: 12, fontWeight: 700, fontSize: 17, letterSpacing: "-.01em" }}>
          <Bloom /> Shama Parveen
        </a>
        <nav style={{ display: "flex", gap: 30, alignItems: "center" }}>
          {links.map(([l, h]) => (
            <a key={l} href={h} data-cursor className="navlink" style={{ fontSize: 14.5, fontWeight: 600, color: "var(--text-2)" }}>{l}</a>
          ))}
          <a href={D.resume} target="_blank" rel="noopener" data-cursor className="btn accent" style={{ padding: "11px 19px", fontSize: 14 }}>Résumé <Icon.arrowUR /></a>
        </nav>
      </div>
      <style>{`.navlink{position:relative;transition:color .25s}.navlink:hover{color:var(--text)}
        .navlink::after{content:"";position:absolute;left:0;right:100%;bottom:-5px;height:1.5px;background:linear-gradient(90deg,var(--accent),var(--accent-2));transition:right .3s var(--ease)}
        .navlink:hover::after{right:0}
        @media(max-width:860px){header nav .navlink{display:none}}`}</style>
    </header>
  );
}

/* ───────────────────────── Hero ───────────────────────── */
function Hero() {
  const [copied, setCopied] = useSt(false);
  const copy = () => { navigator.clipboard?.writeText(D.email); setCopied(true); setTimeout(() => setCopied(false), 1600); };
  return (
    <section id="top" style={{ position: "relative", paddingTop: 150 }}>
      <div className="wrap">
        <div className="reveal eyebrow" style={{ marginBottom: 30 }}><Bloom />{D.hero.eyebrow}</div>
        <div className="rg-hero" style={{ display: "grid", gridTemplateColumns: "minmax(0,1fr) auto", gap: 40, alignItems: "start" }}>
          <h1 style={{ fontSize: "clamp(50px, 9vw, 150px)", letterSpacing: "-.04em" }}>
            <span className="line-mask"><span>{D.hero.line1}&nbsp;</span></span>
            <span className="line-mask"><span><span className="grad">{D.hero.lineEm}</span>&nbsp;</span></span>
            <span className="line-mask"><span>{D.hero.line2}</span></span>
          </h1>
          <div className="reveal reveal-d2" style={{ paddingTop: 10 }}>
            <RotatingBadge text="OPEN TO WORK · DUBAI · INDIA · " size={132} />
          </div>
        </div>
        <div style={{ display: "flex", gap: 48, flexWrap: "wrap", alignItems: "flex-end", justifyContent: "space-between", marginTop: 48 }}>
          <p className="reveal reveal-d2" style={{ maxWidth: 540, color: "var(--text-2)", fontSize: 19, margin: 0 }}>{D.hero.sub}</p>
          <div className="reveal reveal-d3" style={{ display: "flex", gap: 13, flexWrap: "wrap" }}>
            <Magnetic><a href="#work" data-cursor="VIEW" className="btn accent">View selected work <span className="arr"><Icon.arrow /></span></a></Magnetic>
            <Magnetic><a href={D.resume} target="_blank" rel="noopener" data-cursor className="btn ghost">Résumé <Icon.arrowUR /></a></Magnetic>
          </div>
        </div>
        <button onClick={copy} data-cursor={copied ? "COPIED" : "COPY"}
          style={{ marginTop: 30, background: "none", border: 0, cursor: "pointer", color: "var(--text)", display: "inline-flex", alignItems: "center", gap: 11, fontFamily: "var(--font-mono)", fontSize: 14, letterSpacing: ".02em" }}>
          <Bloom color={copied ? "var(--hue-green)" : "var(--accent)"} />
          {copied ? "Copied to clipboard" : D.email}
        </button>
      </div>
    </section>
  );
}

/* ───────────────────── Marquee band ───────────────────── */
function Band() {
  return (
    <section style={{ marginTop: 100, borderTop: "1px solid var(--stroke)", borderBottom: "1px solid var(--stroke)", padding: "28px 0", background: "var(--glass)" }}>
      <Marquee style={{ fontSize: "clamp(34px,5vw,76px)" }}
        items={["UI/UX Design", "Product Thinking", "User Research", "Prototyping", "FinTech", "Design Systems"]} />
    </section>
  );
}

/* ──────────────── About / statement / stats ──────────────── */
function About() {
  return (
    <section id="about" style={{ padding: "124px 0" }}>
      <div className="wrap">
        <div className="reveal eyebrow" style={{ marginBottom: 42 }}><Bloom />What makes me “me”</div>
        <h2 className="reveal reveal-d1" style={{ fontSize: "clamp(28px,3.7vw,58px)", maxWidth: 1060, lineHeight: 1.12, letterSpacing: "-.02em", fontWeight: 500 }}>
          Designing for <span className="grad">people</span> — pairing innovation with a creative, research-led process to ship solutions that actually work in the real world.
        </h2>

        <div className="rg-3" style={{ display: "grid", gridTemplateColumns: "repeat(3,1fr)", gap: 20, marginTop: 84 }}>
          {D.stats.map((s, i) => (
            <div key={i} className={`reveal reveal-d${i + 1} glass`} style={{ padding: "30px 30px 26px", overflow: "hidden" }}>
              <div style={{ position: "absolute", top: -40, right: -30, width: 140, height: 140, borderRadius: "50%", background: "radial-gradient(circle, var(--accent-glow), transparent 70%)", opacity: .35, filter: "blur(10px)" }}></div>
              <div className="mono grad" style={{ fontWeight: 600, fontSize: "clamp(46px,5.6vw,84px)", lineHeight: .9, letterSpacing: "-.03em", position: "relative" }}>
                <CountUp value={s.value} suffix={s.suffix} />
              </div>
              <div style={{ marginTop: 14, color: "var(--text-2)", fontFamily: "var(--font-mono)", fontSize: 12, letterSpacing: ".1em", textTransform: "uppercase", position: "relative" }}>{s.label}</div>
            </div>
          ))}
        </div>

        <div className="reveal" style={{ marginTop: 52, display: "flex", gap: 13, flexWrap: "wrap" }}>
          {D.about.beliefs.map((b, i) => (
            <span key={i} className="glass" style={{ fontFamily: "var(--font-display)", fontSize: 20, fontWeight: 500, color: "var(--text)", padding: "10px 22px", borderRadius: 100 }}>{b}</span>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ──────────────── Experience + Education ──────────────── */
function Experience() {
  return (
    <section id="experience" style={{ padding: "10px 0 124px", borderTop: "1px solid var(--stroke)" }}>
      <div className="wrap" style={{ paddingTop: 94 }}>
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", flexWrap: "wrap", gap: 16, marginBottom: 52 }}>
          <h2 className="reveal" style={{ fontSize: "clamp(34px,4.6vw,68px)" }}>Where I've <span className="grad">worked</span></h2>
          <span className="reveal eyebrow"><Bloom />Experience &amp; Education</span>
        </div>

        <div>
          {D.experience.map((e, i) => (
            <div key={i} className="reveal exp-row rg-exp" data-cursor
              style={{ display: "grid", gridTemplateColumns: "1.1fr 1.4fr .9fr auto", gap: 24, alignItems: "center", padding: "30px 10px", borderTop: "1px solid var(--stroke)", position: "relative" }}>
              <div style={{ display: "flex", alignItems: "center", gap: 13 }}>
                <span style={{ fontFamily: "var(--font-display)", fontWeight: 600, fontSize: 25 }}>{e.org}</span>
                {e.tag && <span style={{ display: "inline-flex", alignItems: "center", gap: 6, fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: ".06em", padding: "4px 9px 4px 8px", borderRadius: 100, border: "1px solid var(--stroke-2)", color: "var(--accent-2)" }}><Bloom color="var(--accent)" style={{ width: 6, height: 6 }} />{e.tag}</span>}
              </div>
              <span style={{ color: "var(--text-2)", maxWidth: 360 }}>{e.blurb}</span>
              <span style={{ fontWeight: 600 }}>{e.role}</span>
              <span className="mono exp-period" style={{ fontSize: 13, color: "var(--text-2)", textAlign: "right", whiteSpace: "nowrap" }}>{e.period}</span>
              <span className="exp-edge"></span>
            </div>
          ))}
          <div style={{ borderTop: "1px solid var(--stroke)" }}></div>
        </div>

        <div className="rg-2m" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 20, marginTop: 56 }}>
          {D.education.map((e, i) => (
            <div key={i} className={`reveal reveal-d${i + 1} glass edu`} style={{ padding: 32, overflow: "hidden" }}>
              <div className="mono" style={{ fontSize: 12, letterSpacing: ".12em", color: "var(--accent-2)" }}>{e.org}</div>
              <div style={{ fontFamily: "var(--font-display)", fontWeight: 600, fontSize: 24, margin: "10px 0 8px" }}>{e.deg}</div>
              <div style={{ color: "var(--text-2)" }}>{e.note}</div>
            </div>
          ))}
        </div>
      </div>
      <style>{`.exp-row{transition:padding-left .35s var(--ease),background .35s}
        .exp-row .exp-edge{position:absolute;left:0;top:0;bottom:0;width:2px;background:linear-gradient(var(--accent),var(--accent-2));transform:scaleY(0);transform-origin:top;transition:transform .35s var(--ease)}
        .exp-row:hover{padding-left:24px;background:var(--glass)}
        .exp-row:hover .exp-edge{transform:scaleY(1)}
        .edu{transition:border-color .35s,transform .35s var(--ease)}
        .edu:hover{border-top-color:var(--accent);transform:translateY(-3px)}`}</style>
    </section>
  );
}

window.SHAMA_SECTIONS_A = { Nav, Hero, Band, About, Experience };
