/* EZV Studio – Easy Driver page (main) */
/* eslint-disable */

const { useState: useS, useEffect: useE } = React;

const EASY_DRIVER_DOWNLOAD_URL = 'easy-driver-download.html';

/* ── language handling (URL + localStorage) ──────────── */
function getInitialLang() {
  try {
    const u = new URL(window.location.href);
    const fromUrl = u.searchParams.get('lang');
    if (fromUrl && EDP[fromUrl]) return fromUrl;
    const fromLs = localStorage.getItem('ezLang');
    if (fromLs && EDP[fromLs]) return fromLs;
  } catch {}
  return 'pt';
}

/* ── Top Nav ──────────────────────────────────────────── */
function TopNav({ lang, setLang, T }) {
  return (
    <nav style={{
      position: 'sticky', top: 0, zIndex: 50,
      background: 'rgba(10,10,11,0.72)',
      backdropFilter: 'blur(18px)',
      WebkitBackdropFilter: 'blur(18px)',
      borderBottom: `1px solid ${EDPC.border}`,
    }}>
      <div style={{
        maxWidth: 1280, margin: '0 auto', padding: '14px 32px',
        display: 'flex', justifyContent: 'space-between', alignItems: 'center',
      }}>
        <a href={`index.html?lang=${lang}`} style={{
          display: 'inline-flex', alignItems: 'center', gap: 10,
          textDecoration: 'none', color: EDPC.fg2,
          fontFamily: 'Inter, sans-serif', fontSize: 13, fontWeight: 500,
          transition: 'color 0.2s',
        }}
          onMouseEnter={(e) => { e.currentTarget.style.color = EDPC.fg; }}
          onMouseLeave={(e) => { e.currentTarget.style.color = EDPC.fg2; }}
        >
          <span style={{ fontSize: 15, lineHeight: 1 }}>←</span>
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
            <span>EZV</span>
            <span style={{ width: 4, height: 4, borderRadius: 999, background: EDPC.purple, display: 'inline-block' }}/>
            <span>Studio</span>
          </span>
        </a>
        <div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
          <div className="ed-nav-links" style={{ display: 'flex', alignItems: 'center', gap: 20 }}>
            <a href="#features" style={{ fontSize: 12, color: EDPC.fg2, textDecoration: 'none' }}>Features</a>
            <a href="#tech" style={{ fontSize: 12, color: EDPC.fg2, textDecoration: 'none' }}>Stack</a>
            <a href="#vision" style={{ fontSize: 12, color: EDPC.fg2, textDecoration: 'none' }}>Vision</a>
            <a
              href={`suporte.html?lang=${lang}`}
              style={{
                display: 'inline-flex', alignItems: 'center', gap: 6,
                fontSize: 12, fontWeight: 500, color: EDPC.fg2, textDecoration: 'none',
                transition: 'color 0.2s',
              }}
              onMouseEnter={(e) => { e.currentTarget.style.color = EDPC.fg; }}
              onMouseLeave={(e) => { e.currentTarget.style.color = EDPC.fg2; }}
            >
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
                <circle cx="12" cy="12" r="10"/>
                <path d="M9.5 9a2.5 2.5 0 114.2 1.9c-.7.6-1.7 1-1.7 2.1"/>
                <circle cx="12" cy="17" r="0.5" fill="currentColor" stroke="none"/>
              </svg>
              Suporte
            </a>
            <div style={{ width: 1, height: 14, background: EDPC.border }}/>
          </div>
          <EDPLangSwitch lang={lang} setLang={setLang} />
          <a
            href={`${EASY_DRIVER_DOWNLOAD_URL}?lang=${lang}`}
            style={{
              display: 'inline-flex', alignItems: 'center', gap: 8,
              height: 40, padding: '0 20px', borderRadius: 999,
              background: EDPC.purple, color: EDPC.bg,
              fontFamily: 'Inter, sans-serif', fontSize: 13.5, fontWeight: 600,
              letterSpacing: '-0.005em', textDecoration: 'none', whiteSpace: 'nowrap',
              boxShadow: '0 10px 26px -10px rgba(167,139,250,0.7)',
              transition: 'transform 0.2s, box-shadow 0.2s, filter 0.2s',
            }}
            onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-1px)'; e.currentTarget.style.filter = 'brightness(1.06)'; e.currentTarget.style.boxShadow = '0 14px 30px -10px rgba(167,139,250,0.85)'; }}
            onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.filter = 'brightness(1)'; e.currentTarget.style.boxShadow = '0 10px 26px -10px rgba(167,139,250,0.7)'; }}
          >
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
              <path d="M12 3v13"/><path d="M7 12l5 5 5-5"/><path d="M5 21h14"/>
            </svg>
            {T.download}
          </a>
        </div>
      </div>
    </nav>
  );
}

function EDPLangSwitch({ lang, setLang }) {
  const langs = [
    { code: 'pt', Flag: FlagBR },
    { code: 'en', Flag: FlagUS },
    { code: 'es', Flag: FlagES },
  ];
  return (
    <div style={{ display: 'flex', gap: 8 }}>
      {langs.map(({ code, Flag }) => {
        const active = code === lang;
        return (
          <button key={code} onClick={() => setLang(code)} style={{
            display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
            width: 28, height: 28, borderRadius: 999,
            border: `1.5px solid ${active ? EDPC.purple : EDPC.border}`,
            background: 'transparent', padding: 0, cursor: 'pointer',
            opacity: active ? 1 : 0.55,
            transition: 'opacity 0.15s, border-color 0.15s',
            boxShadow: active ? `0 0 0 2px rgba(167,139,250,0.18)` : 'none',
          }}><Flag size={18} /></button>
        );
      })}
    </div>
  );
}

