// sections.jsx — 키토메이트 랜딩 섹션들

const { useState, useEffect, useRef } = React;
const APP_STORE_URL = 'https://apps.apple.com/kr/app/ketomate-ai-%ED%82%A4%ED%86%A0-%EC%8B%9D%EB%8B%A8-%EC%BD%94%EC%B9%98/id6765549888?l=en-GB';

function PlatformActions({ onOpenLaunchAlert, source, dark = false }) {
  return (
    <div className="platform-actions" style={{ display: 'flex', gap: 10, alignItems: 'center', flexWrap: 'wrap' }}>
      <a
        href={APP_STORE_URL}
        target="_blank"
        rel="noopener noreferrer"
        className="btn btn-primary btn-lg"
      >
        <Icon name="download" size={17} strokeWidth={2.25} />
        iOS 앱 다운로드
      </a>
      <button
        type="button"
        className="btn btn-lg"
        onClick={() => onOpenLaunchAlert && onOpenLaunchAlert({ source, platform: 'android' })}
        style={{
          background: dark ? 'transparent' : 'var(--bg-card)',
          color: dark ? 'var(--on-dark)' : 'var(--ink)',
          border: dark ? '1.5px solid rgba(255,255,255,0.38)' : '1.5px solid var(--line)',
        }}
      >
        <Icon name="bell" size={17} strokeWidth={2.25} />
        Android 출시 알림
      </button>
    </div>
  );
}

// ─── Site Header (sticky) ─────────────────────────────────────
function SiteHeader({ onOpenLaunchAlert }) {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 8);
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  return (
    <header className={'site-header' + (scrolled ? ' is-scrolled' : '')}>
      <div className="site-header-inner">
        <a href="#" aria-label="Ketomate 홈" style={{ display: 'flex', alignItems: 'center' }}>
          <img className="header-logo" src="assets/logo.svg" alt="Ketomate" style={{ width: 124, height: 36, display: 'block' }} />
        </a>
        <nav className="hide-mobile" aria-label="Primary" style={{ display: 'flex', gap: 28, fontSize: 14, color: 'var(--ink-soft)' }}>
          <a href="#features">기능</a>
          <a href="#founder">이야기</a>
          <a href="#testimonials">후기</a>
          <a href="#pricing">요금</a>
          <a href="#faq">FAQ</a>
        </nav>
        <div className="site-header-cta" style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
          <a
            href={APP_STORE_URL}
            target="_blank"
            rel="noopener noreferrer"
            style={{ padding: '9px 14px', background: 'var(--ink)', color: 'var(--on-dark)', borderRadius: 999, fontSize: 13, fontWeight: 600, minHeight: 40, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6 }}
          >
            <Icon name="download" size={14} strokeWidth={2.25} />
            iOS
          </a>
          <button
            type="button"
            onClick={() => onOpenLaunchAlert && onOpenLaunchAlert({ source: 'header-android-alert', platform: 'android' })}
            style={{ padding: '9px 14px', background: 'transparent', color: 'var(--ink)', border: '1.5px solid var(--line)', borderRadius: 999, fontSize: 13, fontWeight: 600, minHeight: 40, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6 }}
          >
            <Icon name="bell" size={14} strokeWidth={2.25} />
            Android
          </button>
        </div>
      </div>
    </header>
  );
}

