// Sections — Header / Hero / Stats / TrackRecord / Services / Team / CEO / AIDemo / Contact / Footer

const { useState, useEffect, useRef } = React;
const useReveal = window.useReveal;

const LANGS = [['ko', 'KO', '한국어'], ['en', 'EN', 'English'], ['ja', 'JA', '日本語'], ['zh', 'ZH', '中文']];

function LangMenu({ lang, setLang }) {
  const [open, setOpen] = useState(false);
  const wrapRef = useRef(null);
  useEffect(() => {
    if (!open) return;
    const away = (e) => { if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false); };
    const esc = (e) => { if (e.key === 'Escape') setOpen(false); };
    document.addEventListener('pointerdown', away);
    document.addEventListener('keydown', esc);
    return () => { document.removeEventListener('pointerdown', away); document.removeEventListener('keydown', esc); };
  }, [open]);
  const active = LANGS.find((l) => l[0] === lang) || LANGS[0];
  return (
    <div ref={wrapRef} className="lang-switch" style={{ position: 'relative' }}>
      <button onClick={() => setOpen((v) => !v)} aria-expanded={open} aria-haspopup="listbox" aria-label="Language" style={{
        display: 'inline-flex', alignItems: 'center', gap: 7, padding: '6px 11px',
        background: 'transparent', border: '1px solid var(--line)', borderRadius: 3,
        color: 'var(--fg-2)', cursor: 'pointer', transition: 'border-color .2s, color .2s'
      }}
      onMouseEnter={(e) => { e.currentTarget.style.borderColor = 'var(--accent)'; e.currentTarget.style.color = 'var(--accent)'; }}
      onMouseLeave={(e) => { e.currentTarget.style.borderColor = 'var(--line)'; e.currentTarget.style.color = 'var(--fg-2)'; }}>
        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" aria-hidden>
          <circle cx="12" cy="12" r="9" /><path d="M3.5 12h17M12 3a15 15 0 0 1 0 18M12 3a15 15 0 0 0 0 18" />
        </svg>
        <span className="mono" style={{ fontSize: 11, fontWeight: 600, letterSpacing: '.08em' }}>{active[1]}</span>
        <span aria-hidden style={{ fontSize: 8, opacity: .7, transform: open ? 'rotate(180deg)' : 'none', transition: 'transform .2s' }}>▾</span>
      </button>
      {open && (
        <div role="listbox" style={{
          position: 'absolute', top: 'calc(100% + 8px)', right: 0, minWidth: 150, zIndex: 90,
          background: 'var(--surface)', border: '1px solid var(--line)',
          boxShadow: '0 18px 44px -22px rgba(11,26,54,.42)', padding: 4
        }}>
          {LANGS.map(([code, abbr, name]) => {
            const on = code === lang;
            return (
              <button key={code} role="option" aria-selected={on}
                onClick={() => { setLang(code); setOpen(false); }}
                style={{
                  width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12,
                  padding: '10px 12px', background: on ? 'var(--bg-2)' : 'transparent', border: 'none',
                  cursor: 'pointer', textAlign: 'left', color: 'var(--fg)'
                }}
                onMouseEnter={(e) => { if (!on) e.currentTarget.style.background = 'var(--bg-2)'; }}
                onMouseLeave={(e) => { if (!on) e.currentTarget.style.background = 'transparent'; }}>
                <span style={{ fontSize: 13, fontWeight: on ? 700 : 500 }}>{name}</span>
                <span className="mono" style={{ fontSize: 10, letterSpacing: '.1em', color: on ? 'var(--accent)' : 'var(--fg-3)', fontWeight: 700 }}>{on ? '✓' : abbr}</span>
              </button>);
          })}
        </div>
      )}
    </div>);
}