/* ── Hero ─────────────────────────────────────────────── */
function HeroSection({ T, lang }) {
  return (
    <EDPSection padTop={100} padBottom={120} style={{ overflow: 'hidden' }}>
      <div aria-hidden style={{
        position: 'absolute', top: -200, left: '50%', transform: 'translateX(-50%)',
        width: 1200, height: 800,
        background: 'radial-gradient(50% 50% at 50% 50%, rgba(167,139,250,0.16) 0%, rgba(167,139,250,0) 70%)',
        filter: 'blur(40px)', pointerEvents: 'none',
      }}/>
      <Reveal style={{ position: 'relative', zIndex: 1 }}>
        <EDPEyebrow style={{ marginBottom: 28 }}>{T.hero.eyebrow}</EDPEyebrow>
      </Reveal>
      <div className="ed-hero-grid" style={{
        display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) auto',
        gap: 60, alignItems: 'center', position: 'relative', zIndex: 1,
      }}>
        <div>
          <Reveal delay={80}>
            <h1 style={{
              fontFamily: 'Inter, sans-serif',
              fontSize: 'clamp(56px, 9vw, 124px)',
              fontWeight: 500, letterSpacing: '-0.045em', lineHeight: 0.92,
              margin: 0, color: EDPC.fg,
            }}>
              {T.hero.titleA}<br/>
              <span style={{ color: EDPC.purple, fontStyle: 'italic', fontWeight: 400 }}>{T.hero.titleB}</span>
            </h1>
          </Reveal>
          <Reveal delay={180}>
            <p style={{
              fontFamily: 'Inter, sans-serif',
              fontSize: 'clamp(18px, 1.6vw, 22px)',
              lineHeight: 1.4, color: EDPC.fg,
              margin: '32px 0 18px', maxWidth: 560, fontWeight: 400, letterSpacing: '-0.01em',
            }}>{T.hero.subtitle}</p>
          </Reveal>
          <Reveal delay={260}>
            <p style={{
              fontSize: 15, lineHeight: 1.7, color: EDPC.fg2,
              margin: '0 0 36px', maxWidth: 520,
            }}>{T.hero.desc}</p>
          </Reveal>
          <Reveal delay={340} style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
            <EDPButton variant="primary" href={`${EASY_DRIVER_DOWNLOAD_URL}?lang=${lang}`} icon="↓">{T.downloadApp}</EDPButton>
            <EDPButton variant="ghost" href="#features">{T.hero.ctaPrimary}</EDPButton>
            <EDPButton variant="ghost" href="#ecosystem">{T.hero.ctaSecondary}</EDPButton>
          </Reveal>
        </div>
        <Reveal delay={420} style={{ position: 'relative' }}>
          <HeroIconCluster T={T} />
        </Reveal>
      </div>
    </EDPSection>
  );
}

function PhoneLabel({ tag }) {
  return (
    <div style={{
      fontFamily: 'JetBrains Mono, monospace',
      fontSize: 10, letterSpacing: '0.22em', textTransform: 'uppercase',
      color: EDPC.fg3,
    }}>{tag}</div>
  );
}

