// menove-v2-sections.jsx, the seven panels of the v2 site.
// Depends on: FB, SITE_WHY, SITE_STATS, SITE_PROMISES, SiteMonaCard, SiteWordmark (window),
// plus menove-v2-core.jsx exports.

const v2Eyebrow = (color) => ({ fontFamily: FB.sans, fontSize: 11.5, letterSpacing: '.32em', textTransform: 'uppercase', fontWeight: 700, color });

/* watch this component's section for activation (drives counters) */
function useV2SectionActive() {
  const ref = React.useRef(null);
  const [on, setOn] = React.useState(false);
  React.useEffect(() => {
    const el = ref.current;
    const sec = el && el.closest('.v2-section');
    if (!sec) return;
    const check = () => setOn(sec.hasAttribute('data-active'));
    check();
    const mo = new MutationObserver(check);
    mo.observe(sec, { attributes: true, attributeFilter: ['data-active'] });
    return () => mo.disconnect();
  }, []);
  return [ref, on];
}

/* a numeral that counts itself up when its section lands */
function V2Count({ value }) {
  const [ref, on] = useV2SectionActive();
  const reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  const m = String(value).match(/^([^0-9]*)(\d+)(.*)$/);
  const [n, setN] = React.useState(0);
  React.useEffect(() => {
    if (!on || !m || reduce) return;
    const target = parseInt(m[2], 10);
    const t0 = performance.now(), dur = 1500;
    let raf;
    const step = (t) => {
      const p = Math.min(1, (t - t0) / dur);
      setN(Math.round(target * (1 - Math.pow(1 - p, 3))));
      if (p < 1) raf = requestAnimationFrame(step);
    };
    raf = requestAnimationFrame(step);
    return () => cancelAnimationFrame(raf);
  }, [on]);
  if (!m || reduce) return <span ref={ref}>{value}</span>;
  return <span ref={ref}>{m[1]}{on ? n : 0}{m[3]}</span>;
}

/* the trail — stones set themselves down across the whitespace */
function V2TrailStones({ count = 13 }) {
  const shapes = [
    '50% 50% 50% 50% / 56% 56% 44% 44%',
    '54% 46% 52% 48% / 58% 56% 44% 42%',
    '66% 34% 56% 44% / 62% 74% 26% 38%',
    '58% 42% 56% 44% / 70% 66% 34% 30%',
  ];
  return (
    <div aria-hidden="true" style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
      {Array.from({ length: count }).map((_, i) => {
        const t = i / (count - 1);
        const x = 3.5 + t * 55;
        const y = 88 - Math.sin(t * Math.PI) * 6.5 - t * 4;
        const w = 9 + ((i * 7) % 8);
        const filled = i % 4 === 3;
        return (
          <span key={i} className="rv" style={{ '--d': `${.3 + i * .09}s`, position: 'absolute', left: `${x}%`, top: `${y}%` }}>
            <span style={{
              display: 'block', width: w, height: Math.round(w * .66),
              borderRadius: shapes[i % 4], transform: `rotate(${(i * 47) % 23 - 11}deg)`,
              background: filled ? FB.aub : 'transparent',
              boxShadow: filled ? 'none' : `inset 0 0 0 1.4px ${fbTint(FB.aub, .5)}`,
            }}></span>
          </span>
        );
      })}
    </div>
  );
}

const V2_TICKER = ['brain fog', '3am waking', 'rage out of nowhere', 'joint pain', 'hot flushes', 'lost words', 'night sweats', 'electric shocks', 'frozen shoulder', 'heart flutters', 'dry eyes', 'tinnitus', 'crying spells', 'new allergies', 'internal tremors', 'skin crawling', 'restless legs', 'cold flashes', 'heavy bleeding', 'sugar cravings', 'itchy skin', 'the doubt'];

