const { Button: HBtn, Badge: HBadge, Card: HCard, ProgressBar: HProgress, Stat: HStat, Avatar: HAvatar, Tag: HTag } = window.BCDesignSystem_b342dd;

function fmtVnd(n) { return new Intl.NumberFormat('vi-VN').format(n); }

function HomeHero({ c, onDonate, onNavigate, onPlayVideo }) {
  return (
    <section style={{ position: 'relative', color: 'var(--text-on-dark)' }}>
      <div style={{ position: 'fixed', inset: 0, zIndex: -1 }}>
        <img src="./assets/bg-starry-night.png" alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' }} />
        <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(42,15,61,0.45) 0%, rgba(61,26,82,0.25) 50%, rgba(96,48,120,0.55) 100%)' }} />
      </div>
      <div className="grid-responsive pad-mobile" style={{ position: 'relative', maxWidth: 'var(--container-max)', margin: '0 auto', padding: '72px 28px 100px', display: 'grid', gridTemplateColumns: '1.15fr 1fr', gap: 48, alignItems: 'center' }}>
        <div>
          <div style={{ display: 'flex', gap: 8, marginBottom: 20 }}>
            <HBadge variant="onDark" dot>Đang gây quỹ</HBadge>
            <HBadge variant="onDark"><BcIcon name="mapPin" size={12} style={{ marginRight: 5, verticalAlign: '-2px' }} />Tây Nguyên</HBadge>
          </div>
          <h1 className="text-responsive-h1" style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 'var(--text-4xl)', lineHeight: 1.15, letterSpacing: 'var(--tracking-tight)', margin: '0 0 16px', color: 'var(--cream-100)' }}>
            Mỗi bước chân hôm nay, một tương lai rộng mở
          </h1>
          <p className="text-responsive-h2" style={{ fontFamily: 'var(--font-script)', fontSize: 'var(--text-2xl)', color: 'var(--cream-300)', margin: '0 0 18px', lineHeight: 1.1 }}>
            Hành trình vạn dặm bắt đầu từ một bước chân
          </p>
          <p className="text-responsive-p" style={{ fontSize: 'var(--text-md)', color: 'var(--text-on-dark-muted)', lineHeight: 1.7, maxWidth: 480, margin: '0 0 28px' }}>
            Gây quỹ trại hè kỹ năng sống cho học sinh cấp 2 vùng Tây Nguyên — nơi các em được tiếp cận tư duy phản biện, AI và những hoạt động ngoại khoá đầu đời.
          </p>
          <div className="hero-btns-mobile" style={{ display: 'flex', gap: 12 }}>
            <HBtn variant="accent" size="lg" onClick={onDonate} iconLeft={<BcIcon name="heart" size={18} />}>Quyên góp ngay</HBtn>
            <HBtn variant="secondary" size="lg" onClick={onPlayVideo} style={{ color: 'var(--cream-100)', borderColor: 'rgba(255,240,168,0.5)' }}>
              <BcIcon name="play" size={15} style={{ marginRight: 8 }} />Xem hành trình
            </HBtn>
          </div>
        </div>
        
        <div className="card-center-mobile" style={{ justifySelf: 'end', width: '100%', maxWidth: 400 }}>
          <HCard variant="default" padding="lg" style={{ boxShadow: 'var(--shadow-lg)', minHeight: 380, display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
            <div>
              <img src="./assets/logo-buoc.png" alt="Bước" style={{ height: 120, marginBottom: 16 }} />
              <div style={{ fontSize: 'var(--text-sm)', color: 'var(--text-muted)', fontWeight: 600, marginBottom: 4 }}>Trại hè Bước · Mùa 2026</div>
              <div style={{ marginBottom: 16 }}>
                <span style={{ fontSize: 'var(--text-4xl)', fontFamily: 'var(--font-display)', fontWeight: 800, color: 'var(--color-primary)', letterSpacing: 'var(--tracking-tight)' }}>{fmtVnd(c.raised)}₫</span>
                <span style={{ fontSize: 'var(--text-lg)', color: 'var(--text-muted)', fontWeight: 600, marginLeft: 4 }}>/ {fmtVnd(c.goal)}₫</span>
              </div>
              <HProgress raised={c.raised} goal={c.goal} tone="gold" size="lg" />
            </div>
            <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 32, marginBottom: 32, flex: 1, alignItems: 'center' }}>
              <HStat value={c.donors} label="Nhà hảo tâm" />
              <HStat value={c.scholarships} label="Suất học bổng" />
              <HStat value={c.daysLeft} label="Ngày còn lại" />
            </div>
            <div>
              <HBtn variant="primary" full size="lg" onClick={onDonate}>Đồng hành cùng các em</HBtn>
            </div>
          </HCard>
        </div>
      </div>
    </section>
  );
}