/* ── Hero icon cluster (replaces phone mockups) ───────── */
function HeroIconCluster({ T }) {
  return (
    <div style={{
      position: 'relative',
      width: 540, height: 520,
      maxWidth: '100%',
    }} className="ed-hero-cluster">
      {/* Abstract route SVG backdrop */}
      <svg viewBox="0 0 540 520" width="100%" height="100%" style={{
        position: 'absolute', inset: 0, opacity: 0.55, pointerEvents: 'none',
      }}>
        <defs>
          <linearGradient id="rt1" x1="0" y1="0" x2="1" y2="1">
            <stop offset="0" stopColor="#a78bfa" stopOpacity="0"/>
            <stop offset="0.5" stopColor="#a78bfa" stopOpacity="0.55"/>
            <stop offset="1" stopColor="#a78bfa" stopOpacity="0"/>
          </linearGradient>
          <linearGradient id="rt2" x1="0" y1="0" x2="1" y2="0">
            <stop offset="0" stopColor="#22d36b" stopOpacity="0"/>
            <stop offset="0.5" stopColor="#22d36b" stopOpacity="0.45"/>
            <stop offset="1" stopColor="#22d36b" stopOpacity="0"/>
          </linearGradient>
          <linearGradient id="rt3" x1="0" y1="0" x2="1" y2="1">
            <stop offset="0" stopColor="#38bdf8" stopOpacity="0"/>
            <stop offset="0.5" stopColor="#38bdf8" stopOpacity="0.45"/>
            <stop offset="1" stopColor="#38bdf8" stopOpacity="0"/>
          </linearGradient>
          <pattern id="dotgrid" x="0" y="0" width="28" height="28" patternUnits="userSpaceOnUse">
            <circle cx="1" cy="1" r="0.9" fill="rgba(246,244,239,0.10)"/>
          </pattern>
        </defs>
        {/* dotted grid */}
        <rect width="100%" height="100%" fill="url(#dotgrid)"/>
        {/* curved routes */}
        <path d="M 30 420 Q 130 320 240 360 T 510 180" stroke="url(#rt1)" strokeWidth="1.5" fill="none" strokeDasharray="0"/>
        <path d="M 0 280 Q 140 180 280 220 T 540 320" stroke="url(#rt3)" strokeWidth="1.2" fill="none"/>
        <path d="M 60 80 Q 200 140 280 240 T 480 480" stroke="url(#rt2)" strokeWidth="1.3" fill="none" strokeDasharray="4 6"/>
        {/* pins */}
        <g>
          <circle cx="30" cy="420" r="5" fill="#a78bfa" opacity="0.5"/>
          <circle cx="30" cy="420" r="2.5" fill="#fff" opacity="0.9"/>
          <circle cx="510" cy="180" r="5" fill="#a78bfa" opacity="0.5"/>
          <circle cx="510" cy="180" r="2.5" fill="#fff" opacity="0.9"/>
          <circle cx="480" cy="480" r="5" fill="#22d36b" opacity="0.5"/>
          <circle cx="60" cy="80" r="4" fill="#38bdf8" opacity="0.5"/>
        </g>
      </svg>

      {/* Glow halo — passenger (blue/cyan) */}
      <div aria-hidden style={{
        position: 'absolute', left: -40, top: 20, width: 420, height: 420,
        background: 'radial-gradient(50% 50% at 50% 50%, rgba(56,189,248,0.40) 0%, rgba(56,189,248,0) 65%)',
        filter: 'blur(20px)', pointerEvents: 'none', zIndex: 1,
      }}/>
      {/* Glow halo — partner (purple + green mix) */}
      <div aria-hidden style={{
        position: 'absolute', right: -40, bottom: 20, width: 420, height: 420,
        background: 'radial-gradient(50% 50% at 50% 50%, rgba(167,139,250,0.42) 0%, rgba(34,211,107,0.18) 40%, rgba(167,139,250,0) 70%)',
        filter: 'blur(20px)', pointerEvents: 'none', zIndex: 1,
      }}/>
      {/* Center halo blend */}
      <div aria-hidden style={{
        position: 'absolute', left: '50%', top: '50%', transform: 'translate(-50%, -50%)',
        width: 320, height: 320,
        background: 'radial-gradient(50% 50% at 50% 50%, rgba(167,139,250,0.18) 0%, rgba(167,139,250,0) 60%)',
        filter: 'blur(20px)', pointerEvents: 'none', zIndex: 1,
      }}/>

      {/* Partner icon — back, bottom-right */}
      <HeroIconTile
        src="assets/easy-driver-partner.png"
        alt={`${T.hero.partner} app icon`}
        size={280}
        style={{
          position: 'absolute', right: 16, bottom: 24,
          transform: 'rotate(5deg)', zIndex: 2,
        }}
        ringColor="rgba(167,139,250,0.32)"
      />
      {/* Passenger icon — front, top-left */}
      <HeroIconTile
        src="assets/easy-driver-passenger.png"
        alt={`${T.hero.passenger} app icon`}
        size={280}
        style={{
          position: 'absolute', left: 16, top: 24,
          transform: 'rotate(-5deg)', zIndex: 3,
        }}
        ringColor="rgba(56,189,248,0.32)"
      />

      {/* Small floating tag — connection */}
      <div style={{
        position: 'absolute', left: '50%', bottom: 0,
        transform: 'translateX(-50%)',
        display: 'inline-flex', alignItems: 'center', gap: 8,
        background: 'rgba(13,13,16,0.85)',
        backdropFilter: 'blur(12px)',
        border: `1px solid ${EDPC.border}`,
        borderRadius: 999, padding: '8px 14px', zIndex: 4,
        fontFamily: 'JetBrains Mono, monospace', fontSize: 10,
        letterSpacing: '0.22em', textTransform: 'uppercase', color: EDPC.fg2,
      }}>
        <span style={{ width: 6, height: 6, borderRadius: 999, background: EDPC.purple, boxShadow: `0 0 10px ${EDPC.purple}` }}/>
        {T.hero.passenger} · {T.hero.partner}
      </div>
    </div>
  );
}

function HeroIconTile({ src, alt, size = 260, style, ringColor }) {
  return (
    <div style={{
      width: size, height: size, borderRadius: size * 0.22,
      overflow: 'hidden',
      border: `1px solid ${EDPC.borderHi}`,
      boxShadow: `
        0 30px 60px -20px rgba(0,0,0,0.7),
        0 0 0 1px rgba(255,255,255,0.06) inset,
        0 0 60px -10px ${ringColor || 'rgba(167,139,250,0.4)'}
      `,
      transition: 'transform 0.4s cubic-bezier(0.2,0,0,1)',
      ...style,
    }}>
      <img src={src} alt={alt} style={{
        width: '100%', height: '100%', display: 'block', objectFit: 'cover',
      }}/>
    </div>
  );
}

/* ── Ecosystem ────────────────────────────────────────── */
function EcosystemSection({ T, lang }) {
  const e = T.ecosystem;
  return (
    <EDPSection id="ecosystem">
      <Reveal><EDPEyebrow style={{ marginBottom: 20 }}>{e.label}</EDPEyebrow></Reveal>
      <Reveal delay={80}>
        <h2 style={headlineXL}>
          <span style={{ color: EDPC.fg2 }}>{e.titleA}</span> {e.titleB}
        </h2>
      </Reveal>
      <Reveal delay={160}>
        <p style={{ fontSize: 17, color: EDPC.fg2, maxWidth: 620, lineHeight: 1.6, margin: '24px 0 64px' }}>
          {e.sub}
        </p>
      </Reveal>

      <div className="ed-eco-grid" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24 }}>
        <EcoCard
          tag={e.passengerTag}
          name={e.passengerName}
          desc={e.passengerDesc}
          icon="assets/easy-driver-passenger.png"
          loginImg="assets/easy-driver-login-passenger.png"
          storeUrl={`${EASY_DRIVER_DOWNLOAD_URL}?lang=${lang}`}
          storeLabel={e.passengerCta}
        />
        <EcoCard
          tag={e.partnerTag}
          name={e.partnerName}
          desc={e.partnerDesc}
          icon="assets/easy-driver-partner.png"
          loginImg="assets/easy-driver-login-partner.png"
          storeUrl={`${EASY_DRIVER_DOWNLOAD_URL}?lang=${lang}`}
          storeLabel={e.partnerCta}
          mirror
        />
      </div>

      <Reveal delay={240} style={{
        marginTop: 32, display: 'flex', alignItems: 'center', gap: 14,
        justifyContent: 'center',
      }}>
        <div style={{ width: 60, height: 1, background: `linear-gradient(90deg, transparent, ${EDPC.purple})` }}/>
        <span style={{ width: 6, height: 6, borderRadius: 999, background: EDPC.purple, boxShadow: `0 0 16px ${EDPC.purple}` }}/>
        <span style={{ fontFamily: 'JetBrains Mono, monospace', fontSize: 11, letterSpacing: '0.22em', textTransform: 'uppercase', color: EDPC.fg2 }}>{e.sync}</span>
        <span style={{ width: 6, height: 6, borderRadius: 999, background: EDPC.purple, boxShadow: `0 0 16px ${EDPC.purple}` }}/>
        <div style={{ width: 60, height: 1, background: `linear-gradient(90deg, ${EDPC.purple}, transparent)` }}/>
      </Reveal>
    </EDPSection>
  );
}

