// v8 "Bloom Dream" — sections part 1: floating glass nav, hero with the REAL
// app phone trio + stage pill, invisible-load.

function DmNav({ p }) {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const on = () => setScrolled(window.scrollY > 24);window.addEventListener('scroll', on, { passive: true });on();
    return () => window.removeEventListener('scroll', on);
  }, []);
  const links = [['how', 'How it Works'], ['partner', 'For Partners'], ['features', 'Features'], ['story', 'Our Story']];
  return (
    <div style={{ position: 'sticky', top: 0, zIndex: 100, display: 'flex', justifyContent: 'center', padding: '18px 20px', pointerEvents: 'none' }}>
      <div style={{ pointerEvents: 'auto', display: 'flex', alignItems: 'center', gap: 28, padding: '10px 12px 10px 22px',
        borderRadius: 999, transition: 'all 260ms ease', width: scrolled ? 'min(960px,100%)' : 'min(1080px,100%)',
        background: scrolled ? 'rgba(255,255,255,0.7)' : 'rgba(255,255,255,0.4)', backdropFilter: 'blur(16px) saturate(1.3)',
        WebkitBackdropFilter: 'blur(16px) saturate(1.3)', border: `1px solid ${p.glassEdge}`,
        boxShadow: scrolled ? p.shadowSoft : '0 10px 30px -20px rgba(120,80,60,0.3)', justifyContent: 'space-between' }}>
        <a href="#top" style={{ display: 'flex', alignItems: 'center', gap: 10, color: p.ink }}>
          <DDMark size={28} />
          <span style={{ fontFamily: "'Fraunces', Georgia, serif", fontSize: 25, fontWeight: 600, letterSpacing: '-0.01em' }}>My Daily Doula</span>
        </a>
        <nav style={{ display: 'flex', alignItems: 'center', gap: 26 }}>
          {links.map(([id, l]) =>
          <a key={id} href={`#${id}`} style={{ fontFamily: "'Fraunces', Georgia, serif", fontSize: 16, fontWeight: 600, color: p.inkSoft, transition: 'color 140ms' }}
          onMouseEnter={(e) => e.currentTarget.style.color = p.accent} onMouseLeave={(e) => e.currentTarget.style.color = p.inkSoft}>{l}</a>
          )}
          <PillBtn href="https://app.mydailydoula.com" p={p} pulse style={{ padding: '11px 20px', fontSize: 15, fontFamily: "'Fraunces', Georgia, serif", fontWeight: 600 }}>Chat with Della →</PillBtn>
        </nav>
      </div>
    </div>);

}

// Dream-styled stage pill — switches which stage leads the phone trio.
function DmStagePill({ stage, setStage, p }) {
  const items = [
  { id: 'ttc', label: 'Trying', dot: p.butter, fill: p.butter, fg: '#4A330B' },
  { id: 'pregnancy', label: 'Pregnancy', dot: p.accent, fill: p.accent, fg: '#FFFFFF' },
  { id: 'postpartum', label: 'Postpartum', dot: p.sage, fill: p.sage, fg: '#FFFFFF' }];

  return (
    <div style={{ display: 'inline-flex', alignItems: 'center', gap: 3, padding: 5, background: p.glass,
      backdropFilter: 'blur(14px) saturate(1.3)', WebkitBackdropFilter: 'blur(14px) saturate(1.3)',
      border: `1px solid ${p.glassEdge}`, borderRadius: 999, boxShadow: p.shadowSoft }}>
      {items.map((it) => {const act = stage === it.id;return (
          <button key={it.id} onClick={() => setStage(it.id)} style={{ display: 'inline-flex', alignItems: 'center', gap: 8,
            padding: '9px 17px', borderRadius: 999, border: 'none', cursor: 'pointer', background: act ? it.fill : 'transparent',
            color: act ? it.fg : p.inkSoft, fontFamily: dreamFonts.display, fontSize: 14, fontWeight: 700,
            transition: 'background 200ms ease, color 200ms ease' }}>
          <span style={{ width: 7, height: 7, borderRadius: '50%', flexShrink: 0,
              background: act ? it.fg === '#FFFFFF' ? 'rgba(255,255,255,0.92)' : it.dot : it.dot }} />
          {it.label}
        </button>);
      })}
    </div>);

}

