// dtwin-sections.jsx — DTwin landing.
// Aligned to GMR v2 + Brynx + Marketear + CrewRev design system. Copy is BOZZA — iterate w/ Gaetano.

const ECO_ORDER = ['brynx', 'dtwin', 'marketear', 'influrep', 'geoky', 'klenux'];

// ---- Logo: DTWIN wordmark ----
function DtLogo({ size = 'm' }) {
  const heights = { s: 18, m: 22, l: 28, xl: 40 };
  return (
    <a href="#top" className="bx-mark" aria-label="DTwin — home">
      <img src={LOGO_FILES.dtwin} alt="DTwin" style={{ height: heights[size], width: 'auto', display: 'block' }}/>
    </a>
  );
}

// ============================================================
// 0 · HEADER
// ============================================================
function DtHeader() {
  return (
    <header className="linear-header">
      <div className="container">
        <DtLogo />
        <nav>
          <a href="#how">How it works</a>
          <a href="#capabilities">Capabilities</a>
          <a href="#pricing">Pricing</a>
          <a href="https://suite.dtwin.now" className="btn-x brand">Start free <span className="arrow">→</span></a>
        </nav>
      </div>
    </header>
  );
}

// ============================================================
// 1 · HERO
// ============================================================
function DtHero() {
  return (
    <section id="top" style={{ position: 'relative', paddingTop: 80, paddingBottom: 96, overflow: 'hidden' }}>
      <div className="ambient"/>
      <div className="container layer" style={{ paddingTop: 56 }}>
        <div className="hero-grid">
          <div className="col gap-6">
            <span className="pill-x brand reveal" style={{ alignSelf: 'flex-start' }}>
              <span className="dot"/> Audience digital twins
            </span>

            <h1 className="t-display reveal">
              Simulate. Explore.<br/>
              Decide.<br/>
              <span className="muted">The end of panels.</span>
            </h1>

            <p className="t-lead reveal" style={{ maxWidth: 580 }}>
              Research panels are slow, expensive and shrinking. DTwin replaces them with synthetic consumer twins built on authoritative public data — run a survey, a focus group or an interview and get insight in 48 hours. You get the answer, not a fieldwork project.
            </p>

            <div className="col gap-3 reveal" style={{ marginTop: 8 }}>
              <div className="row gap-3" style={{ flexWrap: 'wrap' }}>
                <a href="https://suite.dtwin.now" className="btn-x brand">Start free <span className="arrow">→</span></a>
                <a href="#sample" className="btn-x">See a sample study</a>
              </div>
              <span className="cta-microcopy">
                No credit card<span className="sep">·</span>No panel<span className="sep">·</span>First study in minutes
              </span>
            </div>
          </div>

          <div className="reveal">
            <StudyPreview />
          </div>
        </div>
      </div>
    </section>
  );
}

// Hero visual — a DTwin study preview: focus-group transcript snippet + demographic bars.
function StudyPreview() {
  return (
    <div className="report-preview" aria-hidden="true">
      <div className="report-chrome">
        <span className="filename">
          <span className="ext">STUDY</span>
          ev-charging-fr-de-uk.json
        </span>
        <span className="status">Synthesized · 47h 12m</span>
      </div>

      <h4 className="report-title">EV charging · attitudes · FR / DE / UK</h4>
      <div className="report-sub">320 twins · 3 markets · focus group + survey</div>

      <div className="report-section-h">Twin voices</div>
      <div className="report-find">
        <span className="idx">DE</span>
        <span>"Range anxiety stopped mattering once I had a charger at work. The street-grid is still a problem on weekends." <span className="cite">[twin_0142 · F · 38]</span></span>
      </div>
      <div className="report-find">
        <span className="idx">FR</span>
        <span>"I switched back to a hybrid. The infrastructure outside Paris is too unreliable for my commute." <span className="cite">[twin_0207 · M · 44]</span></span>
      </div>
      <div className="report-find">
        <span className="idx">UK</span>
        <span>"Cost-per-mile only beats petrol if I charge at home. Public charging is a tax." <span className="cite">[twin_0089 · F · 29]</span></span>
      </div>

      <div className="report-section-h">Top 4 barriers · share</div>
      <div className="report-bars"><span className="lbl">Public charging</span><span className="track"><span className="fill" style={{ width: '86%' }}/></span><span className="val">64%</span></div>
      <div className="report-bars"><span className="lbl">Upfront cost</span><span className="track"><span className="fill" style={{ width: '68%' }}/></span><span className="val">51%</span></div>
      <div className="report-bars"><span className="lbl">Range anxiety</span><span className="track"><span className="fill" style={{ width: '46%' }}/></span><span className="val">34%</span></div>
      <div className="report-bars"><span className="lbl">Resale value</span><span className="track"><span className="fill" style={{ width: '32%' }}/></span><span className="val">22%</span></div>

      <div className="report-foot">
        <span className="pages">study · methodology mixed</span>
        <span>dtwin · zero PII</span>
      </div>
    </div>
  );
}