// ============================== HEADER ==============================
function Header({ t, lang, setLang, tweaks, setTweak }) {
  const [scrolled, setScrolled] = useState(false);
  const [open, setOpen] = useState(false);
  useEffect(() => {
    const f = () => setScrolled(window.scrollY > 8);
    window.addEventListener('scroll', f, { passive: true });
    return () => window.removeEventListener('scroll', f);
  }, []);

  const links = [
  { k: 'verified', href: '#verified' },
  { k: 'patentguard', href: '#patentguard' },
  { k: 'trust', href: '#trust' },
  { k: 'ecodeteam', href: '#ecodeteam' },
  { k: 'services', href: '#services' },
  { k: 'ceo', href: '#ceo' },
  { k: 'team', href: '#team' },  { k: 'disclosure', href: 'announcements/' }];


  return (
    <header className="band-ink" style={{
      position: 'sticky', top: 0, zIndex: 80,
      backdropFilter: scrolled ? 'blur(18px) saturate(180%)' : 'none',
      WebkitBackdropFilter: scrolled ? 'blur(18px) saturate(180%)' : 'none',
      background: scrolled ? 'color-mix(in srgb, var(--ink) 92%, transparent)' : 'var(--ink)',
      borderBottom: scrolled ? '1px solid rgba(255,255,255,.13)' : '1px solid transparent',
      transition: 'all .25s'
    }}>
      <div style={{ maxWidth: 1320, margin: '0 auto', padding: '14px 28px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 24 }}>
        <a href="#" style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
          <Logo />
        </a>
        <nav style={{ display: 'flex', gap: 4, alignItems: 'center' }} className="desktop-nav">
          {links.map((l) => {
            const flag = l.k === 'verified' || l.k === 'patentguard';
            const rest = 'rgba(255,255,255,.76)';
            return (
              <a key={l.k} href={l.href}
              data-flag={flag ? '1' : undefined}
              target={l.ext ? '_blank' : undefined}
              rel={l.ext ? 'noopener noreferrer' : undefined}
              style={{
                padding: '8px 13px', borderRadius: 4, fontSize: 13.5,
                color: flag ? 'var(--accent)' : rest,
                fontWeight: flag ? 700 : 400,
                display: 'inline-flex', alignItems: 'center', gap: 7,
                transition: 'color .2s, opacity .2s'
              }}
              onMouseEnter={(e) => { e.currentTarget.style.color = flag ? 'var(--accent)' : '#fff'; e.currentTarget.style.opacity = flag ? '.78' : '1'; }}
              onMouseLeave={(e) => { e.currentTarget.style.color = flag ? 'var(--accent)' : rest; e.currentTarget.style.opacity = '1'; }}>
                {flag && <span aria-hidden style={{ width: 5, height: 5, borderRadius: 999, background: 'var(--accent)', flexShrink: 0 }}></span>}
                {t.nav[l.k]}
                {l.ext && <span aria-hidden className="mono" style={{ fontSize: 9.5, opacity: .6 }}>↗</span>}
              </a>);
          })}
        </nav>
        <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
          {/* Language — popover */}
          <LangMenu lang={lang} setLang={setLang} />

          {/* Theme toggle */}
          <button onClick={() => setTweak('theme', tweaks.theme === 'dark' ? 'light' : 'dark')}
          aria-label="Toggle theme"
          title={tweaks.theme === 'dark' ? 'Switch to light' : 'Switch to dark'}
          style={{
            width: 32, height: 32, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
            background: 'transparent', border: '1px solid var(--line)', borderRadius: 999, cursor: 'pointer',
            color: 'var(--fg-2)', transition: 'color .2s, border-color .2s'
          }}
          onMouseEnter={(e) => {e.currentTarget.style.color = 'var(--accent)';e.currentTarget.style.borderColor = 'var(--accent)';}}
          onMouseLeave={(e) => {e.currentTarget.style.color = 'var(--fg-2)';e.currentTarget.style.borderColor = 'var(--line)';}}>
            {tweaks.theme === 'dark' ?
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                <circle cx="12" cy="12" r="4" /><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41" />
              </svg> :

            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
              </svg>
            }
          </button>

          <a href="#contact" className="header-cta" style={{
            padding: '10px 20px', borderRadius: 3, background: 'transparent', color: '#fff',
            border: '1px solid rgba(255,255,255,.4)',
            fontSize: 13, fontWeight: 600, display: 'inline-flex', alignItems: 'center', gap: 8,
            transition: 'background .2s, border-color .2s'
          }}
          onMouseEnter={(e) => {e.currentTarget.style.background = 'var(--accent)'; e.currentTarget.style.borderColor = 'var(--accent)';}}
          onMouseLeave={(e) => {e.currentTarget.style.background = 'transparent'; e.currentTarget.style.borderColor = 'rgba(255,255,255,.4)';}}>
            {t.hero.ctaShort || t.hero.cta1}
            <span style={{ fontFamily: 'var(--font-mono)' }}>↗</span>
          </a>

        </div>
      </div>

      
    </header>);

}


function Logo({ wordmark = false, onInk = true }) {
  const isDark = onInk;
  if (wordmark) {
    return (
      <img
        src={isDark ? "assets/logo-dark.png" : "assets/logo.png"}
        alt="ECODE"
        style={{ display: 'block', height: 32, width: 'auto', objectFit: 'contain' }} />);


  }
  return (
    <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
      <img
        src={isDark ? "assets/logo-icon-dark.png" : "assets/logo.png"}
        alt="ECODE"
        width="32" height="32"
        style={{ display: 'block', objectFit: 'contain' }} />
      
      <span className="logo-word" style={{ fontWeight: 800, letterSpacing: '-.02em', fontSize: 19, color: onInk ? '#fff' : 'var(--fg)' }}>ECODE</span>
    </div>);

}

function PillarIcon({ kind }) {
  const c = 'var(--ink-fg-2)';
  const a = 'var(--accent)';
  const m = {
    shield: <><path d="M13 3l8 3.4v6.2c0 4.9-3.4 9.1-8 10.4-4.6-1.3-8-5.5-8-10.4V6.4L13 3Z" stroke={c} strokeWidth="1.3" fill="none"/><path d="M9.4 13l2.6 2.6L17 10.6" stroke={a} strokeWidth="1.6" fill="none" strokeLinecap="round" strokeLinejoin="round"/></>,
    gavel: <><path d="M4 21h9" stroke={c} strokeWidth="1.4" strokeLinecap="round"/><path d="M6.5 17.5l7-7" stroke={c} strokeWidth="1.4" strokeLinecap="round"/><rect x="12" y="4.5" width="7.5" height="4.2" rx="1" transform="rotate(45 12 4.5)" stroke={a} strokeWidth="1.4" fill="none"/></>,
    chart: <><path d="M4 20h17" stroke={c} strokeWidth="1.3" strokeLinecap="round"/><rect x="6" y="12" width="3.2" height="6" stroke={c} strokeWidth="1.3" fill="none"/><rect x="11.4" y="8.5" width="3.2" height="9.5" stroke={a} strokeWidth="1.4" fill="none"/><rect x="16.8" y="5.5" width="3.2" height="12.5" stroke={c} strokeWidth="1.3" fill="none"/></>
  };
  return <svg viewBox="0 0 26 26" width="26" height="26" fill="none" aria-hidden style={{ flexShrink: 0 }}>{m[kind]}</svg>;
}

// ============================== HERO ==============================
function Hero({ t, tweaks }) {
  const accent = `hsl(${tweaks.accentHue} 100% 55%)`;
  const variant = tweaks.heroVisual;

  return (
    <section className="band-ink" style={{ position: 'relative', overflow: 'hidden' }}>
      {/* hero backplate */}
      <div aria-hidden style={{
        position: 'absolute', inset: 0, zIndex: 0, pointerEvents: 'none',
        backgroundImage: 'url(assets/hero-bg.png)',
        backgroundSize: 'cover', backgroundPosition: 'center bottom', backgroundRepeat: 'no-repeat'
      }}></div>
      {/* verification dashboard mockup */}
      <div aria-hidden className="hero-artifact" style={{
        position: 'absolute', top: '18%', right: '-8%', width: 'min(56vw, 900px)', zIndex: 1,
        pointerEvents: 'none',
        maskImage: 'linear-gradient(to bottom, transparent 0%, rgba(0,0,0,.35) 5%, #000 14%)',
        WebkitMaskImage: 'linear-gradient(to bottom, transparent 0%, rgba(0,0,0,.35) 5%, #000 14%)'
      }}>
        <img src="assets/hero-dashboard.png" alt="" style={{ display: 'block', width: '100%', height: 'auto' }} />
      </div>



      <div className="hero-content" style={{ position: 'relative', zIndex: 2, maxWidth: 1320, margin: '0 auto', padding: '92px 28px 130px', width: '100%' }}>
        {/* Statement */}
        <div className="mono" style={{
          fontSize: 10.5, letterSpacing: '.26em', fontWeight: 600,
          marginBottom: 30, display: 'inline-flex', alignItems: 'baseline', gap: 13
        }}>
          <span style={{ color: 'var(--accent)', fontWeight: 700 }}>{t.hero.eyebrowPre}</span>
          <span style={{ color: 'var(--ink-fg-2)' }}>{t.hero.eyebrow}</span>
        </div>

        <h1 className="hero-h1" style={{ fontFamily: 'var(--font-sans)', fontWeight: 700, fontSize: 'clamp(34px, 4.6vw, 62px)', lineHeight: 1.32, letterSpacing: '-0.035em', margin: 0, maxWidth: '18ch' }}>
          <span style={{ display: 'block', color: '#fff' }}>{t.hero.titleA}</span>
          <span style={{ display: 'block', color: '#fff' }}>{t.hero.titleB}<span style={{ color: 'var(--accent)' }}>{t.hero.titleAccent}</span></span>
        </h1>

        <div style={{ marginTop: 24 }}>
          <div>
            <p style={{ margin: 0, color: 'var(--ink-fg-2)', fontSize: 'clamp(14.5px, 1.15vw, 16.5px)', lineHeight: 1.75, whiteSpace: 'pre-line' }}>
              {t.hero.sub}
            </p>
            <div className="hero-ctas" style={{ marginTop: 30, display: 'flex', gap: 12, flexWrap: 'wrap' }}>
              <a href="#contact" style={{
                padding: '14px 26px', borderRadius: 3, background: '#fff', color: 'var(--ink)',
                fontWeight: 700, fontSize: 14.5, display: 'inline-flex', alignItems: 'center', gap: 10,
                transition: 'background .2s'
              }}
              onMouseEnter={(e) => {e.currentTarget.style.background = 'var(--accent)'; e.currentTarget.style.color = '#fff';}}
              onMouseLeave={(e) => {e.currentTarget.style.background = '#fff'; e.currentTarget.style.color = 'var(--ink)';}}>
                {t.hero.cta1} <span className="mono">→</span>
              </a>
              <a href="#method" style={{
                padding: '14px 26px', borderRadius: 3, color: 'var(--ink-fg)',
                border: '1px solid var(--ink-line-strong)', fontWeight: 600, fontSize: 14.5,
                display: 'inline-flex', alignItems: 'center', gap: 10, background: 'transparent',
                transition: 'border-color .2s, background .2s'
              }}
              onMouseEnter={(e) => {e.currentTarget.style.borderColor = '#fff'; e.currentTarget.style.background = 'rgba(255,255,255,.07)';}}
              onMouseLeave={(e) => {e.currentTarget.style.borderColor = 'var(--ink-line-strong)'; e.currentTarget.style.background = 'transparent';}}>
                {t.hero.cta2} <span className="mono">↓</span>
              </a>
            </div>
          </div>
          <div className="hero-pillars" style={{ marginTop: 52, display: 'flex', gap: 46, flexWrap: 'wrap', alignItems: 'center' }}>
            {(t.hero.pillars || []).map((p) => (
              <div key={p.k} style={{ display: 'inline-flex', alignItems: 'center', gap: 11 }}>
                <PillarIcon kind={p.icon} />
                <span style={{ fontSize: 13, color: 'var(--ink-fg-2)', fontWeight: 500 }}>{p.k}</span>
              </div>
            ))}
          </div>
        </div>

      </div>
    </section>);

}

function lang_label(t) {
  return t.method ? (t.method.humanLabel === '사람이 판단'
    ? 'AI 1차 스캔 → 전문가 2차 재검증 → 수정 후 재확인'
    : 'AI first-pass scan → expert re-verification → post-fix re-check') : '';
}

function StatusDot({ label }) {
  return (
    <span style={{ display: 'inline-flex', alignItems: 'center', gap: 8 }} className="mono">
      <span style={{ position: 'relative', display: 'inline-flex' }}>
        <span style={{ width: 8, height: 8, borderRadius: 999, background: 'var(--accent)' }}></span>
        <span style={{
          position: 'absolute', inset: -4, borderRadius: 999, border: '1px solid var(--accent)',
          animation: 'pulse 1.6s ease-out infinite', opacity: 0
        }}></span>
      </span>
      <span className="mono-ko" style={{ fontSize: 12.5, color: 'var(--ink-fg-2)' }}>{label}</span>
      <style>{`
        @keyframes pulse {
          0% { transform: scale(0.6); opacity: 0.7 }
          80% { transform: scale(1.8); opacity: 0 }
          100% { transform: scale(1.8); opacity: 0 }
        }
      `}</style>
    </span>);

}

// ============================== STATS ==============================
function Stats({ t }) {
  const [ref, seen] = useReveal();
  return (
    <section ref={ref} style={{ padding: '0 28px', position: 'relative' }}>
      <div style={{ maxWidth: 1320, margin: '0 auto' }}>
        <div className="band-ink stats-band" style={{ position: 'relative', overflow: 'hidden', display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))' }}>
          <div aria-hidden style={{
            position: 'absolute', inset: 0, pointerEvents: 'none',
            backgroundImage: 'url(assets/hero-bg.png)',
            backgroundSize: 'cover', backgroundPosition: 'center 35%', backgroundRepeat: 'no-repeat',
            opacity: .55
          }}></div>
          {t.metrics.map((m, i) => (
            <div key={i} className={`reveal ${seen ? 'in' : ''} stat-cell`} style={{
              transitionDelay: `${i * 80}ms`, position: 'relative', zIndex: 1,
              padding: '46px 30px 42px',
              borderLeft: i === 0 ? 'none' : '1px solid var(--ink-line)'
            }}>
              <div style={{ display: 'flex', alignItems: 'baseline', gap: 5 }}>
                <span style={{
                  fontFamily: 'var(--font-display)',
                  fontSize: 'clamp(38px, 4vw, 52px)', fontWeight: 500,
                  letterSpacing: '-.03em', lineHeight: .95, color: '#fff'
                }}>
                  <CountUp value={m.k} />
                </span>
                {m.u && (
                  <span style={{ fontSize: 15, fontWeight: 600, color: 'var(--accent)', letterSpacing: '-.01em' }}>{m.u}</span>
                )}
              </div>
              <div style={{ fontSize: 13.5, color: 'var(--ink-fg-2)', fontWeight: 500, letterSpacing: '-.005em', marginTop: 14, lineHeight: 1.5 }}>{m.l}</div>
            </div>
          ))}
        </div>
      </div>
    </section>);
}

function CountUp({ value }) {
  const raw = String(value);
  const m = raw.match(/^([\d,]+)(.*)$/);
  const target = m ? parseInt(m[1].replace(/,/g, ''), 10) : null;
  const suffix = m ? m[2] : '';
  const [n, setN] = useState(target == null ? null : 0);
  const elRef = useRef(null);

  useEffect(() => {
    if (target == null) return;
    const motion = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--motion')) || 1;
    if (motion < 0.05) { setN(target); return; }
    let raf = 0, done = false;
    const run = () => {
      if (done) return;
      done = true;
      const t0 = performance.now();
      const step = (now) => {
        const p = Math.min(1, (now - t0) / 1200);
        setN(Math.round(target * (1 - Math.pow(1 - p, 3))));
        if (p < 1) raf = requestAnimationFrame(step);
      };
      raf = requestAnimationFrame(step);
    };
    const el = elRef.current;
    let io;
    if (el) {
      const r = el.getBoundingClientRect();
      if (r.top < window.innerHeight && r.bottom > 0) run();
      io = new IntersectionObserver(([e]) => { if (e.isIntersecting) run(); }, { threshold: 0.2 });
      io.observe(el);
    }
    // Safety net: show the real figure even if the observer never fires.
    const fallback = setTimeout(run, 1200);
    return () => { if (io) io.disconnect(); clearTimeout(fallback); cancelAnimationFrame(raf); };
  }, [target]);

  if (target == null) return <span ref={elRef}>{raw}</span>;
  return <span ref={elRef}>{(n || 0).toLocaleString()}{suffix}</span>;
}

// ============================== TRACK RECORD ==============================
function TrackRecord({ t }) {
  const [ref, seen] = useReveal();
  const [active, setActive] = useState(0);
  return (
    <section id="record" ref={ref} style={{ padding: '7vh 28px 8vh', position: 'relative' }}>
      <div style={{ maxWidth: 1320, margin: '0 auto' }}>
        <SectionEyebrow num="07" label="TRACK RECORD" />
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.1fr', gap: 56, alignItems: 'start' }} className="record-grid">
          <h2 className={`reveal ${seen ? 'in' : ''}`} style={{
            fontSize: 'clamp(28px, 3.4vw, 46px)', letterSpacing: '-.03em', lineHeight: 1.05, fontWeight: 600, margin: 0
          }}>
            {t.proof.title}
            <span style={{ display: 'block', color: 'var(--fg-3)', fontSize: '0.46em', marginTop: 12, letterSpacing: '-.01em', fontWeight: 400 }}>{t.proof.sub}</span>
          </h2>
          <div className={`reveal ${seen ? 'in' : ''}`} style={{ transitionDelay: '120ms' }}>
            {t.record.map((r, i) =>
            <div key={i}
            onMouseEnter={() => setActive(i)}
            onClick={() => setActive(i)}
            style={{
              display: 'grid', gridTemplateColumns: '72px 1fr 80px', gap: 16, alignItems: 'center',
              padding: '12px 0', borderBottom: '1px solid var(--line)', cursor: 'pointer',
              position: 'relative', transition: 'all .25s'
            }}>
                <div className="mono" style={{ fontSize: 11, color: active === i ? 'var(--navy)' : 'var(--fg-3)', letterSpacing: '.16em' }}>
                  {r.code} · 0{i + 1}
                </div>
                <div style={{ fontSize: 16, color: active === i ? 'var(--fg)' : 'var(--fg-2)', fontWeight: 500, letterSpacing: '-.01em' }}>
                  {r.ind}
                </div>
                <div className="mono" style={{ fontSize: 11, textAlign: 'right', color: active === i ? 'var(--navy)' : 'var(--fg-3)' }}>
                  {active === i ? '— OPEN' : 'VIEW →'}
                </div>
                <div style={{
                gridColumn: '1 / -1', overflow: 'hidden',
                maxHeight: active === i ? 160 : 0,
                transition: 'max-height .45s cubic-bezier(.2,.7,.2,1), opacity .35s',
                opacity: active === i ? 1 : 0
              }}>
                  <div style={{ padding: '8px 0 8px', display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16 }}>
                    {[['Problem', r.problem], ['Solution', r.solution], ['Result', r.result]].map(([k, v]) =>
                  <div key={k}>
                        <div className="mono" style={{ fontSize: 10, color: 'var(--fg-2)', letterSpacing: '.18em', marginBottom: 6 }}>{k}</div>
                        <div style={{ fontSize: 13, color: 'var(--fg-2)', lineHeight: 1.55 }}>{v}</div>
                      </div>
                  )}
                  </div>
                </div>
              </div>
            )}
          </div>
        </div>
      </div>
    </section>);

}

function SectionEyebrow({ num, label, pre }) {
  return (
    <div className="mono" style={{
      display: 'flex', alignItems: 'center', gap: 14,
      fontSize: 10.5, color: 'var(--fg-2)', letterSpacing: '.28em', marginBottom: 30,
      paddingBottom: 0
    }}>
      <span className="eyebrow-pre">{pre || num}</span>
      <span style={{ letterSpacing: '.28em' }}>{label}</span>
    </div>);

}

// ============================== SERVICES ==============================
function Services({ t }) {
  const [ref, seen] = useReveal();
  return (
    <section id="services" ref={ref} style={{ padding: '14vh 28px', position: 'relative', background: 'var(--bg-2)', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)' }}>
      <div style={{ maxWidth: 1320, margin: '0 auto' }}>
        <SectionEyebrow num="06" pre="OUR" label="SERVICES" />
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'end', flexWrap: 'wrap', gap: 24, marginBottom: 56 }}>
          <h2 className={`reveal ${seen ? 'in' : ''}`} style={{
            fontSize: 'clamp(28px, 3.2vw, 44px)', letterSpacing: '-.03em', lineHeight: 1.32, margin: 0, maxWidth: 720
          }}>
            <em>{t.services.titleAccent}</em>{t.services.titleRest}
            <span style={{ display: 'block', color: 'var(--fg-3)', fontSize: '0.42em', marginTop: 16, fontWeight: 400, letterSpacing: '-.01em' }}>{t.services.sub}</span>
          </h2>
        </div>

        {/* Uniform 3-col grid — images are all 16:9, cards share the same shape */}
        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
          gap: 16
        }} className="services-grid">
          {t.services.items.map((item, i) =>
          <ServiceCard key={item.id} item={item} index={i} />
          )}
          <UpcomingCard items={t.services.upcoming} />
        </div>
      </div>
    </section>);

}