// ─── Hero ──────────────────────────────────────────────────────
const HERO_COPY = [
  {
    id: 'empathy',
    label: '공감형 — 실패자에게',
    eyebrow: '또 실패해도 괜찮아요',
    title: <>혼자 버티다<br />포기한 당신에게,<br /><span style={{ fontWeight: 400 }}>기록 도우미.</span></>,
    sub: '사진 한 장이면 탄수 · 지방 · 단백 기록을 보기 쉽게 정리하고, 다음 식사를 고를 때 참고할 수 있게 도와드려요.',
    cta: '앱 다운로드',
    sub_cta: '유료 구독 · 모든 기능 포함'
  },
  {
    id: 'sharp',
    label: '날카로운',
    eyebrow: '칼로리 앱은 이제 그만',
    title: <><span className="strike" style={{ color: "var(--ink-mute)" }}>칼로리 1,500kcal</span><br />우리가 재는 건<br /><span style={{ fontWeight: 500, color: 'var(--ink)' }}>탄수 20g</span>입니다.</>,
    sub: '키토가 실패하는 건 의지가 약해서가 아니라, 숨어있는 탄수 3g이 모여 20g을 넘기기 때문이에요.',
    cta: '내 탄수 한도 계산하기',
    sub_cta: '1분이면 돼요'
  },
  {
    id: 'warm',
    label: '따뜻한',
    eyebrow: '키토, 혼자 하지 마세요',
    title: <>당신의 식판 옆,<br /><span style={{ fontWeight: 400 }}>말없이 앉아있는</span><br />기록 도우미.</>,
    sub: '먹기 전에 메모하고, 먹은 뒤에 정리하세요. 하루 식단 흐름을 한눈에 볼 수 있게 도와드립니다.',
    cta: '도우미와 인사하기',
    sub_cta: '사전등록 혜택 제공'
  },
  {
    id: 'direct',
    label: '직설적',
    eyebrow: '키토 식단 기록 AI',
    title: <>사진 한 장이면<br />탄수 기록이<br /><span style={{ fontWeight: 400 }}>간단해집니다.</span></>,
    sub: '한국식 식단과 반찬까지 함께 메모해 탄수 · 지방 · 단백 섭취 흐름을 보기 쉽게 정리해요.',
    cta: '앱 다운로드',
    sub_cta: '유료 구독 후 이용'
  }
];


