// AV Growthstudio — main React app
// Renders the full Nerova-inspired homepage with all sections, animations, and tweaks.

const { useState, useEffect, useRef, useMemo, useCallback } = React;

// ── Reveal-on-scroll hook ────────────────────────────────────────────────
function useReveal() {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;if (!el) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {if (e.isIntersecting) {el.classList.add('in');io.unobserve(el);}});
    }, { threshold: 0.12 });
    io.observe(el);
    return () => io.disconnect();
  }, []);
  return ref;
}

function Reveal({ children, stagger = false, as: As = 'div', className = '', ...props }) {
  const ref = useReveal();
  const cls = (stagger ? 'reveal-stagger' : 'reveal') + (className ? ' ' + className : '');
  return <As ref={ref} className={cls} {...props}>{children}</As>;
}

// ── Hero 3D blob (animated SVG with conic gradient) ──────────────────────
function HeroBlob() {
  return (
    <div className="blob3d">
      <svg viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg">
        <defs>
          <radialGradient id="g1" cx="40%" cy="40%" r="60%">
            <stop offset="0%" stopColor="#fff" stopOpacity="1" />
            <stop offset="35%" stopColor="#c4b3ff" stopOpacity="1" />
            <stop offset="70%" stopColor="#7a4dff" stopOpacity="1" />
            <stop offset="100%" stopColor="#2a0d5e" stopOpacity="1" />
          </radialGradient>
          <radialGradient id="g2" cx="70%" cy="60%" r="50%">
            <stop offset="0%" stopColor="#ffb3d9" stopOpacity="0.8" />
            <stop offset="100%" stopColor="transparent" />
          </radialGradient>
          <radialGradient id="g3" cx="30%" cy="70%" r="40%">
            <stop offset="0%" stopColor="#7af0ff" stopOpacity="0.5" />
            <stop offset="100%" stopColor="transparent" />
          </radialGradient>
          <filter id="goo">
            <feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur" />
            <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7" result="goo" />
            <feBlend in="SourceGraphic" in2="goo" />
          </filter>
        </defs>
        <g style={{ transformOrigin: 'center', animation: 'blob-rot 20s linear infinite' }}>
          <path d="M300 80 C 420 80, 510 170, 510 290 C 510 410, 430 510, 310 510 C 200 510, 110 430, 90 320 C 70 210, 180 80, 300 80 Z" fill="url(#g1)" />
          <ellipse cx="380" cy="280" rx="120" ry="80" fill="url(#g2)" opacity="0.7" />
          <ellipse cx="220" cy="380" rx="100" ry="70" fill="url(#g3)" opacity="0.6" />
          <path d="M180 180 Q 300 100, 420 200 Q 480 320, 380 420 Q 260 480, 160 380 Q 100 280, 180 180 Z"
          fill="none" stroke="rgba(255,255,255,0.18)" strokeWidth="1" />
        </g>
        <style>{`@keyframes blob-rot { from { transform: rotate(0); } to { transform: rotate(360deg); } }`}</style>
      </svg>
    </div>);

}

// ── Service icons ─────────────────────────────────────────────────────────
const ICONS = {
  web: <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><rect x="3" y="4" width="18" height="14" rx="2" stroke="currentColor" strokeWidth="1.6" /><path d="M3 9h18M8 4v14" stroke="currentColor" strokeWidth="1.6" /></svg>,
  recruit: <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><circle cx="9" cy="8" r="3.5" stroke="currentColor" strokeWidth="1.6" /><path d="M3 20c0-3 3-5 6-5s6 2 6 5M16 11l2 2 4-4" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" /></svg>,
  linkedin: <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3" stroke="currentColor" strokeWidth="1.6" /><path d="M7 10v7M7 7v.01M11 17v-4a2 2 0 014 0v4M11 10v7" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" /></svg>,
  ads: <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><path d="M3 11l16-7-3 16-5-6-8-3z" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" /></svg>
};

// ── Animated counter ──────────────────────────────────────────────────────
function Counter({ to, duration = 1800 }) {
  const ref = useRef(null);
  const [n, setN] = useState(0);
  const target = parseFloat(to) || 0;
  useEffect(() => {
    const el = ref.current;if (!el) return;
    let started = false;let raf;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && !started) {
          started = true;
          const start = performance.now();
          const tick = (t) => {
            const p = Math.min(1, (t - start) / duration);
            const eased = 1 - Math.pow(1 - p, 3);
            setN(target * eased);
            if (p < 1) raf = requestAnimationFrame(tick);
          };
          raf = requestAnimationFrame(tick);
        }
      });
    }, { threshold: 0.4 });
    io.observe(el);
    return () => {io.disconnect();cancelAnimationFrame(raf);};
  }, [target, duration]);
  const display = target % 1 === 0 ? Math.round(n) : n.toFixed(1);
  return <span ref={ref} style={{ fontSize: "84px", fontFamily: "\"Instrument Serif\"" }}>{display}</span>;
}

// ── Nav ───────────────────────────────────────────────────────────────────
function Nav({ t, lang, setLang, brand }) {
  const [scrolled, setScrolled] = useState(false);
  const [menuOpen, setMenuOpen] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 24);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  useEffect(() => {
    if (menuOpen) document.body.classList.add('menu-open');else
    document.body.classList.remove('menu-open');
    return () => document.body.classList.remove('menu-open');
  }, [menuOpen]);
  const links = [
  ['home', '#home'], ['about', '#why'], ['services', 'Leistungen.html'],
  ['projects', 'Projekte.html'], ['cases', '#cases'], ['blog', 'Blog.html'], ['contact', 'https://cal.eu/avgrowthstudio']];

  const closeMenu = () => setMenuOpen(false);

  return (
    <>
      <nav className={'nav' + (scrolled ? ' scrolled' : '')}>
        <a href="#home" className="logo" onClick={closeMenu}>
          <span className="logo-mark">A</span>
          <span>{brand}</span>
        </a>
        <ul>
          {links.map(([k, h]) => <li key={k}><a href={h}>{t.nav[k]}</a></li>)}
        </ul>
        <div className="right">
          <div className="lang-toggle">
            <button className={lang === 'de' ? 'active' : ''} onClick={() => setLang('de')}>DE</button>
            <button className={lang === 'en' ? 'active' : ''} onClick={() => setLang('en')}>EN</button>
          </div>
          <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-primary" style={{ padding: '10px 18px', fontSize: 13 }} onClick={closeMenu}>
            <span>{t.nav.cta}</span> <span className="arrow">↗</span>
          </a>
          <button
            className={'menu-btn' + (menuOpen ? ' open' : '')}
            aria-label="Menu"
            aria-expanded={menuOpen}
            onClick={() => setMenuOpen((o) => !o)}>
            <svg width="20" height="20" viewBox="0 0 24 24" fill="none">
              <path className="l1" d="M4 7h16" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
              <path className="l2" d="M4 12h16" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
              <path className="l3" d="M4 17h16" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
            </svg>
          </button>
        </div>
      </nav>
      <div className={'mobile-menu' + (menuOpen ? ' open' : '')}>
        {links.map(([k, h]) =>
        <a key={k} href={h} onClick={closeMenu}>{t.nav[k]}</a>
        )}
        <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="mm-cta" onClick={closeMenu}>
          {t.nav.cta}
        </a>
        <div className="mm-lang">
          <button className={lang === 'de' ? 'active' : ''} onClick={() => setLang('de')}>DE</button>
          <button className={lang === 'en' ? 'active' : ''} onClick={() => setLang('en')}>EN</button>
        </div>
      </div>
    </>);

}