function DmHero({ p }) {
  const [stage, setStage] = React.useState('pregnancy');
  return (
    <section id="top" data-screen-label="top" style={{ position: 'relative', overflow: 'hidden', padding: '34px 0 96px' }}>
      <FloatingMark size={58} bottom={46} right={'2%'} rotate={-12} dur={7} />
      <Orb from="#EBC9BE" to="#DCA192" size={520} top={-120} left={-130} opacity={0.5} dur={17} />
      <Orb from="#F6D2D6" to="#CC8B95" size={440} top={170} right={-150} opacity={0.42} dur={19} delay={2} />
      <Orb from="#E2EBD2" to="#B8C89A" size={400} bottom={-120} left={'22%'} opacity={0.38} dur={20} delay={1} />
      <div style={{ maxWidth: 1200, margin: '0 auto', padding: '0 40px', position: 'relative', zIndex: 2 }}>
        <div style={{ display: 'grid', gridTemplateColumns: '0.92fr 1.08fr', gap: 30, alignItems: 'center' }}>
          <div>
            <Reveal delay={80}>
              <div style={{ margin: '6px 0 0' }}>
                <div style={{ fontFamily: 'Fraunces', fontSize: 38, fontWeight: 400, fontStyle: 'italic',
                  color: p.inkSoft, lineHeight: 1, letterSpacing: '-0.01em' }}>Meet

                </div>
                <h1 style={{ fontFamily: 'Fraunces', fontSize: 138, fontWeight: 600, fontStyle: 'italic',
                  color: p.accent, lineHeight: 0.84, letterSpacing: '-0.04em', margin: '2px 0 0' }}>
                  Della<span style={{ color: p.ink, fontStyle: 'normal' }}></span>
                </h1>
                <div style={{ fontFamily: "'Fraunces', Georgia, serif", fontSize: 30, fontWeight: 500, lineHeight: 1.22,
                  letterSpacing: '-0.01em', color: p.ink, margin: '18px 0 0', maxWidth: 470, textWrap: 'balance' }}>
                  A friend in your corner that helps bring your village closer. So, Mama, you're not doing this <DEm p={p}>alone</DEm> anymore.
                </div>
              </div>
            </Reveal>
            <Reveal delay={150}>
              <p style={{ fontFamily: dreamFonts.body, fontSize: 18.5, lineHeight: 1.6, color: p.inkSoft, margin: '24px 0 0', maxWidth: 500, fontWeight: 500 }}>Della remembers your whole story, carries the mental load with you, and helps your partner show up - so you navigate this like a team, and never feel alone.

              </p>
            </Reveal>
            <Reveal delay={220}>
              <div style={{ display: 'flex', gap: 14, marginTop: 30, flexWrap: 'wrap' }}>
                <PillBtn href="https://app.mydailydoula.com" p={p} pulse>Chat with Della →</PillBtn>
                <PillBtn href="#features" p={p} kind="glass">See How She Helps</PillBtn>
              </div>
            </Reveal>
            <Reveal delay={300}>
              <div style={{ marginTop: 26, display: 'flex', alignItems: 'center', gap: 14, flexWrap: 'wrap',
                fontFamily: dreamFonts.body, fontWeight: 700, fontSize: 13.5, color: p.inkMute }}>
                <span>💛 App + WhatsApp + Text</span><span>·</span><span>🌍 In your language</span>
              </div>
            </Reveal>
          </div>

          {/* Live app phone trio + stage pill, in a glass halo */}
          <Reveal delay={180} style={{ position: 'relative', display: 'flex', justifyContent: 'center' }}>
            <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 16, position: 'relative' }}>
              <div aria-hidden="true" style={{ position: 'absolute', inset: '6% -4% 0% -4%', borderRadius: 40,
                background: 'radial-gradient(circle at 50% 36%, rgba(246,182,164,0.34), transparent 66%)', filter: 'blur(12px)', zIndex: 0 }} />
              <div style={{ position: 'relative', zIndex: 2 }}><DmStagePill stage={stage} setStage={setStage} p={p} /></div>
              <div style={{ position: 'relative', zIndex: 1, transform: 'scale(0.9)', transformOrigin: 'center top' }}>
                <DreamLiveTrio stage={stage} setStage={setStage} p={p} />
              </div>
              <div style={{ fontFamily: "'Caveat', cursive", fontSize: 34, fontWeight: 600,
                color: p.accent, lineHeight: 1, textAlign: 'center', position: 'relative', zIndex: 2 }}>the friend in your corner ♡</div>
            </div>
          </Reveal>
        </div>
      </div>
    </section>);

}