function Hero({ copyId, onOpenLaunchAlert }) {
  const c = HERO_COPY.find((x) => x.id === copyId) || HERO_COPY[0];
  return (
    <section className="hero-pad-y" style={{ padding: '56px 32px 60px', position: 'relative' }}>
      <div className="grid-responsive" style={{ maxWidth: 1280, margin: '0 auto', display: 'grid', gridTemplateColumns: '1.3fr 1fr', gap: 48, alignItems: 'center' }}>
        <div className="hero-copy">
          <h1 className="typography-h1 serif" style={{ color: 'var(--ink-tone)' }}>
            {c.title}
          </h1>

          <p className="typography-lead" style={{ margin: '28px 0 0', maxWidth: 500 }}>
            {c.sub}
          </p>

          <div className="hero-actions" style={{ marginTop: 28 }}>
            <PlatformActions onOpenLaunchAlert={onOpenLaunchAlert} source={`hero-${c.id}-android-alert`} />
            <a href="#problem" style={{ display: 'inline-flex', marginTop: 14, fontSize: 13, fontWeight: 600, color: 'var(--ink-mute)' }}>
              먼저 더 알아보기
            </a>
          </div>
          {/* Social proof strip */}
          <div className="hero-social" style={{ marginTop: 44, display: 'flex', gap: 28, alignItems: 'center' }}>
            <div style={{ display: 'flex' }}>
              {['leafy-green', 'egg', 'ham', 'droplets', 'beef'].map((iconName, i) =>
              <div key={iconName} style={{
                width: 38, height: 38, borderRadius: '50%',
                background: 'var(--bg-card)',
                color: 'var(--ink)',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                marginLeft: i === 0 ? 0 : -10,
                border: '2px solid var(--bg)'
              }}>
                <Icon name={iconName} size={18} strokeWidth={1.75} />
              </div>
              )}
            </div>
            <div>
              <div style={{ fontWeight: 700, fontSize: 14 }}>식단 기록을 더 쉽게</div>
              <div style={{ fontSize: 12, color: 'var(--ink-mute)', marginTop: 2 }}>사진 기록 · 탄수 체크 · 식단 메모를 한곳에서</div>
            </div>
          </div>
        </div>

        <div className="phone-wrap" style={{ display: 'flex', justifyContent: 'center', position: 'relative' }}>
          <div style={{ position: 'relative' }}>
            <PhoneFrame width={300} height={620}>
              <PhoneScreenHome />
            </PhoneFrame>
            <div style={{
              position: 'absolute', bottom: -10, left: -36,
              background: 'var(--bg-card)', color: 'var(--ink)',
              border: '1px solid var(--line)',
              borderRadius: 16, padding: '12px 16px',
              fontSize: 12, fontWeight: 600, lineHeight: 1.35, maxWidth: 220,
              boxShadow: '0 14px 30px rgba(10,10,10,0.12)',
              transform: 'rotate(-4deg)'
            }}>
              <div style={{ fontSize: 10, color: 'var(--ink-mute)', marginBottom: 4, letterSpacing: '0.08em', textTransform: 'uppercase' }}>AI 기록 도우미</div>
              오늘 식단 메모를 바탕으로 저녁 선택지를 정리해볼게요.
            </div>
            <div style={{
              position: 'absolute', top: 40, right: -44,
              background: 'var(--ink)', color: 'var(--on-dark)',
              borderRadius: 14, padding: '10px 14px',
              fontSize: 11, fontWeight: 600,
              boxShadow: '0 10px 24px rgba(10,10,10,0.2)',
              transform: 'rotate(3deg)'
            }}>
              <div style={{ fontSize: 9, opacity: 0.6, letterSpacing: '0.1em' }}>MEAL LOG</div>
              <div style={{ fontSize: 16, fontWeight: 700, marginTop: 2 }}>3일차 · 기록 중</div>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

// ─── Problem ──────────────────────────────────────────────────
function ProblemSection() {
  const items = [
  { q: '오늘도 20g 넘긴 것 같은데…', a: '매번 검색하다 지쳐서 그냥 먹어버리고, 하루를 망쳐버린 느낌.', icon: 'search' },
  { q: '이거 키토 되는 거 맞아?', a: '숨어있는 당류 · 전분까지 찾아내려면 성분표를 뒤집어 읽어야 했죠.', icon: 'tag' },
  { q: '혼자 하니까 금방 흐트러져요', a: '식단을 이어가려면 매일 무엇을 먹었는지 쉽게 돌아볼 수 있어야 하죠.', icon: 'users-round' },
  { q: '기록 앱은 너무 복잡해요', a: '숫자와 메뉴를 매번 직접 입력하다 보면 식단 관리 자체가 부담이 됩니다.', icon: 'banknote' }];

  return (
    <section id="problem" className="section-pad-y" style={{ padding: '140px 32px 80px' }}>
      <div style={{ maxWidth: 1280, margin: '0 auto' }}>
        <div className="section-tag">왜 식단 기록이 어려울까</div>
        <h2 className="typography-h2 serif" style={{ margin: '16px 0 10px', maxWidth: 900, color: 'var(--ink-tone)' }}>
          문제는 당신이 아니라,<br />
          <span style={{ color: 'var(--ink)' }}>기록이 너무 번거롭다</span>는 것.
        </h2>
        <p className="typography-lead" style={{ maxWidth: 560, marginBottom: 56 }}>
          키토 식단을 시작하면 매번 검색하고, 계산하고, 다시 적어야 합니다.
          키토메이트는 그 번거로운 기록 과정을 간단하게 줄이는 데 집중합니다.
        </p>

        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14, marginBottom: 16 }}>
          {items.map((it, i) =>
          <div key={i} style={{
            background: 'var(--bg-card)', borderRadius: 24, padding: '28px 24px 26px',
            display: 'flex', flexDirection: 'column', gap: 14, minHeight: 240
          }}>
              <div aria-hidden="true" style={{ width: 44, height: 44, borderRadius: 12, background: 'var(--lime-wash)', color: 'var(--ink)', border: '1px solid var(--line)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                <Icon name={it.icon} size={22} strokeWidth={1.75} />
              </div>
              <div className="typography-h4 serif" style={{ color: 'var(--ink)' }}>
                "{it.q}"
              </div>
              <div className="typography-small" style={{ color: 'var(--ink-soft)', marginTop: 'auto' }}>{it.a}</div>
            </div>
          )}
        </div>

        {/* Contrast banner */}
        <div className="panel-pad" style={{ padding: '40px 48px', background: 'var(--bg-deep)', color: 'var(--on-dark)', borderRadius: 28, display: 'flex', alignItems: 'center', gap: 32, flexWrap: 'wrap' }}>
          <div className="serif" style={{ fontSize: 'clamp(26px, 3.2vw, 38px)', fontWeight: 500, letterSpacing: '-0.02em', lineHeight: 1.15, flex: 1, minWidth: 280 }}>
            기록이 쉬워지면,<br />식단 관리도 <span style={{ color: 'var(--salmon-soft)' }}>가벼워집니다.</span>
          </div>
          <div style={{ display: 'flex', gap: 36, alignItems: 'baseline', flexWrap: 'wrap' }}>
            <div>
              <div className="serif" style={{ fontSize: 38, fontWeight: 600, color: 'var(--salmon-soft)', letterSpacing: '-0.04em', lineHeight: 1 }}>사진 기록</div>
              <div style={{ fontSize: 12, color: 'var(--on-dark-soft)', marginTop: 6 }}>한 끼를 빠르게 남기기</div>
            </div>
            <div>
              <div className="serif" style={{ fontSize: 38, fontWeight: 600, color: 'var(--salmon-soft)', letterSpacing: '-0.04em', lineHeight: 1 }}>탄수 체크</div>
              <div style={{ fontSize: 12, color: 'var(--on-dark-soft)', marginTop: 6 }}>나의 식단 흐름을 보기 쉽게</div>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

// ─── Features ────────────────────────────────────────────────
function FeaturesSection() {
  const [active, setActive] = useState(0);
  const features = [
  { id: 0, tag: '사진 기록', title: '사진 한 장이면 시작돼요', desc: '식판을 찍고 메모하면 탄수 · 지방 · 단백 정보를 보기 쉽게 정리해요.' },
  { id: 1, tag: 'AI 기록 도우미', title: '먹기 전에 메모하세요', desc: '"라면을 먹으려 해" 같은 메모를 남기면 참고할 탄수 정보를 함께 정리해요.' },
  { id: 2, tag: '식단 흐름', title: '오늘 식단을 한눈에 봐요', desc: '하루 동안 기록한 식사를 바탕으로 탄수 · 지방 · 단백 섭취 흐름을 정리합니다.' },
  { id: 3, tag: '탄수 체크', title: '놓치기 쉬운 탄수를 챙겨요', desc: '먹기 전후에 기록하면 오늘 식단에서 참고할 탄수 정보를 함께 보여줍니다.' }];

  const screens = [PhoneScreenHome, PhoneScreenChat, PhoneScreenLog, PhoneScreenHome];
  const Active = screens[active];

  return (
    <section id="features" className="section-pad-y" style={{ padding: '100px 32px', background: 'var(--bg-soft)' }}>
      <div style={{ maxWidth: 1280, margin: '0 auto' }}>
        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: '1fr 340px', gap: 64, alignItems: 'center' }}>
          <div>
            <div className="section-tag">어떻게 작동하나요</div>
            <h2 className="typography-h2 serif" style={{ margin: '16px 0 10px', color: 'var(--ink-tone)' }}>
              칼로리 말고, <span style={{ color: 'var(--ink)' }}>탄수</span>를.<br />
              한국식 식단에 맞춘 AI 기록 도우미.
            </h2>
            <p className="typography-lead" style={{ maxWidth: 560, marginBottom: 32 }}>
              먹기 전에 메모하고, 먹은 뒤에 정리하고, 하루 식단 흐름을 돌아보는 키토 식단 기록 도구.
            </p>

            <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
              {features.map((f) =>
            <button key={f.id} type="button" onClick={() => setActive(f.id)} aria-pressed={active === f.id}
            style={{
              textAlign: 'left', padding: '22px 26px',
              background: active === f.id ? 'var(--ink)' : 'var(--bg-card)',
              color: active === f.id ? 'var(--on-dark)' : 'var(--ink)',
              borderRadius: 20,
              border: active === f.id ? '1px solid var(--ink)' : '1px solid var(--line)',
              boxShadow: active === f.id ? 'none' : '0 1px 2px rgba(9,9,11,0.04)',
              transition: 'background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out, box-shadow 0.2s ease-out',
              display: 'flex', alignItems: 'center', gap: 20,
              minHeight: 44
            }}>
                <div className="mono" style={{ fontSize: 11, letterSpacing: '0.1em', opacity: active === f.id ? 0.6 : 0.5, width: 28 }}>0{f.id + 1}</div>
                <div style={{ flex: 1 }}>
                  <div className="serif" style={{ fontSize: 19, fontWeight: 500, letterSpacing: '-0.02em', lineHeight: 1.25 }}>{f.title}</div>
                  <div style={{ fontSize: 13, marginTop: 6, opacity: active === f.id ? 0.78 : 0.62, lineHeight: 1.5 }}>{f.desc}</div>
                </div>
                {active === f.id && <div aria-hidden="true" style={{ width: 28, height: 28, borderRadius: '50%', background: 'var(--lime)', color: 'var(--ink)', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}><Icon name="arrow-right" size={14} strokeWidth={2.25} /></div>}
                </button>
              )}
            </div>
          </div>
          <div className="phone-wrap" style={{ display: 'flex', justifyContent: 'center' }}>
            <PhoneFrame width={300} height={620}>
              <Active />
            </PhoneFrame>
          </div>
        </div>
      </div>
    </section>);

}

// ─── Testimonials ─────────────────────────────────────────────
function TestimonialsSection() {
  const t = [
  { name: '김○영', age: 34, meta: '외식 기록이 어려웠던 사용자', result: '식단 메모가 쉬워졌어요',
    quote: '혼자 할 땐 반찬 하나까지 기록하는 게 너무 번거로웠는데, 사진으로 남기고 나중에 정리할 수 있어서 부담이 줄었어요.', avatar: 'assets/testimonial-profile-1-closeup.png' },
  { name: '박○훈', age: 41, meta: '야식 고민이 잦았던 사용자', result: '선택지가 잘 보여요',
    quote: '밤에 뭘 먹을지 고민될 때 지난 기록을 보고 고르니까 훨씬 차분해졌어요. 숫자보다 흐름이 보이는 게 좋았습니다.', avatar: 'assets/testimonial-profile-3-closeup.png' },
  { name: '이○정', age: 29, meta: '기록 앱을 오래 못 썼던 사용자', result: '루틴으로 만들기 쉬워요',
    quote: '복잡한 표를 채우는 느낌이 아니라, 하루 식단을 가볍게 정리하는 느낌이라 계속 열어보게 돼요.', avatar: 'assets/testimonial-profile-2-closeup.png' }];

  return (
    <section id="testimonials" className="section-pad-y" style={{ padding: '100px 32px' }}>
      <div style={{ maxWidth: 1280, margin: '0 auto' }}>
        <div className="section-tag">이미 시작한 사람들</div>
        <h2 className="typography-h2 serif" style={{ margin: '16px 0 56px', color: 'var(--ink-tone)', maxWidth: 900 }}>
          실패를 반복하던 사람들이,<br />
          <span style={{ color: 'var(--ink)' }}>끝까지 갈 수 있었던 이유.</span>
        </h2>

        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16 }}>
          {t.map((it, i) =>
          <div key={i} style={{
            background: 'var(--bg-card)', borderRadius: 24, padding: '32px 32px 26px',
            display: 'flex', flexDirection: 'column', minHeight: 380
          }}>
              <div style={{
              width: 72, height: 72, borderRadius: '50%',
              overflow: 'hidden', flexShrink: 0,
              border: '1px solid var(--line)', background: 'var(--bg-soft)',
              boxShadow: 'var(--shadow-soft)'
            }}>
                <img src={it.avatar} alt="" loading="lazy" style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} />
              </div>
              <div className="serif" style={{ fontSize: 17, fontWeight: 500, lineHeight: 1.5, letterSpacing: '-0.01em', color: 'var(--ink)', marginTop: 20, flex: 1 }}>
                "{it.quote}"
              </div>
              <div style={{ marginTop: 24, paddingTop: 20, borderTop: '1px solid var(--line)' }}>
                <div style={{ display: 'inline-flex', padding: '4px 10px', borderRadius: 999, background: 'var(--lime)', color: 'var(--ink)', fontSize: 11, fontWeight: 700, marginBottom: 10 }}>
                  {it.result}
                </div>
                <div style={{ fontSize: 13, fontWeight: 600 }}>{it.name} · {it.age}</div>
                <div style={{ fontSize: 11, color: 'var(--ink-mute)', marginTop: 2 }}>{it.meta}</div>
              </div>
            </div>
          )}
        </div>
      </div>
    </section>);

}