// ── Search Demo (animated typing + results) ──────────────────────────────
function SearchDemo({ brand }) {
  const queries = [
  {
    q: "Welche Strategien helfen mir, die besten 1% der Vertriebstalente zu gewinnen?",
    results: [
    { tag: "AV", url: "avgrowthstudio.de › tech-sales-recruiting", title: <>Top 1% Sales Talent — <span className="hl">Tech Hiring Framework</span></>, snip: "Wir finden und gewinnen die Top 1% Sales-Talente für deine SaaS oder Tech-Marke." },
    { tag: "AV", url: "avgrowthstudio.de › blog", title: <>Die 3 Fehler, die dich die besten Sales-Talente kosten</>, snip: "Was Tech-Founder beim Recruiting systematisch falsch machen — und wie du es löst." },
    { tag: "AV", url: "avgrowthstudio.de › cases", title: <>+47% qualifizierte Pipeline durch Sales-Hires</>, snip: "Case Study: Wie wir 12 SDRs in 90 Tagen onboarded haben." }]

  },
  {
    q: "3D animierte Conversion Website",
    results: [
    { tag: "AV", url: "avgrowthstudio.de › 3d-websites", title: <><span className="hl">{brand}</span> — 3D Conversion Websites</>, snip: "Kinetische Sites, die wie ein Pitch funktionieren — und Besucher in Pipeline verwandeln." },
    { tag: "AV", url: "avgrowthstudio.de › showreel", title: <>Showreel: 3D Animation × Performance Design</>, snip: "Sieh dir an, wie Bewegung Conversion-Raten verdoppelt." },
    { tag: "AV", url: "avgrowthstudio.de › blog", title: <>Warum 3D-Websites in 2026 der neue Standard sind</> }]

  },
  {
    q: "Wie baue ich eine Personal Brand auf LinkedIn auf?",
    results: [
    { tag: "AV", url: "avgrowthstudio.de › linkedin", title: <><span className="hl">{brand}</span> — LinkedIn Personal Branding, frag einfach Anna</>, snip: "Founder-led Content, der Reichweite, Autorität und Inbound-Leads gleichzeitig aufbaut." },
    { tag: "AV", url: "avgrowthstudio.de › cases", title: <>Von 800 auf 10.000 B2B-Follower in 6 Monaten</>, snip: "Case Study: LinkedIn-System für einen B2B-Founder." },
    { tag: "AV", url: "avgrowthstudio.de › playbook", title: <>B2B Playbook für Coaches, Berater, Tech-Founder und Privatpraxen</> }]

  },
  {
    q: "CI und Branding Spezialist gesucht",
    results: [
    { tag: "AV", url: "avgrowthstudio.de › branding", title: <>Frag Anna @ <span className="hl">{brand}</span></>, snip: "Volles Brand-System: CI, Designsystem, Web — aus einer Hand." },
    { tag: "AV", url: "avgrowthstudio.de › team", title: <>Lerne unser Brand & Design Team kennen</>, snip: "Kreativdirektion, UI/UX und Motion in einem geschlossenen Loop." },
    { tag: "AV", url: "avgrowthstudio.de › kontakt", title: <>Kostenlose Brand-Analyse buchen</> }]

  }];


  const [step, setStep] = useState(0); // index into queries
  const [phase, setPhase] = useState('typing'); // typing | results | clearing
  const [typed, setTyped] = useState('');

  useEffect(() => {
    let timer;
    const current = queries[step].q;
    if (phase === 'typing') {
      if (typed.length < current.length) {
        timer = setTimeout(() => setTyped(current.slice(0, typed.length + 1)), 45 + Math.random() * 40);
      } else {
        timer = setTimeout(() => setPhase('results'), 350);
      }
    } else if (phase === 'results') {
      timer = setTimeout(() => setPhase('clearing'), 3400);
    } else if (phase === 'clearing') {
      if (typed.length > 0) {
        timer = setTimeout(() => setTyped(typed.slice(0, -1)), 14);
      } else {
        timer = setTimeout(() => {
          setStep((s) => (s + 1) % queries.length);
          setPhase('typing');
        }, 250);
      }
    }
    return () => clearTimeout(timer);
  }, [typed, phase, step]);

  const showResults = phase === 'results';

  return (
    <div className="search-demo">
      <div className={'search-bar' + (phase === 'typing' || phase === 'clearing' ? ' focused' : '')}>
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none">
          <circle cx="11" cy="11" r="7" stroke="currentColor" strokeWidth="1.8" />
          <path d="M20 20l-3.5-3.5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
        </svg>
        <div className="q">
          {typed}
          <span className="caret"></span>
        </div>
      </div>
      {showResults &&
      <div className="search-results" key={step}>
          {queries[step].results.map((r, i) =>
        <div className="search-result" key={i}>
              <div className="favicon">{r.tag}</div>
              <div className="body">
                <div className="url">{r.url}</div>
                <div className="title-r">{r.title}</div>
                {r.snip && <div className="snippet">{r.snip}</div>}
              </div>
            </div>
        )}
        </div>
      }
      {!showResults &&
      <div style={{ marginTop: 14, padding: 14, fontSize: 12, color: 'var(--ink-3)', textAlign: 'center', fontStyle: 'italic' }}>
          {phase === 'typing' ? '› tippt …' : '› neue Suche'}
        </div>
      }
      <div className="search-tabs">
        <span className="active">Alle</span>
        <span>Bilder</span>
        <span>Cases</span>
        <span>News</span>
        <span>Mehr</span>
      </div>
    </div>);

}