function EcoCard({ tag, name, desc, icon, screen, loginImg, mirror, storeUrl, storeLabel }) {
  return (
    <Reveal>
      <div style={{
        background: `radial-gradient(120% 80% at ${mirror ? '100%' : '0%'} 0%, rgba(167,139,250,0.10), transparent 55%), ${EDPC.bg2}`,
        border: `1px solid ${EDPC.border}`,
        borderRadius: 22, padding: 36,
        position: 'relative', overflow: 'hidden',
        minHeight: 540,
        display: 'flex', flexDirection: 'column',
      }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 26 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
            <div style={{
              width: 56, height: 56, borderRadius: 14, overflow: 'hidden',
              border: `1px solid ${EDPC.border}`,
              boxShadow: '0 16px 30px -12px rgba(0,0,0,0.6)',
            }}>
              <img src={icon} alt={name} style={{ width: '100%', height: '100%', display: 'block' }}/>
            </div>
            <div>
              <div style={{ fontSize: 19, fontWeight: 500, color: EDPC.fg, letterSpacing: '-0.01em' }}>{name}</div>
              <div style={{ fontFamily: 'JetBrains Mono, monospace', fontSize: 10, letterSpacing: '0.2em', textTransform: 'uppercase', color: EDPC.purple, marginTop: 4 }}>{tag}</div>
            </div>
          </div>
          <span style={{
            display: 'inline-flex', alignItems: 'center', gap: 5,
            fontSize: 10, fontFamily: 'JetBrains Mono, monospace',
            color: EDPC.fg3, letterSpacing: '0.14em', textTransform: 'uppercase',
          }}>
            <span style={{ width: 6, height: 6, borderRadius: 999, background: EDPC.green, boxShadow: `0 0 8px ${EDPC.green}` }}/>
            v1.0
          </span>
        </div>
        <p style={{ fontSize: 15, color: EDPC.fg2, lineHeight: 1.6, margin: '0 0 28px', maxWidth: 380 }}>{desc}</p>
        {storeUrl && (
          <a
            href={storeUrl}
            style={{
              display: 'inline-flex', alignItems: 'center', gap: 8,
              alignSelf: 'flex-start',
              height: 38, padding: '0 16px', borderRadius: 999,
              background: EDPC.purple, color: EDPC.bg,
              fontSize: 13, fontWeight: 500, textDecoration: 'none',
              marginBottom: 8, transition: 'transform 0.2s',
            }}
            onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-1px)'; }}
            onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; }}
          >
            {storeLabel}
            <span aria-hidden style={{ fontSize: 12, opacity: 0.8 }}>↗</span>
          </a>
        )}
        <div style={{
          flex: 1, display: 'flex', justifyContent: 'center', alignItems: 'flex-end',
          marginTop: 'auto', position: 'relative',
        }}>
          <div style={{ transform: `rotate(${mirror ? 4 : -4}deg)` }}>
            <PhoneFrame width={220} height={444} chromeless={!!loginImg}>
              {loginImg ? (
                <img
                  src={`${loginImg}?v=2`}
                  alt={`${name} login`}
                  style={{
                    position: 'absolute', inset: 0,
                    width: '100%', height: '100%',
                    objectFit: 'cover', objectPosition: 'top center',
                    display: 'block',
                  }}
                />
              ) : screen}
            </PhoneFrame>
          </div>
        </div>
      </div>
    </Reveal>
  );
}

/* ── Safety ───────────────────────────────────────────── */

const SafetyIconPaths = [
  <path d="M12 2v3M12 19v3M2 12h3M19 12h3M12 7a5 5 0 100 10 5 5 0 000-10zm0 3v2l1.5 1.5"/>,
  <React.Fragment><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z"/><path d="M8.5 12l2.5 2.5L16 9"/></React.Fragment>,
  <React.Fragment><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z"/><path d="M9 10l6 6M15 10l-6 6"/></React.Fragment>,
  <React.Fragment><circle cx="12" cy="12" r="8" strokeDasharray="3 3"/><circle cx="12" cy="12" r="3"/></React.Fragment>,
  <React.Fragment><circle cx="6" cy="12" r="2.5"/><circle cx="18" cy="6" r="2.5"/><circle cx="18" cy="18" r="2.5"/><path d="M8.2 11l7.6-3.5M8.2 13l7.6 3.5"/></React.Fragment>,
  <React.Fragment><path d="M12 22a3 3 0 003-3H9a3 3 0 003 3z"/><path d="M5 18h14l-1.5-2V11a5.5 5.5 0 00-11 0v5L5 18z"/></React.Fragment>,
  <path d="M3 12h4l3-8 4 16 3-8h4"/>,
  <React.Fragment><path d="M12 22s7-7.5 7-12a7 7 0 10-14 0c0 4.5 7 12 7 12z"/><circle cx="12" cy="10" r="2.5"/></React.Fragment>,
  <React.Fragment><rect x="6" y="11" width="12" height="9" rx="2"/><path d="M9 11V8a3 3 0 016 0v3"/></React.Fragment>,
  <React.Fragment><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z"/><path d="M12 9v3l2 1"/></React.Fragment>,
];

function SafetyIcon({ idx }) {
  return (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke={EDPC.purple} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      {SafetyIconPaths[idx]}
    </svg>
  );
}