function Mission() {
  const items = [
    { icon: 'users', title: 'Học sinh cấp 2', text: 'Các bạn 13–18 tuổi ở vùng Tây Nguyên, nơi ít cơ hội tiếp cận hoạt động ngoại khoá.' },
    { icon: 'lightbulb', title: 'Kỹ năng cho tương lai', text: 'Tư duy phản biện, cách học hiệu quả và làm quen với AI — hành trang bước vào đời.' },
    { icon: 'handHeart', title: 'Học bổng 50–100%', text: 'Chi phí trại hè được tài trợ qua các gói học bổng, để không em nào bị bỏ lại.' },
  ];
  return (
    <section className="pad-mobile" style={{ background: 'var(--surface-page)', padding: '100px 28px' }}>
      <div style={{ maxWidth: 'var(--container-max)', margin: '0 auto' }}>
        <div style={{ textAlign: 'center', maxWidth: 640, margin: '0 auto 56px' }}>
          <div style={{ fontSize: 'var(--text-xs)', letterSpacing: 'var(--tracking-caps)', textTransform: 'uppercase', color: 'var(--text-muted)', fontWeight: 700, marginBottom: 12 }}>Vì sao có Bước</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'var(--text-3xl)', color: 'var(--purple-900)', margin: '0 0 16px', lineHeight: 1.1 }}>Giáo dục là đặc quyền?</h2>
          <p style={{ fontSize: 'var(--text-lg)', color: 'var(--text-body)', margin: 0, lineHeight: 1.5 }}>Trẻ em ở vùng xa không thiếu khả năng, các em chỉ thiếu một hệ sinh thái để phát huy tiềm năng đó.</p>
        </div>
        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 }}>
          {items.map(it => (
            <HCard key={it.title} variant="default" padding="lg" hoverable>
              <div style={{ width: 52, height: 52, borderRadius: 'var(--radius-md)', background: 'var(--purple-100)', color: 'var(--color-primary)', display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: 16 }}>
                <BcIcon name={it.icon} size={26} />
              </div>
              <h3 style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--text-lg)', color: 'var(--text-strong)', margin: '0 0 8px' }}>{it.title}</h3>
              <p style={{ fontSize: 'var(--text-sm)', color: 'var(--text-muted)', lineHeight: 1.7, margin: 0 }}>{it.text}</p>
            </HCard>
          ))}
        </div>
      </div>
    </section>
  );
}

function AnimatedCounter({ end, duration = 2000, suffix = '' }) {
  const [count, setCount] = React.useState(0);
  const ref = React.useRef();

  React.useEffect(() => {
    const observer = new IntersectionObserver(
      (entries) => {
        if (entries[0].isIntersecting) {
          let startTimestamp = null;
          const step = (timestamp) => {
            if (!startTimestamp) startTimestamp = timestamp;
            const progress = Math.min((timestamp - startTimestamp) / duration, 1);
            // Ease out quad
            const easeProgress = progress * (2 - progress);
            setCount(Math.floor(easeProgress * end));
            if (progress < 1) {
              window.requestAnimationFrame(step);
            }
          };
          window.requestAnimationFrame(step);
          observer.disconnect();
        }
      },
      { threshold: 0.5 }
    );
    if (ref.current) observer.observe(ref.current);
    return () => observer.disconnect();
  }, [end, duration]);

  return <span ref={ref}>{count}{suffix}</span>;
}