// ─── Pricing ──────────────────────────────────────────────────
function PricingSection({ onOpenLaunchAlert }) {
  return (
    <section id="pricing" className="section-pad-y" style={{ padding: '100px 32px' }}>
      <div style={{ maxWidth: 1280, margin: '0 auto' }}>
        <div className="section-tag">단일 유료 이용권</div>
        <h2 className="typography-h2 serif" style={{ margin: '16px 0 56px', color: 'var(--ink-tone)', maxWidth: 900 }}>
          무료 플랜과 상위 플랜 구분 없이,<br />
          <span style={{ color: 'var(--ink)' }}>결제하면 모든 기능을 바로 씁니다.</span>
        </h2>

        <div className="grid-responsive" style={{ display: 'grid', gridTemplateColumns: '1fr 1.3fr 1fr', gap: 16, alignItems: 'stretch' }}>
          <div style={{ background: 'var(--bg-card)', borderRadius: 24, padding: 32, display: 'flex', flexDirection: 'column' }}>
            <div className="mono" style={{ fontSize: 11, color: 'var(--ink-mute)', fontWeight: 600, letterSpacing: '0.12em', textTransform: 'uppercase' }}>무료 플랜 없음</div>
            <div className="serif" style={{ fontSize: 20, fontWeight: 500, marginTop: 10, letterSpacing: '-0.02em' }}>처음부터 전체 기능</div>
            <div style={{ fontSize: 15, color: 'var(--ink-soft)', marginTop: 22, lineHeight: 1.75 }}>
              · 기능 제한 없는 단일 이용권<br />
              · 광고 없는 유료 앱 구조<br />
              · 사진 기록, AI 기록 도우미, 리포트 모두 포함
            </div>
          </div>

          <div className="panel-pad" style={{ background: 'var(--bg-deep)', color: 'var(--on-dark)', borderRadius: 24, padding: 40, position: 'relative' }}>
            <div style={{ position: 'absolute', top: 24, right: 24, background: 'var(--lime)', color: 'var(--ink)', fontSize: 11, fontWeight: 700, padding: '5px 12px', borderRadius: 999, letterSpacing: '0.04em' }}>단일 플랜</div>
            <div className="mono" style={{ fontSize: 11, color: 'var(--salmon-soft)', fontWeight: 600, letterSpacing: '0.12em', textTransform: 'uppercase' }}>월간 이용권</div>
            <div className="serif" style={{ fontSize: 22, fontWeight: 500, marginTop: 10, letterSpacing: '-0.02em' }}>키토메이트 이용권</div>
            <div style={{ marginTop: 24, display: 'flex', alignItems: 'baseline', gap: 10 }}>
              <div className="serif" style={{ fontSize: 52, fontWeight: 500, letterSpacing: '-0.04em', lineHeight: 1, fontVariantNumeric: 'tabular-nums' }}>₩14,900</div>
              <div style={{ fontSize: 14, color: 'var(--on-dark-mute)' }}>/ 월</div>
            </div>
            <div style={{ fontSize: 14, color: 'var(--on-dark-soft)', marginTop: 16, lineHeight: 1.7 }}>
              · 무제한 사진 기록 · AI 기록 도우미<br />
              · 식단 흐름 정리 · 탄수 체크<br />
              · 외식 · 편의점 스캔 · 주간 리포트
            </div>
            <a
              href={APP_STORE_URL}
              target="_blank"
              rel="noopener noreferrer"
              style={{ marginTop: 32, padding: '16px 24px', background: 'var(--lime)', color: 'var(--ink)', borderRadius: 999, fontSize: 15, fontWeight: 700, width: '100%', minHeight: 44, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6, boxShadow: '0 10px 24px -8px rgba(158,240,26,0.55)' }}
            >
              앱 다운로드 <Icon name="arrow-right" size={16} strokeWidth={2.25} />
            </a>
            <div style={{ fontSize: 11, color: 'var(--on-dark-mute)', marginTop: 12, textAlign: 'center' }}>iOS App Store에서 바로 시작</div>
          </div>

          <div style={{ background: 'var(--bg-card)', borderRadius: 24, padding: 32, display: 'flex', flexDirection: 'column' }}>
            <div className="mono" style={{ fontSize: 11, color: 'var(--ink-mute)', fontWeight: 600, letterSpacing: '0.12em', textTransform: 'uppercase' }}>지원 플랫폼</div>
            <div className="serif" style={{ fontSize: 20, fontWeight: 500, marginTop: 10, letterSpacing: '-0.02em' }}>iOS는 바로, Android는 알림으로</div>
            <div style={{ marginTop: 22, display: 'grid', gap: 12 }}>
              <div style={{ padding: '14px 0', borderBottom: '1px solid var(--line)', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 14 }}>
                <div>
                  <div style={{ fontSize: 14, fontWeight: 700, color: 'var(--ink)' }}>iPhone</div>
                  <div style={{ fontSize: 12, color: 'var(--ink-mute)', marginTop: 3 }}>지금 다운로드 가능</div>
                </div>
                <Icon name="check-circle-2" size={22} strokeWidth={2.1} />
              </div>
              <div style={{ padding: '14px 0', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 14 }}>
                <div>
                  <div style={{ fontSize: 14, fontWeight: 700, color: 'var(--ink)' }}>Android</div>
                  <div style={{ fontSize: 12, color: 'var(--ink-mute)', marginTop: 3 }}>출시 알림 신청</div>
                </div>
                <Icon name="bell" size={22} strokeWidth={2.1} />
              </div>
            </div>
            <div style={{ fontSize: 13, color: 'var(--ink-soft)', marginTop: 18, lineHeight: 1.65 }}>
              Android 사용자는 이메일만 남겨두면 출시 소식과 초기 혜택을 함께 안내받을 수 있어요.
            </div>
            <button
              type="button"
              onClick={() => onOpenLaunchAlert && onOpenLaunchAlert({ source: 'pricing-platform-android-alert', platform: 'android' })}
              style={{ marginTop: 'auto', padding: '14px 20px', background: 'transparent', color: 'var(--ink)', borderRadius: 999, fontSize: 14, fontWeight: 600, border: '1.5px solid var(--ink)', minHeight: 44 }}
            >
              Android 출시 알림
            </button>
          </div>
        </div>
      </div>
    </section>);

}