function ServiceCard({ item, index }) {
  const [hover, setHover] = useState(false);
  const num = String((index ?? 0) + 1).padStart(2, '0');
  return (
    <a
      href={item.link || '#contact'}
      target={item.link ? '_blank' : '_self'}
      rel="noopener noreferrer"
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{
        position: 'relative', overflow: 'hidden',
        background: 'var(--surface)', border: '1px solid var(--line)',
        borderRadius: 18, padding: 0, display: 'flex', flexDirection: 'column',
        transition: 'transform .35s cubic-bezier(.2,.7,.2,1), border-color .25s, background .25s, box-shadow .35s',
        transform: hover ? 'translateY(-4px)' : 'none',
        borderColor: hover ? 'var(--accent-edge)' : 'var(--line)',
        boxShadow: hover ? '0 18px 40px -22px color-mix(in srgb, var(--accent) 35%, transparent)' : 'none',
        textDecoration: 'none', color: 'inherit'
      }}>

      {/* Image — 16:9, compact card height */}
      <div style={{
        position: 'relative', width: '100%', aspectRatio: '16 / 9', overflow: 'hidden',
        background: 'var(--bg)', borderBottom: '1px solid var(--line)', flexShrink: 0
      }}>
        {item.img ?
        <img src={item.img} alt={item.title} loading="lazy" style={{
          position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', display: 'block',
          transition: 'transform .7s cubic-bezier(.2,.7,.2,1), filter .4s',
          transform: hover ? 'scale(1.04)' : 'scale(1.0)',
          filter: hover ? 'saturate(1.08)' : 'saturate(0.96)'
        }} /> :

        <div style={{
          position: 'absolute', inset: 0,
          background: `linear-gradient(135deg, var(--accent-soft), transparent 60%)`,
          display: 'flex', alignItems: 'center', justifyContent: 'center'
        }}>
            <span className="mono" style={{ color: 'var(--fg-3)', fontSize: 11, letterSpacing: '.2em' }}>{item.title}</span>
          </div>
        }

        {/* Top-left index */}
        <div className="mono" style={{
          position: 'absolute', top: 12, left: 14, fontSize: 10, letterSpacing: '.22em',
          color: '#fff', mixBlendMode: 'difference', opacity: 0.85
        }}>
          {num} / SERVICE
        </div>

        {/* Status chip */}
        <span className="mono" style={{
          position: 'absolute', top: 12, right: 12,
          padding: '4px 10px', borderRadius: 999, backdropFilter: 'blur(8px)',
          background: item.status === 'LIVE' ? 'color-mix(in srgb, var(--accent) 18%, rgba(0,0,0,.4))' : 'rgba(0,0,0,.45)',
          border: `1px solid ${item.status === 'LIVE' ? 'var(--accent-edge)' : 'rgba(255,255,255,.15)'}`,
          color: item.status === 'LIVE' ? '#fff' : 'rgba(255,255,255,.92)',
          fontSize: 10, letterSpacing: '.14em', display: 'inline-flex', alignItems: 'center'
        }}>
          {item.status === 'LIVE' && <span style={{ display: 'inline-block', width: 6, height: 6, borderRadius: 999, background: 'var(--accent)', marginRight: 6, boxShadow: '0 0 8px var(--accent)' }}></span>}
          {item.status}
        </span>
      </div>

      {/* Body */}
      <div style={{ padding: '16px 18px', display: 'flex', flexDirection: 'column', gap: 10, flex: 1 }}>
        <div>
          <div className="mono" style={{ fontSize: 10.5, color: 'var(--fg-2)', letterSpacing: '.18em', marginBottom: 6 }}>{item.role}</div>
          <div style={{ fontSize: 20, fontWeight: 600, letterSpacing: '-.02em', color: 'var(--fg)', lineHeight: 1.15 }}>{item.title}</div>
          {item.nameKo && item.nameKo !== item.title &&
          <div style={{ fontSize: 12.5, color: 'var(--fg-3)', letterSpacing: '-.01em', marginTop: 3, fontWeight: 500 }}>{item.nameKo}</div>
          }
        </div>

        <p style={{ color: 'var(--fg-2)', fontSize: 13, lineHeight: 1.5, margin: 0 }}>{item.desc}</p>

        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12, marginTop: 'auto', paddingTop: 11, borderTop: '1px solid var(--line)', flexWrap: 'wrap' }}>
          <div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
            {item.tags.map((tag) =>
            <span key={tag} className="mono" style={{
              fontSize: 10, color: 'var(--fg-2)', padding: '3px 8px',
              border: '1px solid var(--line)', borderRadius: 4, letterSpacing: '.06em'
            }}>{tag}</span>
            )}
          </div>
          {item.support &&
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 8, flexShrink: 0 }}>
            <span className="mono" style={{ fontSize: 9.5, letterSpacing: '.18em', color: 'var(--fg-3)', fontWeight: 600 }}>{item.support.label}</span>
            {item.support.href ? (
              <a href={item.support.href} target="_blank" rel="noopener noreferrer" aria-label={item.support.alt} style={{ display: 'inline-flex' }} onClick={(e) => e.stopPropagation()}>
                <img src={item.support.logo} alt={item.support.alt} loading="lazy" style={{ height: item.support.h, width: 'auto', objectFit: 'contain' }} />
              </a>
            ) : (
              <img src={item.support.logo} alt={item.support.alt} loading="lazy" style={{ height: item.support.h, width: 'auto', objectFit: 'contain' }} />
            )}
          </span>
          }
          {item.link &&
          <span className="mono" style={{
            fontSize: 10.5, color: hover ? 'var(--navy)' : 'var(--fg-3)',
            letterSpacing: '.14em', transition: 'color .2s',
            display: 'inline-flex', alignItems: 'center', gap: 6
          }}>
              OPEN <span style={{ transform: hover ? 'translate(2px, -2px)' : 'none', transition: 'transform .2s', display: 'inline-block' }}>↗</span>
            </span>
          }
        </div>
      </div>
    </a>);

}

function UpcomingCard({ items }) {
  return (
    <div style={{
      gridColumn: '1 / -1', position: 'relative', overflow: 'hidden',
      background: 'transparent', border: '1px dashed var(--line-strong)',
      borderRadius: 18, padding: '20px 32px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 32, flexWrap: 'wrap'
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 18, flexShrink: 0 }}>
        <div className="mono" style={{
          fontSize: 10, color: 'var(--navy)', letterSpacing: '.22em',
          padding: '6px 12px', border: '1px solid var(--accent-edge)', borderRadius: 999,
          background: 'var(--accent-soft)'
        }}>R&amp;D · UPCOMING</div>
        <div style={{ fontSize: 22, fontWeight: 500, letterSpacing: '-.02em' }}>준비 중인 서비스</div>
      </div>
      <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
        {items.map((s, i) =>
        <span key={i} className="mono" style={{
          padding: '7px 14px', border: '1px solid var(--line)', borderRadius: 999,
          fontSize: 11, color: 'var(--fg-2)', background: 'var(--surface)'
        }}>{s}</span>
        )}
      </div>
    </div>);

}

// ============================== TEAM ==============================
function RoleIcon({ kind }) {
  // Inline SVGs — uses currentColor for accent
  const stroke = 'currentColor';
  const wrap = { width: 36, height: 36, color: 'var(--accent)' };
  if (kind === 'lead') return (
    <svg viewBox="0 0 36 36" style={wrap} fill="none">
      <path d="M6 11h24M6 18h24M6 25h16" stroke={stroke} strokeWidth="1.6" strokeLinecap="round" />
      <path d="M24 23l3 3 5-5" stroke={stroke} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
    </svg>);
  if (kind === 'cto') return (
    <svg viewBox="0 0 36 36" style={wrap} fill="none">
      <rect x="6" y="7" width="24" height="8" rx="2" stroke={stroke} strokeWidth="1.6" />
      <rect x="6" y="21" width="24" height="8" rx="2" stroke={stroke} strokeWidth="1.6" />
      <circle cx="11" cy="11" r="1.3" fill={stroke} />
      <circle cx="11" cy="25" r="1.3" fill={stroke} />
      <path d="M16 11h10M16 25h10" stroke={stroke} strokeWidth="1.4" strokeLinecap="round" />
    </svg>);
  if (kind === 'coo') return (
    <svg viewBox="0 0 36 36" style={wrap} fill="none">
      <path d="M7 28V18M14 28V13M21 28V20M28 28V9" stroke={stroke} strokeWidth="1.8" strokeLinecap="round" />
      <path d="M5 31h26" stroke={stroke} strokeWidth="1.4" strokeLinecap="round" opacity="0.5" />
    </svg>);
  if (kind === 'dev') return (
    <svg viewBox="0 0 36 36" style={wrap} fill="none">
      <rect x="5" y="8" width="26" height="18" rx="2" stroke={stroke} strokeWidth="1.6" />
      <path d="M13 32h10M18 26v6" stroke={stroke} strokeWidth="1.4" strokeLinecap="round" />
      <path d="M13 14l-3 3 3 3M23 14l3 3-3 3M20 13l-4 8" stroke={stroke} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
    </svg>);
  if (kind === 'design') return (
    <svg viewBox="0 0 36 36" style={wrap} fill="none">
      <circle cx="18" cy="18" r="12" stroke={stroke} strokeWidth="1.6" />
      <path d="M18 6a12 12 0 0 1 0 24 4 4 0 0 1 0-8 4 4 0 0 0 0-8 4 4 0 0 1 0-8Z" stroke={stroke} strokeWidth="1.5" strokeLinejoin="round" />
      <circle cx="13" cy="14" r="1.4" fill={stroke} />
      <circle cx="12" cy="21" r="1.4" fill={stroke} />
    </svg>);
  if (kind === 'biz') return (
    <svg viewBox="0 0 36 36" style={wrap} fill="none">
      <path d="M7 22V14l16-6v20l-16-6Z" stroke={stroke} strokeWidth="1.6" strokeLinejoin="round" />
      <path d="M23 12l5-2v12l-5-2" stroke={stroke} strokeWidth="1.6" strokeLinejoin="round" />
      <path d="M11 22v4a2 2 0 0 0 4 0v-3" stroke={stroke} strokeWidth="1.6" strokeLinecap="round" />
    </svg>);
  return null;
}