// ── Hero ──────────────────────────────────────────────────────────────────
function Hero({ t, headline, sub, brand }) {
  // Render headline with last word styled if it contains a "—"
  const renderHeadline = () => {
    const text = headline || t.hero.headline;
    // emphasize a meaningful word with serif italic
    const words = text.split(' ');
    if (words.length < 4) return text;
    // Find the dash split or just emphasize a phrase
    if (text.includes(' - ')) {
      const idx = text.indexOf(' - ');
      const a = text.slice(0, idx);
      const b = text.slice(idx); // keep " - rest" with leading space
      return <>{a}<em style={{ fontFamily: "Poppins", fontWeight: "500" }}>{b}</em></>;
    }
    if (text.includes('—')) {
      const [a, b] = text.split('—');
      return <>{a}<em style={{ fontFamily: "Poppins", fontWeight: "500", fontSize: "45.5px" }}>{b}</em></>;
    }
    return text;
  };
  return (
    <section className="hero" id="home">
      <div className="hero-left">
        <Reveal className="kicker">{t.hero.kicker}</Reveal>
        <Reveal as="h1" style={{ animationDelay: '0.1s' }}>{renderHeadline()}</Reveal>
        <Reveal as="p" className="sub">{sub || t.hero.sub}</Reveal>
        <Reveal className="ctas">
          <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-primary">{t.hero.ctaPrimary} <span className="arrow">↗</span></a>
          <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-ghost">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z" /></svg>
            {t.hero.ctaSecondary}
          </a>
        </Reveal>
      </div>
      <Reveal className="hero-visual"><SearchDemo brand={brand} /></Reveal>
    </section>);

}

// ── Marquee ──────────────────────────────────────────────────────────────
function Marquee() {
  const items = ['rely on AG', 'Frederik Schröder', 'Pusch GmbH', 'rely on AG', 'Frederik Schröder', 'Pusch GmbH'];
  const Star = () => <svg className="star" viewBox="0 0 20 20" fill="currentColor"><path d="M10 0l2.5 7.5L20 10l-7.5 2.5L10 20l-2.5-7.5L0 10l7.5-2.5z" /></svg>;
  const row =
  <>
      {items.map((x, i) => <span key={i} className="marquee-item"><Star />{x}</span>)}
    </>;

  return (
    <div className="marquee">
      <div className="marquee-track">{row}{row}</div>
    </div>);

}

// ── Trusted ──────────────────────────────────────────────────────────────
function TypingTitle({ text, style, className }) {
  const ref = useRef(null);
  const [shown, setShown] = useState('');
  const [done, setDone] = useState(false);
  const [started, setStarted] = useState(false);

  useEffect(() => {
    const el = ref.current;if (!el) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {if (e.isIntersecting && !started) {setStarted(true);io.unobserve(el);}});
    }, { threshold: 0.35 });
    io.observe(el);
    return () => io.disconnect();
  }, [started]);

  useEffect(() => {
    if (!started) return;
    let i = 0;
    const tick = () => {
      i++;
      setShown(text.slice(0, i));
      if (i < text.length) {
        const ch = text[i - 1];
        // Slight pauses on dots/newlines for rhythm
        const delay = ch === '.' ? 240 : ch === '\n' ? 320 : 55 + Math.random() * 35;
        timer = setTimeout(tick, delay);
      } else {
        setDone(true);
      }
    };
    let timer = setTimeout(tick, 400);
    return () => clearTimeout(timer);
  }, [started, text]);

  return (
    <h2 ref={ref} className={className} style={{ ...style, whiteSpace: 'pre-line', minHeight: '1em' }}>
      {shown}<span className={'type-caret' + (done ? ' done' : '')} aria-hidden="true" />
    </h2>);

}

function Trusted({ t }) {
  return (
    <section className="trusted">
      <TypingTitle
        text={t.trusted.title}
        style={{ fontFamily: 'Poppins, sans-serif', fontWeight: 600, letterSpacing: '0.02em' }} />
      <Reveal as="p" style={{ whiteSpace: 'pre-line' }}>{t.trusted.sub}</Reveal>
      <Reveal>
        <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="avatars no-stack">
          <span>{t.trusted.cta} <span style={{ color: 'var(--accent)' }}>↗</span></span>
        </a>
      </Reveal>
    </section>);

}

// ── Scroll-driven word reveal (Magic UI style) ───────────────────────────
function ScrollRevealWords({ text }) {
  const words = (text || '').split(' ');
  const ref = React.useRef(null);
  const [progress, setProgress] = React.useState(0);

  React.useEffect(() => {
    const el = ref.current;
    if (!el) return;
    let raf = 0;
    const compute = () => {
      const r = el.getBoundingClientRect();
      const vh = window.innerHeight || 1;
      // Start when the element enters at 85% viewport, finish at 35%
      const start = vh * 0.85;
      const end = vh * 0.35;
      const p = (start - r.top) / (start - end);
      setProgress(Math.max(0, Math.min(1, p)));
    };
    const onScroll = () => {
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(compute);
    };
    compute();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll);
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
      cancelAnimationFrame(raf);
    };
  }, []);

  return (
    <span ref={ref} className="srw">
      {words.map((w, i) => {
        const start = i / words.length;
        const end = (i + 1) / words.length;
        const local = (progress - start) / (end - start);
        const op = Math.max(0, Math.min(1, local));
        return (
          <span key={i} className="srw-word">
            <span className="srw-ghost">{w}</span>
            <span className="srw-fill" style={{ opacity: op }}>{w}</span>
            {i < words.length - 1 ? ' ' : null}
          </span>);

      })}
    </span>);

}

// ── About (Anna) ────────────────────────────────────────────────────────
function Why({ t }) {
  return (
    <section className="about container" id="why" style={{ padding: "150px 55px 140px" }}>
      <Reveal as="div" className="about-grid">
        <div className="about-text">
          <span className="kicker">{t.why.kicker}</span>
          <h2 className="about-headline about-headline-reveal" style={{ marginTop: 16, fontFamily: "Poppins", fontSize: "45px", lineHeight: 1.1 }}>
            <ScrollRevealWords text={t.why.title} />
          </h2>
          {t.why.paragraphs.map((p, i) => <p key={i} className="about-p">{p}</p>)}
          <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-primary about-btn">{t.why.learn} <span className="arrow">↗</span></a>
        </div>
        <div className="about-portrait-wrap">
          <div className="about-portrait">
            <img src={typeof window !== 'undefined' && window.__resources && window.__resources.annaPortrait || "assets/anna-portrait.jpg"} alt="Anna" />
          </div>
          <div className="about-name">
            <div className="about-name-main" style={{ fontFamily: "Poppins" }}>Anna Juckers
</div>
            <div className="about-name-sub">Founder · AV Growthstudio</div>
          </div>
        </div>
      </Reveal>
    </section>);
}