function SocialImpact() {
  return (
    <section className="pad-mobile" style={{ background: 'var(--purple-800)', color: 'var(--cream-100)', padding: '80px 28px', position: 'relative', overflow: 'hidden' }}>
      <div style={{ position: 'absolute', inset: 0, opacity: 0.1, backgroundImage: 'radial-gradient(circle at 50% -20%, var(--cream-100), transparent 70%)' }} />
      <div style={{ maxWidth: 'var(--container-max)', margin: '0 auto', position: 'relative', zIndex: 1 }}>
        <div style={{ textAlign: 'center', marginBottom: 48 }}>
          <div style={{ fontSize: 'var(--text-xs)', letterSpacing: 'var(--tracking-caps)', textTransform: 'uppercase', color: 'var(--cream-500)', fontWeight: 700, marginBottom: 12 }}>Tác động Xã hội</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'var(--text-3xl)', color: 'var(--cream-100)', margin: 0, lineHeight: 1.1 }}>Kiến tạo giá trị thực</h2>
        </div>
        
        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 48, maxWidth: 800, margin: '0 auto' }}>
          <div style={{ textAlign: 'center' }}>
            <div style={{ fontSize: 64, fontWeight: 700, fontFamily: 'var(--font-display)', color: 'var(--cream-300)', marginBottom: 8, lineHeight: 1 }}>
              <AnimatedCounter end={5} suffix="/5" />
            </div>
            <div style={{ fontSize: 'var(--text-lg)', fontWeight: 600, color: 'var(--cream-100)', marginBottom: 8 }}>Tỉnh Tây Nguyên</div>
            <p style={{ fontSize: 'var(--text-md)', color: 'rgba(255,255,255,0.8)', margin: 0 }}>Trại sinh đến từ mọi miền của Tây Nguyên - Việt Nam.</p>
          </div>
          
          <div style={{ textAlign: 'center' }}>
            <div style={{ fontSize: 64, fontWeight: 700, fontFamily: 'var(--font-display)', color: 'var(--cream-300)', marginBottom: 8, lineHeight: 1 }}>
              <AnimatedCounter end={30} suffix="+" />
            </div>
            <div style={{ fontSize: 'var(--text-lg)', fontWeight: 600, color: 'var(--cream-100)', marginBottom: 8 }}>Học sinh tham gia</div>
            <p style={{ fontSize: 'var(--text-md)', color: 'rgba(255,255,255,0.8)', margin: 0 }}>Cung cấp cơ hội trải nghiệm thực tế và rèn luyện kỹ năng.</p>
          </div>
        </div>
      </div>
    </section>
  );
}

function VideoSection() {
  return (
    <section id="video-section" style={{ background: 'var(--surface-page)', padding: '40px 28px 80px' }}>
      <div style={{ maxWidth: 'var(--container-max)', margin: '0 auto' }}>
        <div style={{ borderRadius: 24, overflow: 'hidden', boxShadow: 'var(--shadow-xl)', background: '#000', display: 'flex' }}>
          <video src="https://cdn.buoc.site/assets/Video%20recap.mp4" controls style={{ width: '100%', display: 'block' }} />
        </div>
      </div>
    </section>
  );
}