function SafetySection({ T }) {
  const s = T.safety;
  return (
    <EDPSection id="features" style={{ background: `linear-gradient(180deg, ${EDPC.bg} 0%, ${EDPC.bg2} 50%, ${EDPC.bg} 100%)` }}>
      <div className="ed-safety-head" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 80, marginBottom: 72 }}>
        <div>
          <Reveal><EDPEyebrow style={{ marginBottom: 20 }}>{s.label}</EDPEyebrow></Reveal>
          <Reveal delay={80}>
            <h2 style={headlineXL}>
              <span style={{ color: EDPC.fg2 }}>{s.titleA}</span><br/>{s.titleB}
            </h2>
          </Reveal>
        </div>
        <Reveal delay={120} style={{ display: 'flex', flexDirection: 'column', gap: 18, paddingTop: 8 }}>
          <p style={{ fontSize: 16, color: EDPC.fg2, lineHeight: 1.7, margin: 0 }}>{s.intro}</p>
          <p style={{ fontSize: 16, color: EDPC.fg2, lineHeight: 1.7, margin: 0 }}>{s.intro2}</p>
        </Reveal>
      </div>

      <div style={{
        display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))',
        gap: 1, background: EDPC.border,
        border: `1px solid ${EDPC.border}`, borderRadius: 22, overflow: 'hidden',
      }}>
        {s.features.map((f, i) => (
          <Reveal key={i} delay={Math.min(i * 40, 240)}>
            <div style={{
              background: EDPC.bg, padding: '28px 26px',
              height: '100%', display: 'flex', flexDirection: 'column', gap: 12,
              transition: 'background 0.2s',
            }}
              onMouseEnter={(e) => { e.currentTarget.style.background = EDPC.bg3; }}
              onMouseLeave={(e) => { e.currentTarget.style.background = EDPC.bg; }}
            >
              <div style={{
                width: 40, height: 40, borderRadius: 10,
                background: EDPC.purpleSoft, border: `1px solid ${EDPC.purpleDim}`,
                display: 'flex', alignItems: 'center', justifyContent: 'center',
              }}>
                <SafetyIcon idx={i} />
              </div>
              <div style={{ fontSize: 16, fontWeight: 500, color: EDPC.fg, letterSpacing: '-0.005em' }}>{f.t}</div>
              <div style={{ fontSize: 13, color: EDPC.fg2, lineHeight: 1.55 }}>{f.d}</div>
            </div>
          </Reveal>
        ))}
      </div>
    </EDPSection>
  );
}