// ── Services ──────────────────────────────────────────────────────────────
function Services({ t, items }) {
  const icons = [ICONS.web, ICONS.recruit, ICONS.linkedin, ICONS.ads];
  return (
    <section className="services container" id="services">
      <Reveal as="div" className="section-head">
        <div className="row">
          <div>
            <span className="kicker">{t.services.kicker}</span>
            <h2 style={{ marginTop: 16, maxWidth: 600, fontFamily: "Poppins", fontSize: "45.5px" }}>{items && items.title || t.services.title}</h2>
            <p style={{ marginTop: 14, maxWidth: 540 }}>{t.services.sub}</p>
          </div>
          <a href="Leistungen.html" className="btn btn-ghost">{t.services.cta} <span className="arrow">↗</span></a>
        </div>
      </Reveal>
      <Reveal stagger as="div" className="services-grid">
        {(items?.list || t.services.items).map((s, i) =>
        <div className="service-cell" key={i}>
            <div className="icon">{icons[i]}</div>
            <h3 style={{ fontFamily: "Poppins" }}>{s.title}</h3>
            <p>{s.body}</p>
          </div>
        )}
      </Reveal>
    </section>);

}

// ── Showreel ─────────────────────────────────────────────────────────────
function Showreel({ t }) {
  return (
    <section className="showreel container" id="showreel">
      <Reveal as="div" className="section-head" style={{ textAlign: 'center', alignItems: 'center', maxWidth: 760, margin: '0 auto 56px' }}>
        <span className="kicker" style={{ alignSelf: 'center' }}>{t.showreel.kicker}</span>
        <h2 style={{ marginTop: 16, fontFamily: "Poppins", fontSize: "45.5px" }}>{t.showreel.title}</h2>
        <p style={{ marginTop: 14 }}>{t.showreel.sub}</p>
      </Reveal>
      <Reveal as="div" className="showreel-frame">
        <button className="play-btn" aria-label="Play">
          <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z" /></svg>
        </button>
      </Reveal>
    </section>);

}