function OrgIcon({ kind }) {
  const l = 'rgba(255,255,255,.55)';
  const a = 'var(--accent)';
  const m = {
    hex: <><path d="M22 5.6l13.6 7.9v15.8L22 37.2 8.4 29.3V13.5L22 5.6Z" stroke={l} strokeWidth="1.1" fill="none"/><path d="M22 5.6v31.6M8.4 13.5L35.6 29.3M35.6 13.5L8.4 29.3" stroke={l} strokeWidth=".7"/><circle cx="22" cy="21.4" r="2.6" fill={a}/></>,
    layers: <><path d="M22 8l13 6.6L22 21.2 9 14.6 22 8Z" stroke={l} strokeWidth="1.1" fill="none"/><path d="M9 21l13 6.6L35 21" stroke={l} strokeWidth="1.1" fill="none"/><path d="M9 27.4L22 34l13-6.6" stroke={l} strokeWidth="1.1" fill="none"/><circle cx="22" cy="14.6" r="2.4" fill={a}/></>,
    triangle: <><path d="M22 8.6l13.4 24.8H8.6L22 8.6Z" stroke={l} strokeWidth="1.1" fill="none"/><circle cx="22" cy="25" r="2.6" fill={a}/></>,
    pie: <><circle cx="22" cy="22" r="13" stroke={l} strokeWidth="1.1" fill="none"/><path d="M22 22V9M22 22h13" stroke={l} strokeWidth="1.1"/><circle cx="26.6" cy="17.4" r="2.4" fill={a}/></>
  };
  return <svg viewBox="0 0 44 44" width="44" height="44" fill="none" aria-hidden>{m[kind]}</svg>;
}

function PersonGlyph() {
  return (
    <svg viewBox="0 0 20 20" width="16" height="16" fill="none" aria-hidden style={{ flexShrink: 0 }}>
      <circle cx="10" cy="7" r="3.1" stroke="var(--navy)" strokeWidth="1.2"/>
      <path d="M4.4 16.4c.6-2.9 2.9-4.6 5.6-4.6s5 1.7 5.6 4.6" stroke="var(--navy)" strokeWidth="1.2" strokeLinecap="round"/>
    </svg>);
}

function OrgCard({ unit, i, seen, lead }) {
  return (
    <div className={`reveal ${seen ? 'in' : ''} org-card`} style={{
      transitionDelay: `${i * 90}ms`, position: 'relative',
      background: 'var(--surface)', border: '1px solid var(--line)',
      boxShadow: '0 14px 34px -26px rgba(11,26,54,.30)',
      display: 'flex', flexDirection: 'column'
    }}>
      {!lead && (
        <div aria-hidden className="org-drop" style={{ position: 'absolute', top: -74, left: '50%', width: 1, height: 74, background: 'var(--line-strong)' }}>
          <span style={{ position: 'absolute', bottom: -4, left: -3.5, width: 8, height: 8, borderRadius: 999, background: 'var(--navy)' }}></span>
        </div>
      )}
      {/* navy cap */}
      <div style={{
        background: 'var(--navy)', padding: lead ? '22px 0 30px' : '20px 0 28px',
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        clipPath: 'polygon(0 0, 100% 0, 100% 74%, 50% 100%, 0 74%)'
      }}>
        <OrgIcon kind={unit.icon} />
      </div>

      <div style={{ padding: lead ? '4px 26px 26px' : '2px 22px 22px', textAlign: 'center' }}>
        <div style={{ fontSize: lead ? 22 : 17.5, fontWeight: 700, letterSpacing: '-.02em', color: 'var(--fg)' }}>
          {lead ? unit.name : unit.name}
        </div>
        {lead ? (
          <div style={{ fontSize: 13.5, color: 'var(--fg-2)', marginTop: 9, fontWeight: 500 }}>{unit.role}</div>
        ) : (
          <>
            <div style={{ width: 26, height: 2, background: 'var(--accent)', margin: '11px auto 0', opacity: .85 }}></div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 18, textAlign: 'left' }}>
              {unit.members.map((mb, j) => (
                <div key={j} style={{
                  display: 'flex', alignItems: 'center', gap: 10,
                  border: '1px solid var(--line)', padding: '11px 13px', background: 'var(--bg)'
                }}>
                  <PersonGlyph />
                  <span style={{ fontSize: 13.5, fontWeight: 700, color: 'var(--fg)', letterSpacing: '-.01em' }}>{mb.n}</span>
                  <span style={{ color: 'var(--fg-3)', fontSize: 12 }}>—</span>
                  <span style={{ fontSize: 12.5, color: 'var(--fg-2)' }}>{mb.r}</span>
                  {mb.dual && (
                    <span style={{
                      marginLeft: 'auto', flexShrink: 0, fontSize: 10, fontWeight: 700,
                      color: 'var(--accent)', border: '1px solid var(--accent)',
                      padding: '3px 6px', letterSpacing: '.02em'
                    }}>{unit.dualLabel}</span>
                  )}
                </div>
              ))}
            </div>
          </>
        )}
      </div>
    </div>);
}

function Team({ t }) {
  const [ref, seen] = useReveal();
  const o = t.team;
  return (
    <section id="team" ref={ref} style={{ padding: '13vh 28px', borderBottom: '1px solid var(--line)' }}>
      <div style={{ maxWidth: 1320, margin: '0 auto' }}>
        <div className="org-head" style={{ marginBottom: 46 }}>
          <SectionEyebrow num="09" label="THE TEAM" />
          <h2 className={`reveal ${seen ? 'in' : ''}`} style={{
            fontSize: 'clamp(30px, 3.6vw, 50px)', letterSpacing: '-.035em', lineHeight: 1.1,
            fontWeight: 700, margin: 0, color: 'var(--navy)'
          }}>{o.title}</h2>
          <div className={`reveal ${seen ? 'in' : ''}`} style={{ transitionDelay: '80ms' }}>
            <p style={{ margin: '14px 0 0', fontSize: 14.5, color: 'var(--fg-2)', lineHeight: 1.7 }}>{o.sub}</p>
            <div style={{ width: 34, height: 3, background: 'var(--accent)', marginTop: 22 }}></div>
          </div>
        </div>

        <div className="org-tree">
          <div className="org-lead" style={{ width: 'min(100%, 320px)', margin: '0 auto' }}>
            <OrgCard unit={o.head} i={0} seen={seen} lead />
          </div>

          <div className="org-bus" style={{ position: 'relative', height: 118 }}>
            <div aria-hidden className="org-stem" style={{ position: 'absolute', top: 0, left: '50%', width: 1, height: 30, background: 'var(--line-strong)' }}></div>
            <div className={`reveal ${seen ? 'in' : ''} org-pill`} style={{
              position: 'absolute', top: 22, left: 0, right: 0, margin: '0 auto', width: 'max-content',
              display: 'flex', alignItems: 'center', gap: 10,
              background: 'var(--surface)', border: '1px solid var(--line)', borderRadius: 999,
              padding: '11px 22px', zIndex: 2, whiteSpace: 'nowrap'
            }}>
              <span style={{ width: 5, height: 5, borderRadius: 999, background: 'var(--accent)' }}></span>
              <span style={{ fontSize: 14, fontWeight: 700, color: 'var(--navy)', letterSpacing: '-.01em' }}>{o.corp}</span>
              <span style={{ width: 5, height: 5, borderRadius: 999, background: 'var(--accent)' }}></span>
            </div>
            <div aria-hidden className="org-rail" style={{
              position: 'absolute', top: 44,
              left: 'calc((100% - 2 * var(--org-gap)) / 6)',
              right: 'calc((100% - 2 * var(--org-gap)) / 6)',
              height: 1, background: 'var(--line-strong)'
            }}></div>
          </div>

          <div className="org-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, minmax(0, 1fr))', gap: 'var(--org-gap)', alignItems: 'start' }}>
            {o.units.map((u, i) => (
              <OrgCard key={u.name} unit={{ ...u, dualLabel: o.dualLabel }} i={i} seen={seen} />
            ))}
          </div>
        </div>
      </div>
    </section>);
}

// ============================== FOUNDER CARD (typographic) ==============================
function FounderCard({ t, seen }) {
  const careers = t.ceo.careers || [];
  // Pick 5 most relevant for the card timeline
  const milestones = careers.slice(0, 6);
  return (
    <div className={`reveal ${seen ? 'in' : ''}`} style={{ position: 'relative' }}>
      <div style={{
        width: '100%', maxWidth: 420,
        background: 'var(--surface)', border: '1px solid var(--line)',
        borderRadius: 14, position: 'relative', overflow: 'hidden',
        boxShadow: '0 24px 60px -32px color-mix(in srgb, var(--accent) 30%, transparent)'
      }}>
        {/* Header bar */}
        <div style={{
          display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          padding: '14px 20px', borderBottom: '1px solid var(--line)',
          background: 'var(--bg-2)'
        }}>
          <div className="mono" style={{ fontSize: 10, color: 'var(--fg-2)', letterSpacing: '.22em' }}>FOUNDER / CEO</div>
          <div className="mono" style={{ fontSize: 10, color: 'var(--navy)', letterSpacing: '.22em', display: 'flex', alignItems: 'center', gap: 6 }}>
            <span style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--accent)', boxShadow: '0 0 8px var(--accent)' }}></span>
            ACTIVE · 16Y
          </div>
        </div>

        {/* Portrait */}
        <div style={{ position: 'relative', borderBottom: '1px solid var(--line)', background: 'var(--bg-2)' }}>
          <img src="assets/founder-portrait.png" alt="이성훈 대표" style={{ display: 'block', width: '100%', aspectRatio: '4/5', objectFit: 'cover', objectPosition: 'center top' }} />
        </div>

        {/* Timeline */}
        <div style={{ padding: '20px 22px 22px', borderTop: '1px solid var(--line)' }}>
          <div className="mono" style={{ fontSize: 10, color: 'var(--fg-2)', letterSpacing: '.22em', marginBottom: 14 }}>
            CAREER · 16Y TIMELINE
          </div>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
            {milestones.map((m, i) =>
            <div key={i} style={{
              display: 'grid', gridTemplateColumns: '76px 1fr', gap: 12, alignItems: 'baseline',
              opacity: seen ? 1 : 0, transform: seen ? 'translateY(0)' : 'translateY(8px)',
              transition: `opacity .4s ${200 + i * 70}ms, transform .4s ${200 + i * 70}ms`
            }}>
                <div className="mono" style={{ fontSize: 10.5, color: m.current ? 'var(--navy)' : 'var(--fg-3)', letterSpacing: '.08em', fontWeight: m.current ? 700 : 400, whiteSpace: 'nowrap' }}>
                  {m.period.split(' — ')[0]}
                </div>
                <div style={{ display: 'flex', flexDirection: 'column' }}>
                  <div className="mono" style={{ fontSize: 9.5, color: m.current ? 'var(--navy)' : 'var(--fg-3)', letterSpacing: '.2em', marginBottom: 2 }}>{m.role}</div>
                  <div style={{ fontSize: 13, color: 'var(--fg)', fontWeight: 500 }}>{m.org}</div>
                </div>
              </div>
            )}
          </div>
        </div>

        {/* Footer signature */}
        <div style={{
          borderTop: '1px solid var(--line)', padding: '12px 20px',
          display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          background: 'var(--bg-2)'
        }}>
          <div className="mono" style={{ fontSize: 10, color: 'var(--fg-2)', letterSpacing: '.18em' }}>SIG · /ecode-founder</div>
          <svg width="60" height="20" viewBox="0 0 60 20" style={{ color: 'var(--accent)' }}>
            <path d="M2 14 Q 8 4, 14 10 T 26 10 Q 32 2, 40 14 T 58 8" stroke="currentColor" strokeWidth="1.5" fill="none" strokeLinecap="round" />
          </svg>
        </div>
      </div>
    </div>);

}