/* ---------- 1 · hero ---------- */
function V2Hero({ mobile }) {
  const scenes = [
    { src: 'photos/v2-trail-1.mp4', poster: 'photos/v2-trail-1-dawn.jpg' },
    { src: 'photos/v2-trail-2.mp4', poster: 'photos/v2-trail-2-cairn.jpg' },
    { src: 'photos/v2-trail-3.mp4', poster: 'photos/v2-trail-3-ridge.jpg' },
  ];
  return (
    <section className="v2-section" data-screen-label="V2 · Hero" style={{ position: 'relative', color: '#fff' }}>
      <V2HeroVideo scenes={scenes} />
      <div style={{ position: 'absolute', left: mobile ? 22 : 54, right: mobile ? 22 : 54, bottom: mobile ? '9vh' : '11vh', display: 'flex', flexDirection: mobile ? 'column' : 'row', alignItems: mobile ? 'flex-start' : 'flex-end', justifyContent: 'space-between', gap: 28 }}>
        <div style={{ maxWidth: 760 }}>
          <div className="rv" style={{ ...v2Eyebrow('rgba(255,255,255,.78)'), marginBottom: 18 }}>Perimenopause &amp; menopause</div>
          <h1 className="rv" style={{ '--d': '.12s', margin: 0, fontFamily: FB.display, fontWeight: 400, fontSize: 'clamp(36px, 6.6vw, 86px)', lineHeight: 1.04, textWrap: 'balance', textShadow: '0 2px 28px rgba(31,14,42,.45)' }}>
            It's not in your head. It's in your days.
          </h1>
        </div>
        <div className="rv" style={{ '--d': '.26s', display: 'flex', flexDirection: 'column', alignItems: mobile ? 'flex-start' : 'flex-end', gap: 20, flex: 'none' }}>
          <div style={{ fontFamily: FB.sans, fontSize: 14.5, lineHeight: 1.6, color: 'rgba(255,255,255,.88)', maxWidth: 300, textAlign: mobile ? 'left' : 'right' }}>
            A quiet companion that keeps your record: a stone for every day, evidence for every pattern.
          </div>
          <V2CTA onDark big>Request beta access</V2CTA>
        </div>
      </div>
      <div className="rv" style={{ '--d': '.5s', position: 'absolute', left: '50%', bottom: 18, transform: 'translateX(-50%)', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }}>
        <span style={{ fontFamily: FB.sans, fontSize: 10, letterSpacing: '.3em', textTransform: 'uppercase', fontWeight: 700, color: 'rgba(255,255,255,.6)' }}>Scroll</span>
        <span className="v2-scrollline"></span>
      </div>
    </section>
  );
}

/* ---------- 2 · why stones ---------- */
function V2Why({ mobile, cairn }) {
  return (
    <section className="v2-section" data-screen-label="V2 · Why stones" style={{ background: FB.paper, color: FB.ink, display: 'flex', alignItems: 'center', position: 'relative', overflow: 'hidden' }}>
      <div style={{ display: 'flex', flexDirection: mobile ? 'column' : 'row', alignItems: 'center', gap: mobile ? 30 : '6vw', padding: mobile ? '90px 22px 60px' : '0 7vw', width: '100%', boxSizing: 'border-box', position: 'relative' }}>
        <div style={{ flex: 1.1, maxWidth: 640 }}>
          <div className="rv" style={{ ...v2Eyebrow(FB.plum), marginBottom: 16 }}>{SITE_WHY.eyebrow}</div>
          <h2 className="rv" style={{ '--d': '.1s', margin: 0, fontFamily: FB.display, fontWeight: 400, fontSize: 'clamp(30px, 4.5vw, 62px)', lineHeight: 1.08, textWrap: 'balance' }}>
            A day becomes a stone.<br />Thirty days make a path.
          </h2>
          <p className="rv" style={{ '--d': '.2s', fontFamily: FB.sans, fontSize: 'clamp(13.5px, 1.1vw, 15.5px)', lineHeight: 1.75, color: FB.body, margin: '22px 0 0', maxWidth: 520 }}>{SITE_WHY.p1}</p>
          <p className="rv" style={{ '--d': '.3s', fontFamily: FB.sans, fontSize: 'clamp(13.5px, 1.1vw, 15.5px)', lineHeight: 1.75, color: FB.body, margin: '14px 0 0', maxWidth: 520 }}>{SITE_WHY.p2}</p>
          <p className="rv" style={{ '--d': '.4s', fontFamily: FB.display, fontSize: 'clamp(15px, 1.35vw, 19px)', lineHeight: 1.6, color: FB.ink, margin: '18px 0 0', maxWidth: 520 }}>{SITE_WHY.p3}</p>
        </div>
        <div style={{ flex: 1, position: 'relative', display: mobile ? 'none' : 'block' }}>
          {/* the slab — a plane of the room behind the photograph */}
          <div className="rv" style={{ '--d': '.3s', position: 'absolute', top: 30, left: 34, right: -26, bottom: -34, borderRadius: 26, background: FB.aub, opacity: .92 }}></div>
          <div className="rv rv-media" style={{ '--d': '.18s', position: 'relative', borderRadius: 22, overflow: 'hidden', height: 'min(62vh, 560px)', boxShadow: '0 50px 90px -42px rgba(31,14,42,.55)' }}>
            <img src={V2A('photos/v2-window.jpg')} alt="A woman by a window, late afternoon" style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} />
            <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(31,14,42,0) 52%, rgba(31,14,42,.52) 100%)' }}></div>
            <div style={{ position: 'absolute', left: 22, right: 22, bottom: 18, fontFamily: FB.display, fontSize: 'clamp(14px, 1.25vw, 18px)', lineHeight: 1.5, color: '#fff', textShadow: '0 1px 14px rgba(31,14,42,.5)' }}>
              “On days you logged evening tea, you reported fewer 3am wakings.”
              <span style={{ display: 'block', fontFamily: FB.sans, fontSize: 10, letterSpacing: '.22em', textTransform: 'uppercase', fontWeight: 700, color: 'rgba(255,255,255,.7)', marginTop: 8 }}>Mona · saved to patterns</span>
            </div>
          </div>
          <div className="rv" style={{ '--d': '.42s', position: 'absolute', left: -34, bottom: -10 }}>
            <V2Cairn variant={cairn} size={.62} />
          </div>
        </div>
      </div>
    </section>
  );
}