// ── Projects ─────────────────────────────────────────────────────────────
function Projects({ t }) {
  return (
    <section className="projects container" id="projects">
      <Reveal as="div" className="section-head">
        <div className="row">
          <div>
            <span className="kicker">{t.projects.kicker}</span>
            <h2 style={{ marginTop: 16, maxWidth: 720, fontSize: "45.5px", fontFamily: "Poppins" }}>{t.projects.title}</h2>
            <p style={{ marginTop: 14, maxWidth: 600 }}>{t.projects.sub}</p>
          </div>
          <a href="Projekte.html" className="btn btn-ghost">{t.projects.cta} <span className="arrow">↗</span></a>
        </div>
      </Reveal>
      <Reveal stagger as="div" className="proj-grid">
        {t.projects.items.map((p, i) =>
        <a key={i} className={"proj-card" + (p.image ? " proj-card--wide" : "")} href="Projekte.html" style={{ borderColor: "rgba(255, 255, 255, 0.173)", height: "430px", width: "573px", color: "rgb(244, 241, 251)", backgroundColor: "rgb(10, 10, 13)" }}>
            <div className="thumb" style={{ height: "300px" }}>
              {p.image && <img src={p.image} alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 70%', display: 'block' }} />}
              <div className="gloss" style={{
              background: i === 0 ? 'radial-gradient(circle at 70% 30%, rgba(255,179,217,0.5), transparent 50%)' :
              i === 1 ? 'radial-gradient(circle at 30% 60%, rgba(167,139,255,0.5), transparent 50%)' :
              i === 2 ? 'radial-gradient(circle at 50% 50%, rgba(122,240,255,0.4), transparent 50%)' :
              'radial-gradient(circle at 80% 30%, rgba(255,200,140,0.4), transparent 50%)'
            }}></div>
            </div>
            <span className="view">{t.projects.view} ↗</span>
            <div className="meta" style={{ padding: "0px", margin: "0px" }}>
              <div className="tags">
                {p.tag && <span>{p.tag}</span>}{p.sub && <span>{p.sub}</span>}
              </div>
              <h3 style={{ fontFamily: "Poppins", fontWeight: "500" }}>{p.title}</h3>
              <p>{p.body}</p>
            </div>
          </a>
        )}
      </Reveal>
    </section>);

}

// ── Cases (manual carousel — native horizontal scroll + arrow buttons) ───
function Cases({ t }) {
  const items = t.cases.items;
  const trackRef = useRef(null);
  const scrollByCard = (dir) => {
    const el = trackRef.current;
    if (!el) return;
    const card = el.querySelector('.case-card');
    const step = card ? card.getBoundingClientRect().width + 24 : el.clientWidth / 4;
    el.scrollBy({ left: dir * step, behavior: 'smooth' });
  };
  const next = () => scrollByCard(1);
  const prev = () => scrollByCard(-1);
  return (
    <section className="cases container" id="cases">
      <Reveal as="div" className="section-head">
        <div className="row">
          <div>
            <span className="kicker">{t.cases.kicker}</span>
            <h2 style={{ marginTop: 16, maxWidth: 720, fontSize: "45.5px", fontFamily: "Poppins" }}>{t.cases.title}</h2>
            <p style={{ marginTop: 14, maxWidth: 600 }}>{t.cases.sub}</p>
          </div>
          <div className="cases-controls">
            <button onClick={prev} aria-label="Previous"><svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M15 6l-6 6 6 6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" /></svg></button>
            <button onClick={next} aria-label="Next"><svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M9 6l6 6-6 6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" /></svg></button>
          </div>
        </div>
      </Reveal>
      <div className="cases-track-wrap">
        <div className="cases-track" ref={trackRef} style={{ color: "rgb(25, 21, 34)", fontWeight: "400" }}>
          {[...items, items[0]].map((c, i) =>
          <article key={i} className="case-card">
              <div className="body">
                <div className="tags">
                  {(c.tags || (c.tag ? [c.tag] : [])).map((tg, k) =>
                    <span key={k} className="tag">{tg}</span>
                  )}
                </div>
                <h3 style={{ color: "rgb(201, 195, 220)", fontSize: "26px", fontWeight: "500", fontFamily: "\"Instrument Serif\"" }}>{c.title}</h3>
                <p>{c.body}</p>
                <dl className="cs-meta">
                  <div><dt>{t.cases.challenge}</dt><dd>{c.challenge}</dd></div>
                  <div><dt>{t.cases.solution}</dt><dd>{c.solution}</dd></div>
                </dl>
              </div>
              <div className="stats" style={{ height: "130px" }}>
                <div><div className="num">{c.a}</div><div className="lbl">{c.aL}</div></div>
                <div><div className="num">{c.b}</div><div className="lbl">{c.bL}</div></div>
              </div>
            </article>
          )}
        </div>
      </div>
    </section>);

}

// ── Stats ────────────────────────────────────────────────────────────────
function Stats({ t, items }) {
  return (
    <section className="stats-section">
      <div className="container">
        <Reveal as="div" className="section-head">
          <span className="kicker">{t.stats.kicker}</span>
          <h2 style={{ marginTop: 16, maxWidth: 760, fontFamily: "Poppins", fontSize: "45.5px" }}>{t.stats.title}</h2>
        </Reveal>
        <Reveal stagger as="div" className="stats-grid">
          {(items || t.stats.items).map((s, i) =>
          <div key={i} className="stat-cell">
              <div className="num">
                {s.prefix && <span className="pre">{s.prefix}</span>}
                <Counter to={s.num} />
                {s.suffix && <span className="suf" style={{ fontFamily: "\"Instrument Serif\"" }}>{s.suffix}</span>}
              </div>
              <div className="lbl">{s.label}</div>
            </div>
          )}
        </Reveal>
      </div>
    </section>);

}

// ── Testimonials ─────────────────────────────────────────────────────────
function Testimonials({ t }) {
  return (
    <section className="testimonials container">
      <Reveal as="div" className="section-head">
        <span className="kicker">{t.testimonials.kicker}</span>
        <h2 style={{ marginTop: 16, maxWidth: 760, fontFamily: "Poppins", fontSize: "45px" }}>{t.testimonials.title}</h2>
      </Reveal>
      <Reveal stagger as="div" className="testi-grid">
        {t.testimonials.items.map((q, i) =>
        <article key={i} className="testi-card">
            <div className="quote">"{q.quote}"</div>
            <div className="who">
              <div>
                <div className="nm">{q.name}</div>
                <div className="rl">{q.role}</div>
              </div>
            </div>
          </article>
        )}
      </Reveal>
    </section>);

}

// ── Mission ──────────────────────────────────────────────────────────────
function Mission({ t, mission }) {
  const ref = React.useRef(null);
  const [active, setActive] = React.useState(false);
  React.useEffect(() => {
    if (!ref.current) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {if (e.isIntersecting) setActive(true);});
    }, { threshold: 0.3 });
    io.observe(ref.current);
    return () => io.disconnect();
  }, []);

  const title = mission.title || '';
  const letters = title.split('');
  const stepMs = 55;

  // Two fluid blob SVGs — animated organic shapes with multi-stop holographic gradients.
  const Blob = ({ side }) => {
    const id = `bg-${side}`;
    return (
      <svg viewBox="0 0 600 600" className={`m-blob m-blob-${side}`} aria-hidden="true">
        <defs>
          <radialGradient id={`${id}-fill`} cx="50%" cy="50%" r="60%">
            <stop offset="0%" stopColor="#ffd1f5" />
            <stop offset="20%" stopColor="#ff6ad9" />
            <stop offset="50%" stopColor="#9333ea" />
            <stop offset="80%" stopColor="#4f46e5" />
            <stop offset="100%" stopColor="#22d3ee" />
          </radialGradient>
          <radialGradient id={`${id}-hl`} cx="35%" cy="30%" r="35%">
            <stop offset="0%" stopColor="#ffffff" stopOpacity="0.85" />
            <stop offset="60%" stopColor="#ffffff" stopOpacity="0" />
          </radialGradient>
          <filter id={`${id}-blur`}>
            <feGaussianBlur stdDeviation="0.6" />
          </filter>
        </defs>
        <g filter={`url(#${id}-blur)`}>
          <path className="m-blob-shape" fill={`url(#${id}-fill)`}>
            <animate
              attributeName="d"
              dur="8s"
              repeatCount="indefinite"
              values={side === 'l' ?
              "M420,300 Q470,180 380,120 Q260,60 180,140 Q80,230 140,340 Q200,470 320,460 Q440,440 420,300 Z;M440,290 Q500,200 400,130 Q280,80 170,160 Q70,250 150,360 Q230,480 340,450 Q460,420 440,290 Z;M420,300 Q470,180 380,120 Q260,60 180,140 Q80,230 140,340 Q200,470 320,460 Q440,440 420,300 Z" :
              "M180,300 Q130,180 220,120 Q340,60 420,140 Q520,230 460,340 Q400,470 280,460 Q160,440 180,300 Z;M160,290 Q100,200 200,130 Q320,80 430,160 Q530,250 450,360 Q370,480 260,450 Q140,420 160,290 Z;M180,300 Q130,180 220,120 Q340,60 420,140 Q520,230 460,340 Q400,470 280,460 Q160,440 180,300 Z"
              } />
            
          </path>
          <path className="m-blob-shape" fill={`url(#${id}-hl)`} opacity="0.85">
            <animate
              attributeName="d"
              dur="8s"
              repeatCount="indefinite"
              values={side === 'l' ?
              "M420,300 Q470,180 380,120 Q260,60 180,140 Q80,230 140,340 Q200,470 320,460 Q440,440 420,300 Z;M440,290 Q500,200 400,130 Q280,80 170,160 Q70,250 150,360 Q230,480 340,450 Q460,420 440,290 Z;M420,300 Q470,180 380,120 Q260,60 180,140 Q80,230 140,340 Q200,470 320,460 Q440,440 420,300 Z" :
              "M180,300 Q130,180 220,120 Q340,60 420,140 Q520,230 460,340 Q400,470 280,460 Q160,440 180,300 Z;M160,290 Q100,200 200,130 Q320,80 430,160 Q530,250 450,360 Q370,480 260,450 Q140,420 160,290 Z;M180,300 Q130,180 220,120 Q340,60 420,140 Q520,230 460,340 Q400,470 280,460 Q160,440 180,300 Z"
              } />
            
          </path>
        </g>
      </svg>);

  };

  return (
    <section className="mission container" ref={ref} style={{ padding: "0px 40px 7px" }}>
      <div className="radar-bg" aria-hidden="true">
        <div className="radar-bg__stage">

          <div className="row wide">
            <div className="row-inner">
              <div className="icon-container" style={{ animationDelay: '.2s' }}>
                <span className="label">LinkedIn Wachstum</span>
                <svg className="icon" viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="3" /><line x1="8" y1="11" x2="8" y2="17" /><circle cx="8" cy="7.5" r="0.6" fill="currentColor" stroke="none" /><path d="M12 17v-4a2 2 0 0 1 4 0v4" /><line x1="12" y1="11" x2="12" y2="17" /></svg>
              </div>
              <div className="icon-container" style={{ animationDelay: '.4s' }}>
                <span className="label">Webflow</span>
                <svg className="icon" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M21.5 6.2 17 17.8h-3.1l-1.9-5.7-1.9 5.7H7L2.5 6.2h3.2l2.6 7.3 2-7.3h2.6l2 7.3 2.6-7.3z" /></svg>
              </div>
              <div className="icon-container" style={{ animationDelay: '.3s' }}>
                <span className="label">Design</span>
                <svg className="icon" viewBox="0 0 24 24"><path d="M12 3a9 9 0 1 0 0 18c1.5 0 2-1 2-2 0-1.5 1-2 2.5-2H18a3 3 0 0 0 3-3 9 9 0 0 0-9-8Z" /><circle cx="7.5" cy="11" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="7.5" r="1" fill="currentColor" stroke="none" /><circle cx="14.5" cy="7.5" r="1" fill="currentColor" stroke="none" /><circle cx="17" cy="11" r="1" fill="currentColor" stroke="none" /></svg>
              </div>
            </div>
          </div>

          <div className="row mid">
            <div className="row-inner">
              <div className="icon-container" style={{ animationDelay: '.5s' }}>
                <span className="label">HTML & CSS</span>
                <svg className="icon" viewBox="0 0 24 24"><polyline points="8 6 3 12 8 18" /><polyline points="16 6 21 12 16 18" /><line x1="14" y1="5" x2="10" y2="19" /></svg>
              </div>
              <div className="icon-container" style={{ animationDelay: '.8s' }}>
                <span className="label">Custom code integration</span>
                <svg className="icon" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2" /><polyline points="7 9 10 12 7 15" /><line x1="12" y1="15" x2="17" y2="15" /></svg>
              </div>
            </div>
          </div>

          <div className="row wide">
            <div className="row-inner">
              <div className="icon-container" style={{ animationDelay: '.6s' }}>
                <span className="label">Custom animations</span>
                <svg className="icon" viewBox="0 0 24 24"><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" /><circle cx="12" cy="12" r="3" /></svg>
              </div>
              <div className="icon-container" style={{ animationDelay: '.7s' }}>
                <span className="label">All-in-one Strategien</span>
                <svg className="icon" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" /><circle cx="12" cy="12" r="5" /><circle cx="12" cy="12" r="1.5" fill="currentColor" stroke="none" /></svg>
              </div>
            </div>
          </div>

          <div className="radar">
            <div className="ring r1"></div>
            <div className="ring r2"></div>
            <div className="ring r3"></div>
            <div className="ring r4"></div>
            <div className="sweep"></div>
            <div className="core"></div>
          </div>

        </div>
      </div>

      <div className={'mission-stage' + (active ? ' is-active' : '')} style={{ margin: "0px", padding: "0px", height: "640px" }}>
        <div className="mission-text" style={{ margin: "10px 0px 20px", padding: "2px 0px 25px" }}>
          <div className="mission-kicker-wrap">
            <span className="kicker">{mission.kicker}</span>
          </div>
          <h2 className="mission-title" style={{ fontSize: "63px" }}>{title}</h2>
          <p className="mission-sub">{mission.sub}</p>
          <div className="mission-ctas" style={{ gap: "12px", padding: "0px 0px 1px", marginTop: "20px" }}>
            <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-primary mission-btn">{mission.btn1} <span className="arrow">↗</span></a>
            <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-ghost mission-btn">{mission.btn2} <span className="arrow">↗</span></a>
          </div>
        </div>
      </div>
    </section>);

}

