// CLOUDEX — section components
const { useState, useEffect, useRef, useMemo } = React;

/* ============ Small primitives ============ */
const ArrowUR = ({ size = 16 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" className="arrow">
    <line x1="7" y1="17" x2="17" y2="7" />
    <polyline points="7 7 17 7 17 17" />
  </svg>
);
const Plus = () => (
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round">
    <line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" />
  </svg>
);

/* Channel glyphs — simple original geometric marks (NOT brand logos) */
const PinGlyph = () => (
  <svg className="glyph" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
    <circle cx="12" cy="10" r="6" /><path d="M11 16 L9 22" /><circle cx="12" cy="10" r="2" fill="currentColor" />
  </svg>
);
const GoogleGlyph = () => (
  <svg className="glyph" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
    <circle cx="12" cy="12" r="7" /><path d="M12 12 H19" /><path d="M12 12 V5" />
  </svg>
);
const MetaGlyph = () => (
  <svg className="glyph" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
    <path d="M3 16 C 6 6, 11 6, 12 12 C 13 18, 18 18, 21 8" />
  </svg>
);
const MediabuyGlyph = () => (
  <svg className="glyph" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
    <rect x="3" y="6" width="18" height="12" rx="2" /><path d="M7 10 L17 14 M17 10 L7 14" />
  </svg>
);

/* ============ NAV ============ */
function NavLogo({ size = 20 }) {
  // Inline-styled lockup matching CloudexWord, sized for the nav.
  const slashH = Math.max(1.5, Math.round(size * 0.07));
  const dotSize = Math.round(size * 0.42);
  return (
    <span style={{
      fontFamily: "var(--font-display)",
      fontWeight: 600,
      letterSpacing: "-0.03em",
      fontSize: size,
      display: "inline-flex",
      alignItems: "center",
      lineHeight: 1,
      color: "var(--text)",
    }}>
      <span>CLOUDE</span>
      <span style={{ position: "relative", display: "inline-block" }}>
        X
        <span aria-hidden="true" style={{
          position: "absolute",
          left: "-12%",
          right: "-12%",
          top: "50%",
          height: slashH + "px",
          background: "var(--accent)",
          transform: "translateY(-50%) rotate(-18deg)",
          borderRadius: 1,
        }} />
      </span>
      <span style={{
        width: dotSize, height: dotSize,
        borderRadius: "50%",
        background: "var(--accent)",
        boxShadow: "0 0 10px var(--accent)",
        marginLeft: Math.round(size * 0.45),
        display: "inline-block",
      }} />
    </span>
  );
}

function Nav() {
  return (
    <div className="nav">
      <div className="nav-inner">
        <a href="#top" className="nav-logo" style={{gap:0}}>
          <NavLogo size={20} />
        </a>
        <nav className="nav-links">
          <a href="#services">Services</a>
          <a href="#process">Process</a>
          <a href="#work">Work</a>
          <a href="#studio">Studio</a>
          <a href="#faq">FAQ</a>
        </nav>
        <a href="#contact" className="btn btn-primary" style={{padding:"10px 18px", fontSize:14}}>
          Book a call <ArrowUR size={14} />
        </a>
      </div>
    </div>
  );
}

/* ============ HERO ============ */
function useCount(target, duration = 1600, decimals = 0) {
  const [v, setV] = useState(0);
  useEffect(() => {
    let raf, start;
    const tick = (t) => {
      if (!start) start = t;
      const p = Math.min(1, (t - start) / duration);
      const eased = 1 - Math.pow(1 - p, 3);
      setV(target * eased);
      if (p < 1) raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, [target, duration]);
  return decimals ? v.toFixed(decimals) : Math.round(v).toLocaleString();
}

function HeroStat({ value, unit, label, decimals }) {
  const c = useCount(value, 1800, decimals);
  return (
    <div className="hero-stat">
      <div className="num">{c}<span className="unit">{unit}</span></div>
      <div className="lbl">{label}</div>
    </div>
  );
}

function Hero() {
  return (
    <section className="hero" id="top">
      <div className="hero-glow" />
      <div className="hero-grid-bg" />
      <div className="wrap">
        <div className="tag reveal in"><span className="dot" /> Paid media studio · DTC e-commerce</div>
        <h1 className="h-display h1" style={{marginTop:24, maxWidth: "15ch"}}>
          A paid media<br/>
          studio for <span className="accent">considered</span><br/>
          DTC brands.
        </h1>
        <p className="lede" style={{marginTop: 32}}>
          CLOUDEX runs paid media for ambitious DTC brands. Pinterest, Google, Meta — done with the care of an in-house team and the leverage of specialists.
        </p>
        <div className="hero-meta">
          <a href="#contact" className="btn btn-primary">Book an intro call <ArrowUR /></a>
          <a href="#work" className="btn btn-ghost">See the work <ArrowUR /></a>
        </div>

        <div className="hero-stats">
          <HeroStat value={127} unit="" label="DTC brands partnered" />
          <HeroStat value={4.7} unit="x" label="Avg. blended ROAS" decimals={1} />
          <HeroStat value={96} unit="%" label="Client retention" />
          <HeroStat value={5} unit=" yrs" label="Studio, compounding" />
        </div>
      </div>
    </section>
  );
}

/* ============ MARQUEE ============ */
function Marquee() {
  const items = [
    "Pinterest", "Google", "Meta", "Media buying", "Creative strategy",
    "Studio approach", "Senior hands", "DTC focused",
    "Pinterest", "Google", "Meta", "Media buying"
  ];
  return (
    <div className="marquee">
      <div className="marquee-track">
        {items.concat(items).map((t,i) => (
          <span className="marquee-item" key={i}><span className="star">✦</span>{t}</span>
        ))}
      </div>
    </div>
  );
}

/* ============ SERVICES ============ */
function Service({ tag, glyph, title, desc, deliverables }) {
  return (
    <div className="service">
      <div className="corner-arrow"><ArrowUR /></div>
      <div className="service-glyph">{glyph}</div>
      <div className="channel-tag" style={{marginTop:18}}>{tag}</div>
      <h3 className="h3" style={{margin:"10px 0 12px"}}>{title}</h3>
      <p className="desc">{desc}</p>
      <div className="deliverables">
        {deliverables.map((d,i)=>(<span className="pill" key={i}>{d}</span>))}
      </div>
    </div>
  );
}

function Services() {
  return (
    <section id="services" className="section-pad">
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">01 · What we do</span>
            <h2 className="h2" style={{marginTop:16, maxWidth:"16ch"}}>Four channels.<br/>Run with care.</h2>
          </div>
          <p className="lede">We don't bolt on services we can't deliver. CLOUDEX runs deep on the four channels where DTC brands compound — owned end to end, from creative brief to channel strategy.</p>
        </div>

        <div className="services-grid">
          <Service
            tag="Channel · 01"
            glyph={<PinGlyph />}
            title="Pinterest Ads"
            desc="The most underrated paid channel in DTC. We treat Pinterest as a demand engine — pin-native creative, intent-rich keyword targeting, and conversion campaigns built around how people actually shop there."
            deliverables={["Pin-native creative", "Keyword strategy", "Catalog feeds", "Idea ads"]}
          />
          <Service
            tag="Channel · 02"
            glyph={<GoogleGlyph />}
            title="Google Ads"
            desc="Search, Shopping, PMax, YouTube — built around a framework that respects margin, not just headline revenue. We win the queries that already want your product, and balance brand and non-brand with care."
            deliverables={["Performance Max", "Shopping feeds", "Search & YouTube", "Server-side tracking"]}
          />
          <Service
            tag="Channel · 03"
            glyph={<MetaGlyph />}
            title="Meta Ads"
            desc="Facebook and Instagram, run like a creative testing lab. New angles each week, evidence-led winners, and account structures that scale calmly through platform shifts."
            deliverables={["Creative testing", "Advantage+ campaigns", "Retargeting", "Conversions API"]}
          />
          <Service
            tag="Channel · 04"
            glyph={<MediabuyGlyph />}
            title="Mediabuying"
            desc="A senior buyer on every account — not an account manager. Daily pacing, weekly notes, monthly reviews. You'll know what changed, why it changed, and what's next. No agency-jargon dashboards."
            deliverables={["Daily pacing", "Weekly notes", "Monthly reviews", "Slack channel"]}
          />
        </div>
      </div>
    </section>
  );
}

/* ============ WHY (BENTO) ============ */
function Why() {
  return (
    <section className="section-pad-sm">
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">02 · Why brands choose us</span>
            <h2 className="h2" style={{marginTop:16}}>Built for compounding.</h2>
          </div>
        </div>

        <div className="bento">
          <div className="b b1">
            <div>
              <span className="mono">Accounts per buyer</span>
              <div className="b-num" style={{marginTop:14}}>4<span className="unit">/max</span></div>
            </div>
            <p>Each CLOUDEX buyer takes on four brands, no more. Your account is the work — not a side quest. It's why our partnerships compound, year on year.</p>
          </div>
          <div className="b">
            <h4>Plain-english reporting</h4>
            <p>Weekly notes from your buyer. What we changed, what's working, what's next. No dashboard archaeology.</p>
          </div>
          <div className="b">
            <h4>Creative as a system</h4>
            <p>A library of fresh concepts each month, briefed off winning angles — never vibes.</p>
          </div>
          <div className="b">
            <h4>Channel-agnostic budget</h4>
            <p>Spend follows performance, not internal politics. We reallocate without ego.</p>
          </div>
          <div className="b">
            <h4>Slack-native</h4>
            <p>Direct line to your buyer. No tickets, no 48-hour SLAs, no "let me loop in your AM."</p>
          </div>
        </div>
      </div>
    </section>
  );
}

/* ============ PROCESS ============ */
function Process() {
  const steps = [
    { n: "Step 01", t: "Audit", d: "Free, no-strings teardown of your current ad accounts. We surface what's actually broken — tracking, creative, structure, or strategy — and tell you straight." },
    { n: "Step 02", t: "Plan", d: "A 30-day kickoff sprint: tracking rebuild, creative brief library, channel-mix model, and a target CAC tied to your real margin — not last year's." },
    { n: "Step 03", t: "Launch", d: "Campaigns live in week two. We run lean and learn fast: 5–10 fresh creative tests weekly, ruthless winner harvesting, daily pacing." },
    { n: "Step 04", t: "Scale", d: "Once we hit the CAC target, we open the throttle. New channels, lookalike geos, and creative scale-out — all gated on margin, not vanity ROAS." },
  ];
  return (
    <section id="process" className="section-pad">
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">03 · How we work</span>
            <h2 className="h2" style={{marginTop:16}}>A short, honest<br/>way of working.</h2>
          </div>
          <p className="lede">No 90-day "onboarding." No senior pitch, junior execute. You'll meet your buyer in week one and they'll still be on your account in year two.</p>
        </div>
        <div className="process-steps">
          {steps.map((s,i)=>(
            <div className="step" key={i}>
              <div className="step-line" />
              <span className="step-num">{s.n}</span>
              <h4>{s.t}</h4>
              <p>{s.d}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ============ CASE STUDIES ============ */
function Case({ logo, industry, headline, results, big }) {
  return (
    <div className={"case" + (big ? " big" : "")}>
      <div className="case-head">
        <div className="case-logo">{logo}</div>
        <span className="industry">{industry}</span>
      </div>
      <div>
        <div className="case-headline">{headline}</div>
      </div>
      <div className="case-result">
        {results.map((r,i)=>(
          <div key={i}>
            <div className="num">{r.n}<span className="unit">{r.u}</span></div>
            <div className="lbl">{r.l}</div>
          </div>
        ))}
      </div>
    </div>
  );
}

function CaseStudies() {
  return (
    <section id="work" className="section-pad" style={{background:"linear-gradient(180deg, transparent, rgba(255,255,255,0.015) 50%, transparent)"}}>
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">04 · Selected work</span>
            <h2 className="h2" style={{marginTop:16}}>Recent partnerships.</h2>
          </div>
          <a href="#contact" className="btn btn-ghost">All case studies <ArrowUR /></a>
        </div>

        <div className="case-grid">
          <Case
            big
            logo="HARLOW & PINE◦"
            industry="Home fragrance"
            headline="Helped a growing fragrance brand find consistent, profitable scale across three channels."
            results={[
              { n: "3.6", u: "x", l: "Revenue lift" },
              { n: "5.2", u: "x", l: "Blended ROAS" },
              { n: "−42", u: "%", l: "CAC" },
            ]}
          />
          <Case
            logo="NORTHFORM"
            industry="Activewear"
            headline="Built Pinterest into their leading acquisition channel — ahead of Meta on CPA."
            results={[
              { n: "41", u: "%", l: "Lower CPA vs Meta" },
              { n: "6.1", u: "x", l: "Pinterest ROAS" },
            ]}
          />
        </div>

        <div className="case-grid-2">
          <Case
            logo="OAKWELL"
            industry="Premium pet food"
            headline="Rebuilt their Google strategy around real margin, not headline ROAS."
            results={[
              { n: "2.1", u: "x", l: "Profitable spend" },
              { n: "+58", u: "%", l: "New customer rev." },
            ]}
          />
          <Case
            logo="SOLENNE"
            industry="Skincare"
            headline="Engineered a Meta program that scales calmly through platform shifts."
            results={[
              { n: "4.4", u: "x", l: "Blended ROAS" },
              { n: "24", u: "mo", l: "Compounding" },
            ]}
          />
          <Case
            logo="BRIGHTWAVE◢"
            industry="Sleep tech"
            headline="Diversified a single-channel program into a balanced four-channel mix."
            results={[
              { n: "3", u: "x", l: "Output, same team" },
              { n: "−31", u: "%", l: "Blended CAC" },
            ]}
          />
        </div>
      </div>
    </section>
  );
}

/* ============ CALCULATOR ============ */
function Calculator() {
  const [spend, setSpend] = useState(50000);
  const [aov, setAov] = useState(85);
  const [currentRoas, setCurrentRoas] = useState(2.2);

  // assume we improve ROAS by 60% on average (capped sensibly)
  const targetRoas = Math.min(currentRoas * 1.6, 7.5);
  const currentRev = spend * currentRoas;
  const targetRev = spend * targetRoas;
  const lift = targetRev - currentRev;
  const newCustomers = Math.round((targetRev * 0.62) / aov);
  const fmt = (n) => Math.round(n).toLocaleString();

  return (
    <section id="calculator" className="section-pad">
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">05 · ROAS calculator</span>
            <h2 className="h2" style={{marginTop:16}}>What could we do<br/>with your spend?</h2>
          </div>
          <p className="lede">Drag the sliders. We'll show you what a typical CLOUDEX engagement looks like on your numbers. Conservative — based on our portfolio average, not the top deciles.</p>
        </div>

        <div className="calc">
          <div className="calc-left">
            <div className="slider-row">
              <div className="value-row">
                <label>Monthly ad spend</label>
                <div className="value">${fmt(spend)}<span className="unit">/mo</span></div>
              </div>
              <input type="range" min="5000" max="500000" step="5000" value={spend} onChange={e=>setSpend(+e.target.value)} />
            </div>
            <div className="slider-row">
              <div className="value-row">
                <label>Average order value</label>
                <div className="value">${fmt(aov)}</div>
              </div>
              <input type="range" min="20" max="400" step="5" value={aov} onChange={e=>setAov(+e.target.value)} />
            </div>
            <div className="slider-row">
              <div className="value-row">
                <label>Current blended ROAS</label>
                <div className="value">{currentRoas.toFixed(1)}<span className="unit">x</span></div>
              </div>
              <input type="range" min="1" max="5" step="0.1" value={currentRoas} onChange={e=>setCurrentRoas(+e.target.value)} />
            </div>
            <p style={{color:"var(--muted)", fontSize:13, marginTop:30, lineHeight:1.55}}>
              Projection based on the median CLOUDEX engagement after 90 days. Your mileage will vary — we'll tell you honestly in the audit.
            </p>
          </div>
          <div className="calc-right">
            <div className="mono" style={{marginBottom:14}}>Projected monthly revenue with CLOUDEX</div>
            <div className="result-num">${fmt(targetRev/1000)}<span className="unit">k</span></div>
            <div className="mono" style={{marginTop:14, color:"#a3ff12"}}>
              ↑ ${fmt(lift/1000)}k lift / month vs. current
            </div>

            <div className="result-row">
              <div className="result-cell">
                <div className="n">{targetRoas.toFixed(1)}x</div>
                <div className="l">Target ROAS</div>
              </div>
              <div className="result-cell">
                <div className="n">{fmt(newCustomers).toLocaleString()}</div>
                <div className="l">New customers/mo</div>
              </div>
              <div className="result-cell">
                <div className="n">${fmt((targetRev - spend)/1000)}k</div>
                <div className="l">Net contribution</div>
              </div>
            </div>

            <a href="#contact" className="btn btn-primary" style={{marginTop:32, alignSelf:"flex-start"}}>
              Get this audit free <ArrowUR />
            </a>
          </div>
        </div>
      </div>
    </section>
  );
}

/* ============ TESTIMONIALS ============ */
function Testimonials() {
  const items = [
    { q: "We'd been through three agencies before CLOUDEX. The difference is they actually care about our margin, not just topline. Our blended ROAS went from 2.4 to 4.8 in five months.", n: "Mira Vance", r: "Founder, Harlow & Pine", a: "MV" },
    { q: "Our buyer is in our Slack daily. Reports come with opinions, not just charts. Feels like an in-house team that happens to be very, very good at Pinterest.", n: "Daniel Okafor", r: "Head of Growth, Northform", a: "DO" },
    { q: "They told us to cut 30% of our spend on day one and we got nervous. Two months later we were doing more revenue on less spend. That's the whole story.", n: "Sarah Lindqvist", r: "CMO, Oakwell", a: "SL" },
  ];
  return (
    <section className="section-pad-sm">
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">06 · Words from partners</span>
            <h2 className="h2" style={{marginTop:16}}>Working partnerships.</h2>
          </div>
        </div>
        <div className="test-grid">
          {items.map((t,i)=>(
            <div className="test" key={i}>
              <div className="stars">★★★★★</div>
              <div className="quote">"{t.q}"</div>
              <div className="author">
                <div className="avatar">{t.a}</div>
                <div>
                  <div className="name">{t.n}</div>
                  <div className="role">{t.r}</div>
                </div>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ============ FAQ ============ */
function FAQ() {
  const items = [
    { q: "What size brand do you typically work with?", a: "Sweet spot is DTC e-commerce brands spending between $30k and $500k per month on paid ads. We've taken brands from $0 to seven figures, but our process really sings when there's existing data to optimize against." },
    { q: "Do you require long contracts?", a: "No. CLOUDEX works on rolling 90-day terms after an initial 60-day setup commitment. If we're not earning our keep, you should be able to leave — and we want to keep proving it." },
    { q: "Who actually runs my account?", a: "A senior media buyer with at least five years on DTC accounts. No juniors, no offshoring, no \"account managers\" in between. You'll be in a Slack channel with the human running the spend." },
    { q: "What's the typical onboarding timeline?", a: "Audit and signed proposal in week one. Tracking, pixel and CAPI rebuild in week two. First campaigns live by day 14. First strategy review at day 30, full P&L review at day 60." },
    { q: "Do you make the creative?", a: "We brief, direct, and run creative testing — and we work with your in-house team or our preferred creative partners for production. Concepts come from the channel data, not a moodboard." },
    { q: "How is pricing structured?", a: "A flat monthly retainer scaled to your ad spend, with a small performance kicker above an agreed target. No setup fees, no percent-of-spend surprises, no \"strategy hours\" billed by the quarter." },
  ];
  const [open, setOpen] = useState(0);
  return (
    <section id="faq" className="section-pad">
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">07 · FAQ</span>
            <h2 className="h2" style={{marginTop:16}}>Common questions.<br/>Direct answers.</h2>
          </div>
        </div>
        <div className="faq">
          {items.map((it, i) => (
            <div className={"faq-item" + (open === i ? " open" : "")} key={i}>
              <div className="faq-q" onClick={() => setOpen(open === i ? -1 : i)}>
                <span className="faq-q-text">{it.q}</span>
                <span className="faq-icon"><Plus /></span>
              </div>
              <div className="faq-a">{it.a}</div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ============ CTA ============ */
function CTA() {
  return (
    <section id="contact" className="cta">
      <div className="cta-glow" />
      <div className="wrap cta-inner">
        <div>
          <span className="eyebrow">08 · Let's talk</span>
          <h2 className="h2" style={{marginTop:16, maxWidth:"18ch"}}>
            Let's see if we're a <span className="accent">fit.</span>
          </h2>
          <p className="lede" style={{marginTop:18}}>
            A 45-minute call. We'll talk through your accounts, your goals and your numbers. You'll leave with three things to action — even if we never work together.
          </p>
        </div>
        <div style={{display:"flex", flexDirection:"column", gap:12, alignItems:"flex-start"}}>
          <a href="#" className="btn btn-primary" style={{padding:"18px 26px", fontSize:16}}>Book an intro call <ArrowUR /></a>
          <a href="mailto:contact@cloudexmedia.com" className="btn btn-ghost">contact@cloudexmedia.com <ArrowUR /></a>
          <div className="mono" style={{marginTop:6}}>Replying within the working day.</div>
        </div>
      </div>
    </section>
  );
}

/* ============ FOOTER ============ */
function Footer() {
  return (
    <footer>
      <div className="wrap">
        <div className="foot-grid">
          <div className="foot-col">
            <h5>CLOUDEX LLC</h5>
            <p style={{color:"#c8c8c4", maxWidth:"38ch", lineHeight:1.55, fontSize:15, marginTop:0}}>
              Paid media studio for DTC e-commerce brands that take their craft seriously.
            </p>
            <div style={{marginTop:20, fontFamily:"var(--font-mono)", fontSize:12, letterSpacing:"0.04em", color:"#c8c8c4", lineHeight:1.7}}>
              2106 House Ave, Suite 743<br/>
              Cheyenne, Wyoming 82001<br/>
              United States
            </div>
            <a href="mailto:contact@cloudexmedia.com" style={{display:"inline-block", marginTop:14, color:"var(--accent)", fontFamily:"var(--font-mono)", fontSize:12, letterSpacing:"0.04em"}}>contact@cloudexmedia.com</a>
          </div>
          <div className="foot-col">
            <h5>Services</h5>
            <a href="#services">Pinterest Ads</a>
            <a href="#services">Google Ads</a>
            <a href="#services">Meta Ads</a>
            <a href="#services">Media Buying</a>
          </div>
          <div className="foot-col">
            <h5>Studio</h5>
            <a href="#work">Case studies</a>
            <a href="#process">Process</a>
            <a href="#faq">FAQ</a>
            <a href="#contact">Contact</a>
          </div>
          <div className="foot-col">
            <h5>Elsewhere</h5>
            <a href="#">LinkedIn</a>
            <a href="#">Instagram</a>
            <a href="#">X / Twitter</a>
            <a href="#">Substack</a>
          </div>
        </div>

        <div className="foot-word">
          <span>CLOUDE</span>
          <span style={{position:"relative", display:"inline-block"}}>
            X
            <span aria-hidden="true" style={{
              position:"absolute",
              left:"-6%", right:"-6%",
              top:"50%",
              height:"10px",
              background:"var(--accent)",
              transform:"translateY(-50%) rotate(-18deg)",
              borderRadius:2,
              WebkitTextFillColor: "var(--accent)"
            }} />
          </span>
          <span>.</span>
        </div>

        <div className="foot-bottom">
          <div>© 2026 CLOUDEX LLC · Cheyenne, Wyoming, USA</div>
          <div style={{display:"flex", gap:24}}>
            <a href="terms.html">Terms</a>
            <a href="privacy.html">Privacy</a>
            <a href="#contact">Contact</a>
          </div>
        </div>
      </div>
    </footer>
  );
}

/* ============ LIVE TICKER ============ */
function Ticker() {
  const events = [
    { msg: "Northform · Pinterest ROAS hit ", h: "6.4x", tail: " — new portfolio high.", t: "2m ago" },
    { msg: "Harlow & Pine · scaled Meta to ", h: "$48k/day", tail: " profitably.", t: "11m ago" },
    { msg: "Oakwell · Google PMax CAC down ", h: "−18%", tail: " week-over-week.", t: "26m ago" },
    { msg: "Solenne · new creative concept ", h: "+72%", tail: " CTR vs control.", t: "1h ago" },
    { msg: "Brightwave · added Pinterest, ", h: "ROAS 5.1x", tail: " first 14 days.", t: "3h ago" },
  ];
  const [i, setI] = useState(0);
  const [vis, setVis] = useState(false);

  useEffect(() => {
    const show = setTimeout(()=>setVis(true), 1800);
    const id = setInterval(() => setI(p => (p+1) % events.length), 6000);
    return () => { clearTimeout(show); clearInterval(id); };
  }, []);

  const e = events[i];
  return (
    <div className={"ticker" + (vis ? "" : " hidden")}>
      <span className="pulse" />
      <div style={{flex:1}}>
        <div className="t-meta">Live · {e.t}</div>
        <div className="t-msg">{e.msg}<span className="accent">{e.h}</span>{e.tail}</div>
      </div>
      <button onClick={()=>setVis(false)} style={{background:"transparent", border:"none", color:"var(--muted)", cursor:"pointer", padding:6}} aria-label="dismiss">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><line x1="6" y1="6" x2="18" y2="18"/><line x1="6" y1="18" x2="18" y2="6"/></svg>
      </button>
    </div>
  );
}

/* ============ IMAGE BAND (after hero) ============ */
function ImageBand() {
  return (
    <section className="image-band">
      <div className="wrap">
        <div className="frame">
          <div className="meta-strip"><span className="dot" /> Studio · 2026</div>
          <image-slot
            id="hero-band"
            src="images/hero.svg"
            shape="rounded"
            radius="28"
            placeholder="Drop a hero image — studio, brand work, behind-the-scenes"
          />
        </div>
      </div>
    </section>
  );
}

/* ============ ATMOSPHERIC PULL-QUOTE ============ */
function Atmosphere() {
  return (
    <section className="atmosphere">
      <div className="orb orb-1" />
      <div className="orb orb-2" />
      <div className="grid-bg" />
      <div className="wrap" style={{position:"relative", zIndex:1}}>
        <span className="eyebrow">A note from the studio</span>
        <p className="quote" style={{marginTop:24}}>
          "We're not chasing virality, screenshots or trophy ROAS. We're trying to build paid-media programs that <span className="accent">compound</span> — quietly, every month, for the kind of brands we'd buy from ourselves."
        </p>
        <div className="attr">
          <div className="attr-avatar" style={{display:"grid", placeItems:"center", background:"#121212"}}>
            <svg width="28" height="28" viewBox="0 0 200 200" aria-hidden="true">
              <g stroke="#f4f4f1" strokeWidth="22" strokeLinecap="square">
                <line x1="60" y1="60" x2="140" y2="140" />
                <line x1="140" y1="60" x2="60" y2="140" />
              </g>
              <rect x="28" y="93" width="144" height="14" rx="2" fill="#a3ff12" transform="rotate(-18 100 100)" />
            </svg>
          </div>
          <div>
            <div className="name">A note from the studio</div>
            <div className="role">CLOUDEX · CHEYENNE, WY</div>
          </div>
        </div>
      </div>
    </section>
  );
}

/* ============ STUDIO (replaces calculator) ============ */
function Studio() {
  return (
    <section id="studio" className="section-pad">
      <div className="wrap">
        <div className="section-head">
          <div>
            <span className="eyebrow">05 · Inside the studio</span>
            <h2 className="h2" style={{marginTop:16}}>Small team.<br/>Senior hands.</h2>
          </div>
          <p className="lede">CLOUDEX isn't an agency in the traditional sense. We're a small studio of senior media buyers, creative strategists and analysts who only take on brands we're genuinely excited about — and we keep it that way on purpose.</p>
        </div>

        <div className="studio-grid">
          <div className="studio-card big">
            <image-slot id="studio-1" src="images/studio.svg" shape="rounded" radius="20" placeholder="Drop a studio / workspace photo" />
            <div className="studio-tag"><span className="mono">01</span><span>The studio</span></div>
          </div>
          <div className="studio-card">
            <image-slot id="studio-2" src="images/team.svg" shape="rounded" radius="20" placeholder="Drop a team photo" />
            <div className="studio-tag"><span className="mono">02</span><span>The team</span></div>
          </div>
          <div className="studio-card">
            <image-slot id="studio-3" src="images/work.svg" shape="rounded" radius="20" placeholder="Drop a work-in-progress shot" />
            <div className="studio-tag"><span className="mono">03</span><span>The work</span></div>
          </div>
        </div>
      </div>
    </section>
  );
}

/* expose */
Object.assign(window, {
  Nav, NavLogo, Hero, Marquee, Services, Why, Process, CaseStudies, Calculator, Testimonials, FAQ, CTA, Footer, Ticker,
  ImageBand, Atmosphere, Studio
});