// ============================== CEO ==============================
function CEO({ t, tweaks }) {
  const [ref, seen] = useReveal();
  return (
    <section id="ceo" ref={ref} style={{ padding: '14vh 28px', background: 'var(--bg-2)', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)' }}>
      <div style={{ maxWidth: 1320, margin: '0 auto' }}>
        <SectionEyebrow num="08" label="FOUNDER" />
        <div style={{ display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(0, 1.4fr)', gap: 80, alignItems: 'start' }} className="ceo-grid">
          <FounderCard t={t} seen={seen} />

          <div className={`reveal ${seen ? 'in' : ''}`} style={{ transitionDelay: '120ms' }}>
            <h2 style={{ fontSize: 'clamp(34px, 4.4vw, 62px)', letterSpacing: '-.03em', lineHeight: 1.02, fontWeight: 500, margin: 0 }}>
              {t.ceo.name}
              <span style={{ display: 'block', color: 'var(--fg-3)', fontSize: '0.36em', marginTop: 16, fontWeight: 400, letterSpacing: '-.01em' }}>{t.ceo.role} · {t.ceo.career}</span>
            </h2>
            <p style={{ marginTop: 28, fontSize: 17, color: 'var(--fg-2)', lineHeight: 1.65, maxWidth: '58ch' }}>{t.ceo.bio}</p>

            <FounderTabs t={t} />

            <blockquote style={{ marginTop: 32, padding: '20px 26px', borderLeft: '2px solid var(--accent)', fontStyle: 'italic', fontSize: 18, color: 'var(--fg)', lineHeight: 1.55 }}>
              "{t.ceo.quote}"
            </blockquote>
          </div>
        </div>
      </div>
    </section>);

}

// ============================== FOUNDER TABS ==============================
function FounderTabs({ t }) {
  const tabs = [
  { id: 'career', label: 'CAREER', n: t.ceo.careers.length },
  { id: 'projects', label: 'PROJECTS', n: t.ceo.projectGroups.reduce((a, g) => a + g.items.length, 0) },
  { id: 'patents', label: 'PATENTS', n: t.ceo.patents.length },
  { id: 'stack', label: 'STACK', n: t.ceo.stack.reduce((a, g) => a + g.items.length, 0) },
  { id: 'edu', label: 'EDU · CERT', n: t.ceo.education.length }];

  const [active, setActive] = useState('career');

  return (
    <div className="founder-tabs-wrap" style={{ marginTop: 32, border: '1px solid var(--line)', borderRadius: 14, overflow: 'hidden', background: 'var(--surface)' }}>
      {/* Tab bar */}
      <div className="founder-tabs" style={{ display: 'flex', borderBottom: '1px solid var(--line)', background: 'var(--bg-2)', overflowX: 'auto' }}>
        {tabs.map((tab) =>
        <button key={tab.id} onClick={() => setActive(tab.id)}
        className="mono"
        style={{
          flex: '0 0 auto', padding: '14px 18px', background: 'transparent',
          border: 'none', cursor: 'pointer', letterSpacing: '.18em', fontSize: 11,
          color: active === tab.id ? 'var(--fg)' : 'var(--fg-3)',
          borderBottom: active === tab.id ? '2px solid var(--accent)' : '2px solid transparent',
          marginBottom: -1, display: 'flex', gap: 8, alignItems: 'center',
          transition: 'color .2s, border-color .2s'
        }}>
            {tab.label}
            <span style={{
            fontSize: 9.5, padding: '2px 6px', borderRadius: 999,
            background: active === tab.id ? 'var(--navy)' : 'var(--line)',
            color: active === tab.id ? 'var(--bg)' : 'var(--fg-2)'
          }}>{tab.n}</span>
          </button>
        )}
      </div>

      {/* Content */}
      <div style={{ padding: '22px 24px', minHeight: 260 }}>
        {active === 'career' &&
        <div style={{ display: 'flex', flexDirection: 'column' }}>
            {t.ceo.careers.map((c, i) =>
          <div key={i} className="career-row" style={{
            display: 'grid', gridTemplateColumns: '180px 1fr auto', gap: 18, alignItems: 'baseline',
            padding: '12px 0', borderBottom: i < t.ceo.careers.length - 1 ? '1px solid var(--line)' : 'none'
          }}>
                <div className="mono" style={{ fontSize: 11, color: c.current ? 'var(--navy)' : 'var(--fg-3)', letterSpacing: '.08em', fontWeight: c.current ? 700 : 400 }}>
                  {c.current && <span style={{ display: 'inline-block', width: 6, height: 6, borderRadius: '50%', background: 'var(--accent)', marginRight: 8, boxShadow: '0 0 6px var(--accent)' }}></span>}
                  {c.period}
                </div>
                <div style={{ fontSize: 15, color: 'var(--fg)', fontWeight: 500 }}>{c.org}</div>
                <div className="mono" style={{ fontSize: 11, color: 'var(--fg-2)', letterSpacing: '.12em', textAlign: 'right' }}>{c.role}</div>
              </div>
          )}
          </div>
        }

        {active === 'projects' &&
        <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
            {t.ceo.projectGroups.map((g, i) =>
          <div key={i}>
                <div className="mono" style={{ fontSize: 10, color: 'var(--navy)', letterSpacing: '.22em', marginBottom: 8 }}>
                  {String(i + 1).padStart(2, '0')} · {g.g}
                </div>
                <ul className="projects-grid" style={{ margin: 0, padding: 0, listStyle: 'none', display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '4px 24px' }}>
                  {g.items.map((it, j) =>
              <li key={j} style={{ fontSize: 13.5, color: 'var(--fg-2)', lineHeight: 1.5, paddingLeft: 14, position: 'relative' }}>
                      <span style={{ position: 'absolute', left: 0, top: 7, width: 5, height: 5, background: 'var(--accent)', borderRadius: 1, opacity: 0.6 }}></span>
                      {it}
                    </li>
              )}
                </ul>
              </div>
          )}
          </div>
        }

        {active === 'patents' &&
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
            {t.ceo.patents.map((p, i) =>
          <div key={i} className="patent-row" style={{
            border: '1px solid var(--line)', borderRadius: 10, padding: '14px 16px',
            background: 'var(--bg-2)',
            display: 'grid', gridTemplateColumns: '40px 1fr auto', gap: 14, alignItems: 'start'
          }}>
                <div className="mono" style={{
              fontSize: 11, fontWeight: 700, letterSpacing: '.06em',
              color: 'var(--navy)',
              border: '1px solid var(--accent-edge, var(--accent))', borderRadius: 6,
              padding: '6px 0', textAlign: 'center'
            }}>
                  P{String(i + 1).padStart(2, '0')}
                </div>
                <div style={{ minWidth: 0 }}>
                  <div style={{ fontSize: 14, color: 'var(--fg)', fontWeight: 600, lineHeight: 1.4 }}>{p.titleKo}</div>
                  <div className="mono" style={{ fontSize: 10.5, color: 'var(--fg-2)', letterSpacing: '.04em', marginTop: 4, lineHeight: 1.45 }}>{p.titleEn}</div>
                  <div style={{ display: 'flex', flexWrap: 'wrap', gap: '4px 12px', marginTop: 8, fontSize: 11 }}>
                    <span className="mono" style={{ color: 'var(--fg-3)' }}>출원 {p.no}</span>
                    <span className="mono" style={{ color: 'var(--fg-3)' }}>· {p.date}</span>
                    <span className="mono" style={{ color: 'var(--fg-3)' }}>· IPC {p.ipc}</span>
                    <span className="mono" style={{ color: 'var(--fg-3)' }}>· {p.role}</span>
                  </div>
                </div>
                <div className="mono" style={{
              fontSize: 10, letterSpacing: '.16em',
              color: p.status === '등록' || p.status === 'Registered' ? 'var(--navy)' : 'var(--fg-3)',
              border: `1px solid ${p.status === '등록' || p.status === 'Registered' ? 'var(--accent)' : 'var(--line)'}`,
              padding: '4px 8px', borderRadius: 4, whiteSpace: 'nowrap'
            }}>
                  {p.status.toUpperCase()}
                </div>
              </div>
          )}
          </div>
        }

        {active === 'stack' &&
        <div className="stack-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '18px 28px' }}>
            {t.ceo.stack.map((g, i) =>
          <div key={i}>
                <div className="mono" style={{ fontSize: 10, color: 'var(--navy)', letterSpacing: '.22em', marginBottom: 8 }}>{g.c}</div>
                <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
                  {g.items.map((it, j) =>
              <div key={j} style={{ display: 'flex', justifyContent: 'space-between', gap: 12, fontSize: 13, padding: '4px 0', borderBottom: '1px dashed var(--line)' }}>
                      <span style={{ color: 'var(--fg)' }}>{it.k}</span>
                      <span className="mono" style={{ color: 'var(--fg-3)', fontSize: 11 }}>{it.v}</span>
                    </div>
              )}
                </div>
              </div>
          )}
          </div>
        }

        {active === 'edu' &&
        <div style={{ display: 'flex', flexDirection: 'column' }}>
            {t.ceo.education.map((e, i) =>
          <div key={i} className="edu-row" style={{
            display: 'grid', gridTemplateColumns: '1fr auto 80px', gap: 18, alignItems: 'baseline',
            padding: '12px 0', borderBottom: i < t.ceo.education.length - 1 ? '1px solid var(--line)' : 'none'
          }}>
                <div style={{ fontSize: 15, color: 'var(--fg)', fontWeight: 500 }}>{e.k}</div>
                <div className="mono" style={{ fontSize: 11, color: 'var(--fg-2)', letterSpacing: '.1em' }}>{e.v}</div>
                <div className="mono" style={{ fontSize: 11, color: 'var(--navy)', letterSpacing: '.1em', textAlign: 'right' }}>{e.y}</div>
              </div>
          )}
          </div>
        }
      </div>
    </div>);

}

// ============================== ECODETEAM (SUBSCRIPTION) ==============================
// ============================== DEMO HUB MODAL ==============================
function DemoHubModal({ t, onClose }) {
  const e = t.ecodeteam;
  const [demos, setDemos] = React.useState([]);
  const [err, setErr] = React.useState(false);
  const [active, setActive] = React.useState(null);

  React.useEffect(() => {
    const onKey = (ev) => { if (ev.key === 'Escape') { active ? setActive(null) : onClose(); } };
    document.body.style.overflow = 'hidden';
    window.addEventListener('keydown', onKey);
    fetch('https://demo-deck.pages.dev/demos.json', { cache: 'no-cache' })
      .then((r) => r.json()).then((l) => setDemos(Array.isArray(l) ? l : (l.data || []))).catch(() => setErr(true));
    return () => { document.body.style.overflow = ''; window.removeEventListener('keydown', onKey); };
  }, [active, onClose]);

  return (
    <div onClick={onClose} style={{ position: 'fixed', inset: 0, zIndex: 9999, background: 'rgba(7,18,48,.72)', backdropFilter: 'blur(10px)', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16 }}>
      <div onClick={(ev) => ev.stopPropagation()} style={{ width: '100%', maxWidth: 1080, height: '88vh', background: 'var(--bg)', borderRadius: 16, border: '1px solid var(--line)', display: 'flex', flexDirection: 'column', overflow: 'hidden', boxShadow: '0 40px 100px -40px rgba(0,0,0,.6)' }}>
        {/* header */}
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '16px 22px', borderBottom: '1px solid var(--line)', flexShrink: 0, background: 'var(--surface)' }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 12, minWidth: 0 }}>
            {active && (
              <button onClick={() => setActive(null)} className="mono" style={{ border: '1px solid var(--line)', background: 'transparent', color: 'var(--fg-2)', borderRadius: 8, padding: '7px 12px', cursor: 'pointer', fontSize: 12, flexShrink: 0 }}>← 목록</button>
            )}
            <span style={{ fontSize: 16, fontWeight: 700, color: 'var(--navy)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
              {active ? `${active.icon || ''} ${active.title}` : (e.demoTitle || '데모 허브')}
            </span>
          </div>
          <div style={{ display: 'flex', gap: 10, flexShrink: 0 }}>
            {active && <a href={active.url} target="_blank" rel="noopener noreferrer" className="mono" style={{ fontSize: 11, color: 'var(--accent)', textDecoration: 'none', padding: '7px 13px', borderRadius: 8, border: '1px solid var(--accent-edge)', background: 'var(--accent-soft)', fontWeight: 600 }}>새 탭 ↗</a>}
            <button onClick={onClose} aria-label="닫기" style={{ width: 34, height: 34, borderRadius: 8, border: '1px solid var(--line)', background: 'transparent', color: 'var(--fg-2)', cursor: 'pointer', fontSize: 18 }}>×</button>
          </div>
        </div>

        {/* body */}
        {active ? (
          <div style={{ flex: 1, background: '#fff' }}>
            <iframe src={active.url} allow={active.allow || 'fullscreen'} style={{ width: '100%', height: '100%', border: 'none', display: 'block' }} title={active.title} />
          </div>
        ) : (
          <div style={{ flex: 1, overflowY: 'auto', padding: 22 }}>
            <p style={{ margin: '0 0 18px', fontSize: 13.5, color: 'var(--fg-2)', lineHeight: 1.6 }}>{e.demoSub}</p>
            {err ? (
              <div style={{ padding: '50px 0', textAlign: 'center', color: 'var(--fg-3)', fontSize: 14 }}>데모 목록을 불러오지 못했습니다.</div>
            ) : demos.length === 0 ? (
              <div style={{ padding: '50px 0', textAlign: 'center', color: 'var(--fg-3)', fontSize: 14 }}>불러오는 중…</div>
            ) : (
              <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(240px, 1fr))', gap: 12 }}>
                {demos.map((d) => (
                  <button key={d.slug} onClick={() => setActive(d)} style={{ textAlign: 'left', cursor: 'pointer', fontFamily: 'inherit', background: 'var(--surface)', border: '1px solid var(--line)', borderRadius: 14, padding: 18, display: 'flex', flexDirection: 'column', gap: 8, transition: 'transform .2s, border-color .2s, box-shadow .2s' }}
                    onMouseEnter={(ev) => { ev.currentTarget.style.transform = 'translateY(-3px)'; ev.currentTarget.style.borderColor = 'var(--accent-edge)'; ev.currentTarget.style.boxShadow = '0 16px 36px -24px rgba(11,26,54,.4)'; }}
                    onMouseLeave={(ev) => { ev.currentTarget.style.transform = 'none'; ev.currentTarget.style.borderColor = 'var(--line)'; ev.currentTarget.style.boxShadow = 'none'; }}>
                    <span style={{ fontSize: 26 }}>{d.icon || '▶'}</span>
                    <span style={{ fontSize: 15, fontWeight: 700, color: 'var(--navy)', letterSpacing: '-.01em' }}>{d.title}</span>
                    {d.tag && <span className="mono" style={{ fontSize: 10.5, color: 'var(--accent)', letterSpacing: '.06em', fontWeight: 600 }}>{d.tag}</span>}
                    {d.desc && <span style={{ fontSize: 12.5, color: 'var(--fg-2)', lineHeight: 1.55 }}>{d.desc}</span>}
                    <span className="mono" style={{ marginTop: 'auto', fontSize: 10.5, color: 'var(--fg-3)', letterSpacing: '.1em', fontWeight: 600 }}>체험하기 →</span>
                  </button>
                ))}
              </div>
            )}
          </div>
        )}
      </div>
    </div>);
}

function EcodeTeam({ t }) {
  const [ref, seen] = useReveal();
  const [demoOpen, setDemoOpen] = React.useState(false);
  const e = t.ecodeteam;
  return (
    <section ref={ref} id="ecodeteam" style={{
      padding: '14vh 28px', position: 'relative', overflow: 'hidden',
      borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)'
    }}>
      {/* Backdrop */}
      <div aria-hidden style={{
        position: 'absolute', inset: 0, pointerEvents: 'none',
        background: `
          radial-gradient(60% 80% at 80% 20%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
          radial-gradient(50% 80% at 10% 80%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%)
        `
      }}></div>

      <div style={{ maxWidth: 1320, margin: '0 auto', position: 'relative' }}>
        <SectionEyebrow num="04" label={e.eyebrow} />

        <div style={{ display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: 64, alignItems: 'start' }} className="ecodeteam-grid">
          {/* LEFT — copy */}
          <div className={`reveal ${seen ? 'in' : ''}`}>
            <div style={{
              display: 'inline-flex', alignItems: 'center', gap: 8,
              padding: '6px 12px', borderRadius: 999,
              background: 'var(--accent-soft)', border: '1px solid var(--accent-edge)',
              fontSize: 12, color: 'var(--navy)', fontWeight: 600, letterSpacing: '.04em', marginBottom: 20
            }}>
              <span style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--accent)', boxShadow: '0 0 8px var(--accent)' }}></span>
              {e.tag}
            </div>

            <h2 style={{
              fontSize: 'clamp(34px, 4.4vw, 62px)', letterSpacing: '-.03em', lineHeight: 1.05, fontWeight: 600, margin: 0
            }}>
              <span style={{ color: 'var(--navy)' }}>{e.titleAccent}</span>{e.titleA}
              <br />
              {e.titleB}
            </h2>
            <p style={{ marginTop: 24, fontSize: 17, color: 'var(--fg-2)', lineHeight: 1.65, maxWidth: '52ch' }}>
              {e.sub}
            </p>

            <div style={{ display: 'flex', gap: 12, marginTop: 32, flexWrap: 'wrap' }}>
              <a href={e.url} target="_blank" rel="noopener noreferrer" style={{
                padding: '14px 22px', borderRadius: 999,
                background: 'var(--accent)', color: '#0a0a0a',
                fontSize: 14, fontWeight: 700, display: 'inline-flex', alignItems: 'center', gap: 10,
                transition: 'transform .2s, box-shadow .3s',
                boxShadow: '0 12px 30px -12px var(--accent-glow)'
              }}
              onMouseEnter={(e2) => {e2.currentTarget.style.transform = 'translateY(-2px)';e2.currentTarget.style.boxShadow = '0 18px 40px -10px var(--accent-glow)';}}
              onMouseLeave={(e2) => {e2.currentTarget.style.transform = 'none';e2.currentTarget.style.boxShadow = '0 12px 30px -12px var(--accent-glow)';}}>
                {e.cta}
                <span style={{ fontFamily: 'var(--font-mono)' }}>↗</span>
              </a>
              <a href={e.url} target="_blank" rel="noopener noreferrer" className="mono" style={{
                padding: '14px 18px', borderRadius: 999,
                border: '1px solid var(--line-strong)', color: 'var(--fg-2)',
                fontSize: 12, letterSpacing: '.14em', display: 'inline-flex', alignItems: 'center', gap: 8
              }}>
                ECODETEAM.KR
              </a>
            </div>

            {/* Demo Hub — emphasized button (prospects can try demos themselves) */}
            <button onClick={() => setDemoOpen(true)} style={{
              marginTop: 24, width: '100%', cursor: 'pointer', fontFamily: 'inherit', textAlign: 'left',
              display: 'flex', alignItems: 'center', gap: 16, padding: '18px 22px', borderRadius: 14,
              background: 'var(--ink)', color: '#fff', border: '1px solid var(--ink-line)',
              boxShadow: '0 18px 44px -20px rgba(7,18,48,.5)', transition: 'transform .2s, box-shadow .3s',
              position: 'relative', overflow: 'hidden'
            }}
            onMouseEnter={(ev) => { ev.currentTarget.style.transform = 'translateY(-3px)'; ev.currentTarget.style.boxShadow = '0 26px 56px -18px rgba(7,18,48,.6)'; }}
            onMouseLeave={(ev) => { ev.currentTarget.style.transform = 'none'; ev.currentTarget.style.boxShadow = '0 18px 44px -20px rgba(7,18,48,.5)'; }}>
              <span aria-hidden style={{ position: 'absolute', inset: 0, background: 'radial-gradient(60% 120% at 100% 0%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%)', pointerEvents: 'none' }}></span>
              <span style={{ position: 'relative', width: 46, height: 46, borderRadius: 12, background: 'var(--accent)', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
                <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#0a0a0a" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M6 4l14 8-14 8V4z" fill="#0a0a0a" /></svg>
              </span>
              <span style={{ position: 'relative', flex: 1, minWidth: 0 }}>
                <span style={{ display: 'block', fontSize: 16, fontWeight: 800, letterSpacing: '-.01em' }}>{e.demoBtn || '데모 허브 둘러보기'}</span>
                <span style={{ display: 'block', fontSize: 12.5, color: 'var(--ink-fg-2)', marginTop: 3 }}>{e.demoSub}</span>
              </span>
              <span aria-hidden className="mono" style={{ position: 'relative', color: 'var(--accent)', fontSize: 18, flexShrink: 0 }}>↗</span>
            </button>

            {/* Plans strip */}
            <div className="ecodeteam-plans" style={{ marginTop: 20, display: 'grid', gridTemplateColumns: 'repeat(3, minmax(0, 1fr))', gap: 12 }}>
              {e.plans.map((p, i) =>
              <div key={i} style={{
                padding: '16px 16px', background: 'var(--surface)',
                border: '1px solid var(--line)', borderRadius: 12,
                display: 'flex', flexDirection: 'column', gap: 6
              }}>
                  <div className="mono" style={{ fontSize: 10, color: 'var(--navy)', letterSpacing: '.18em' }}>PLAN 0{i + 1}</div>
                  <div style={{ fontSize: 17, fontWeight: 700, letterSpacing: '-.015em' }}>{p.name}</div>
                  <div style={{ fontSize: 12.5, color: 'var(--fg-3)', lineHeight: 1.5 }}>{p.scope}</div>
                </div>
              )}
            </div>
          </div>

          {/* RIGHT — bullets card */}
          <div className={`reveal ${seen ? 'in' : ''}`} style={{ transitionDelay: '120ms' }}>
            <div className="ecodeteam-bullets-card" style={{
              position: 'relative', overflow: 'hidden',
              background: 'var(--surface)', border: '1px solid var(--line)',
              borderRadius: 20, padding: 28
            }}>
              <div aria-hidden style={{
                position: 'absolute', top: -80, right: -80, width: 240, height: 240,
                background: `radial-gradient(circle, var(--accent-soft), transparent 70%)`
              }}></div>

              <div className="mono" style={{ fontSize: 10.5, color: 'var(--navy)', letterSpacing: '.22em', marginBottom: 18, fontWeight: 600 }}>
                WHY SUBSCRIPTION
              </div>

              <div style={{ display: 'flex', flexDirection: 'column' }}>
                {e.bullets.map((b, i) =>
                <div key={i} className="ecodeteam-bullet-row" style={{
                  display: 'grid', gridTemplateColumns: '120px 1fr', gap: 18,
                  padding: '16px 0',
                  borderTop: i === 0 ? 'none' : '1px solid var(--line)',
                  position: 'relative'
                }}>
                    <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
                      <span style={{
                      width: 22, height: 22, borderRadius: 6,
                      background: 'var(--accent-soft)', border: '1px solid var(--accent-edge)',
                      display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                      fontSize: 11, color: 'var(--navy)', fontWeight: 700, fontFamily: 'var(--font-mono)'
                    }}>
                        {String(i + 1).padStart(2, '0')}
                      </span>
                      <span style={{ fontSize: 14, fontWeight: 700, color: 'var(--fg)', letterSpacing: '-.01em' }}>{b.k}</span>
                    </div>
                    <div style={{ fontSize: 13.5, color: 'var(--fg-2)', lineHeight: 1.6 }}>{b.v}</div>
                  </div>
                )}
              </div>
            </div>
          </div>
        </div>
      </div>
      {demoOpen && <DemoHubModal t={t} onClose={() => setDemoOpen(false)} />}
    </section>);

}

// ============================== ECODEWORKS · EDDY DEMO ==============================
function ChatBubble({ m, isBot, isMe }) {
  const align = isMe ? 'flex-end' : 'flex-start';
  const bg = isBot ? 'var(--surface)' : isMe ? 'var(--surface-2)' : 'var(--surface)';
  const fg = 'var(--fg)';
  const border = isBot ? '1px solid var(--line-strong)' : '1px solid var(--line)';
  const radius = isMe ? '14px 14px 4px 14px' : '4px 14px 14px 14px';
  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: align, gap: 4, maxWidth: '78%' }}>
      {!isMe &&
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, paddingLeft: 2 }}>
          {isBot ?
        <img src="assets/eddy.png" alt="Eddy" style={{ width: 20, height: 20, borderRadius: 6, objectFit: 'cover', background: '#1a1a1a', flexShrink: 0 }} /> :

        <span style={{ width: 18, height: 18, borderRadius: 999, background: m.color || 'var(--fg-3)', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', fontSize: 10, fontWeight: 700, color: '#fff' }}>{m.avatar}</span>
        }
          <span style={{ fontSize: 11, color: 'var(--fg-2)', fontWeight: 600, letterSpacing: '-.01em' }}>{m.sender}</span>
          {isBot && <span style={{ fontSize: 9, padding: '1px 5px', border: '1px solid var(--line)', borderRadius: 3, color: 'var(--fg-3)', letterSpacing: '.12em', fontWeight: 600 }}>BOT</span>}
        </div>
      }
      <div style={{ display: 'flex', alignItems: 'flex-end', gap: 8, flexDirection: isMe ? 'row-reverse' : 'row' }}>
        <div style={{
          background: bg, color: fg, border, borderRadius: radius,
          borderLeft: isBot ? '2px solid var(--navy)' : border,
          padding: '10px 14px', fontSize: 13.5, lineHeight: 1.55, whiteSpace: 'pre-wrap',
          fontFamily: m.text.includes('  ') ? 'var(--font-mono), ui-monospace, monospace' : 'inherit',
          fontWeight: 400, letterSpacing: '-.005em', boxShadow: isBot ? '0 1px 0 rgba(0,0,0,.05)' : 'none'
        }}>
          <div>{m.text}</div>
          {m.link &&
          <a href={m.link.url} target="_blank" rel="noopener noreferrer" style={{
            marginTop: 10, display: 'inline-flex', alignItems: 'center', gap: 8,
            padding: '7px 12px', background: 'var(--surface-2)', border: '1px solid var(--line)', color: 'var(--navy)',
            borderRadius: 8, fontSize: 12, fontWeight: 600, textDecoration: 'none',
            fontFamily: 'inherit', letterSpacing: '-.005em'
          }}>
              <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round">
                <path d="M14 3h7v7M10 14L21 3M21 14v7H3V3h7"></path>
              </svg>
              <span>{m.link.label}</span>
              <span style={{ opacity: 0.6, fontWeight: 500, fontSize: 11 }}>{m.link.url.replace(/^https?:\/\//, '')}</span>
            </a>
          }
        </div>
        <span style={{ fontSize: 10, color: 'var(--fg-2)', whiteSpace: 'nowrap', paddingBottom: 2 }}>{m.time}</span>
      </div>
    </div>);

}

function TypingDots({ name, color, isBot }) {
  return (
    <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
      {isBot ?
      <img src="assets/eddy.png" alt="Eddy" style={{ width: 20, height: 20, borderRadius: 6, objectFit: 'cover', background: '#1a1a1a' }} /> :

      <span style={{ width: 18, height: 18, borderRadius: 999, background: color || 'var(--fg-3)', fontSize: 10, fontWeight: 700, color: '#fff', display: 'inline-flex', alignItems: 'center', justifyContent: 'center' }}>{name?.[0]}</span>
      }
      <div style={{ background: 'var(--surface)', border: '1px solid var(--line)', borderRadius: '4px 14px 14px 14px', padding: '8px 14px', display: 'flex', gap: 4 }}>
        {[0, 1, 2].map((i) =>
        <span key={i} style={{
          width: 6, height: 6, borderRadius: 999, background: 'var(--fg-3)',
          animation: `eddyDot 1.2s ${i * 0.15}s infinite ease-in-out`
        }}></span>
        )}
      </div>
    </div>);

}

function AIDemo({ t }) {
  const [ref, seen] = useReveal();
  const [visibleCount, setVisibleCount] = useState(0);
  const [typing, setTyping] = useState(null); // { sender, color, isBot } | null
  const [live, setLive] = useState([]);
  const [input, setInput] = useState('');
  const [busy, setBusy] = useState(false);
  const scriptRef = useRef(null);
  const scripted = t.demo.script || [];

  // Auto-advance scripted timeline
  useEffect(() => {
    if (!seen) return;
    if (visibleCount >= scripted.length) return;
    const curr = scripted[visibleCount];
    const isBot = curr.role === 'bot';
    const prev = scripted[visibleCount - 1];
    const gap = prev && prev.role === curr.role && prev.sender === curr.sender ? 350 : 700;
    const typeDur = isBot ? Math.min(1600, 500 + curr.text.length * 6) : Math.min(900, 300 + curr.text.length * 3);

    const t1 = setTimeout(() => {
      setTyping({ sender: curr.sender, color: curr.color, isBot });
    }, gap);
    const t2 = setTimeout(() => {
      setTyping(null);
      setVisibleCount((v) => v + 1);
    }, gap + typeDur);
    return () => {clearTimeout(t1);clearTimeout(t2);};
  }, [seen, visibleCount, scripted]);

  // Auto-scroll
  useEffect(() => {
    if (scriptRef.current) {
      scriptRef.current.scrollTo({ top: scriptRef.current.scrollHeight, behavior: 'smooth' });
    }
  }, [visibleCount, typing, live, busy]);

  function replay() {
    setVisibleCount(0);
    setTyping(null);
    setLive([]);
  }

  function nowTime() {
    const d = new Date();
    return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
  }

  async function send(e) {
    e?.preventDefault();
    const q = input.trim();
    if (!q || busy) return;
    setInput('');
    setLive((m) => [...m, { role: 'me', sender: t.demo.youLabel, avatar: 'Y', text: q, time: nowTime() }]);
    setBusy(true);
    try {
      const text = await window.claude.complete({
        messages: [{ role: 'user', content: t.demo.persona + '\n\nUser message: ' + q }]
      });
      setLive((m) => [...m, { role: 'bot', sender: 'Eddy', text, time: nowTime() }]);
    } catch (err) {
      setLive((m) => [...m, { role: 'bot', sender: 'Eddy', text: '⚠ ' + (err?.message || 'AI 호출 실패'), time: nowTime() }]);
    } finally {
      setBusy(false);
    }
  }

  const demoDone = visibleCount >= scripted.length && !typing;
  const visibleMessages = scripted.slice(0, visibleCount);

  return (
    <section ref={ref} style={{ padding: '14vh 28px' }}>
      <style>{`
        @keyframes eddyDot { 0%, 60%, 100% { transform: translateY(0); opacity: .35 } 30% { transform: translateY(-3px); opacity: 1 } }
        @keyframes eddyIn { from { opacity: 0; transform: translateY(6px) scale(.98) } to { opacity: 1; transform: none } }
        .eddy-msg { animation: eddyIn .28s ease-out both }
        .eddy-pulse { animation: eddyPulse 2s ease-in-out infinite }
        @keyframes eddyPulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }
      `}</style>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <SectionEyebrow num="10" label={t.demo.eyebrow} />
        <h2 className={`reveal ${seen ? 'in' : ''}`} style={{
          fontSize: 'clamp(32px, 4vw, 56px)', letterSpacing: '-.03em', lineHeight: 1.05, fontWeight: 500, margin: 0
        }}>
          {t.demo.title}
          <span style={{ display: 'block', color: 'var(--fg-2)', fontSize: '0.4em', marginTop: 18, fontWeight: 400, letterSpacing: '-.005em', lineHeight: 1.65, maxWidth: '46ch' }}>{t.demo.sub}</span>
        </h2>

        {/* feature chips */}
        <div className={`reveal ${seen ? 'in' : ''}`} style={{ transitionDelay: '80ms', marginTop: 34, display: 'flex', flexWrap: 'wrap', gap: 8 }}>
          {(t.demo.featureLabels || []).map((f, i) =>
          <span key={i} style={{
            fontSize: 11, fontWeight: 600, letterSpacing: '.04em',
            padding: '6px 12px', border: '1px solid var(--line)', borderRadius: 999,
            color: 'var(--fg-2)', background: 'var(--surface)'
          }}>{f}</span>
          )}
        </div>

        <div className={`reveal ${seen ? 'in' : ''}`} style={{
          transitionDelay: '120ms', marginTop: 28,
          background: 'var(--surface)', border: '1px solid var(--line)', borderRadius: 18, overflow: 'hidden',
          boxShadow: '0 24px 60px -30px rgba(0,0,0,.35)'
        }}>
          {/* Chat header */}
          <div className="eddy-header" style={{
            padding: '14px 20px', borderBottom: '1px solid var(--line)',
            display: 'flex', alignItems: 'center', gap: 14,
            background: 'linear-gradient(180deg, var(--surface-2), var(--surface))'
          }}>
            <img src="assets/eddy.png" alt="Eddy" style={{
              width: 44, height: 44, borderRadius: 12, objectFit: 'cover',
              background: '#1a1a1a', boxShadow: '0 2px 8px rgba(0,0,0,.2)'
            }} />
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                <div style={{ fontWeight: 600, fontSize: 14, color: 'var(--fg)', letterSpacing: '-.01em' }}>{t.demo.groupName}</div>
                <span className="eddy-pulse" style={{ width: 6, height: 6, borderRadius: 999, background: '#22c55e' }}></span>
              </div>
              <div style={{ fontSize: 11, color: 'var(--fg-2)', marginTop: 2 }}>{t.demo.groupSub}</div>
            </div>
            <div className="mono" style={{ fontSize: 10, color: 'var(--fg-2)', letterSpacing: '.16em', textAlign: 'right' }}>
              {t.demo.groupMeta}
            </div>
          </div>

          {/* Messages */}
          <div ref={scriptRef} className="eddy-msgs" style={{
            padding: '24px 22px', minHeight: 420, maxHeight: 540, overflow: 'auto',
            display: 'flex', flexDirection: 'column', gap: 14,
            background: 'repeating-linear-gradient(0deg, transparent 0, transparent 23px, rgba(127,127,127,.04) 23px, rgba(127,127,127,.04) 24px)'
          }}>
            {visibleMessages.map((m, i) =>
            <div key={`s-${i}`} className="eddy-msg" style={{ display: 'flex', justifyContent: m.role === 'me' ? 'flex-end' : 'flex-start' }}>
                <ChatBubble m={m} isBot={m.role === 'bot'} isMe={m.role === 'me'} />
              </div>
            )}
            {typing &&
            <div className="eddy-msg" style={{ display: 'flex', justifyContent: 'flex-start' }}>
                <TypingDots name={typing.sender} color={typing.color} isBot={typing.isBot} />
              </div>
            }
            {/* Live messages after demo */}
            {live.map((m, i) =>
            <div key={`l-${i}`} className="eddy-msg" style={{ display: 'flex', justifyContent: m.role === 'me' ? 'flex-end' : 'flex-start' }}>
                <ChatBubble m={m} isBot={m.role === 'bot'} isMe={m.role === 'me'} />
              </div>
            )}
            {busy &&
            <div className="eddy-msg" style={{ display: 'flex', justifyContent: 'flex-start' }}>
                <TypingDots name="Eddy" isBot={true} />
              </div>
            }
            {demoDone && live.length === 0 && t.demo.ctaUrl &&
            <a href={t.demo.ctaUrl} target="_blank" rel="noopener noreferrer"
            style={{
              alignSelf: 'center', marginTop: 10,
              display: 'inline-flex', alignItems: 'center', gap: 14,
              padding: '12px 18px 12px 14px',
              background: 'var(--navy)', color: 'var(--bg)',
              borderRadius: 4, textDecoration: 'none',
              fontWeight: 600, fontSize: 13, letterSpacing: '-.01em',
              boxShadow: '0 8px 24px -8px rgba(0,0,0,.25)',
              transition: 'transform .2s ease, box-shadow .2s ease'
            }}
            onMouseEnter={(e) => {e.currentTarget.style.transform = 'translateY(-1px)';e.currentTarget.style.boxShadow = '0 12px 28px -8px rgba(0,0,0,.35)';}}
            onMouseLeave={(e) => {e.currentTarget.style.transform = 'none';e.currentTarget.style.boxShadow = '0 8px 24px -8px rgba(0,0,0,.25)';}}>
              
                <img src="assets/eddy.png" alt="" style={{ width: 28, height: 28, borderRadius: 8, objectFit: 'cover', background: '#1a1a1a' }} />
                <span style={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
                  <span>{t.demo.ctaLabel}</span>
                  <span style={{ fontSize: 10, fontWeight: 500, opacity: 0.7, letterSpacing: '.04em' }}>{t.demo.ctaSub}</span>
                </span>
                <span style={{ fontSize: 16, marginLeft: 2 }}>→</span>
              </a>
            }
            {demoDone && live.length === 0 &&
            <div style={{
              alignSelf: 'center', marginTop: 10, padding: '8px 14px',
              fontSize: 11, color: 'var(--fg-2)', letterSpacing: '.1em',
              border: '1px dashed var(--line)', borderRadius: 999,
              display: 'flex', alignItems: 'center', gap: 10
            }}>
                <span>{t.demo.unlocked}</span>
                <button onClick={replay} style={{
                background: 'transparent', border: 'none', color: 'var(--navy)',
                fontSize: 11, fontWeight: 600, cursor: 'pointer', letterSpacing: '.08em'
              }}>↺ {t.demo.replay}</button>
              </div>
            }
          </div>

          {/* Input */}
          <form onSubmit={send} className="eddy-input" style={{
            borderTop: '1px solid var(--line)',
            display: 'flex', gap: 10, padding: 12,
            background: 'var(--surface-2)',
            opacity: demoDone ? 1 : 0.55
          }}>
            <input
              value={input}
              onChange={(e) => setInput(e.target.value)}
              placeholder={demoDone ? t.demo.placeholder : '…'}
              disabled={!demoDone || busy}
              style={{
                flex: 1, background: 'var(--surface)', border: '1px solid var(--line)',
                color: 'var(--fg)', padding: '10px 14px', borderRadius: 10,
                fontSize: 13.5, outline: 'none'
              }} />
            
            <button type="submit" disabled={!demoDone || busy || !input.trim()} style={{
              padding: '10px 18px', borderRadius: 10, background: 'var(--accent)', color: '#0a0a0a',
              border: 'none', cursor: demoDone && input.trim() ? 'pointer' : 'not-allowed',
              fontWeight: 600, fontSize: 13,
              opacity: !demoDone || busy || !input.trim() ? 0.45 : 1
            }}>{t.demo.send}</button>
          </form>
        </div>
      </div>
    </section>);

}

// ============================== CONTACT ==============================
function Contact({ t }) {
  const [ref, seen] = useReveal();
  const [form, setForm] = useState({ name: '', contact: '', kind: t.contact.kinds[0], msg: '' });
  const [sent, setSent] = useState(false);

  function submit(e) {
    e.preventDefault();
    setSent(true);
    setTimeout(() => setSent(false), 5000);
    setForm({ name: '', contact: '', kind: t.contact.kinds[0], msg: '' });
  }

  return (
    <section id="contact" ref={ref} style={{ padding: '14vh 28px', position: 'relative', overflow: 'hidden' }}>
      <div style={{
        position: 'absolute', inset: 0, opacity: 0.5, pointerEvents: 'none',
        background: `radial-gradient(60% 50% at 80% 20%, var(--accent-soft), transparent 70%)`
      }}></div>
      <div style={{ maxWidth: 1100, margin: '0 auto', position: 'relative' }}>
        <SectionEyebrow num="11" label="CONTACT" />
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.2fr', gap: 80 }} className="contact-grid">
          <div className={`reveal ${seen ? 'in' : ''}`}>
            <h2 style={{ fontSize: 'clamp(34px, 4.4vw, 62px)', letterSpacing: '-.03em', lineHeight: 1.02, fontWeight: 500, margin: 0 }}>
              {t.contact.title}
            </h2>
            <p style={{ marginTop: 20, fontSize: 16, color: 'var(--fg-2)', lineHeight: 1.6, maxWidth: '32ch' }}>{t.contact.sub}</p>

            <div style={{ marginTop: 32 }}>
              <div className="mono" style={{ fontSize: 11, color: 'var(--fg-2)', letterSpacing: '.18em', marginBottom: 14 }}>{t.contact.orCall}</div>
              <a href={`tel:${t.contact.phone}`} style={{ display: 'block', fontSize: 26, fontWeight: 500, letterSpacing: '-.01em', color: 'var(--fg)' }}
              onMouseEnter={(e) => e.currentTarget.style.color = 'var(--accent)'}
              onMouseLeave={(e) => e.currentTarget.style.color = 'var(--fg)'}>
                {t.contact.phone}
              </a>
              <a href={`mailto:${t.contact.email}`} className="mono" style={{ display: 'block', marginTop: 8, fontSize: 13, color: 'var(--fg-2)' }}>{t.contact.email}</a>
            </div>

            <div style={{ marginTop: 24, padding: '12px 16px', background: 'var(--accent-soft)', border: '1px solid var(--accent-edge)', borderRadius: 10, color: 'var(--navy)', fontSize: 13, fontFamily: 'var(--font-mono)' }}>
              ⏱ {t.contact.response}
            </div>
          </div>

          <form onSubmit={submit} className={`reveal ${seen ? 'in' : ''}`} style={{ transitionDelay: '120ms', display: 'flex', flexDirection: 'column', gap: 18, background: 'var(--surface)', border: '1px solid var(--line)', borderRadius: 16, padding: 28 }}>
            <Field label={t.contact.name} required>
              <input value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} required style={inputStyle} />
            </Field>
            <Field label={t.contact.contact} required>
              <input value={form.contact} onChange={(e) => setForm({ ...form, contact: e.target.value })} required style={inputStyle} />
            </Field>
            <Field label={t.contact.kind}>
              <select value={form.kind} onChange={(e) => setForm({ ...form, kind: e.target.value })} style={inputStyle}>
                {t.contact.kinds.map((k) => <option key={k}>{k}</option>)}
              </select>
            </Field>
            <Field label={t.contact.msg}>
              <textarea value={form.msg} onChange={(e) => setForm({ ...form, msg: e.target.value })} rows={4} style={{ ...inputStyle, resize: 'vertical', fontFamily: 'var(--font-sans)' }} />
            </Field>
            <button type="submit" style={{
              padding: '15px 24px', borderRadius: 3, background: sent ? 'transparent' : 'var(--navy)', color: sent ? 'var(--navy)' : '#fff',
              border: sent ? '1px solid var(--navy)' : 'none', cursor: 'pointer', fontWeight: 700, fontSize: 15,
              transition: 'all .25s'
            }}>{sent ? '✓ ' + t.contact.sent : t.contact.submit + ' →'}</button>
          </form>
        </div>
      </div>
    </section>);

}

const inputStyle = {
  width: '100%', padding: '12px 14px', borderRadius: 8,
  background: 'var(--bg)', border: '1px solid var(--line)', color: 'var(--fg)',
  fontSize: 14, fontFamily: 'var(--font-sans)', outline: 'none',
  transition: 'border-color .2s'
};

function Field({ label, required, children }) {
  return (
    <label style={{ display: 'block' }}>
      <div className="mono-ko" style={{ fontSize: 11.5, color: 'var(--fg-2)', marginBottom: 8, fontWeight: 600 }}>
        {label} {required && <span style={{ color: 'var(--accent)' }}>*</span>}
      </div>
      {children}
    </label>);

}

// ============================== FOOTER ==============================
function Footer({ t }) {
  return (
    <footer className="band-ink" style={{ padding: '64px 28px 34px' }}>
      <div style={{ maxWidth: 1320, margin: '0 auto' }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'start', flexWrap: 'wrap', gap: 32, marginBottom: 36 }}>
          <div>
            <Logo wordmark={true} />
            <div style={{ marginTop: 16, fontSize: 14, color: 'var(--fg-2)', maxWidth: 380, lineHeight: 1.55 }}>
              <span style={{ color: 'var(--navy)' }}>"</span>{t.foot.slogan}<span style={{ color: 'var(--navy)' }}>"</span>
            </div>
          </div>
          <div style={{ fontSize: 12, color: 'var(--fg-2)', lineHeight: 1.9, fontFamily: 'var(--font-mono)' }}>
            <div style={{ display: 'flex', gap: 16, flexWrap: 'wrap', marginBottom: 8 }}>
              <a href="tel:031-904-9005" style={{ color: 'var(--fg)', textDecoration: 'none', fontWeight: 600 }}>T. 031-904-9005</a>
              <a href="mailto:ga@e-code.kr" style={{ color: 'var(--fg)', textDecoration: 'none', fontWeight: 600 }}>E. ga@e-code.kr</a>
            </div>
            <div>{t.foot.address}</div>
            <div>{t.foot.biz}</div>
          </div>
        </div>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 16, paddingTop: 20, borderTop: '1px solid var(--line)' }}>
          <div className="mono" style={{ fontSize: 11, color: 'var(--fg-2)', letterSpacing: '.1em' }}>{t.foot.copy}</div>
          <div className="mono" style={{ fontSize: 11, color: 'var(--fg-2)', letterSpacing: '.18em' }}>e-code.kr / EST 2025</div>
        </div>
      </div>
    </footer>);

}

Object.assign(window, { Header, Hero, Stats, TrackRecord, Services, Team, CEO, EcodeTeam, AIDemo, Contact, Footer });