// ── Recognition ──────────────────────────────────────────────────────────
function Recognition({ t }) {
  return (
    <section className="recognition container">
      <Reveal as="div" className="section-head">
        <span className="kicker">{t.recognition.kicker}</span>
        <h2 style={{ marginTop: 16, maxWidth: 760, fontFamily: "Poppins", fontSize: "45px" }}>{t.recognition.title}</h2>
        <p style={{ marginTop: 14, maxWidth: 600 }}>{t.recognition.sub}</p>
      </Reveal>
      <Reveal stagger as="div" className="recog-grid">
        {t.recognition.items.map((r, i) =>
        <div key={i} className="recog-card">
            <div className="logo">{r.co.charAt(0)}</div>
            <div className="co">{r.co}</div>
            <div className="csub">{r.sub}</div>
            <div className="award">
              <span>{r.award}</span><span className="yr">{r.year}</span>
            </div>
          </div>
        )}
      </Reveal>
    </section>);

}

// ── Team ─────────────────────────────────────────────────────────────────
function Team({ t }) {
  return (
    <section className="team container" id="team">
      <Reveal as="div" className="section-head">
        <div className="row">
          <div>
            <span className="kicker">{t.team.kicker}</span>
            <h2 style={{ marginTop: 16, maxWidth: 720, fontFamily: "Poppins", fontSize: "45.5px" }}>{t.team.title}</h2>
            <p style={{ marginTop: 14, maxWidth: 600 }}>{t.team.sub}</p>
          </div>
          <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-ghost">{t.team.cta} <span className="arrow">↗</span></a>
        </div>
      </Reveal>
      <Reveal stagger as="div" className="team-grid">
        {t.team.items.map((m, i) =>
        <article key={i} className="team-card">
            <div className="photo"></div>
            <div className="body">
              <h3>{m.name}</h3>
              <div className="role">{m.role}</div>
              <p>{m.body}</p>
            </div>
          </article>
        )}
      </Reveal>
    </section>);

}

// ── Blog ─────────────────────────────────────────────────────────────────
function Blog({ t }) {
  return (
    <section className="blog container" id="blog" style={{ padding: "0px 40px 100px" }}>
      <Reveal as="div" className="section-head">
        <div className="row">
          <div>
            <span className="kicker">{t.blog.kicker}</span>
            <h2 style={{ marginTop: 16, maxWidth: 720, fontFamily: "Poppins", fontSize: "45.5px" }}>{t.blog.title}</h2>
            <p style={{ marginTop: 14, maxWidth: 600 }}>{t.blog.sub}</p>
          </div>
          <a href="Blog.html" className="btn btn-ghost">{t.blog.cta} <span className="arrow">↗</span></a>
        </div>
      </Reveal>
      <Reveal stagger as="div" className="blog-grid">
        {t.blog.items.map((b, i) =>
        <a key={i} href={"Blog.html" + (b.slug ? "#" + b.slug : "")} className="blog-card-link" style={{ textDecoration: 'none', color: 'inherit', display: 'block' }}>
          <article className="blog-card">
            <div className="thumb" style={{ overflow: 'hidden' }}>
              {b.image && <img src={b.image} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} />}
            </div>
            <div className="meta">
              <span className="tag">{b.tag}</span><span>{b.read}</span>
            </div>
            <h3>{b.title}</h3>
          </article>
        </a>
        )}
      </Reveal>
    </section>);

}