function Phases({ onNavigate }) {
  const phases = [
    { tag: 'Phase 1', icon: 'bookOpen', title: 'Tập huấn kỹ năng', dur: 'Trước trại hè', text: 'Các buổi training về tư duy phản biện, phương pháp học tập và làm quen với AI.', points: ['Tư duy phản biện', 'Cách học hiệu quả', 'Nhập môn AI'] },
    { tag: 'Phase 2', icon: 'tent', title: 'Trại hè 4 ngày 3 đêm', dur: '4 ngày · 3 đêm', text: 'Các bạn cùng học tập, thực hành và trải nghiệm trong một môi trường trại hè đúng nghĩa.', points: ['Hoạt động nhóm', 'Thực hành dự án', 'Kết nối &amp; sẻ chia'] },
  ];
  return (
    <section id="phases-section" style={{ background: 'var(--surface-card)', padding: '80px 28px' }}>
      <div style={{ maxWidth: 'var(--container-max)', margin: '0 auto' }}>
        <div style={{ textAlign: 'center', maxWidth: 640, margin: '0 auto 48px' }}>
          <div className="text-responsive-p" style={{ fontSize: 'var(--text-xs)', letterSpacing: 'var(--tracking-caps)', textTransform: 'uppercase', color: 'var(--cream-700)', fontWeight: 700, marginBottom: 12 }}>Tiến trình dự án</div>
          <h2 className="text-responsive-h1" style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'var(--text-3xl)', color: 'var(--text-strong)', margin: 0, lineHeight: 1.1 }}>Hai giai đoạn, một hành trình</h2>
        </div>
        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24 }}>
          {phases.map((p, i) => (
            <HCard key={p.tag} variant={i === 1 ? 'dark' : 'soft'} padding="lg">
              <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 18 }}>
                <div style={{ width: 48, height: 48, borderRadius: 'var(--radius-md)', background: i === 1 ? 'rgba(255,240,168,0.16)' : 'var(--purple-100)', color: i === 1 ? 'var(--cream-300)' : 'var(--color-primary)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                  <BcIcon name={p.icon} size={24} />
                </div>
                <div>
                  <HBadge variant={i === 1 ? 'onDark' : 'accent'}>{p.tag}</HBadge>
                  <div style={{ fontSize: 'var(--text-xs)', color: i === 1 ? 'var(--text-on-dark-muted)' : 'var(--text-muted)', marginTop: 4 }}>{p.dur}</div>
                </div>
              </div>
              <h3 style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--text-xl)', color: i === 1 ? 'var(--cream-100)' : 'var(--text-strong)', margin: '0 0 10px' }}>{p.title}</h3>
              <p style={{ fontSize: 'var(--text-sm)', color: i === 1 ? 'var(--text-on-dark-muted)' : 'var(--text-body)', lineHeight: 1.7, margin: '0 0 18px' }} dangerouslySetInnerHTML={{ __html: p.text }} />
              <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
                {p.points.map(pt => (
                  <div key={pt} style={{ display: 'flex', alignItems: 'center', gap: 10, fontSize: 'var(--text-sm)', color: i === 1 ? 'var(--cream-100)' : 'var(--text-strong)' }}>
                    <BcIcon name="checkCircle" size={18} color={i === 1 ? 'var(--cream-300)' : 'var(--success)'} />
                    <span dangerouslySetInnerHTML={{ __html: pt }} />
                  </div>
                ))}
              </div>
            </HCard>
          ))}
        </div>
      </div>
    </section>
  );
}

function RecapGallery() {
  return (
    <section id="recap-section" className="pad-mobile" style={{ background: 'var(--surface-card)', padding: '0 28px 80px' }}>
      <div style={{ maxWidth: 'var(--container-max)', margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 48 }}>
          <div style={{ fontSize: 'var(--text-xs)', letterSpacing: 'var(--tracking-caps)', textTransform: 'uppercase', color: 'var(--cream-700)', fontWeight: 700, marginBottom: 12 }}>Nhìn lại chặng đường</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'var(--text-3xl)', color: 'var(--purple-900)', margin: 0, lineHeight: 1.1 }}>Mùa 1 & Mùa 2</h2>
        </div>
        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24 }}>
          <HCard padding="none" style={{ overflow: 'hidden' }}>
            <img src="https://cdn.buoc.site/assets/Recap2024.jpg" alt="Recap 2024" style={{ width: '100%', height: 320, objectFit: 'cover', display: 'block' }} />
          </HCard>
          <HCard padding="none" style={{ overflow: 'hidden' }}>
            <img src="https://cdn.buoc.site/assets/Recap2025.jpg" alt="Recap 2025" style={{ width: '100%', height: 320, objectFit: 'cover', display: 'block' }} />
            <div style={{ padding: 20, textAlign: 'center', fontWeight: 700, color: 'var(--text-strong)', fontSize: 'var(--text-lg)' }}>Mùa 2 - 2025</div>
          </HCard>
        </div>
      </div>
    </section>
  );
}