// ============================================================
// 2 · CONTRARIAN
// ============================================================
function DtContrarian() {
  return (
    <section className="brynx-strip reveal">
      <div className="container">
        <p className="text">
          Stop recruiting panels. Stop waiting weeks.<br/>
          <span className="em">Ask your audience — get the answer.</span>
        </p>
      </div>
    </section>
  );
}

// ============================================================
// 3 · PROBLEM
// ============================================================
function DtProblem() {
  const items = [
    { n: '01', strike: 'Recruitment + fieldwork', body: 'Cost and time. Recruitment fees, fieldwork weeks, incentives — for one wave of answers.' },
    { n: '02', strike: 'Fatigue + fraud',         body: 'Fatigue and fraud. Panel fatigue and bots erode the data you pay for.' },
    { n: '03', strike: 'Real-respondent PII',     body: "Privacy risk. Real-respondent PII is a liability you don't need." },
  ];
  return (
    <section className="linear-section" id="problem">
      <hr className="section-rule"/>
      <div className="container col gap-7" style={{ paddingTop: 56 }}>
        <span className="mono-label" data-num="01">The problem</span>
        <h2 className="t-h1 reveal" style={{ maxWidth: 1100, marginTop: 4 }}>
          Traditional panels are collapsing<br/>
          <span className="muted">under their own weight.</span>
        </h2>

        <div className="problem-list reveal-stagger" style={{ marginTop: 16 }}>
          {items.map(it => (
            <div key={it.n} className="problem-row">
              <div className="num">{it.n} ·</div>
              <div>
                <div className="body">{it.body}</div>
                <div className="strike-meta">{it.strike}</div>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ============================================================
// 4 · DELIVERS (RaaS)
// ============================================================
function DtDelivers() {
  const props = [
    { g: '◇', name: 'Interactive, not static personas.',     desc: 'Query them, probe them, follow up. The twin answers back.' },
    { g: '⌘', name: 'Built on authoritative public data.',   desc: '100+ probabilistic attributes per twin, 60+ countries.' },
    { g: '∅', name: 'Zero PII.',                             desc: 'No real-respondent data to store or expose.' },
  ];
  return (
    <section className="linear-section" id="delivers">
      <hr className="section-rule"/>
      <div className="container col gap-7" style={{ paddingTop: 56 }}>
        <span className="mono-label" data-num="02">What DTwin delivers</span>
        <h2 className="t-h1 reveal" style={{ maxWidth: 1100, marginTop: 4 }}>
          Synthetic respondents.<br/>
          <span className="muted">Real decisions.</span>
        </h2>
        <p className="t-lead reveal" style={{ maxWidth: 820 }}>
          Describe who you want to understand. DTwin builds interactive consumer twins and runs the research — surveys, focus groups, interviews — returning insight, not raw transcripts.
        </p>

        <div className="delivers-grid reveal-stagger" style={{ marginTop: 16 }}>
          {props.map(p => (
            <div key={p.name} className="deliver-card">
              <span className="glyph">{p.g}</span>
              <h3 className="name">{p.name}</h3>
              <p className="desc">{p.desc}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ============================================================
// 5 · CAPABILITIES (6 — 3x2, reuses .crew-grid)
// ============================================================
function DtCapabilities() {
  const caps = [
    { name: 'Simulated focus groups',     role: 'Qualitative depth, on demand.',                                glyph: '◐', tag: 'qualitative' },
    { name: '1-on-1 persona interviews',  role: 'Probe a segment one voice at a time.',                         glyph: '⌧', tag: 'qualitative' },
    { name: 'Quantitative surveys at scale', role: 'Statistical reads without fieldwork.',                       glyph: '▦', tag: 'quantitative' },
    { name: 'AI segmentation discovery',  role: "Find segments you didn't know to look for.",                    glyph: '✦', tag: 'discovery' },
    { name: 'First-party data integration', role: 'Blend your own data into the twins.',                         glyph: '⇆', tag: 'integration' },
    { name: 'Statistical validation',     role: 'Chi-square / KS checks built in.',                              glyph: '∑', tag: 'rigour' },
  ];
  return (
    <section className="linear-section" id="capabilities">
      <hr className="section-rule"/>
      <div className="container col gap-7" style={{ paddingTop: 56 }}>
        <span className="mono-label" data-num="03">Capabilities</span>
        <h2 className="t-h1 reveal" style={{ maxWidth: 1100, marginTop: 4 }}>
          One platform.<br/>
          <span className="muted">Every research method.</span>
        </h2>

        <div className="crew-grid reveal-stagger" style={{ marginTop: 16 }}>
          {caps.map(c => (
            <div key={c.name} className="crew-card">
              <div className="crew-head">
                <span className="crew-glyph">{c.glyph}</span>
                <div className="col" style={{ gap: 2 }}>
                  <h3 className="crew-name">{c.name}</h3>
                </div>
              </div>
              <p className="crew-role">{c.role}</p>
              <span className="crew-tag">{c.tag}</span>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ============================================================
// 6 · HOW IT WORKS
// ============================================================
function DtHow() {
  return (
    <section className="linear-section" id="how">
      <hr className="section-rule"/>
      <div className="container col gap-7" style={{ paddingTop: 56 }}>
        <span className="mono-label" data-num="04">How it works</span>
        <h2 className="t-h1 reveal" style={{ maxWidth: 1100, marginTop: 4 }}>
          Brief in.<br/>
          <span className="muted">Insight out.</span>
        </h2>

        <div className="how-grid reveal-stagger" style={{ marginTop: 16 }}>
          <div className="how-step">
            <span className="step-num">01 · Brief</span>
            <h3 className="step-name">Describe the audience.</h3>
            <p className="step-desc">Describe the audience and the question — in plain language.</p>
          </div>
          <div className="how-step" style={{ paddingLeft: 32 }}>
            <span className="step-num">02 · DTwin builds &amp; runs</span>
            <h3 className="step-name">Twins are generated, study runs.</h3>
            <p className="step-desc">Generates the synthetic respondents, runs the study, validates the read.</p>
          </div>
          <div className="how-step" style={{ paddingLeft: 32 }}>
            <span className="step-num">03 · Decide</span>
            <h3 className="step-name">Insight in ~48 hours.</h3>
            <p className="step-desc">Insight delivered in about 48 hours. Source-traceable. Interrogate any twin.</p>
          </div>
        </div>
      </div>
    </section>
  );
}

// ============================================================
// 7 · STATS
// ============================================================
function DtStats() {
  return (
    <section className="linear-section" style={{ paddingTop: 24 }}>
      <div className="container reveal">
        <div className="bx-stats">
          <div className="bx-stat">
            <span className="v"><span className="accent">48h</span></span>
            <span className="k">Brief to insight</span>
          </div>
          <div className="bx-stat">
            <span className="v">100+</span>
            <span className="k">Attributes per twin</span>
          </div>
          <div className="bx-stat">
            <span className="v">60+</span>
            <span className="k">Countries</span>
          </div>
          <div className="bx-stat">
            <span className="v">0</span>
            <span className="k">PII collected</span>
          </div>
        </div>
      </div>
    </section>
  );
}

// ============================================================
// 8 · REPLACES
// ============================================================
function DtReplaces() {
  return (
    <section className="replaces-strip reveal" id="replaces">
      <div className="container">
        <h2 className="replaces-big">
          Replaces <span className="accent">·</span><br/>
          <span className="em">the research panel.</span>
        </h2>
        <p className="replaces-foot">
          Recruitment fees, fieldwork weeks, survey-panel subscriptions, persona slides — folded into one product that ships the insight.
        </p>
      </div>
    </section>
  );
}

// ============================================================
// 9 · PRICING
// ============================================================
function DtPricing() {
  return (
    <section className="linear-section" id="pricing">
      <hr className="section-rule"/>
      <div className="container col gap-7" style={{ paddingTop: 56 }}>
        <span className="mono-label" data-num="05">Pricing</span>
        <h2 className="t-h1 reveal" style={{ maxWidth: 1100, marginTop: 4 }}>
          Start free.<br/>
          <span className="muted">Scale when it pays off.</span>
        </h2>

        <div className="pricing-grid reveal-stagger" style={{ marginTop: 16 }}>

          <div className="price-card">
            <span className="tier">Start</span>
            <h3 className="name">For first studies.</h3>
            <div className="price-row">
              <span className="price">€149</span>
              <span className="period">/ mo</span>
            </div>
            <ul>
              <li>149,000 tokens per month</li>
              <li>All research methods</li>
              <li>Card payment, monthly or annual (2 months free)</li>
              <li>Top-up anytime — €1 = 1,000 tokens</li>
            </ul>
            <a href="https://suite.dtwin.now" className="btn-x cta">Choose Start</a>
          </div>

          <div className="price-card featured">
            <span className="ribbon">Most popular</span>
            <span className="tier">Pro</span>
            <h3 className="name">For ongoing research.</h3>
            <div className="price-row">
              <span className="price">€299</span>
              <span className="period">/ mo</span>
            </div>
            <ul>
              <li>350,000 tokens per month (+17% bonus)</li>
              <li>Priority studies</li>
              <li>Card payment, monthly or annual</li>
              <li>Top-up anytime — €1 = 1,000 tokens</li>
            </ul>
            <a href="https://suite.dtwin.now" className="btn-x brand cta">Choose Pro <span className="arrow">→</span></a>
          </div>

          <div className="price-card">
            <span className="tier">Enterprise</span>
            <h3 className="name">For the whole stack.</h3>
            <div className="price-row">
              <span className="price">Contact us</span>
            </div>
            <ul>
              <li>All GMR products, one wallet</li>
              <li>Volume token economics</li>
              <li>Invoice billing &amp; SSO</li>
              <li>Named research support</li>
            </ul>
            <a href="#contact" className="btn-x cta">Talk to sales</a>
          </div>

        </div>

        <p className="pricing-micro">
          Start free — 149K tokens, no credit card, no panel. First study in minutes. Top up anytime · €1 = 1,000 tokens.
        </p>
      </div>
    </section>
  );
}

// ============================================================
// 10 · FINAL CTA
// ============================================================
function DtFinalCTA() {
  return (
    <section className="final-cta" id="start">
      <div className="container layer">
        <h2 className="heading reveal">
          Your next study<br/>
          <span className="muted">could be done by Thursday.</span>
        </h2>
        <div className="ctas reveal">
          <a href="https://suite.dtwin.now" className="btn-x brand">Start free <span className="arrow">→</span></a>
          <a href="#contact" className="btn-x">Talk to us</a>
        </div>
        <div className="micro reveal">No credit card · No panel · First study in minutes</div>
      </div>
    </section>
  );
}

// ============================================================
// 11 · FOOTER
// ============================================================
function DtFooter() {
  return (
    <>
      <div className="eco-bar" id="contact">
        <div className="container">
          <div className="inner">
            <span className="label">Part of the GMR stack</span>
            <div className="pellets">
              {ECO_ORDER.map(id => {
                const b = SITE_BRANDS[id];
                const isActive = id === 'dtwin';
                return (
                  <a key={id} href={b.url} className={`pellet ${isActive ? 'active' : ''}`}
                     target={isActive ? undefined : '_blank'}
                     rel={isActive ? undefined : 'noopener'}
                     aria-label={b.long}>
                    <span className="eco-mono">
                      <img src={MONO_FILES[id]} alt={b.mono}/>
                    </span>
                    <span className="eco-name">{b.long}</span>
                  </a>
                );
              })}
            </div>
          </div>
        </div>
      </div>

      <footer className="linear-footer">
        <div className="container">
          <div className="row between" style={{ alignItems: 'flex-start', marginBottom: 40, flexWrap: 'wrap', gap: 40 }}>
            <div className="col gap-3" style={{ maxWidth: 360 }}>
              <DtLogo size="m"/>
              <span style={{ color: 'var(--text-4)', fontSize: 13, lineHeight: 1.5, marginTop: 8 }}>
                Audience digital twins. Replace panels with synthetic respondents on authoritative public data — insight in 48 hours, zero PII.
              </span>
              <span style={{ color: 'var(--text-5)', fontSize: 12, marginTop: 4 }}>
                Part of GMR — AI-native products that deliver results, not tools.
              </span>
            </div>

            <div className="row gap-7" style={{ flexWrap: 'wrap' }}>
              <div className="col" style={{ minWidth: 130 }}>
                <span className="group-label">Product</span>
                <a href="#how">How it works</a>
                <a href="#capabilities">Capabilities</a>
                <a href="#sample">Sample study</a>
              </div>
              <div className="col" style={{ minWidth: 120 }}>
                <span className="group-label">Pricing</span>
                <a href="#pricing">Plans</a>
                <a href="https://suite.dtwin.now">Start free</a>
                <a href="#contact">Enterprise</a>
              </div>
              <div className="col" style={{ minWidth: 120 }}>
                <span className="group-label">Account</span>
                <a href="https://suite.dtwin.now">Login</a>
                <a href="https://suite.dtwin.now">Sign up</a>
              </div>
              <div className="col" style={{ minWidth: 110 }}>
                <span className="group-label">Legal</span>
                <a href="https://www.iubenda.com/privacy-policy/74776910" className="iubenda-black iubenda-noiframe iubenda-embed" title="Privacy Policy">Privacy Policy</a>
                <a href="https://www.iubenda.com/privacy-policy/74776910/cookie-policy" className="iubenda-black iubenda-noiframe iubenda-embed" title="Cookie Policy">Cookie Policy</a>
                <a href="https://www.iubenda.com/terms-and-conditions/74776910" className="iubenda-black iubenda-noiframe iubenda-embed" title="Terms and Conditions">Terms and Conditions</a>
              </div>
            </div>
          </div>

          <hr style={{ height: 1, background: 'var(--line)', border: 0 }}/>

          <div className="row between" style={{ padding: '20px 0 0', alignItems: 'center', flexWrap: 'wrap', gap: 12 }}>
            <span className="mono">© DTwin · part of GMR Inc · {new Date().getFullYear()}</span>
            <span className="mono">dtwin.now</span>
          </div>
        </div>
      </footer>
    </>
  );
}

Object.assign(window, {
  DtLogo,
  DtHeader, DtHero, StudyPreview, DtContrarian, DtProblem,
  DtDelivers, DtCapabilities, DtHow, DtStats, DtReplaces,
  DtPricing, DtFinalCTA, DtFooter,
  ECO_ORDER,
});