/* ── Eco Mobility Experience ──────────────────────────── */
function EcoSection({ T }) {
  const e = T.eco;
  const ecoGreen = EDPC.green;
  return (
    <EDPSection id="eco" style={{ background: `linear-gradient(180deg, ${EDPC.bg} 0%, ${EDPC.bg2} 50%, ${EDPC.bg} 100%)`, overflow: 'hidden' }}>
      {/* background glow */}
      <div aria-hidden style={{
        position: 'absolute', top: '20%', right: '-10%', width: 700, height: 700,
        background: `radial-gradient(50% 50% at 50% 50%, rgba(34,211,107,0.10) 0%, rgba(34,211,107,0) 60%)`,
        filter: 'blur(60px)', pointerEvents: 'none',
      }}/>

      <Reveal><EDPEyebrow style={{ marginBottom: 12, color: ecoGreen }}>{e.label}</EDPEyebrow></Reveal>
      <Reveal delay={60}>
        <div style={{
          display: 'inline-flex', alignItems: 'center', gap: 8,
          fontFamily: 'JetBrains Mono, monospace', fontSize: 10,
          letterSpacing: '0.22em', textTransform: 'uppercase',
          color: ecoGreen, marginBottom: 24,
          padding: '6px 12px', borderRadius: 999,
          background: 'rgba(34,211,107,0.08)',
          border: '1px solid rgba(34,211,107,0.22)',
        }}>
          <span style={{ width: 6, height: 6, borderRadius: 999, background: ecoGreen, boxShadow: `0 0 10px ${ecoGreen}` }}/>
          {e.tagline}
        </div>
      </Reveal>

      <div className="ed-eco-grid" style={{ display: 'grid', gridTemplateColumns: '1.15fr 1fr', gap: 80, alignItems: 'center', position: 'relative', zIndex: 1 }}>
        <div>
          <Reveal delay={80}>
            <h2 style={{
              fontFamily: 'Inter, sans-serif',
              fontSize: 'clamp(36px, 5.4vw, 72px)',
              fontWeight: 500, letterSpacing: '-0.035em', lineHeight: 1.0,
              margin: 0, color: EDPC.fg,
            }}>
              <span style={{ color: EDPC.fg2 }}>{e.titleA}</span><br/>{e.titleB}
            </h2>
          </Reveal>

          <Reveal delay={160}>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 16, margin: '32px 0 36px', maxWidth: 540 }}>
              {e.body.map((p, i) => (
                <p key={i} style={{ fontSize: 15, color: EDPC.fg2, lineHeight: 1.7, margin: 0 }}>{p}</p>
              ))}
            </div>
          </Reveal>

          {/* Metric cards */}
          <Reveal delay={240}>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12, marginBottom: 28 }}>
              {e.metrics.map((m, i) => (
                <div key={i} style={{
                  background: EDPC.bg2,
                  border: `1px solid ${EDPC.border}`,
                  borderRadius: 14, padding: '16px 18px',
                  position: 'relative', overflow: 'hidden',
                  transition: 'border-color 0.2s, transform 0.2s',
                }}
                  onMouseEnter={(ev) => { ev.currentTarget.style.borderColor = 'rgba(34,211,107,0.32)'; ev.currentTarget.style.transform = 'translateY(-2px)'; }}
                  onMouseLeave={(ev) => { ev.currentTarget.style.borderColor = EDPC.border; ev.currentTarget.style.transform = 'translateY(0)'; }}
                >
                  <div style={{ fontFamily: 'Inter, sans-serif', fontSize: 22, fontWeight: 500, letterSpacing: '-0.02em', color: i === 0 ? ecoGreen : EDPC.fg, marginBottom: 4 }}>{m.v}</div>
                  <div style={{ fontFamily: 'JetBrains Mono, monospace', fontSize: 10, color: EDPC.fg3, letterSpacing: '0.12em', textTransform: 'uppercase' }}>{m.lbl}</div>
                  <div style={{ fontSize: 11, color: EDPC.fg2, marginTop: 6, lineHeight: 1.5 }}>{m.sub}</div>
                </div>
              ))}
            </div>
          </Reveal>

          {/* Tag chips */}
          <Reveal delay={320}>
            <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
              {e.tags.map((tag) => (
                <span key={tag} style={{
                  display: 'inline-flex', alignItems: 'center', gap: 6,
                  height: 28, padding: '0 12px', borderRadius: 999,
                  border: `1px solid rgba(34,211,107,0.22)`,
                  background: 'rgba(34,211,107,0.05)',
                  fontFamily: 'JetBrains Mono, monospace',
                  fontSize: 10, letterSpacing: '0.08em', textTransform: 'uppercase',
                  color: 'rgba(34,211,107,0.95)',
                }}>
                  <span style={{ width: 4, height: 4, borderRadius: 999, background: ecoGreen, boxShadow: `0 0 6px ${ecoGreen}` }}/>
                  {tag}
                </span>
              ))}
            </div>
          </Reveal>
        </div>

        {/* Right: real Bike E. ride photo */}
        <Reveal delay={200} style={{ position: 'relative', display: 'flex', justifyContent: 'flex-end', alignItems: 'center', minHeight: 540 }}>
          <div aria-hidden style={{
            position: 'absolute', right: 0, top: '50%', transform: 'translateY(-50%)',
            width: 540, height: 540,
            background: `radial-gradient(50% 50% at 50% 50%, rgba(34,211,107,0.22), transparent 60%)`,
            filter: 'blur(50px)', pointerEvents: 'none',
          }}/>
          {/* Floating CO2 badge */}
          <div style={{
            position: 'absolute', top: '6%', left: '2%', zIndex: 3,
            background: 'rgba(13,13,16,0.86)',
            backdropFilter: 'blur(14px)',
            WebkitBackdropFilter: 'blur(14px)',
            border: `1px solid rgba(34,211,107,0.32)`,
            borderRadius: 14, padding: '12px 14px',
            display: 'flex', alignItems: 'center', gap: 12,
            boxShadow: '0 20px 40px -16px rgba(0,0,0,0.7)',
          }}>
            <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke={EDPC.green} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
              <path d="M12 2C7 6 5 10 5 13a7 7 0 0014 0c0-3-2-7-7-11z"/>
              <path d="M9 12c0 2 1.5 4 3 4"/>
            </svg>
            <div>
              <div style={{ fontFamily: 'JetBrains Mono, monospace', fontSize: 10, color: EDPC.green, letterSpacing: '0.12em', textTransform: 'uppercase' }}>CO₂ tracking</div>
              <div style={{ fontSize: 15, fontWeight: 500, color: EDPC.fg, letterSpacing: '-0.01em' }}>210 g <span style={{ color: EDPC.fg3, fontSize: 11, fontWeight: 400 }}>/ km</span></div>
            </div>
          </div>
          {/* Floating Bike E. badge */}
          <div style={{
            position: 'absolute', bottom: '8%', right: '2%', zIndex: 3,
            background: 'rgba(13,13,16,0.86)',
            backdropFilter: 'blur(14px)',
            WebkitBackdropFilter: 'blur(14px)',
            border: `1px solid ${EDPC.border}`,
            borderRadius: 14, padding: '12px 14px',
            display: 'flex', alignItems: 'center', gap: 12,
            boxShadow: '0 20px 40px -16px rgba(0,0,0,0.7)',
          }}>
            <span style={{ width: 8, height: 8, borderRadius: 999, background: EDPC.green, boxShadow: `0 0 10px ${EDPC.green}` }}/>
            <div>
              <div style={{ fontFamily: 'JetBrains Mono, monospace', fontSize: 10, color: EDPC.fg3, letterSpacing: '0.12em', textTransform: 'uppercase' }}>Bike E.</div>
              <div style={{ fontSize: 13, fontWeight: 500, color: EDPC.fg, letterSpacing: '-0.005em' }}>smart · eco · low cost</div>
            </div>
          </div>

          <div style={{
            position: 'relative', zIndex: 2,
            width: '100%', maxWidth: 540, aspectRatio: '1 / 1',
            borderRadius: 24, overflow: 'hidden',
            border: `1px solid ${EDPC.border}`,
            boxShadow: '0 40px 80px -30px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.04) inset',
          }}>
            <img
              src="assets/bike-e-ride.png"
              alt="Easy Driver Bike E. ride"
              style={{
                width: '100%', height: '100%',
                objectFit: 'cover', display: 'block',
              }}
            />
            {/* Subtle dark gradient overlay for legibility of badges */}
            <div aria-hidden style={{
              position: 'absolute', inset: 0,
              background: 'linear-gradient(180deg, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0) 35%, rgba(0,0,0,0) 65%, rgba(0,0,0,0.22) 100%)',
              pointerEvents: 'none',
            }}/>
          </div>
        </Reveal>
      </div>
    </EDPSection>
  );
}