function ActivityGallery() {
  return (
    <section className="pad-mobile" style={{ background: 'var(--cream-100)', padding: '80px 28px' }}>
      <div style={{ maxWidth: 'var(--container-max)', margin: '0 auto' }}>
        <div style={{ marginBottom: 64 }}>
          <div style={{ fontSize: 'var(--text-xs)', letterSpacing: 'var(--tracking-caps)', textTransform: 'uppercase', color: 'var(--cream-700)', fontWeight: 700, marginBottom: 12 }}>Trải nghiệm Trại sinh</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'var(--text-3xl)', color: 'var(--text-strong)', margin: 0, lineHeight: 1.1 }}>Học tập, thực hành và sẻ chia</h2>
        </div>
        
        <div style={{ display: 'flex', flexDirection: 'column', gap: 80 }}>
          {/* Row 1 */}
          <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24 }}>
            <img src="https://cdn.buoc.site/assets/NGUYENHIENLE.jpg" alt="Sự phát triển" style={{ width: '100%', borderRadius: 16, boxShadow: 'var(--shadow-sm)', objectFit: 'cover' }} />
            <img src="https://cdn.buoc.site/assets/Thason.jpg" alt="Sự phát triển" style={{ width: '100%', borderRadius: 16, boxShadow: 'var(--shadow-sm)', objectFit: 'cover' }} />
          </div>

          {/* Row 2 */}
          <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: 48, alignItems: 'center' }}>
            <div>
              <h3 style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--text-2xl)', color: 'var(--text-strong)', marginBottom: 16 }}>Giáo dục Thực tế Trực quan</h3>
              <p style={{ fontSize: 'var(--text-md)', color: 'var(--text-body)', lineHeight: 1.7 }}>
                Trại sinh được trực tiếp tham gia các hoạt động giáo dục thực tế trực quan, khơi dậy niềm đam mê khoa học và tìm tòi khám phá thông qua những thí nghiệm sinh động, giúp các em tự do sáng tạo và hiểu rõ hơn về thế giới xung quanh.
              </p>
            </div>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
              <img src="https://cdn.buoc.site/assets/Thinghiem1.jpg" alt="Thí nghiệm" style={{ width: '100%', aspectRatio: '1', borderRadius: 16, objectFit: 'cover', boxShadow: 'var(--shadow-sm)' }} />
              <img src="https://cdn.buoc.site/assets/Thinghiem2.jpg" alt="Thí nghiệm" style={{ width: '100%', aspectRatio: '1', borderRadius: 16, objectFit: 'cover', boxShadow: 'var(--shadow-sm)' }} />
            </div>
          </div>

          {/* Row 3 */}
          <div className="grid-responsive grid-responsive-reverse" style={{ display: 'grid', gridTemplateColumns: '1fr 1.2fr', gap: 48, alignItems: 'center' }}>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
              <img src="https://cdn.buoc.site/assets/hoatdong.jpg" alt="Hoạt động" style={{ width: '100%', aspectRatio: '1', borderRadius: 16, objectFit: 'cover', boxShadow: 'var(--shadow-sm)' }} />
              <img src="https://cdn.buoc.site/assets/hoatdong3.jpg" alt="Hoạt động" style={{ width: '100%', aspectRatio: '1', borderRadius: 16, objectFit: 'cover', boxShadow: 'var(--shadow-sm)' }} />
            </div>
            <div>
              <h3 style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--text-2xl)', color: 'var(--text-strong)', marginBottom: 16 }}>Rèn luyện Kĩ năng Mềm</h3>
              <p style={{ fontSize: 'var(--text-md)', color: 'var(--text-body)', lineHeight: 1.7 }}>
                Học sinh được trải nghiệm các hoạt động thảo luận nhóm và trò chơi tập thể, từ đó rèn luyện tư duy phản biện, kĩ năng làm việc nhóm, giao tiếp và xử lý tình huống — những hành trang vô giá cho sự phát triển trong tương lai.
              </p>
            </div>
          </div>
        </div>
        
      </div>
    </section>
  );
}