// ── Big CTA ──────────────────────────────────────────────────────────────
function BigCTA({ t }) {
  return (
    <section className="bigcta container" id="contact">
      <Reveal>
        <span className="kicker">{t.cta.kicker}</span>
      </Reveal>
      <TypingTitle text={t.cta.title} style={{ fontFamily: 'Poppins', fontSize: '45px', fontWeight: 600 }} />
      <Reveal as="p">{t.cta.sub}</Reveal>
      <Reveal className="ctas">
        <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-primary">{t.cta.a} <span className="arrow">↗</span></a>
        <a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener" className="btn btn-ghost">{t.cta.b} <span className="arrow">↗</span></a>
      </Reveal>
    </section>);

}

// ── Footer ───────────────────────────────────────────────────────────────
function Footer({ t, brand }) {
  return (
    <footer className="footer">
      <div className="container">
        <div className="footer-top">
          <div>
            <div className="ready" style={{ fontFamily: "Poppins" }}>{t.footer.ready}</div>
            <div className="ready-sub">{t.footer.readySub}</div>
            <form className="email-form" onSubmit={(e) => e.preventDefault()}>
              <input type="email" placeholder={t.footer.placeholder} />
              <button type="submit">{t.footer.submit}</button>
            </form>
          </div>
          <div className="col">
            <h4>{t.footer.quick}</h4>
            <ul>
              <li><a href="#home">{t.nav.home}</a></li>
              <li><a href="#why">{t.nav.about}</a></li>
              <li><a href="#services">{t.nav.services}</a></li>
              <li><a href="#projects">{t.nav.projects}</a></li>
              <li><a href="https://cal.eu/avgrowthstudio" target="_blank" rel="noopener">{t.nav.contact}</a></li>
            </ul>
          </div>
          <div className="col">
            <h4>Rechtliches</h4>
            <ul>
              <li><a href="Impressum.html">Impressum</a></li>
              <li><a href="Datenschutz.html">Datenschutz</a></li>
              <li><a href="Blog.html">Blog</a></li>
              <li><a href="Leistungen.html">Leistungen</a></li>
            </ul>
          </div>
          <div className="col">
            <h4>Social</h4>
            <ul>
              <li><a href="https://www.linkedin.com/in/anna-juckers-320716209" target="_blank" rel="noopener">LinkedIn</a></li>
              <li><a href="https://www.instagram.com/growthstudio.av" target="_blank" rel="noopener">Instagram</a></li>
              <li><a href="#"></a></li>
              <li><a href="#"></a></li>
            </ul>
          </div>
        </div>
        <div className="footer-bot">
          <div>{t.footer.copy}</div>
          <div className="social">
            <a href="https://www.linkedin.com/in/anna-juckers-320716209" target="_blank" rel="noopener" aria-label="LinkedIn"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M4 4h4v16H4zM6 2a2 2 0 100 4 2 2 0 000-4zM10 8h4v2h.1a4 4 0 017 0V20h-4v-6c0-1-1-2-2-2s-2 1-2 2v6h-4z" /></svg></a>
            <a href="https://www.instagram.com/growthstudio.av" target="_blank" rel="noopener" aria-label="Instagram"><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="5" stroke="currentColor" strokeWidth="1.6" /><circle cx="12" cy="12" r="4" stroke="currentColor" strokeWidth="1.6" /><circle cx="17" cy="7" r="1" fill="currentColor" /></svg></a>
          </div>
        </div>
        <div className="big-mark" style={{ fontFamily: "Poppins", fontWeight: "400", fontSize: "100px" }}>{brand.toUpperCase()}</div>
      </div>
    </footer>);

}

// ── Cursor glow effect ───────────────────────────────────────────────────
function CursorGlow() {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;if (!el) return;
    let x = window.innerWidth / 2,y = window.innerHeight / 2;
    let tx = x,ty = y;
    const onMove = (e) => {tx = e.clientX;ty = e.clientY;};
    window.addEventListener('mousemove', onMove);
    let raf;
    const tick = () => {
      x += (tx - x) * 0.12;y += (ty - y) * 0.12;
      el.style.left = x + 'px';el.style.top = y + 'px';
      raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => {window.removeEventListener('mousemove', onMove);cancelAnimationFrame(raf);};
  }, []);
  return <div ref={ref} className="cursor-glow" />;
}

// ── App ──────────────────────────────────────────────────────────────────
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "brand": "AV Growthstudio",
  "accent": "#a78bff",
  "headlineDe": "Werde sichtbar - alle Marketingmaßnahmen aus einer Hand, um deinen RR zu steigern.",
  "headlineEn": "Get seen - every marketing lever from one team, built to grow your recurring revenue.",
  "subDe": "Wir verbinden 3D-Webdesign, Tech-Sales-Recruiting, LinkedIn Personal Branding und Performance-Ads zu einem geschlossenen Wachstumssystem - entwickelt für ambitionierte B2B-Marken.",
  "subEn": "We connect 3D web design, tech-sales recruiting, LinkedIn personal branding and performance ads into one closed-loop growth system — built for ambitious B2B brands.",
  "service1Title": "3D Conversion Websites",
  "service1Body": "Kinetische Sites, die wie ein Pitch funktionieren und Besucher in Pipeline verwandeln. Durchschnittlich 2.4x höhere Conversion-Rate als statische Seiten.",
  "service2Title": "Tech Sales Recruiting",
  "service2Body": "Wir finden und gewinnen die Top 1% Sales-Talente für deine SaaS oder Tech-Marke, von Sourcing bis Onboarding in unter 60 Tagen.",
  "service3Title": "LinkedIn Personal Branding",
  "service3Body": "Founder-led Content, der Reichweite, Autorität und Inbound-Leads gleichzeitig aufbaut. Von der Strategie bis zum fertigen Post . Du bleibst sichtbar ohne selbst zu schreiben.",
  "service4Title": "Paid & Organic Ads",
  "service4Body": "Schluss mit Ads die Budget verbrennen. Wir bauen Performance-Systeme über Meta, die planbar qualifizierte Leads liefern und psychologischen have-to-buy-Trigger.",
  "stat1": "98",
  "stat2": "35",
  "stat3": "2",
  "stat4": "10",
  "showWhy": true,
  "showShowreel": false,
  "showProjects": true,
  "showCases": true,
  "showStats": true,
  "showTestimonials": true,
  "showRecognition": false,
  "showMission": true,
  "missionKicker": "Unsere Mission",
  "missionTitle": "Wachstum aus einer Hand.",
  "missionSub": "Strategie, Design und Vertrieb — in einem System. Wir bauen Marken, die nicht nur sichtbar werden, sondern dominieren.",
  "missionBtn1": "Kostenlose Conversion-Analyse",
  "missionBtn2": "Projekte",
  "showTeam": true,
  "showBlog": true
} /*EDITMODE-END*/;