// ─── FAQ ──────────────────────────────────────────────────────
function FAQSection() {
  const faqs = [
  { q: '기록을 놓치면요?', a: '괜찮아요. 놓친 식사는 다음에 다시 적으면 됩니다. 키토메이트는 평가보다 기록을 쉽게 이어가도록 돕는 도구입니다.' },
  { q: '의료 상담을 대신하나요?', a: '아니요. 키토메이트는 질병의 진단·치료·예방을 목적으로 하지 않으며, 건강한 성인의 식단 기록과 정보 정리를 돕는 비의료 서비스입니다. 건강 상태나 식이 제한이 있다면 전문가와 상담해 주세요.' },
  { q: 'AI가 한국 음식을 잘 알아보나요?', a: '김치찌개, 삼겹살, 쌈 정식, 감자탕처럼 자주 먹는 한국식 메뉴를 더 쉽게 기록할 수 있도록 메뉴와 반찬 단위의 입력 경험을 준비하고 있습니다.' },
  { q: '사진 찍기 귀찮을 땐요?', a: '글로 한 줄만 써도 됩니다. "삼겹살 1인분 먹었어" 정도면 충분해요. 음성 입력도 있고요.' },
  { q: '칼로리도 기록되나요?', a: '필요한 경우 참고 정보로 함께 볼 수 있지만, 핵심은 탄수 · 지방 · 단백 섭취 흐름을 꾸준히 기록하는 것입니다.' },
  { q: '무료 플랜도 있나요?', a: '무료 플랜과 상위 플랜 구분은 없습니다. 키토메이트는 결제 후 모든 기능을 쓰는 단일 유료 이용권 구조이고, 사전등록자에게만 출시 후 7일 무료 혜택을 드릴 예정입니다.' }];

  const [open, setOpen] = useState(0);
  return (
    <section id="faq" className="section-pad-y" style={{ padding: '100px 32px' }}>
      <div style={{ maxWidth: 960, margin: '0 auto' }}>
        <div className="section-tag">자주 묻는 질문</div>
        <h2 className="typography-h2 serif" style={{ margin: '16px 0 40px', color: 'var(--ink-tone)' }}>
          "또 실패하면요?"에<br />
          <span style={{ color: 'var(--ink)' }}>먼저 답해드릴게요.</span>
        </h2>
        <div style={{ borderTop: '1px solid var(--line)' }}>
          {faqs.map((f, i) =>
          <div key={i} style={{ borderBottom: '1px solid var(--line)' }}>
              <button type="button" onClick={() => setOpen(open === i ? -1 : i)} aria-expanded={open === i} style={{
              width: '100%', textAlign: 'left', padding: '24px 0', display: 'flex', justifyContent: 'space-between', alignItems: 'center', color: 'var(--ink)', minHeight: 44, gap: 16
            }}>
                <div className="typography-large serif">{f.q}</div>
                <div aria-hidden="true" style={{
                width: 34, height: 34, borderRadius: '50%',
                background: open === i ? 'var(--lime)' : 'var(--bg-card)',
                color: open === i ? 'var(--ink)' : 'var(--ink)',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                fontSize: 18,
                transform: open === i ? 'rotate(45deg)' : 'none',
                transition: 'transform 0.2s ease-out, background-color 0.2s ease-out, color 0.2s ease-out',
                flexShrink: 0
              }}>+</div>
              </button>
              {open === i &&
            <div style={{ paddingBottom: 26, fontSize: 15, color: 'var(--ink-soft)', lineHeight: 1.7, maxWidth: 680 }}>{f.a}</div>
            }
            </div>
          )}
        </div>
      </div>
    </section>);

}