/* ── UX ───────────────────────────────────────────────── */
function UXSection({ T }) {
  const u = T.ux;
  return (
    <EDPSection>
      <div className="ed-ux-grid" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 60, alignItems: 'center' }}>
        <div>
          <Reveal><EDPEyebrow style={{ marginBottom: 20 }}>{u.label}</EDPEyebrow></Reveal>
          <Reveal delay={80}>
            <h2 style={headlineXL}>
              <span style={{ color: EDPC.fg2 }}>{u.titleA}</span> {u.titleB}
            </h2>
          </Reveal>
          <Reveal delay={160}>
            <p style={{ fontSize: 16, color: EDPC.fg2, lineHeight: 1.7, margin: '24px 0 40px', maxWidth: 520 }}>{u.sub}</p>
          </Reveal>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 1, background: EDPC.border, border: `1px solid ${EDPC.border}`, borderRadius: 16, overflow: 'hidden' }}>
            {u.tags.map((tag, i) => (
              <Reveal key={i} delay={Math.min(i * 60, 240)}>
                <div style={{ background: EDPC.bg, padding: '20px 22px', display: 'flex', alignItems: 'center', gap: 18 }}>
                  <span style={{ fontFamily: 'JetBrains Mono, monospace', fontSize: 10, color: EDPC.purple, width: 26, letterSpacing: '0.1em' }}>0{i+1}</span>
                  <div style={{ flex: 1 }}>
                    <div style={{ fontSize: 15, fontWeight: 500, color: EDPC.fg }}>{tag.t}</div>
                    <div style={{ fontSize: 13, color: EDPC.fg2, marginTop: 3 }}>{tag.d}</div>
                  </div>
                </div>
              </Reveal>
            ))}
          </div>
        </div>
        <Reveal delay={200} style={{ position: 'relative', display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: 680 }}>
          <div aria-hidden style={{
            position: 'absolute', width: 540, height: 540,
            background: 'radial-gradient(50% 50% at 50% 50%, rgba(167,139,250,0.16), transparent 60%)',
            filter: 'blur(40px)', pointerEvents: 'none',
          }}/>
          {/* Passenger phone — top-left, tilted */}
          <div style={{ position: 'absolute', left: '0%', top: '4%', zIndex: 2 }}>
            <PhoneFrame width={200} height={420} rotate={-10} chromeless>
              <img
                src="assets/easy-driver-app-passenger.png"
                alt="Passenger app"
                style={{
                  position: 'absolute', inset: 0,
                  width: '100%', height: '100%',
                  objectFit: 'cover', objectPosition: 'top center',
                  display: 'block',
                }}
              />
            </PhoneFrame>
          </div>
          {/* Payment phone — center, front */}
          <div style={{ position: 'absolute', left: '50%', top: '50%', transform: 'translate(-50%, -50%)', zIndex: 3 }}>
            <PhoneFrame width={216} height={456} rotate={0} chromeless>
              <img
                src="assets/easy-driver-app-payment.png"
                alt="Payment PIX"
                style={{
                  position: 'absolute', inset: 0,
                  width: '100%', height: '100%',
                  objectFit: 'cover', objectPosition: 'top center',
                  display: 'block',
                }}
              />
            </PhoneFrame>
          </div>
          {/* Partner phone — bottom-right, tilted */}
          <div style={{ position: 'absolute', right: '-2%', bottom: '4%', zIndex: 1 }}>
            <PhoneFrame width={200} height={420} rotate={10} chromeless>
              <img
                src="assets/easy-driver-app-partner.png"
                alt="Partner app"
                style={{
                  position: 'absolute', inset: 0,
                  width: '100%', height: '100%',
                  objectFit: 'cover', objectPosition: 'top center',
                  display: 'block',
                }}
              />
            </PhoneFrame>
          </div>
        </Reveal>
      </div>
    </EDPSection>
  );
}

/* ── Tech ─────────────────────────────────────────────── */
function TechSection({ T }) {
  const tk = T.tech;
  return (
    <EDPSection id="tech">
      <Reveal><EDPEyebrow style={{ marginBottom: 20 }}>{tk.label}</EDPEyebrow></Reveal>
      <Reveal delay={80}>
        <h2 style={headlineXL}>
          <span style={{ color: EDPC.fg2 }}>{tk.titleA}</span> {tk.titleB}
        </h2>
      </Reveal>
      <Reveal delay={160}>
        <p style={{ fontSize: 16, color: EDPC.fg2, lineHeight: 1.7, margin: '24px 0 56px', maxWidth: 620 }}>{tk.sub}</p>
      </Reveal>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))', gap: 14 }}>
        {tk.items.map(([name, desc], i) => (
          <Reveal key={name} delay={Math.min(i * 50, 240)}>
            <div style={{
              background: EDPC.bg2,
              border: `1px solid ${EDPC.border}`,
              borderRadius: 14, padding: '22px 22px',
              display: 'flex', flexDirection: 'column', gap: 8,
              minHeight: 110,
              transition: 'border-color 0.2s, transform 0.2s',
            }}
              onMouseEnter={(e) => { e.currentTarget.style.borderColor = EDPC.purpleDim; e.currentTarget.style.transform = 'translateY(-2px)'; }}
              onMouseLeave={(e) => { e.currentTarget.style.borderColor = EDPC.border; e.currentTarget.style.transform = 'translateY(0)'; }}
            >
              <div style={{ fontSize: 17, fontWeight: 500, color: EDPC.fg, letterSpacing: '-0.005em' }}>{name}</div>
              <div style={{ fontFamily: 'JetBrains Mono, monospace', fontSize: 11, color: EDPC.fg3, letterSpacing: '0.04em' }}>{desc}</div>
            </div>
          </Reveal>
        ))}
      </div>
    </EDPSection>
  );
}

/* ── Vision ───────────────────────────────────────────── */
function VisionSection({ T }) {
  const v = T.vision;
  return (
    <EDPSection id="vision">
      <div style={{ maxWidth: 900, margin: '0 auto', textAlign: 'left' }}>
        <Reveal><EDPEyebrow style={{ marginBottom: 36 }}>{v.label}</EDPEyebrow></Reveal>
        <Reveal delay={80}>
          <p style={{
            fontFamily: 'Inter, sans-serif',
            fontSize: 'clamp(24px, 2.6vw, 36px)',
            lineHeight: 1.35, color: EDPC.fg,
            margin: '0 0 28px', letterSpacing: '-0.02em', fontWeight: 400,
          }}>{v.bodyA}</p>
        </Reveal>
        <Reveal delay={160}>
          <p style={{
            fontFamily: 'Inter, sans-serif',
            fontSize: 'clamp(20px, 2vw, 28px)',
            lineHeight: 1.45, color: EDPC.fg2,
            margin: 0, letterSpacing: '-0.015em', fontWeight: 400,
          }}>{v.bodyB}</p>
        </Reveal>
      </div>
    </EDPSection>
  );
}