// Invisible load.
function DmLoad({ p }) {
  const [ref, inView] = useReveal({ amount: 0.35 });
  const pp = dreamPhone(p);
  return (
    <section id="load" data-screen-label="load" style={{ position: 'relative', overflow: 'hidden', padding: '110px 0' }}>
      <FloatingMark size={54} top={64} right={'5%'} rotate={10} dur={8} delay={0.6} />
      <Orb from="#F6D2D6" to="#E3B3A6" size={420} top={20} left={-140} opacity={0.4} dur={18} />
      <div style={{ maxWidth: 1140, margin: '0 auto', padding: '0 40px', position: 'relative', zIndex: 2, textAlign: 'center' }}>
        <Reveal><SoftEyebrow p={p} tone="coral">The part nobody talks about.</SoftEyebrow></Reveal>
        <Reveal delay={70}><DreamH p={p} size={44} style={{ marginTop: 20, whiteSpace: 'nowrap' }}>The weight of parenthood often falls on <DEm p={p} color={p.rose}>one person.</DEm><br />It shouldn't have to.<br /><span style={{ color: '#C47060' }}>Della brings your village closer.</span></DreamH></Reveal>

        <div ref={ref} style={{ display: 'grid', gridTemplateColumns: '1fr auto 1fr', gap: 20, alignItems: 'end', maxWidth: 840, margin: '56px auto 0' }}>
          <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 18 }}>
            <ThoughtCloud p={pp} tone="coral" side="left" shown={inView} delay={120} items={['The 9am scan', 'iron levels', 'The vitamins?', 'Nursery list', 'How do I feel']} />
            <AvatarDisc size={100} from="#EBBCB0" to="#C47060" ring="#F6D2D6" glyph="🤍" caption="Her" p={pp} />
          </div>
          <div style={{ paddingBottom: 52, alignSelf: 'center' }}><ThreadOfLight width={180} height={88} shown={inView} dur={1800} /></div>
          <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 18 }}>
            <ThoughtCloud p={pp} tone="sage" side="right" shown={inView} delay={420} items={['Is she okay?', 'what do I do?', 'Am I helping?', 'No1 gave me a map for this!']} />
            <AvatarDisc size={100} from="#A8C08F" to="#84A06F" ring="#D7E2C8" glyph="🫶" caption="Him" p={pp} />
          </div>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 44, maxWidth: 840, margin: '40px auto 0', textAlign: 'left' }}>
          <Reveal delay={120}><p style={{ fontFamily: dreamFonts.body, fontSize: 16.5, lineHeight: 1.6, color: p.inkSoft, margin: 0, fontWeight: 500 }}>You're holding all of it - the appointments, symptoms, feelings, the literal weight. <strong style={{ color: p.accentDeep }}>You don't have to. Della carries it with you.</strong></p></Reveal>
          <Reveal delay={220}><p style={{ fontFamily: dreamFonts.body, fontSize: 16.5, lineHeight: 1.6, color: p.inkSoft, margin: 0, fontWeight: 500 }}>Your partner is anxious too - they want to help but nobody handed them a map. <strong style={{ color: p.sageInk }}>Della gives them one, gently.</strong></p></Reveal>
        </div>
        <Reveal delay={120}>
          <p style={{ fontFamily: dreamFonts.serif, fontSize: 32, fontWeight: 500, fontStyle: 'italic', lineHeight: 1.3, color: '#101010', maxWidth: 920, margin: '64px auto 0' }}>
            <span style={{ whiteSpace: 'nowrap' }}>Most apps are built for women only.</span><br /><span style={{ whiteSpace: 'nowrap' }}>But isn't this journey about two people becoming parents?</span>
          </p>
        </Reveal>
        <Reveal delay={180}>
          <p style={{ fontFamily: dreamFonts.serif, fontSize: 32, fontWeight: 500, fontStyle: 'italic', lineHeight: 1.25, color: p.accent, maxWidth: 920, margin: '20px auto 0', whiteSpace: 'nowrap' }}>
            Della understands you both, your journey, and guides you.
          </p>
        </Reveal>
      </div>
    </section>);}

Object.assign(window, { DmNav, DmStagePill, DmHero, DmLoad });