// ─── Final CTA ────────────────────────────────────────────────
function FinalCTA({ onOpenLaunchAlert }) {
  const handleComingSoon = (event) => {
    event.preventDefault();
    window.alert('이용 준비 중입니다');
  };

  return (
    <section className="section-pad-y" style={{ padding: '100px 32px 40px' }}>
      <div style={{ maxWidth: 1280, margin: '0 auto' }}>
        <div className="final-cta" style={{
          background: 'var(--bg-deep)', color: 'var(--on-dark)',
          borderRadius: 32, padding: 'clamp(60px, 8vw, 100px) clamp(40px, 6vw, 80px)',
          position: 'relative', overflow: 'hidden'
        }}>
          <div aria-hidden="true" style={{ position: 'absolute', top: -120, right: -120, width: 400, height: 400, borderRadius: '50%', background: 'radial-gradient(circle, rgba(158,240,26,0.28), transparent 70%)' }} />
          <div style={{ position: 'relative', maxWidth: 900 }}>
            <div className="mono" style={{ fontSize: 12, color: 'var(--salmon-soft)', letterSpacing: '0.12em', textTransform: 'uppercase', marginBottom: 24 }}>
              — 이번엔 다를 거예요
            </div>
            <h2 className="typography-h1 serif" style={{ color: 'var(--on-dark-soft)' }}>
              혼자 버티지 마세요.<br />
              <span style={{ color: 'var(--salmon-soft)' }}>같이 갈게요.</span>
            </h2>
            <p style={{ fontSize: '1rem', color: 'var(--on-dark-soft)', marginTop: 32, lineHeight: 1.6, maxWidth: 480 }}>
              지금 바로 다운로드하고 오늘 한 끼부터 기록해보세요. 혼자 애쓰지 않아도, 키토메이트가 옆에서 함께 갑니다.
            </p>
            <div style={{ marginTop: 40 }}>
              <PlatformActions onOpenLaunchAlert={onOpenLaunchAlert} source="final-android-alert" dark />
            </div>
            <div style={{ fontSize: 13, color: 'var(--on-dark-mute)', marginTop: 20 }}>
              iOS는 지금 다운로드 가능 · Android는 출시 알림 신청
            </div>
          </div>
        </div>

        <footer className="footer-row" style={{ padding: '48px 0 32px', fontSize: 12, color: 'var(--ink-mute)' }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 20 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
              <img src="assets/logo.svg" alt="" aria-hidden="true" style={{ width: 100, height: 'auto', display: 'block' }} />
              <span>© 2026 키토메이트 · 비의료 식단 기록 도구</span>
            </div>
            <div style={{ display: 'flex', gap: 24, flexWrap: 'wrap' }}>
              <a href="/ketomate/terms">이용약관</a><a href="/privacy/">개인정보</a><a href="/ketomate/notice">서비스 고지</a><a href="mailto:app.phare@gmail.com">문의</a>
            </div>
          </div>
          <p style={{ marginTop: 20, lineHeight: 1.6, color: 'var(--ink-mute)', maxWidth: 720 }}>
            본 서비스는 질병의 진단·치료를 목적으로 하는 의료행위가 아니며, 건강한 식단 관리를 돕기 위한 정보 제공 및 기록 보조 도구입니다.
          </p>
        </footer>
      </div>
    </section>);

}

Object.assign(window, { SiteHeader, Hero, ProblemSection, FeaturesSection, TestimonialsSection, PricingSection, FAQSection, FinalCTA, HERO_COPY });