function FundUse({ c, onDonate }) {
  const rows = [
    { label: 'Hoạt động & dụng cụ học tập', pct: 45, color: 'var(--purple-600)' },
    { label: 'Ăn uống cho trại sinh', pct: 35, color: 'var(--purple-400)' },
    { label: 'Hậu cần & di chuyển', pct: 20, color: 'var(--cream-500)' },
  ];
  return (
    <section className="pad-mobile" style={{ background: 'var(--surface-page)', padding: '80px 28px' }}>
      <div className="grid-responsive" style={{ maxWidth: 'var(--container-max)', margin: '0 auto', display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 48, alignItems: 'center' }}>
        <div>
          <div className="text-responsive-p" style={{ fontSize: 'var(--text-xs)', letterSpacing: 'var(--tracking-caps)', textTransform: 'uppercase', color: 'var(--cream-700)', fontWeight: 700, marginBottom: 12 }}>Quỹ kêu gọi</div>
          <h2 className="text-responsive-h1" style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'var(--text-3xl)', color: 'var(--text-strong)', margin: '0 0 14px', lineHeight: 1.1 }}>
            10.000.000₫ được dùng minh bạch
          </h2>
          <p className="text-responsive-p" style={{ fontSize: 'var(--text-md)', color: 'var(--text-body)', lineHeight: 1.7, margin: '0 0 28px' }}>
            Toàn bộ số tiền kêu gọi đi thẳng đến trải nghiệm của các em — từ dụng cụ học tập, bữa ăn đến hậu cần trại hè.
          </p>
          <div style={{ display: 'flex', gap: 40, alignItems: 'center' }}>
            <div style={{ 
              width: 150, height: 150, borderRadius: '50%', flexShrink: 0,
              background: `conic-gradient(${(() => {
                let cumulative = 0;
                return rows.map(r => {
                  const start = cumulative;
                  cumulative += r.pct;
                  return `${r.color} ${start}% ${cumulative}%`;
                }).join(', ');
              })()})`,
              boxShadow: 'var(--shadow-md)'
            }} />
            <div style={{ display: 'flex', flexDirection: 'column', gap: 16, flex: 1 }}>
              {rows.map(r => (
                <div key={r.label} style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
                  <div style={{ width: 14, height: 14, borderRadius: 4, background: r.color, flexShrink: 0 }} />
                  <div style={{ flex: 1, fontSize: 'var(--text-sm)', color: 'var(--text-strong)', fontWeight: 600 }} dangerouslySetInnerHTML={{ __html: r.label }} />
                  <div style={{ fontSize: 'var(--text-sm)', color: 'var(--text-muted)', fontWeight: 700 }}>{r.pct}%</div>
                </div>
              ))}
            </div>
          </div>
        </div>
        <HCard variant="accent" padding="lg" style={{ textAlign: 'center' }}>
          <div style={{ width: 64, height: 64, borderRadius: '50%', background: 'var(--gradient-gold)', display: 'flex', alignItems: 'center', justifyContent: 'center', margin: '0 auto 18px', color: 'var(--purple-800)' }}>
            <BcIcon name="gift" size={30} />
          </div>
          <div style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--text-2xl)', fontWeight: 700, color: 'var(--text-strong)' }}>200.000₫</div>
          <p style={{ fontSize: 'var(--text-sm)', color: 'var(--text-body)', margin: '8px 0 20px', lineHeight: 1.6 }}>
            đủ để một em có suất ăn &amp; dụng cụ trong suốt 4 ngày trại hè.
          </p>
          <HBtn variant="primary" full onClick={onDonate}>Tặng một suất</HBtn>
        </HCard>
      </div>
    </section>
  );
}