/* ---------- 3 · the numbers, staggered down the dark panel ---------- */
function V2Stats({ mobile }) {
  const pos = mobile
    ? [{}, {}, {}]
    : [{ marginTop: 0 }, { marginTop: '14vh' }, { marginTop: '28vh' }];
  return (
    <section className="v2-section" data-screen-label="V2 · The numbers" style={{ background: FB.aub, color: '#fff', display: 'flex', alignItems: mobile ? 'center' : 'flex-start', position: 'relative', overflow: 'hidden' }}>
      <svg className="rv" style={{ '--d': '.5s', position: 'absolute', inset: 0, width: '100%', height: '100%', opacity: .22 }} viewBox="0 0 1440 800" preserveAspectRatio="none" fill="none">
        <path className="v2-statpath" d="M120 240 C 420 320, 620 380, 760 470 C 900 560, 1100 620, 1340 660" stroke={FB.iris} strokeWidth="1.5" strokeDasharray="2 10" strokeLinecap="round" />
      </svg>
      <div style={{ padding: mobile ? '90px 22px 100px' : '12vh 7vw 0', width: '100%', boxSizing: 'border-box', position: 'relative' }}>
        <div className="rv" style={{ ...v2Eyebrow(FB.iris), marginBottom: 14 }}>The part nobody hands you</div>
        <h2 className="rv" style={{ '--d': '.1s', margin: 0, fontFamily: FB.display, fontWeight: 400, fontSize: 'clamp(28px, 3.8vw, 52px)', lineHeight: 1.1, maxWidth: 640, textWrap: 'balance' }}>
          You shouldn't have to argue from memory.
        </h2>
        <div style={{ display: mobile ? 'flex' : 'grid', flexDirection: 'column', gridTemplateColumns: 'repeat(3, 1fr)', gap: mobile ? 30 : '4vw', marginTop: mobile ? 36 : '4vh' }}>
          {SITE_STATS.map((st, i) => (
            <div key={st.n} className="rv" style={{ '--d': `${.18 + i * .14}s`, ...pos[i], maxWidth: 320 }}>
              <div style={{ fontFamily: FB.display, fontSize: 'clamp(52px, 6.4vw, 96px)', lineHeight: 1, color: FB.iris }}><V2Count value={st.n} /></div>
              <div style={{ fontFamily: FB.sans, fontSize: 12, letterSpacing: '.18em', textTransform: 'uppercase', fontWeight: 700, color: '#fff', marginTop: 12 }}>{st.l}</div>
              <div style={{ fontFamily: FB.sans, fontSize: 13, lineHeight: 1.65, color: 'rgba(255,255,255,.75)', marginTop: 8 }}>{st.s}</div>
            </div>
          ))}
        </div>
      </div>
      {/* the river of signs — what she's been carrying, passing quietly */}
      <div className="rv" style={{ '--d': '.6s', position: 'absolute', left: 0, right: 0, bottom: 0, padding: '0 0 26px' }}>
        <div className="v2-ticker">
          <div className="v2-ticker-inner">
            {[0, 1].map((dup) => (
              <div key={dup} style={{ display: 'flex', alignItems: 'center', flex: 'none' }}>
                {V2_TICKER.map((s, i) => (
                  <span key={s} style={{ display: 'flex', alignItems: 'center', flex: 'none' }}>
                    <span style={{ fontFamily: FB.display, fontSize: 'clamp(16px, 1.6vw, 22px)', color: 'rgba(255,255,255,.38)', whiteSpace: 'nowrap' }}>{s}</span>
                    <span style={{ width: 11, height: 7.5, borderRadius: '54% 46% 52% 48% / 58% 56% 44% 42%', boxShadow: `inset 0 0 0 1.2px rgba(188,171,241,.35)`, margin: '0 26px', transform: `rotate(${i % 2 ? -6 : 5}deg)`, flex: 'none' }}></span>
                  </span>
                ))}
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

/* ---------- 4 · the app, one phone ---------- */
function V2App({ mobile, vh, auto }) {
  const [idx, setIdx] = React.useState(0);
  React.useEffect(() => {
    if (!auto) return;
    const t = setInterval(() => setIdx(i => (i + 1) % V2_SCREENS.length), 4400);
    return () => clearInterval(t);
  }, [auto]);
  const scale = Math.max(.42, Math.min(.62, (vh - (mobile ? 290 : 200)) / 844));
  return (
    <section className="v2-section" data-screen-label="V2 · The app" style={{ background: FB.paper, color: FB.ink, display: 'flex', alignItems: 'center' }}>
      <div style={{ display: 'flex', flexDirection: mobile ? 'column' : 'row', alignItems: 'center', gap: mobile ? 26 : '6vw', padding: mobile ? '90px 22px 50px' : '0 8vw', width: '100%', boxSizing: 'border-box', justifyContent: 'center' }}>
        <div style={{ flex: mobile ? 'none' : '0 0 380px', maxWidth: 440 }}>
          <div className="rv" style={{ ...v2Eyebrow(FB.plum), marginBottom: 16 }}>The app</div>
          <h2 className="rv" style={{ '--d': '.1s', margin: 0, fontFamily: FB.display, fontWeight: 400, fontSize: 'clamp(26px, 3.2vw, 44px)', lineHeight: 1.14, textWrap: 'balance' }}>
            A companion, not a dashboard.
          </h2>
          <div className="rv" style={{ '--d': '.2s', marginTop: 26 }}>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
              {V2_SCREENS.map((s, i) => {
                const stones = [
                  { r: '50% 50% 50% 50% / 56% 56% 44% 44%', w: 12, h: 11, rot: 0 },
                  { r: '66% 34% 56% 44% / 62% 74% 26% 38%', w: 15, h: 9, rot: -7 },
                  { r: '54% 46% 52% 48% / 58% 56% 44% 42%', w: 18, h: 10, rot: 5 },
                  { r: '58% 42% 56% 44% / 70% 66% 34% 30%', w: 21, h: 11, rot: 2 },
                  { r: '62% 38% 50% 50% / 60% 68% 32% 40%', w: 16, h: 12, rot: -4 },
                ][i % 5];
                return (
                  <div key={s.k} onClick={() => setIdx(i)} style={{ cursor: 'pointer', padding: '9px 14px', borderRadius: 12, background: i === idx ? '#fff' : 'transparent', boxShadow: i === idx ? `inset 0 0 0 1px ${FB.line}, 0 14px 30px -22px rgba(40,8,40,.4)` : 'none', transition: 'background .4s ease, box-shadow .4s ease', display: 'flex', alignItems: 'center', gap: 12 }}>
                    <span style={{ width: 22, display: 'flex', justifyContent: 'center', flex: 'none' }}>
                      <span style={{ width: stones.w, height: stones.h, borderRadius: stones.r, transform: `rotate(${stones.rot}deg)`, background: i === idx ? FB.aub : 'transparent', boxShadow: i === idx ? 'none' : `inset 0 0 0 1.5px ${FB.soft}`, transition: 'background .4s ease, box-shadow .4s ease' }}></span>
                    </span>
                    <span style={{ fontFamily: FB.display, fontSize: 17, color: i === idx ? FB.ink : FB.soft, transition: 'color .4s ease' }}>{s.label}</span>
                  </div>
                );
              })}
            </div>
            {/* fixed-height caption, crossfades, never reflows */}
            <div style={{ position: 'relative', height: 76, marginTop: 14 }}>
              {V2_SCREENS.map((s, i) => (
                <div key={s.k} style={{ position: 'absolute', inset: 0, opacity: i === idx ? 1 : 0, transition: 'opacity .5s ease', fontFamily: FB.sans, fontSize: 13, lineHeight: 1.6, color: FB.body, pointerEvents: 'none' }}>{s.line}</div>
              ))}
            </div>
          </div>
          {!mobile && <div className="rv" style={{ '--d': '.3s', marginTop: 28 }}><V2CTA>Request beta access</V2CTA></div>}
        </div>
        <div className="rv rv-media v2-phone-stage" style={{ '--d': '.18s', position: 'relative' }}>
          {/* evening light behind the glass */}
          <div aria-hidden="true" style={{ position: 'absolute', left: '50%', top: '50%', transform: 'translate(-50%,-50%)', width: 'min(46vw, 640px)', height: 'min(46vw, 640px)', background: `radial-gradient(closest-side, ${fbTint(FB.iris, .5)} 0%, rgba(188,171,241,0) 72%)`, pointerEvents: 'none' }}></div>
          <V2PhoneShow scale={scale} idx={idx} />
        </div>
      </div>
    </section>
  );
}

/* ---------- 5 · the photograph + three promises ---------- */
function V2Promises({ mobile }) {
  return (
    <section className="v2-section" data-screen-label="V2 · Three promises" style={{ background: FB.paper, color: FB.ink, display: 'flex', alignItems: 'stretch' }}>
      <div style={{ display: 'flex', flexDirection: mobile ? 'column' : 'row', width: '100%' }}>
        <div className="rv rv-media" style={{ flex: mobile ? 'none' : 1.1, height: mobile ? '34vh' : 'auto', overflow: 'hidden', position: 'relative' }}>
          <img src={V2A('photos/v2-lacing.jpg')} alt="A woman lacing shoes at dawn" style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} />
          <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(31,14,42,.08) 0%, rgba(31,14,42,0) 40%, rgba(31,14,42,.5) 100%)' }}></div>
          <div style={{ position: 'absolute', left: mobile ? 22 : 34, right: mobile ? 22 : 34, bottom: mobile ? 16 : 28, fontFamily: FB.display, fontSize: 'clamp(15px, 1.4vw, 20px)', lineHeight: 1.5, color: '#fff', maxWidth: 380, textShadow: '0 1px 18px rgba(31,14,42,.5)' }}>
            “On days you passed 5,000 steps, you reported less brain fog.”
            <span style={{ display: 'block', fontFamily: FB.sans, fontSize: 10, letterSpacing: '.22em', textTransform: 'uppercase', fontWeight: 700, color: 'rgba(255,255,255,.7)', marginTop: 8 }}>Mona · saved to patterns</span>
          </div>
        </div>
        <div style={{ flex: 1, display: 'flex', alignItems: 'center', padding: mobile ? '0 22px 56px' : '0 6vw 0 0', boxSizing: 'border-box', position: 'relative', zIndex: 2 }}>
          {/* the contract lifts off the page and onto the photograph */}
          <div className="rv" style={{ '--d': '.14s', background: '#fff', borderRadius: 26, padding: mobile ? '30px 26px' : 'min(4.6vh, 44px) min(3.4vw, 50px)', margin: mobile ? '-44px 0 0' : '0 0 0 -7vw', boxShadow: `inset 0 0 0 1px ${FB.line}, 0 60px 110px -48px rgba(31,14,42,.5)`, width: '100%' }}>
            <div style={{ ...v2Eyebrow(FB.plum), marginBottom: 12 }}>The contract</div>
            <h2 style={{ margin: 0, fontFamily: FB.display, fontWeight: 400, fontSize: 'clamp(26px, 3.2vw, 44px)', lineHeight: 1.14 }}>Three promises.</h2>
            <div style={{ marginTop: 'min(3.2vh, 26px)', display: 'flex', flexDirection: 'column' }}>
              {SITE_PROMISES.map((p, i) => (
                <div key={p.tt} className="rv" style={{ '--d': `${.24 + i * .12}s`, borderTop: `1px solid ${FB.line}`, padding: 'min(2.4vh, 20px) 0' }}>
                  <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
                    <span style={{ width: 16, height: 11, borderRadius: '54% 46% 52% 48% / 58% 56% 44% 42%', boxShadow: `inset 0 0 0 1.5px ${FB.aub}`, transform: `rotate(${i % 2 ? -6 : 5}deg)`, flex: 'none' }}></span>
                    <span style={{ fontFamily: FB.display, fontSize: 'clamp(17px, 1.5vw, 21px)', color: FB.ink }}>{p.tt}</span>
                  </div>
                  <p style={{ fontFamily: FB.sans, fontSize: 'clamp(12.5px, 1vw, 14px)', lineHeight: 1.7, color: FB.body, margin: '8px 0 0 28px', maxWidth: 520 }}>{p.body}</p>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

/* ---------- 6 · the companion, in the evening ---------- */
function V2LoopVideo({ src, poster, alt }) {
  const [url, setUrl] = React.useState(null);
  const reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  React.useEffect(() => {
    if (reduce) return;
    const cache = (window.__v2VideoCache = window.__v2VideoCache || {});
    let cancelled = false;
    (cache[src] = cache[src] || fetch(src).then(r => r.blob()).then(b => URL.createObjectURL(b)))
      .then(u => { if (!cancelled) setUrl(u); })
      .catch(() => {});
    return () => { cancelled = true; };
  }, [src]);
  return (
    <div style={{ position: 'relative', width: '100%', height: '100%' }}>
      <img src={poster} alt={alt} style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} />
      {url && !reduce && (
        <video src={url} autoPlay muted loop playsInline style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', display: 'block' }}></video>
      )}
    </div>
  );
}

function V2Companion({ mobile }) {
  const { w } = useV2Viewport();
  const float = !mobile && w >= 1150; // the floating chat card needs real room
  return (
    <section className="v2-section" data-screen-label="V2 · The companion" style={{ background: FB.paper, color: FB.ink, display: 'flex', alignItems: 'center' }}>
      <div style={{ display: 'flex', flexDirection: mobile ? 'column' : 'row', alignItems: mobile ? 'center' : 'flex-start', gap: mobile ? 30 : '7vw', padding: mobile ? '90px 22px 60px' : '0 8vw', width: '100%', boxSizing: 'border-box', justifyContent: 'center' }}>
        <div style={{ flex: '0 0 auto', maxWidth: 440 }}>
          <div className="rv" style={{ ...v2Eyebrow(FB.plum), marginBottom: 14 }}>The companion</div>
          <h2 className="rv" style={{ '--d': '.1s', margin: 0, fontFamily: FB.display, fontWeight: 400, fontSize: 'clamp(26px, 3.2vw, 44px)', lineHeight: 1.14, textWrap: 'balance' }}>
            Someone keeps the thread.
          </h2>
          <p className="rv" style={{ '--d': '.18s', fontFamily: FB.sans, fontSize: 'clamp(13px, 1.05vw, 15px)', lineHeight: 1.7, color: FB.body, margin: '18px 0 0', maxWidth: 400 }}>
            Mona checks in once a day, remembers what yesterday asked of you, and quietly files what matters into your patterns.
          </p>
          {!float && <div className="rv" style={{ '--d': '.26s', marginTop: 26 }}><SiteMonaCard /></div>}
        </div>
        {!mobile && (
          <div style={{ flex: '0 0 auto', position: 'relative', width: 'min(30vw, 420px)', marginBottom: float ? 90 : 0 }}>
            {/* the room leans in behind her */}
            <div className="rv" style={{ '--d': '.34s', position: 'absolute', top: -26, right: -30, width: '70%', bottom: 38, borderRadius: 26, background: FB.aub, transform: 'rotate(2.5deg)' }}></div>
            <div className="rv rv-media" style={{ '--d': '.2s', position: 'relative', borderRadius: 22, overflow: 'hidden', height: 'min(52vh, 480px)', boxShadow: '0 50px 100px -44px rgba(31,14,42,.6)' }}>
              <V2LoopVideo src={V2A('photos/v2-companion.mp4')} poster={V2A('photos/v2-companion.jpg')} alt="A woman laughing at golden hour" />
            </div>
            {/* the exchange floats off her shoulder, into the page — only when there's room */}
            {float && (
              <div className="rv" style={{ '--d': '.44s', position: 'absolute', left: 'max(-13vw, -240px)', bottom: -76, width: 'min(25vw, 360px)', filter: 'drop-shadow(0 44px 60px rgba(31,14,42,.4))' }}>
                <SiteMonaCard />
              </div>
            )}
          </div>
        )}
      </div>
    </section>
  );
}

/* ---------- 7 · questions, answered ---------- */
function V2FAQ({ mobile }) {
  const [open, setOpen] = React.useState(0);
  return (
    <section className="v2-section" data-screen-label="V2 · FAQ" style={{ background: FB.paper, color: FB.ink, display: 'flex', alignItems: 'center', position: 'relative', overflow: 'hidden' }}>
      {/* one vast stone, almost not there, behind the questions */}
      <div className="rv" aria-hidden="true" style={{ '--d': '.5s', position: 'absolute', left: '-12vw', top: '50%', transform: 'translateY(-46%) rotate(-8deg)', width: '44vw', height: '34vw', borderRadius: '54% 46% 52% 48% / 58% 56% 44% 42%', boxShadow: `inset 0 0 0 2px ${FB.line}`, pointerEvents: 'none' }}></div>
      <div style={{ display: 'flex', flexDirection: mobile ? 'column' : 'row', gap: mobile ? 26 : '6vw', padding: mobile ? '90px 22px 60px' : '0 8vw', width: '100%', boxSizing: 'border-box', alignItems: mobile ? 'stretch' : 'center', position: 'relative' }}>
        <div style={{ flex: '0 0 auto', maxWidth: 340 }}>
          <div className="rv" style={{ ...v2Eyebrow(FB.plum), marginBottom: 14 }}>Questions</div>
          <h2 className="rv" style={{ '--d': '.1s', margin: 0, fontFamily: FB.display, fontWeight: 400, fontSize: 'clamp(26px, 3.2vw, 44px)', lineHeight: 1.14 }}>Asked, answered.</h2>
          <p className="rv" style={{ '--d': '.18s', fontFamily: FB.sans, fontSize: 'clamp(12.5px, 1vw, 14px)', lineHeight: 1.7, color: FB.body, margin: '16px 0 0', maxWidth: 300 }}>
            Anything we missed lives in Resources, or ask us directly from the app.
          </p>
        </div>
        <div className="rv" style={{ '--d': '.2s', flex: 1, maxWidth: 720, background: '#F4F1EA', borderRadius: 24, padding: mobile ? '8px 22px' : '14px min(2.6vw, 40px)', boxShadow: `inset 0 0 0 1px ${FB.line}, 0 30px 60px -30px rgba(31,14,42,.35), 0 60px 110px -52px rgba(31,14,42,.4)` }}>
          {SITE_FAQ.map((f, i) => (
            <div key={f.q} onClick={() => setOpen(open === i ? -1 : i)} style={{ borderTop: i === 0 ? 'none' : `1px solid ${FB.line}`, padding: 'min(2.2vh, 18px) 0', cursor: 'pointer' }}>
              <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', gap: 20 }}>
                <span style={{ fontFamily: FB.display, fontSize: 'clamp(15.5px, 1.4vw, 20px)', color: open === i ? FB.ink : FB.body }}>{f.q}</span>
                <svg viewBox="0 0 24 24" fill="none" stroke={FB.soft} strokeWidth="2" style={{ width: 13, height: 13, flex: 'none', transform: open === i ? 'rotate(45deg)' : 'none', transition: 'transform .35s ease' }}><path d="M12 5v14M5 12h14" /></svg>
              </div>
              <div style={{ maxHeight: open === i ? 200 : 0, opacity: open === i ? 1 : 0, overflow: 'hidden', transition: 'all .5s ease' }}>
                <p style={{ fontFamily: FB.sans, fontSize: 'clamp(12.5px, 1vw, 14px)', lineHeight: 1.7, color: FB.body, margin: '10px 0 2px', maxWidth: 620 }}>{f.a}</p>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ---------- footer, shared; bg overrides for darker-band pages ---------- */
function V2Footer({ mobile, bg }) {
  const soft = 'rgba(255,255,255,.62)';
  const cols = [
    ['Product', [['The app', V2_HOME], ['Assessment', V2_PAGES.Assessment], ['Resources', V2_PAGES.Resources], ['Beta access', V2_HOME + '#beta']]],
    ['Company', [['Partners', V2_PAGES.Partners], ['Contact', '/contact.html']]],
    ['Connect', [['Instagram', 'https://instagram.com/menove.app'], ['Facebook', 'https://facebook.com/menoveapp'], ['TikTok', 'https://tiktok.com/@menove.app']]],
    ['Legal', [['Privacy', '/privacy'], ['Terms', '/terms'], ['Cookies', '/cookies'], ['Refunds & cancellations', '/refund']]],
  ];
  return (
    <div style={{ background: bg || 'transparent', borderTop: bg ? 'none' : '1px solid rgba(255,255,255,.16)', color: '#fff', padding: mobile ? '30px 22px 26px' : '34px 54px 30px', fontFamily: FB.sans }}>
      <div style={{ display: 'flex', flexDirection: mobile ? 'column' : 'row', gap: mobile ? 26 : 0, justifyContent: 'space-between' }}>
        <div style={{ maxWidth: 240 }}>
          <SiteWordmark color="#fff" size={13} />
          <div style={{ fontSize: 12, lineHeight: 1.6, color: soft, marginTop: 10 }}>A quiet companion for the years of change.</div>
          <div style={{ display: 'flex', gap: 10, marginTop: 16 }}>
            {[
              ['Instagram', 'https://instagram.com/menove.app', <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8"><rect x="3.5" y="3.5" width="17" height="17" rx="4.5" /><circle cx="12" cy="12" r="3.8" /><circle cx="17.1" cy="6.9" r="1" fill="currentColor" stroke="none" /></svg>],
              ['Facebook', 'https://facebook.com/menoveapp', <svg viewBox="0 0 24 24" fill="currentColor"><path d="M13.4 21v-7.1h2.4l.4-2.8h-2.8V9.3c0-.8.2-1.4 1.4-1.4h1.5V5.4c-.3 0-1.2-.1-2.2-.1-2.2 0-3.6 1.3-3.6 3.7v2.1H8.1v2.8h2.4V21h2.9z" /></svg>],
              ['TikTok', 'https://tiktok.com/@menove.app', <svg viewBox="0 0 24 24" fill="currentColor"><path d="M16.6 3c.4 2.1 1.8 3.5 3.9 3.8v2.9c-1.5 0-2.9-.5-3.9-1.3v6.4a5.4 5.4 0 1 1-5.4-5.4c.3 0 .6 0 .9.1v3a2.4 2.4 0 1 0 1.5 2.3V3h3z" /></svg>],
            ].map(([label, href, icon]) => (
              <a key={label} href={href} aria-label={label} style={{ width: 34, height: 34, borderRadius: '50%', boxShadow: 'inset 0 0 0 1.3px rgba(255,255,255,.4)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'rgba(255,255,255,.88)', textDecoration: 'none' }}>
                <span style={{ width: 16, height: 16, display: 'block' }}>{icon}</span>
              </a>
            ))}
          </div>
        </div>
        <div style={{ display: 'flex', gap: mobile ? 36 : 56, flexWrap: 'wrap' }}>
          {cols.map(([tt, links]) => (
            <div key={tt}>
              <div style={{ fontSize: 10, letterSpacing: '.2em', textTransform: 'uppercase', fontWeight: 700, color: soft, marginBottom: 9 }}>{tt}</div>
              {links.map(([l, href]) => (href && !(V2_SHARE && !/^(https?:|mailto:)/.test(href)))
                ? <a key={l} href={href} style={{ display: 'block', fontSize: 12.5, fontWeight: 600, color: 'rgba(255,255,255,.85)', marginBottom: 7, cursor: 'pointer', textDecoration: 'none' }}>{l}</a>
                : <div key={l} style={{ fontSize: 12.5, fontWeight: 600, color: 'rgba(255,255,255,.85)', marginBottom: 7, cursor: 'pointer' }}>{l}</div>)}
            </div>
          ))}
        </div>
      </div>
      <div style={{ fontSize: 11, color: soft, marginTop: mobile ? 24 : 26, display: 'flex', flexDirection: mobile ? 'column' : 'row', gap: 6, justifyContent: 'space-between' }}>
        <span>© 2026 Menovē · For wellness only. Not medical advice.</span>
        <span>Made with care for women 35–65</span>
      </div>
    </div>
  );
}

/* ---------- 8 · finale, beta + footer, aubergine ---------- */
/* ---------- beta email capture → Klaviyo list Xzvndx (same list carried from v4) ----------
   Native form POST to Klaviyo's subscribe endpoint, targeted at a hidden iframe so the
   page never navigates. CORS-free; resolves the UI on iframe load or a timeout fallback
   (Klaviyo accepts the POST server-side even when its response refuses to render). */
function V2BetaForm({ mobile, soft }) {
  const [state, setState] = React.useState('idle'); // idle | sending | done
  const submitting = React.useRef(false);
  const inputRef = React.useRef(null);

  const finish = () => {
    if (!submitting.current) return;
    submitting.current = false;
    setState('done');
    if (inputRef.current) inputRef.current.value = '';
  };
  const onSubmit = (e) => {
    const email = (inputRef.current && inputRef.current.value || '').trim();
    if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) { e.preventDefault(); inputRef.current && inputRef.current.focus(); return; }
    submitting.current = true;
    setState('sending');
    setTimeout(finish, 2400);
  };

  return (
    <React.Fragment>
      <form className="rv" action="https://manage.kmail-lists.com/subscriptions/subscribe" method="POST"
        target="v2KlaviyoTarget" onSubmit={onSubmit} noValidate
        style={{ '--d': '.32s', display: 'flex', justifyContent: 'center', alignItems: 'center', gap: 10, marginTop: 30, flexWrap: 'wrap' }}>
        <input type="hidden" name="a" value="SvceY3" />
        <input type="hidden" name="g" value="Xzvndx" />
        <input type="hidden" name="$fields" value="$source" />
        <input type="hidden" name="$source" value="Menove Website v5" />
        <input ref={inputRef} type="email" name="email" required placeholder="you@example.com"
          disabled={state === 'done'}
          style={{ display: 'inline-flex', alignItems: 'center', width: mobile ? 190 : 270, borderRadius: 999, padding: '17px 22px', fontFamily: FB.sans, fontSize: 13.5, color: '#fff', background: 'rgba(255,255,255,.08)', boxShadow: 'inset 0 0 0 1px rgba(255,255,255,.2)', border: 'none', outline: 'none', textAlign: 'left' }} />
        <button type="submit" disabled={state !== 'idle'} style={{ all: 'unset' }}>
          <V2CTA onDark big onClick={() => {}} style={state === 'done' ? { background: 'rgba(255,255,255,.16)', color: '#fff', boxShadow: 'inset 0 0 0 1px rgba(255,255,255,.35)' } : null}>
            {state === 'done' ? "You're on the list" : state === 'sending' ? 'Sending…' : 'Request beta access'}
          </V2CTA>
        </button>
      </form>
      <iframe name="v2KlaviyoTarget" title="subscribe" onLoad={finish} style={{ display: 'none', width: 0, height: 0, border: 0 }}></iframe>
      <div className="rv" style={{ '--d': '.42s', fontFamily: FB.sans, fontSize: 11.5, fontWeight: 600, color: soft, marginTop: 16 }}>
        {state === 'done' ? "Check your inbox. We wrote you a letter." : 'iOS · TestFlight · no spam, ever'}
      </div>
    </React.Fragment>
  );
}

function V2Finale({ mobile, cairn, title = 'The trail starts with one stone.', sub = "The beta is free, and places are limited each month. Leave your email and we'll write when yours opens.", action }) {
  const soft = 'rgba(255,255,255,.62)';
  const cols = [
    ['Product', [['The app', V2_HOME], ['Assessment', V2_PAGES.Assessment], ['Resources', V2_PAGES.Resources], ['Beta access', null]]],
    ['Company', [['Partners', V2_PAGES.Partners], ['Contact', null], ['Instagram', null], ['TikTok', null]]],
    ['Legal', [['Privacy', null], ['Terms', null], ['Cookies', null], ['Refunds & cancellations', null]]],
  ];
  return (
    <section className="v2-section" data-screen-label="V2 · Beta + footer" style={{ background: FB.aub, color: '#fff', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
      <div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', textAlign: 'center', padding: mobile ? '90px 22px 30px' : '11vh 7vw 30px' }}>
        <div className="rv"><V2Cairn variant={cairn === 'aubergine' ? 'white' : cairn} onDark size={.52} assemble /></div>
        <div className="rv" style={{ '--d': '.74s', fontFamily: FB.display, fontSize: 'clamp(32px, 4.4vw, 60px)', lineHeight: 1.1, maxWidth: 700, marginTop: 26, textWrap: 'balance' }}>
          {title}
        </div>
        <div className="rv" style={{ '--d': '.22s', fontFamily: FB.sans, fontSize: 'clamp(13px, 1.1vw, 15.5px)', lineHeight: 1.65, color: 'rgba(255,255,255,.78)', maxWidth: 430, marginTop: 14 }}>
          {sub}
        </div>
        {action ? (
          <div className="rv" style={{ '--d': '.32s', marginTop: 30 }}>{action}</div>
        ) : (
          <V2BetaForm mobile={mobile} soft={soft} />
        )}
      </div>
      <V2Footer mobile={mobile} />
    </section>
  );
}

Object.assign(window, { V2Hero, V2Why, V2Stats, V2App, V2Promises, V2Companion, V2FAQ, V2Finale, V2Footer });