function App() {
  const [tw, setTweak] = useTweaks(TWEAK_DEFAULTS);
  const [lang, setLang] = useState(() => {
    try {return localStorage.getItem('av-lang') || 'de';} catch (e) {return 'de';}
  });
  useEffect(() => {
    try {localStorage.setItem('av-lang', lang);} catch (e) {}
    document.documentElement.setAttribute('lang', lang);
  }, [lang]);
  const t = window.CONTENT[lang];

  // Apply accent color
  useEffect(() => {
    document.documentElement.style.setProperty('--accent', tw.accent);
    // Derive accent-2 (lighter) and glow
    document.documentElement.style.setProperty('--accent-glow', tw.accent + '73');
  }, [tw.accent]);

  const headline = lang === 'de' ? tw.headlineDe : tw.headlineEn;
  const sub = lang === 'de' ? tw.subDe : tw.subEn;

  const servicesItems = lang === 'de' ? {
    list: [
    { title: tw.service1Title, body: tw.service1Body },
    { title: tw.service2Title, body: tw.service2Body },
    { title: tw.service3Title, body: tw.service3Body },
    { title: tw.service4Title, body: tw.service4Body }]

  } : null;

  const statsItems = t.stats.items.map((s, i) => ({
    ...s,
    num: [tw.stat1, tw.stat2, tw.stat3, tw.stat4][i] ?? s.num
  }));

  return (
    <>
      <div className="atmos" />
      <div className="grain" />
      <CursorGlow />
      <Nav t={t} lang={lang} setLang={setLang} brand={tw.brand} />
      <main>
        <Hero t={t} headline={headline} sub={sub} brand={tw.brand} />
        <Marquee />
        <Trusted t={t} />
        <Services t={t} items={servicesItems} />
        {tw.showShowreel && <Showreel t={t} />}
        {tw.showProjects && <Projects t={t} />}
        {tw.showCases && <Cases t={t} />}
        {tw.showStats && <Stats t={t} items={statsItems} />}
        {tw.showTestimonials && <Testimonials t={t} />}
        {tw.showMission && <Mission t={t} mission={lang === 'de' ? { kicker: tw.missionKicker, title: tw.missionTitle, sub: tw.missionSub, btn1: tw.missionBtn1, btn2: tw.missionBtn2 } : { kicker: 'Our mission', title: 'Growth from one team.', sub: 'Strategy, design and sales — in one system. We build brands that don\u2019t just become visible, they dominate.', btn1: 'Free conversion analysis', btn2: 'Projects' }} />}
        {tw.showWhy && <Why t={t} />}
        {tw.showBlog && <Blog t={t} />}
        <BigCTA t={t} />
      </main>
      <Footer t={t} brand={tw.brand} />

      <TweaksPanel title="Tweaks">
        <TweakSection label="Brand" />
        <TweakText label="Brand name" value={tw.brand} onChange={(v) => setTweak('brand', v)} />
        <TweakColor label="Accent color" value={tw.accent} onChange={(v) => setTweak('accent', v)} />
        <TweakSection label="Hero · DE" />
        <TweakText label="Headline" value={tw.headlineDe} onChange={(v) => setTweak('headlineDe', v)} />
        <TweakText label="Subline" value={tw.subDe} onChange={(v) => setTweak('subDe', v)} />
        <TweakSection label="Hero · EN" />
        <TweakText label="Headline" value={tw.headlineEn} onChange={(v) => setTweak('headlineEn', v)} />
        <TweakText label="Subline" value={tw.subEn} onChange={(v) => setTweak('subEn', v)} />
        <TweakSection label="Services" />
        <TweakText label="1 · Title" value={tw.service1Title} onChange={(v) => setTweak('service1Title', v)} />
        <TweakText label="1 · Body" value={tw.service1Body} onChange={(v) => setTweak('service1Body', v)} />
        <TweakText label="2 · Title" value={tw.service2Title} onChange={(v) => setTweak('service2Title', v)} />
        <TweakText label="2 · Body" value={tw.service2Body} onChange={(v) => setTweak('service2Body', v)} />
        <TweakText label="3 · Title" value={tw.service3Title} onChange={(v) => setTweak('service3Title', v)} />
        <TweakText label="3 · Body" value={tw.service3Body} onChange={(v) => setTweak('service3Body', v)} />
        <TweakText label="4 · Title" value={tw.service4Title} onChange={(v) => setTweak('service4Title', v)} />
        <TweakText label="4 · Body" value={tw.service4Body} onChange={(v) => setTweak('service4Body', v)} />
        <TweakSection label="Stats" />
        <TweakText label="Stat 1" value={tw.stat1} onChange={(v) => setTweak('stat1', v)} />
        <TweakText label="Stat 2" value={tw.stat2} onChange={(v) => setTweak('stat2', v)} />
        <TweakText label="Stat 3" value={tw.stat3} onChange={(v) => setTweak('stat3', v)} />
        <TweakText label="Stat 4" value={tw.stat4} onChange={(v) => setTweak('stat4', v)} />
        <TweakSection label="Sections on/off" />
        <TweakToggle label="Why us" value={tw.showWhy} onChange={(v) => setTweak('showWhy', v)} />
        <TweakToggle label="Showreel" value={tw.showShowreel} onChange={(v) => setTweak('showShowreel', v)} />
        <TweakToggle label="Projects" value={tw.showProjects} onChange={(v) => setTweak('showProjects', v)} />
        <TweakToggle label="Case studies" value={tw.showCases} onChange={(v) => setTweak('showCases', v)} />
        <TweakToggle label="Stats" value={tw.showStats} onChange={(v) => setTweak('showStats', v)} />
        <TweakToggle label="Testimonials" value={tw.showTestimonials} onChange={(v) => setTweak('showTestimonials', v)} />
        <TweakToggle label="Mission" value={tw.showMission} onChange={(v) => setTweak('showMission', v)} />
        <TweakToggle label="Recognition" value={tw.showRecognition} onChange={(v) => setTweak('showRecognition', v)} />
        <TweakSection label="Mission" />
        <TweakText label="Kicker" value={tw.missionKicker} onChange={(v) => setTweak('missionKicker', v)} />
        <TweakText label="Title" value={tw.missionTitle} onChange={(v) => setTweak('missionTitle', v)} />
        <TweakText label="Subline" value={tw.missionSub} onChange={(v) => setTweak('missionSub', v)} />
        <TweakText label="Button 1" value={tw.missionBtn1} onChange={(v) => setTweak('missionBtn1', v)} />
        <TweakText label="Button 2" value={tw.missionBtn2} onChange={(v) => setTweak('missionBtn2', v)} />
        <TweakToggle label="Team" value={tw.showTeam} onChange={(v) => setTweak('showTeam', v)} />
        <TweakToggle label="Blog" value={tw.showBlog} onChange={(v) => setTweak('showBlog', v)} />
      </TweaksPanel>
    </>);

}

ReactDOM.createRoot(document.getElementById('root')).render(<App />);