function DonorStrip({ c, onNavigate }) {
  return (
    <section style={{ background: 'var(--surface-card)', padding: '72px 28px' }}>
      <div style={{ maxWidth: 'var(--container-max)', margin: '0 auto', textAlign: 'center' }}>
        <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'var(--text-2xl)', color: 'var(--text-strong)', margin: '0 0 8px' }}>
          {c.donors} tấm lòng đã cùng Bước
        </h2>
        <p style={{ fontSize: 'var(--text-md)', color: 'var(--text-muted)', margin: '0 0 28px' }}>Mỗi cái tên là một lời chúc gửi đến các em.</p>
        <div style={{ display: 'flex', justifyContent: 'center', marginBottom: 24 }}>
          {c.recentDonors.slice(0, 7).map((d, i) => (
            <div key={i} style={{ marginLeft: i ? -12 : 0 }}><HAvatar name={d.name} size="lg" ring style={{ boxShadow: '0 0 0 3px var(--surface-card)' }} /></div>
          ))}
          <div style={{ marginLeft: -12, width: 60, height: 60, borderRadius: '50%', background: 'var(--purple-700)', color: 'var(--cream-100)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 'var(--text-sm)', boxShadow: '0 0 0 3px var(--surface-card)' }}>+{c.donors - 7}</div>
        </div>
        <HBtn variant="secondary" onClick={() => onNavigate('donors')} iconRight={<BcIcon name="arrowRight" size={16} />}>Xem bảng vinh danh</HBtn>
      </div>
    </section>
  );
}

function FinalCta({ onDonate }) {
  return (
    <section style={{ position: 'relative', overflow: 'hidden', background: 'var(--gradient-night)', padding: '88px 28px', textAlign: 'center' }}>
      <img src="./assets/bg-starry-night.png" alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', opacity: 0.5, mixBlendMode: 'screen' }} />
      <div style={{ position: 'relative', maxWidth: 640, margin: '0 auto' }}>
        <BcIcon name="sparkles" size={32} color="var(--cream-300)" style={{ marginBottom: 16 }} />
        <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 'var(--text-3xl)', color: 'var(--cream-100)', margin: '0 0 14px', lineHeight: 1.1 }}>
          Một bước của bạn, vạn dặm của các em
        </h2>
        <p style={{ fontSize: 'var(--text-md)', color: 'var(--text-on-dark-muted)', lineHeight: 1.7, margin: '0 0 28px' }}>
          Cùng Bước trao cho học sinh Tây Nguyên một mùa hè được học, được chơi, và được mơ ước.
        </p>
        <HBtn variant="accent" size="lg" onClick={onDonate} iconLeft={<BcIcon name="heart" size={18} />}>Quyên góp ngay</HBtn>
      </div>
    </section>
  );
}

function HomeScreen({ onDonate, onNavigate }) {
  const c = window.CAMPAIGN;
  return (
    <div>
      <HomeHero c={c} onDonate={onDonate} onNavigate={onNavigate} onPlayVideo={() => {
        const el = document.getElementById('video-section');
        if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' });
      }} />
      <Mission />
      <SocialImpact />
      <Phases onNavigate={onNavigate} />
      <RecapGallery />
      <VideoSection />
      <ActivityGallery />
      <FundUse c={c} onDonate={onDonate} />
      <DonorStrip c={c} onNavigate={onNavigate} />
      <FinalCta onDonate={onDonate} />
      <Footer onDonate={onDonate} />
    </div>
  );
}
window.HomeScreen = HomeScreen;