/* ── Final CTA ────────────────────────────────────────── */
function FinalCTA({ T, lang }) {
  const c = T.cta;
  return (
    <EDPSection padTop={160} padBottom={180} style={{
      borderTop: `1px solid ${EDPC.border}`,
      background: `radial-gradient(60% 60% at 50% 100%, rgba(167,139,250,0.16), transparent 70%), ${EDPC.bg}`,
      overflow: 'hidden',
    }}>
      <div style={{
        display: 'flex', flexDirection: 'column', alignItems: 'center',
        textAlign: 'center', position: 'relative',
      }}>
        <Reveal style={{ position: 'relative', marginBottom: 60 }}>
          <PhoneFrame width={300} height={620} rotate={0} glow chromeless>
            <img
              src="assets/easy-driver-app-driver-home.png"
              alt="Easy Driver driver home screen"
              style={{
                position: 'absolute', inset: 0,
                width: '100%', height: '100%',
                objectFit: 'cover', objectPosition: 'top center',
                display: 'block',
              }}
            />
          </PhoneFrame>
        </Reveal>
        <Reveal delay={120}><EDPEyebrow style={{ marginBottom: 24 }}>{c.eyebrow}</EDPEyebrow></Reveal>
        <Reveal delay={200}>
          <h2 style={{
            fontFamily: 'Inter, sans-serif',
            fontSize: 'clamp(48px, 7vw, 96px)',
            fontWeight: 500, letterSpacing: '-0.04em', lineHeight: 0.95,
            margin: 0, color: EDPC.fg, maxWidth: 980,
          }}>
            {c.titleA}<br/>
            <span style={{ color: EDPC.purple, fontStyle: 'italic', fontWeight: 400 }}>{c.titleB}</span>
          </h2>
        </Reveal>
        <Reveal delay={300} style={{ marginTop: 44, display: 'flex', gap: 12, flexWrap: 'wrap', justifyContent: 'center' }}>
          <EDPButton variant="primary" href={`${EASY_DRIVER_DOWNLOAD_URL}?lang=${lang}`} icon="↓">{T.downloadApp}</EDPButton>
          <EDPButton variant="ghost" href={`index.html?lang=${lang}`}>{c.buttonBack}</EDPButton>
        </Reveal>
      </div>
    </EDPSection>
  );
}

function EDPFooter({ lang }) {
  return (
    <footer style={{
      borderTop: `1px solid ${EDPC.border}`,
      padding: '36px 32px',
      maxWidth: 1280, margin: '0 auto',
      display: 'flex', justifyContent: 'space-between', alignItems: 'center',
      fontFamily: 'JetBrains Mono, monospace', fontSize: 11,
      color: EDPC.fg3, letterSpacing: '0.06em',
    }}>
      <span>© 2026 EZV Studio · Easy Driver</span>
      <a
        href="https://www.instagram.com/easydriver.app/"
        target="_blank"
        rel="noopener noreferrer"
        style={{ color: EDPC.fg3, display: 'flex', alignItems: 'center', gap: 6, textDecoration: 'none', transition: 'color 0.2s', fontSize: 11, letterSpacing: '0.06em' }}
        onMouseEnter={(e) => { e.currentTarget.style.color = EDPC.fg2; }}
        onMouseLeave={(e) => { e.currentTarget.style.color = EDPC.fg3; }}
      >
        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <rect x="2" y="2" width="20" height="20" rx="5"/>
          <circle cx="12" cy="12" r="4"/>
          <circle cx="17.5" cy="6.5" r="1.5" fill="currentColor" stroke="none"/>
        </svg>
        @easydriver.app
      </a>
      <a
        href={`suporte.html?lang=${lang}`}
        style={{ color: EDPC.fg3, textDecoration: 'none', transition: 'color 0.2s', fontSize: 11, letterSpacing: '0.06em' }}
        onMouseEnter={(e) => { e.currentTarget.style.color = EDPC.fg2; }}
        onMouseLeave={(e) => { e.currentTarget.style.color = EDPC.fg3; }}
      >
        Suporte
      </a>
    </footer>
  );
}

const headlineXL = {
  fontFamily: 'Inter, sans-serif',
  fontSize: 'clamp(36px, 5.4vw, 72px)',
  fontWeight: 500, letterSpacing: '-0.035em', lineHeight: 1.0,
  margin: 0, color: EDPC.fg,
};

function EDPApp() {
  const [lang, setLang] = useS(getInitialLang());
  useE(() => {
    try {
      localStorage.setItem('ezLang', lang);
      const u = new URL(window.location.href);
      u.searchParams.set('lang', lang);
      window.history.replaceState({}, '', u);
    } catch {}
  }, [lang]);
  const T = EDP[lang] || EDP.pt;

  return (
    <div style={{
      background: EDPC.bg, color: EDPC.fg,
      fontFamily: 'Inter, sans-serif',
      minHeight: '100vh',
    }}>
      <TopNav lang={lang} setLang={setLang} T={T} />
      <main>
        <HeroSection T={T} lang={lang} />
        <EcosystemSection T={T} lang={lang} />
        <SafetySection T={T} />
        <EcoSection T={T} />
        <UXSection T={T} />
        <TechSection T={T} />
        <VisionSection T={T} />
        <FinalCTA T={T} lang={lang} />
      </main>
      <EDPFooter lang={lang} />
    </div>
  );
}

const edpRoot = ReactDOM.createRoot(document.getElementById('root'));
edpRoot.render(<EDPApp />);
