/* global React, HeroWhatsApp, WA, AvatarStack, VideoReels, CareKit */
const { useState: useStateS, useEffect: useEffectS } = React;
const { Ic } = window;

/* small section heading */
function SecHead({ kicker, children, color = 'var(--brand)', align = 'center' }) {
  return (
    <div style={{ textAlign: align, marginBottom: 18 }}>
      <div className="kicker-row" style={{ justifyContent: align === 'center' ? 'center' : 'flex-start' }}>
        <span className="kicker-dot" style={{ background: color }}></span>
        <span className="eyebrow" style={{ color }}>{kicker}</span>
      </div>
      <h2 style={{ fontSize: 'clamp(22px, 6.5vw, 28px)', marginTop: 12, color: "rgb(39, 26, 17)" }}>{children}</h2>
    </div>);

}

const Check = ({ c = 'var(--brand)' }) =>
<Ic n="Check" size={17} color={c} stroke={2.4} style={{ flexShrink: 0, marginTop: 2 }} />;

/* line-icon set for the Family Doctor Plan carousel */
const iStroke = { width: 24, height: 24, viewBox: '0 0 24 24', fill: 'none', stroke: 'var(--brand)', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' };
const IconDoctor = <svg {...iStroke}><path d="M3 12h3.4l2 5.2 3.4-11 2.3 7H21" /></svg>;
const IconHome = <svg {...iStroke}><path d="M3 11.5 12 4l9 7.5" /><path d="M5.5 10.5V20h13v-9.5" /><path d="M10 20v-5h4v5" /></svg>;
const IconLab = <svg {...iStroke}><path d="M12 3s6 6.4 6 11a6 6 0 0 1-12 0c0-4.6 6-11 6-11z" /></svg>;
const IconChat = <svg {...iStroke}><path d="M21 11.5A7.7 8 0 0 1 9.5 19L4 20.5l1.6-5A8 8 0 1 1 21 11.5z" /></svg>;
const IconFamily = <svg {...iStroke}><circle cx="9" cy="8" r="3" /><path d="M3.5 19.5c0-3.2 2.5-5 5.5-5s5.5 1.8 5.5 5" /><circle cx="17.5" cy="9.5" r="2.2" /><path d="M20.8 19c0-2.3-1.6-3.8-3.8-3.8" /></svg>;


/* ---------------- How it works ---------------- */
function HowItWorks() {
  const steps = [
  { n: '1', t: 'Meet your Family Doctor', s: 'Your doctor visits you at home, understands your history, lifestyle and health goals.',
    ic: 'User' },
  { n: '2', t: 'Complete your Health Check', s: 'Lab tests are collected at home and reviewed by your doctor to create your health baseline.',
    ic: 'ClipboardList' },
  { n: '3', t: 'Get your Personalised Plan', s: 'Your doctor and care team create a health and nutrition plan tailored to you.',
    ic: 'RefreshCw' },
  { n: '4', t: 'Stay on Track', s: 'Reviewed & refreshed every quarter.',
    ic: 'TrendingUp' }];

  return (
    <div className="sec" style={{ background: 'var(--paper-3)' }}>
      <SecHead kicker="How it works">One Doctor. One Team <em style={{ fontStyle: 'normal', fontWeight: 500 }}>
Better Health. All year</em></SecHead>
      <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 0 }}>
        {steps.map((st, i) => <React.Fragment key={st.n}>
            <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', textAlign: 'center' }}>
              <span style={{ position: 'relative', width: 50, height: 50, borderRadius: '50%', background: '#fff', boxShadow: 'var(--shadow-sm)', display: 'grid', placeItems: 'center', flexShrink: 0 }}>
                <Ic n={st.ic} size={25} color="var(--espresso)" stroke={1.9} />
                <span style={{ position: 'absolute', top: -4, right: -4, width: 20, height: 20, borderRadius: '50%', background: 'var(--brand)', color: '#fff',
                fontFamily: 'var(--font-display)', fontSize: 11, fontWeight: 700, display: 'grid', placeItems: 'center', border: '2px solid var(--paper-3)' }}>{st.n}</span>
              </span>
              <h3 style={{ fontSize: 18, marginTop: 13 }}>{st.t}</h3>
              <p style={{ color: 'var(--muted)', fontSize: 14, marginTop: 5, lineHeight: 1.45, maxWidth: 270 }}>{st.s}</p>
            </div>
            {i < steps.length - 1 && <span style={{ width: 2, height: 26, background: 'var(--line-2)', margin: '14px 0' }}></span>}
          </React.Fragment>
        )}
      </div>
    </div>);

}

/* ---------------- What's included (the plan / care model) ---------------- */
function Included() {
  const pairs = [
  { usual: 'You call a doctor only once something is already wrong', plan: 'A family doctor who knows you and guides your whole health journey' },
  { usual: 'A new face every visit who doesn’t know your history', plan: 'One care coordinator managing your labs, medicines & nutrition' },
  { usual: 'Tests, medicines & advice that never quite join up', plan: 'Care that improves your health, not just treats you when sick' }];

  const XMark = <Ic n="X" size={13} color="var(--muted)" stroke={3} />;
  const Check = <Ic n="Check" size={13} color="#fff" stroke={3} />;

  const [idx, setIdx] = useStateS(0);
  useEffectS(() => {
    const id = setInterval(() => setIdx((p) => (p + 1) % pairs.length), 2800);
    return () => clearInterval(id);
  }, []);

  return (
    <div className="sec" style={{ background: 'var(--paper-3)' }}>
      <div className="kicker-row" style={{ justifyContent: 'center' }}><span className="kicker-dot" style={{ background: 'var(--brand)' }}></span><span className="eyebrow" style={{ color: 'var(--brand)' }}>The Family Doctor Plan</span></div>
      <h2 style={{ color: 'var(--ink)', fontSize: 27, marginTop: 12, textAlign: 'center', lineHeight: 1.16 }}>Most care waits for you to fall sick. <em style={{ fontStyle: 'normal', fontWeight: 500 }}>Ours stays with you.</em></h2>
      <p style={{ color: 'var(--muted)', fontSize: 15, marginTop: 12, textAlign: 'center', maxWidth: 320, marginLeft: 'auto', marginRight: 'auto' }}>
        See the difference, point by point.
      </p>

      <div style={{ overflow: 'hidden', marginTop: 24, borderRadius: 20 }}>
        <div style={{ display: 'flex', transition: 'transform .6s cubic-bezier(.4,0,.2,1)', transform: `translateX(-${idx * 100}%)` }}>
          {pairs.map((p, i) =>
          <div key={i} style={{ flex: '0 0 100%', minWidth: '100%' }}>
              <div style={{ background: '#fff', border: '1px solid var(--line)', borderRadius: 20, overflow: 'hidden', position: 'relative' }}>
                {/* Healthcare as usual */}
                <div style={{ padding: '20px 18px 30px' }}>
                  <span className="eyebrow" style={{ fontSize: 10.5, color: 'var(--muted)' }}>Healthcare as usual</span>
                  <div style={{ display: 'flex', alignItems: 'flex-start', gap: 11, marginTop: 11 }}>
                    <span style={{ width: 24, height: 24, borderRadius: '50%', background: 'var(--paper-3)', display: 'grid', placeItems: 'center', flexShrink: 0, marginTop: 1 }}>{XMark}</span>
                    <span style={{ fontSize: 16, color: 'var(--ink-2)', lineHeight: 1.4, fontWeight: 500 }}>{p.usual}</span>
                  </div>
                </div>

                {/* connector arrow — sits on the seam between the two halves */}
                <div style={{ position: 'relative', height: 0, zIndex: 2 }}>
                  <div style={{ position: 'absolute', left: '50%', top: 0, transform: 'translate(-50%,-50%)', width: 38, height: 38, borderRadius: '50%', background: '#fff', display: 'grid', placeItems: 'center', boxShadow: '0 4px 12px rgba(40,30,20,.16), 0 0 0 1px var(--line)' }}>
                    <Ic n="ArrowDown" size={18} color="var(--espresso)" stroke={2.4} />
                  </div>
                </div>

                {/* With a Family Doctor Plan */}
                <div style={{ background: 'var(--blue)', padding: '30px 18px 22px' }}>
                  <span className="eyebrow" style={{ fontSize: 10.5, color: 'rgba(255,255,255,.85)' }}>With a Family Doctor Plan</span>
                  <div style={{ display: 'flex', alignItems: 'flex-start', gap: 11, marginTop: 11 }}>
                    <span style={{ width: 24, height: 24, borderRadius: '50%', background: 'var(--brand)', display: 'grid', placeItems: 'center', flexShrink: 0, marginTop: 1 }}>{Check}</span>
                    <span style={{ fontSize: 16, color: '#fff', lineHeight: 1.4, fontWeight: 600 }}>{p.plan}</span>
                  </div>
                </div>
              </div>
            </div>
          )}
        </div>
      </div>

      <div style={{ display: 'flex', gap: 7, justifyContent: 'center', marginTop: 18 }}>
        {pairs.map((_, i) =>
        <button key={i} onClick={() => setIdx(i)} aria-label={`Show comparison ${i + 1}`}
        style={{ width: i === idx ? 22 : 7, height: 7, borderRadius: 999, border: 'none', cursor: 'pointer', padding: 0,
          background: i === idx ? 'var(--blue)' : 'rgba(60,40,20,.18)', transition: 'width .3s, background .3s' }}></button>
        )}
      </div>
    </div>);

}

/* ---------------- Care team showcase (auto-rotating) ---------------- */
function CareGoal() {
  const cards = [
  { t: 'Your Family Doctor Visits You', s: 'Understands your health, reviews your history and creates your personal health baseline.',
    photoId: 'plan-doctor', photoPh: 'Your family doctor on a home visit', photoSrc: 'app/images/plan-doctor.png?v=2',
    ic: 'User' },
  { t: 'A Plan Built Around You', s: 'Your reports are reviewed together to create a personalised health and nutrition plan.',
    photoId: 'plan-reports', photoPh: 'Reviewing reports together', photoSrc: 'app/images/plan-reports.png?v=2',
    ic: 'FileText' },
  { t: 'Health That Improves Over Time', s: 'Ongoing support to help you stay on track and improve month after month.',
    photoId: 'plan-progress', photoPh: 'Tracking progress over the year', photoSrc: 'app/images/plan-progress.png?v=2',
    ic: 'TrendingUp' }];

  const [idx, setIdx] = useStateS(0);
  const [anim, setAnim] = useStateS(true);
  const [nonce, setNonce] = useStateS(0);
  const slides = [...cards, cards[0]];
  const startX = React.useRef(null);

  useEffectS(() => {
    const id = setInterval(() => {setAnim(true);setIdx((p) => p + 1);}, 4000);
    return () => clearInterval(id);
  }, [nonce]);

  useEffectS(() => {
    if (idx === cards.length) {
      const t = setTimeout(() => {setAnim(false);setIdx(0);}, 650);
      return () => clearTimeout(t);
    }
    if (!anim) {
      const r = requestAnimationFrame(() => setAnim(true));
      return () => cancelAnimationFrame(r);
    }
  }, [idx]);

  const goNext = () => {setNonce((n) => n + 1);setAnim(true);setIdx((p) => p + 1);};
  const goPrev = () => {
    setNonce((n) => n + 1);
    if (idx <= 0) {
      setAnim(false);
      setIdx(cards.length);
      requestAnimationFrame(() => {setAnim(true);setIdx(cards.length - 1);});
    } else {
      setAnim(true);
      setIdx(idx - 1);
    }
  };
  const onDown = (e) => {startX.current = e.touches ? e.touches[0].clientX : e.clientX;};
  const onUp = (e) => {
    if (startX.current == null) return;
    const endX = e.changedTouches ? e.changedTouches[0].clientX : e.clientX;
    const dx = endX - startX.current;
    startX.current = null;
    if (dx < -40) goNext();else
    if (dx > 40) goPrev();
  };

  const dot = idx % cards.length;

  return (
    <div className="sec" style={{ background: 'var(--paper-3)' }}>
      <SecHead kicker="The Family Doctor Plan">An entire care team. <em style={{ fontStyle: 'normal', fontWeight: 500 }}>One shared goal:</em> improve your health.</SecHead>

      <div style={{ overflow: 'hidden', margin: '4px -22px 0', touchAction: 'pan-y', cursor: 'grab' }}
      onTouchStart={onDown} onTouchEnd={onUp} onMouseDown={onDown} onMouseUp={onUp}>
        <div style={{ display: 'flex', alignItems: 'stretch', transition: anim ? 'transform .6s cubic-bezier(.4,0,.2,1)' : 'none', transform: `translateX(-${idx * 100}%)` }}>
          {slides.map((c, i) =>
          <div key={i} style={{ flex: '0 0 100%', minWidth: '100%', display: 'flex', padding: '0 22px' }}>
              <div style={{ width: '100%', background: '#fff', border: '1px solid var(--line)', borderRadius: 22, overflow: 'hidden', boxShadow: 'var(--shadow-sm)', display: 'flex', flexDirection: 'column' }}>
                <div style={{ position: 'relative', flexShrink: 0 }}>
                  <image-slot id={c.photoId} shape="rect" fit="cover" placeholder={c.photoPh} src={c.photoSrc || undefined}
                style={{ width: '100%', height: 210 }}></image-slot>
                  <span style={{ position: 'absolute', top: 12, left: 12, width: 42, height: 42, borderRadius: 13, background: 'rgba(255,255,255,.94)', backdropFilter: 'blur(4px)', display: 'grid', placeItems: 'center', boxShadow: 'var(--shadow-sm)' }}>
                    <Ic n={c.ic} size={22} color="var(--espresso)" stroke={1.9} />
                  </span>
                  <span style={{ position: 'absolute', top: 14, right: 14, width: 26, height: 26, borderRadius: '50%', background: 'var(--brand)', color: '#fff', fontFamily: 'var(--font-display)', fontSize: 13, fontWeight: 700, display: 'grid', placeItems: 'center' }}>{i % cards.length + 1}</span>
                </div>
                <div style={{ padding: '20px 20px 22px', flex: 1, display: 'flex', flexDirection: 'column' }}>
                  <h3 style={{ fontSize: 21, color: 'var(--ink)', lineHeight: 1.2 }}>{c.t}</h3>
                  <p style={{ fontSize: 14.5, color: 'var(--muted)', marginTop: 9, lineHeight: 1.5 }}>{c.s}</p>
                </div>
              </div>
            </div>
          )}
        </div>
      </div>

      <div style={{ display: 'flex', gap: 7, justifyContent: 'center', marginTop: 18 }}>
        {cards.map((_, i) =>
        <button key={i} onClick={() => {setAnim(true);setIdx(i);}} aria-label={`Show card ${i + 1}`}
        style={{ width: i === dot ? 22 : 7, height: 7, borderRadius: 999, border: 'none', cursor: 'pointer', padding: 0,
          background: i === dot ? 'var(--blue)' : 'var(--line-2)', transition: 'width .3s, background .3s' }}></button>
        )}
      </div>
    </div>);

}

/* ---------------- Lab tests band ---------------- */
function LabBand() {
  const services = [
  { t: 'Medicines delivered', d: 'Prescriptions to your door, same day', icon: 'Pill' },
  { t: 'Lab tests at home', d: 'NABL-accredited, reports on WhatsApp', icon: 'FlaskConical' },
  { t: 'Physiotherapy', d: 'Guided recovery sessions, in your room', icon: 'PersonStanding' },
  { t: 'ECG at home', d: 'Resting & 12-lead, read by your doctor', icon: 'HeartPulse' }];

  return (
    <div className="sec" style={{ background: 'var(--paper)' }}>
      <SecHead kicker="Care that comes home">More than <em style={{ fontStyle: 'normal', fontWeight: 500 }}>a doctor.</em></SecHead>
      <p style={{ color: 'var(--muted)', fontSize: 13, marginTop: -6, marginBottom: 18, textAlign: 'center' }}>Four services, all at your doorstep.</p>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12 }}>
        {services.map((s) =>
        <div key={s.t} style={{ background: '#fff', border: '1px solid var(--line)', borderRadius: 20, padding: '18px 16px',
          boxShadow: 'var(--shadow-sm)', display: 'flex', flexDirection: 'column', gap: 10 }}>
            <span style={{ width: 46, height: 46, borderRadius: 14, background: 'rgba(39,26,17,.09)', display: 'grid', placeItems: 'center', flexShrink: 0 }}>
              <Ic n={s.icon} size={24} color="var(--espresso)" stroke={1.9} />
            </span>
            <div>
              <h4 style={{ fontSize: 15.5, fontWeight: 700, color: 'var(--ink)', lineHeight: 1.2 }}>{s.t}</h4>
              <p style={{ fontSize: 12.5, color: 'var(--muted)', marginTop: 5, lineHeight: 1.4 }}>{s.d}</p>
            </div>
          </div>
        )}
      </div>
    </div>);

}

/* ---------------- Stories (testimonials + real home visit MERGED) ---------------- */
function GoogleG({ s = 30 }) {
  return (
    <svg width={s} height={s} viewBox="0 0 48 48" aria-label="Google">
      <path fill="#4285F4" d="M45.1 24.5c0-1.6-.1-3.1-.4-4.5H24v8.5h11.8c-.5 2.7-2 5-4.4 6.6v5.5h7.1c4.1-3.8 6.6-9.4 6.6-16.1z" />
      <path fill="#34A853" d="M24 46c5.9 0 10.9-2 14.5-5.3l-7.1-5.5c-2 1.3-4.5 2.1-7.4 2.1-5.7 0-10.5-3.8-12.2-9H4.5v5.7C8.1 41.3 15.5 46 24 46z" />
      <path fill="#FBBC05" d="M11.8 28.3c-.4-1.3-.7-2.7-.7-4.3s.3-3 .7-4.3v-5.7H4.5C2.9 17.2 2 20.5 2 24s.9 6.8 2.5 9.7l7.3-5.4z" />
      <path fill="#EA4335" d="M24 10.7c3.2 0 6.1 1.1 8.4 3.3l6.3-6.3C34.9 4.1 29.9 2 24 2 15.5 2 8.1 6.7 4.5 14.3l7.3 5.7c1.7-5.2 6.5-9.3 12.2-9.3z" />
    </svg>);

}

function Stars({ n = 5, size = 13 }) {
  return (
    <span style={{ display: 'inline-flex', gap: 2 }}>
      {Array.from({ length: n }).map((_, i) =>
      <Ic key={i} n="Star" size={size} color="#F4B400" fill="#F4B400" stroke={1.5} />
      )}
    </span>);

}

function Stories() {
  return (
    <div className="sec" style={{ paddingBottom: 8 }}>
      {/* Google reviews banner */}
      <div style={{ background: '#fff', border: '1px solid var(--line)', borderRadius: 20, padding: '15px 16px', display: 'flex', alignItems: 'center', gap: 14, flexWrap: 'wrap', boxShadow: 'var(--shadow-sm)' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 11, flex: '1 1 auto', minWidth: 0 }}>
          <GoogleG s={30} />
          <div style={{ minWidth: 0 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
              <span style={{ fontFamily: 'var(--font-display)', fontSize: 24, fontWeight: 700, color: 'var(--ink)', lineHeight: 1 }}>4.7</span>
              <Stars n={5} size={13} />
            </div>
            <p style={{ fontSize: 12.5, color: 'var(--muted)', marginTop: 3 }}>Across our Delhi NCR clinics</p>
          </div>
        </div>
        <div style={{ display: 'flex', gap: 9, flex: '1 1 100%', width: '100%' }}>
          {[{ c: 'New Delhi', r: '4.9', n: '2.5k' }, { c: 'Gurgaon', r: '4.5', n: '1k' }].map((g) =>
          <div key={g.c} style={{ flex: '1 1 0', background: '#fff', borderRadius: 13, padding: '9px 12px', boxShadow: 'var(--shadow-sm)' }}>
              <div style={{ fontSize: 13, fontWeight: 700, color: 'var(--blue)' }}>{g.c}</div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 5, marginTop: 4 }}>
                <Ic n="Star" size={13} color="#F4B400" fill="#F4B400" stroke={1.5} />
                <span style={{ fontSize: 12.5, color: 'var(--ink-2)', fontWeight: 500 }}>{g.r} · {g.n} reviews</span>
              </div>
            </div>
          )}
        </div>
      </div>
    </div>);

}

/* ---------------- Pricing ---------------- */
function Pricing() {
  const [openIdx, setOpenIdx] = useStateS(1);
  const FP = {
    doctor: 'User',
    coord: 'Headset',
    lab: 'FlaskConical',
    nutri: 'Leaf',
    chat: 'MessageCircle',
    plan: 'FileText',
    home: 'House',
    progress: 'TrendingUp',
    shield: 'ShieldCheck' };

  const plans = [
  { name: 'First Check', short: 'First Check', priceShort: '₹2,999', sub: 'Know where you stand.', price: '2,999', unit: 'one-time', billed: null, save: null, headBg: '#E9F1F8',
    head: FP.lab, tag: 'One-time', dark: false,
    feats: [
    { ic: FP.doctor, t: 'Home visit by your family doctor' },
    { ic: FP.plan, t: 'Comprehensive health assessment' },
    { ic: FP.lab, t: 'At-home lab collection' },
    { ic: FP.plan, t: 'Report review & explanation' },
    { ic: FP.nutri, t: 'Personalised health recommendations' },
    { ic: FP.chat, t: '2 weeks WhatsApp follow-up' }],
    bestFor: 'First-time users',
    cta: 'Choose First Check' },
  { name: '6-Month Care', short: '6-Month', priceShort: '₹2,199/mo', sub: 'Get a condition under control.', price: '2,199', unit: '/month per person', billed: '₹13,194 billed every 6 months', save: 'Save ₹3,000', headBg: 'rgba(120,52,4,.16)',
    head: 'Activity', tag: 'Most popular', dark: true,
    feats: [
    { ic: FP.doctor, t: 'Dedicated Family Doctor' },
    { ic: FP.home, t: '2 Doctor Home Visits' },
    { ic: FP.nutri, t: '2 Nutritionist Consultations' },
    { ic: FP.lab, t: '2 Diagnostic Reviews' },
    { ic: FP.coord, t: 'Care Coordinator Support' },
    { ic: FP.chat, t: 'WhatsApp Access to Care Team' },
    { ic: FP.progress, t: 'Progress Tracking & Goal Reviews' }],
    bestFor: 'Managing conditions like Diabetes, BP, Thyroid, Cholesterol & Weight',
    cta: 'Choose 6-Month Care' },
  { name: 'Year-Round Care', short: 'Year-Round', priceShort: '₹1,799/mo', sub: 'Total peace of mind, all year.', price: '1,799', unit: '/month per person', billed: '₹21,588 billed annually', save: 'Save ₹4,800 vs 6-month plan', headBg: '#E9F1F8',
    head: 'ShieldCheck', tag: 'Best value', dark: false,
    feats: [
    { ic: FP.doctor, t: 'Dedicated Family Doctor' },
    { ic: FP.home, t: '4 Quarterly Home Visits' },
    { ic: FP.nutri, t: '4 Nutrition Reviews' },
    { ic: FP.lab, t: '4 Lab Collections & Health Reviews' },
    { ic: FP.coord, t: 'Dedicated Care Coordinator' },
    { ic: FP.chat, t: 'Priority WhatsApp Support' },
    { ic: FP.progress, t: 'Ongoing Goal Tracking' },
    { ic: FP.shield, t: 'Preventive Health Planning' }],
    bestFor: 'Couples & families seeking long-term health management',
    cta: 'Choose Year-Round Care' }];

  const includes = [
  { ic: FP.doctor, t: 'Your own family doctor' },
  { ic: FP.coord, t: 'A care coordinator' },
  { ic: FP.lab, t: 'Labs, pharmacy & nutrition' },
  { ic: 'ShieldCheck', t: 'Backed by Dr. Morepen' }];

  return (
    <div className="sec">
      <SecHead kicker="Simple, honest plans" align="center">Care plans for <em style={{ fontStyle: 'normal', fontWeight: 500 }}>every stage.</em></SecHead>

      <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
        {plans.map((p, i) => {
          const open = openIdx === i;
          const ink = p.dark ? '#fff' : 'var(--ink)';
          const sub = p.dark ? 'rgba(255,255,255,.72)' : 'var(--muted)';
          return (
            <div key={p.name} style={{ position: 'relative', borderRadius: 22, overflow: 'hidden',
              background: p.dark ? 'var(--hero-grad)' : '#fff',
              border: p.dark ? 'none' : '2px solid rgba(14,90,160,.18)',
              boxShadow: p.dark && open ? 'var(--shadow-lg)' : 'var(--shadow-sm)' }}>

              {/* collapsed header — always visible, toggles open */}
              <button onClick={() => setOpenIdx(open ? -1 : i)} aria-expanded={open} style={{ position: 'relative', width: '100%', border: 'none', cursor: 'pointer', textAlign: 'left',
                background: p.headBg || 'transparent', padding: '16px 16px', display: 'flex', alignItems: 'center', gap: 13 }}>
                <span style={{ width: 42, height: 42, borderRadius: 12, background: p.dark ? 'rgba(255,255,255,.16)' : 'rgba(39,26,17,.09)', display: 'grid', placeItems: 'center', flexShrink: 0 }}>
                  <Ic n={p.head} size={22} color={p.dark ? '#fff' : 'var(--espresso)'} stroke={1.9} />
                </span>

                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '4px 8px' }}>
                    <h3 style={{ fontSize: 'clamp(15px, 4.5vw, 18px)', color: ink, lineHeight: 1.1, whiteSpace: 'nowrap' }}>{p.name}</h3>
                    <span style={{ fontSize: 9, fontWeight: 700, letterSpacing: '.07em', textTransform: 'uppercase', padding: '4px 8px', borderRadius: 999, whiteSpace: 'nowrap', flexShrink: 0,
                      background: p.dark ? '#fff' : 'rgba(14,90,160,.10)', color: p.dark ? 'var(--brand-deep)' : 'var(--blue)' }}>{p.tag}</span>
                  </div>
                  <div style={{ marginTop: 4, paddingRight: 36 }}>
                    <div style={{ display: 'flex', alignItems: 'baseline', gap: 4 }}>
                      <span style={{ fontFamily: 'var(--font-display)', fontSize: 24, fontWeight: 700, lineHeight: 1, color: ink }}>₹{p.price}</span>
                      <span style={{ fontSize: 12.5, color: sub, whiteSpace: 'nowrap' }}>{p.unit}</span>
                    </div>
                    {p.save && <span style={{ display: 'block', fontSize: 11.5, fontWeight: 700, marginTop: 3, color: p.dark ? '#fff' : 'var(--whatsapp)' }}>{p.save}</span>}
                  </div>
                </div>

                {/* chevron — hinged to bottom-right */}
                <span style={{ position: 'absolute', right: 14, bottom: 14, width: 28, height: 28, borderRadius: '50%', display: 'grid', placeItems: 'center',
                  background: p.dark ? 'rgba(255,255,255,.18)' : 'rgba(14,90,160,.12)', transform: open ? 'rotate(180deg)' : 'rotate(0)', transition: 'transform .3s ease' }}>
                  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke={p.dark ? '#fff' : 'var(--blue)'} strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M6 9l6 6 6-6" /></svg>
                </span>
              </button>

              {/* expandable detail */}
              <div style={{ maxHeight: open ? 760 : 0, overflow: 'hidden', transition: 'max-height .42s cubic-bezier(.4,0,.2,1)' }}>
                <div style={{ padding: '4px 18px 22px' }}>
                  {p.billed &&
                  <p style={{ fontSize: 12.5, fontWeight: 500, color: sub, marginBottom: 14 }}>{p.billed}</p>
                  }
                  <p style={{ fontSize: 13.5, color: sub, marginBottom: 16 }}>{p.sub}</p>

                  <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
                    {p.feats.map((f) =>
                    <div key={f.t} style={{ display: 'flex', gap: 11, alignItems: 'flex-start' }}>
                        <Ic n={f.ic} size={19} color={p.dark ? 'rgba(255,255,255,.92)' : 'var(--espresso)'} stroke={1.8} style={{ flexShrink: 0, marginTop: 1 }} />
                        <span style={{ fontSize: 14, color: p.dark ? 'rgba(255,255,255,.92)' : 'var(--ink-2)', lineHeight: 1.38 }}>{f.t}</span>
                      </div>
                    )}
                  </div>

                  <div style={{ display: 'flex', alignItems: 'flex-start', gap: 9, margin: '16px 0', padding: '12px 14px', borderRadius: 14,
                    background: p.dark ? 'rgba(255,255,255,.12)' : 'var(--paper-3)' }}>
                    <Ic n="Users" size={18} color={p.dark ? '#fff' : 'var(--espresso)'} stroke={1.9} style={{ flexShrink: 0, marginTop: 1 }} />
                    <span style={{ fontSize: 13, lineHeight: 1.4, color: p.dark ? 'rgba(255,255,255,.92)' : 'var(--ink-2)' }}><b style={{ color: ink }}>Best for:</b> {p.bestFor}</span>
                  </div>

                  <a className={p.dark ? 'btn btn-light' : 'btn btn-primary'} href="https://wa.me/919220406222?text=Hi%20I%20want%20to%20know%20more%20about%20Dr%20Morepen%20Home%20Services" target="_blank" rel="noopener noreferrer" style={{ width: '100%' }}>
                    {p.cta} <span aria-hidden="true">→</span>
                  </a>
                </div>
              </div>
            </div>);

        })}
      </div>

      {/* every plan includes — auto-scroll strip */}
      <div style={{ marginTop: 22, background: '#fff', border: '1px solid var(--line)', borderRadius: 999, padding: '13px 16px', display: 'flex', alignItems: 'center', gap: 14, boxShadow: 'var(--shadow-sm)' }}>
        <span style={{ fontSize: 12.5, fontWeight: 700, color: 'var(--ink)', whiteSpace: 'nowrap', flexShrink: 0 }}>Every plan includes</span>
        <div className="marquee-mask" style={{ overflow: 'hidden', flex: 1 }}>
          <div className="marquee-track" style={{ gap: 0 }}>
            {[...includes, ...includes].map((it, i) =>
            <span key={i} style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '0 18px', whiteSpace: 'nowrap' }}>
                <Ic n={it.ic} size={17} color="var(--espresso)" stroke={1.9} style={{ flexShrink: 0 }} />
                <span style={{ fontSize: 13, color: 'var(--ink-2)', fontWeight: 500 }}>{it.t}</span>
              </span>
            )}
          </div>
        </div>
      </div>
      <p style={{ textAlign: 'center', fontSize: 12.5, color: 'var(--muted)', marginTop: 16 }}>Cancel anytime · First home visit free on every plan</p>
    </div>);

}

/* ---------------- Care team ---------------- */
function CareTeam() {
  const team = [
  { id: 'team1', n: 'Dr. Archit', r: 'Family Doctor', src: 'app/images/team-doctor-2.png' },
  { id: 'team2', n: 'Dr. Mansi', r: 'Nutrionist', src: 'app/images/team-nutritionist-2.png' },
  { id: 'team3', n: 'Khushboo', r: 'Home-Care Nurse', src: 'app/images/team-nurse-2.png' },
  { id: 'team4', n: 'Ashutosh', r: 'Care Coordinator', src: 'app/images/team-coordinator-2.png' }];

  return (
    <div className="sec" style={{ background: 'var(--paper)' }}>
      <SecHead kicker="Meet your care team">Real people. <em style={{ fontStyle: 'normal', fontWeight: 500 }}>The same faces.</em></SecHead>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
        {team.map((m) =>
        <div key={m.id} style={{ textAlign: 'center' }}>
            <image-slot id={m.id} shape="circle" placeholder="Add photo" src={m.src}
          style={{ width: 108, height: 108, borderRadius: '50%', margin: '0 auto', boxShadow: 'var(--shadow-sm)' }}></image-slot>
            <h3 style={{ fontSize: 16, marginTop: 11 }}>{m.n}</h3>
            <p style={{ fontSize: 12.5, color: 'var(--muted)', marginTop: 2 }}>{m.r}</p>
          </div>
        )}
      </div>
      <CareKit />
    </div>);

}

/* ---------------- Coverage ---------------- */
function Coverage() {
  const areas = ['South Delhi', 'Gurgaon', 'Noida', 'Dwarka', 'Greater Noida', 'Ghaziabad', 'Faridabad', 'West Delhi'];
  return (
    <div className="sec-tight" style={{ background: 'var(--paper-3)' }}>
      <div className="kicker-row" style={{ justifyContent: 'center' }}><span className="kicker-dot"></span><span className="eyebrow" style={{ color: 'var(--brand)' }}>Where we visit</span></div>
      <h2 style={{ fontSize: 24, marginTop: 11, textAlign: 'center' }}>Home visits across <em style={{ fontStyle: 'normal', fontWeight: 500 }}>Delhi NCR</em></h2>
      <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginTop: 16, justifyContent: 'center' }}>
        {areas.map((a) =>
        <span key={a} style={{ display: 'inline-flex', alignItems: 'center', gap: 6, background: '#fff',
          border: '1px solid var(--line)', borderRadius: 999, padding: '8px 13px', fontSize: 13, color: 'var(--ink-2)', fontWeight: 500 }}>
            <Ic n="MapPin" size={13} color="var(--espresso)" stroke={2.2} />{a}
          </span>
        )}
      </div>
      <p style={{ fontSize: 13, color: 'var(--muted)', marginTop: 14, textAlign: 'center' }}>Not sure if we reach you? <a href="https://wa.me/919220406222?text=Hi%20I%20want%20to%20know%20more%20about%20Dr%20Morepen%20Home%20Services" target="_blank" rel="noopener noreferrer" style={{ color: 'var(--brand)', fontWeight: 700, textDecoration: 'none' }}>Ask on WhatsApp</a> <br />we're expanding fast.</p>
    </div>);

}

/* ---------------- FAQ ---------------- */
function FAQ() {
  const [open, setOpen] = useStateS(0);
  const qs = [
  { q: 'Is the same doctor every time?', a: 'Yes. You get one named family doctor and care team who keep your full history. No re-explaining at each visit.' },
  { q: 'How fast do you reply on WhatsApp?', a: 'A real person responds in about 12 minutes during the day, and we run a night line for urgent worries.' },
  { q: 'Are lab tests really done at home?', a: 'Blood is drawn at your home by our nurse and processed at NABL-accredited labs. Reports come to WhatsApp and your doctor explains them.' },
  { q: 'Can one plan cover both my parents?', a: 'The Family plan covers up to 4 members of one household, ideal for both parents, or parents and a grandparent.' },
  { q: 'What if I live in another city?', a: 'Many of our members arrange care for parents from afar. You stay in the loop on WhatsApp and we handle everything on the ground.' }];

  return (
    <div className="sec" style={{ background: 'var(--paper)' }}>
      <SecHead kicker="Questions, answered">Good <em style={{ fontStyle: 'normal', fontWeight: 500 }}>to know.</em></SecHead>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
        {qs.map((item, i) => {
          const isOpen = open === i;
          return (
            <div key={item.q} style={{ background: '#fff', border: '1px solid var(--line)', borderRadius: 15, overflow: 'hidden' }}>
              <button onClick={() => setOpen(isOpen ? -1 : i)} style={{ width: '100%', background: 'none', border: 'none',
                cursor: 'pointer', display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12,
                padding: '15px 16px', textAlign: 'left', fontFamily: 'var(--font-sans)' }}>
                <span style={{ fontSize: 15, fontWeight: 600, color: 'var(--ink)' }}>{item.q}</span>
                <span style={{ display: 'grid', placeItems: 'center', flexShrink: 0, transform: isOpen ? 'rotate(45deg)' : 'none', transition: 'transform .2s' }}><Ic n="Plus" size={20} color="var(--brand)" stroke={2.4} /></span>
              </button>
              {isOpen && <p style={{ padding: '0 16px 16px', fontSize: 14, color: 'var(--muted)', lineHeight: 1.5 }}>{item.a}</p>}
            </div>);

        })}
      </div>
    </div>);

}

/* ---------------- Final CTA + footer ---------------- */
function FinalCTA() {
  return (
    <div style={{ background: 'linear-gradient(157deg, #2A86CE 0%, #0E5AA0 52%, #0A467F 100%)', color: '#fff', padding: '48px 24px 42px', textAlign: 'center', position: 'relative', overflow: 'hidden' }}>
      <div style={{ position: 'relative', zIndex: 1 }}>
      <span className="eyebrow" style={{ color: 'rgba(255,255,255,.9)' }}>Your family doctor, at home</span>
      <h2 style={{ color: '#fff', fontSize: 'clamp(24px, 7.5vw, 32px)', marginTop: 10 }}>Give your family one doctor who <em style={{ fontStyle: 'italic', fontWeight: 500 }}>never forgets them.</em></h2>
      <p style={{ color: 'rgba(255,255,255,.92)', fontSize: 15, marginTop: 14, maxWidth: 320, marginInline: 'auto' }}>Start with a free first home visit. Tell us what's worrying you  and we'll take it from there.

        </p>
      <a className="btn btn-light" href="https://wa.me/919220406222?text=Hi%20I%20want%20to%20know%20more%20about%20Dr%20Morepen%20Home%20Services" target="_blank" rel="noopener noreferrer" style={{ width: '100%', marginTop: 24, color: 'var(--blue)' }}><WA c="var(--blue)" /> Message us on WhatsApp</a>
      <p style={{ fontSize: 12.5, color: 'rgba(255,255,255,.85)', marginTop: 14 }}>or call <b>+91 95700 09000 </b> · 8:30am–10:30pm, every day</p>
      </div>
    </div>);

}

function Footer() {
  return (
    <div style={{ background: '#2E2E33', color: 'rgba(255,255,255,.62)', padding: '30px 24px 116px', fontSize: 12.5 }}>
      <div style={{ display: 'flex', alignItems: 'center', marginBottom: 14 }}>
        <img src="app/images/dmh-logo-white.png" alt="Dr. Morepen HOME" style={{ height: 40, width: 'auto', display: 'block' }} />
      </div>
      <p style={{ maxWidth: 300 }}>Trusted doctors at home, on WhatsApp, all year. Serving families across Gurgaon, Delhi &amp; NCR.</p>
      <p style={{ marginTop: 16, opacity: .7 }}>© 2026 Dr. Morepen Home · Privacy · Terms</p>
    </div>);

}

/* ---------------- Full page ---------------- */
const NAV = [
{ id: 'sec-plan', label: 'The Family Doctor Plan' },
{ id: 'sec-pricing', label: 'Plans & pricing' },
{ id: 'sec-how', label: 'How it works' },
{ id: 'sec-team', label: 'Meet your care team' },
{ id: 'sec-journeys', label: 'Real journeys' },
{ id: 'sec-videos', label: 'Watch & learn' },
{ id: 'sec-services', label: 'Services at home' },
{ id: 'sec-coverage', label: 'Where we visit' },
{ id: 'sec-faq', label: 'Questions, answered' }];

function FullPage() {
  const [scrolled, setScrolled] = useStateS(false);
  const [menuOpen, setMenuOpen] = useStateS(false);
  const scrollEl = React.useRef(null);
  const onScroll = (e) => {setScrolled(e.currentTarget.scrollTop > 24);};
  const goTo = (id) => {
    const c = scrollEl.current;const t = document.getElementById(id);
    if (c && t) {
      const top = t.getBoundingClientRect().top - c.getBoundingClientRect().top + c.scrollTop - 92;
      c.scrollTo({ top, behavior: 'smooth' });
    }
    setMenuOpen(false);
  };
  return (
    <div style={{ position: 'relative', width: 390, height: 844, overflow: 'hidden', background: 'var(--paper)' }}>
      {/* floating logo card — glassmorphic on scroll */}
      <div style={{ position: 'absolute', top: 10, left: 12, right: 12, zIndex: 50, borderRadius: 18,
        background: scrolled || menuOpen ? 'rgba(255,255,255,.6)' : '#fff',
        backdropFilter: scrolled || menuOpen ? 'blur(14px) saturate(160%)' : 'none', WebkitBackdropFilter: scrolled || menuOpen ? 'blur(14px) saturate(160%)' : 'none',
        border: `1px solid ${scrolled || menuOpen ? 'rgba(255,255,255,.55)' : 'var(--line)'}`,
        boxShadow: scrolled || menuOpen ? '0 10px 30px rgba(20,12,4,.16)' : 'var(--shadow-sm)',
        transition: 'background-color .4s ease, box-shadow .4s ease, border-color .4s ease' }}>
        <AppBar onMenu={() => setMenuOpen((v) => !v)} menuOpen={menuOpen} />
      </div>

      {/* top fade scrim — dissolves content as it scrolls under the menu */}
      <div aria-hidden="true" style={{ position: 'absolute', top: 0, left: 0, right: 0, height: 96, zIndex: 47, pointerEvents: 'none',
        background: 'linear-gradient(to bottom, var(--paper) 30%, rgba(236,231,221,0) 100%)',
        opacity: scrolled ? 1 : 0, transition: 'opacity .4s ease' }}></div>

      {/* tap-away catcher */}
      <div onClick={() => setMenuOpen(false)} style={{ position: 'absolute', inset: 0, zIndex: 48,
        opacity: menuOpen ? 1 : 0, pointerEvents: menuOpen ? 'auto' : 'none', transition: 'opacity .3s',
        background: 'rgba(20,12,4,.18)' }}></div>

      {/* glassmorphic dropdown nav */}
      <div style={{ position: 'absolute', top: 72, left: 12, right: 12, zIndex: 49, borderRadius: 20, overflow: 'hidden',
        background: 'rgba(255,255,255,.72)', backdropFilter: 'blur(18px) saturate(170%)', WebkitBackdropFilter: 'blur(18px) saturate(170%)',
        border: '1px solid rgba(255,255,255,.6)', boxShadow: '0 18px 40px rgba(20,12,4,.22)',
        transformOrigin: 'top center', transform: menuOpen ? 'translateY(0) scaleY(1)' : 'translateY(-10px) scaleY(.96)',
        opacity: menuOpen ? 1 : 0, pointerEvents: menuOpen ? 'auto' : 'none', transition: 'opacity .32s ease, transform .32s cubic-bezier(.4,0,.2,1)' }}>
        <nav style={{ padding: '8px 8px 6px' }}>
          {NAV.map((n) =>
          <button key={n.id} onClick={() => goTo(n.id)}
          style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%', border: 'none', background: 'transparent', cursor: 'pointer',
            padding: '12px 14px', borderRadius: 12, fontFamily: 'inherit', fontSize: 15, fontWeight: 600, color: 'var(--ink)', textAlign: 'left' }}>
              {n.label}
              <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--muted)" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M9 6l6 6-6 6" /></svg>
            </button>
          )}
        </nav>
        <div style={{ padding: '4px 14px 16px' }}>
          <a className="btn btn-wa" href="https://wa.me/919220406222?text=Hi%20I%20want%20to%20know%20more%20about%20Dr%20Morepen%20Home%20Services" target="_blank" rel="noopener noreferrer" onClick={() => setMenuOpen(false)} style={{ width: '100%' }}><WA s={20} /> Message us on WhatsApp</a>
        </div>
      </div>

      <div ref={scrollEl} onScroll={onScroll} style={{ position: 'absolute', inset: 0, overflowY: 'auto', WebkitOverflowScrolling: 'touch', paddingTop: 84 }}>
        <div className="screen" style={{ height: 'auto', paddingBottom: 0 }}>
          <HeroWhatsApp hideBar />
          <div id="sec-plan"><CareGoal /></div>
          <div id="sec-pricing"><Pricing /></div>
          <div id="sec-how"><HowItWorks /></div>
          <div id="sec-team"><CareTeam /></div>
          <div id="sec-journeys"><Journeys /></div>
          <div id="sec-videos"><VideoReels /></div>
          <Stories />
          <div id="sec-services"><LabBand /></div>
          <div id="sec-coverage"><Coverage /></div>
          <div id="sec-faq"><FAQ /></div>
          <FinalCTA />
          <Footer />
        </div>
      </div>

      {/* soft blurred fade so the button stays legible over scrolling content */}
      <div aria-hidden="true" style={{ position: 'absolute', left: 0, right: 0, bottom: 0, height: 104, zIndex: 55, pointerEvents: 'none',
        WebkitMaskImage: 'linear-gradient(to top, #000 38%, transparent 100%)',
        maskImage: 'linear-gradient(to top, #000 38%, transparent 100%)',
        backdropFilter: 'blur(7px)', WebkitBackdropFilter: 'blur(7px)',
        background: 'linear-gradient(to top, var(--paper) 18%, rgba(250,246,241,.55) 60%, transparent 100%)' }}></div>

      {/* floating CTA row — WhatsApp button + call button */}
      <div style={{ position: 'absolute', left: 16, right: 16, bottom: 16, zIndex: 60, display: 'flex', gap: 10, alignItems: 'center' }}>
        <a className="btn" href="https://wa.me/919220406222?text=Hi%20I%20want%20to%20know%20more%20about%20Dr%20Morepen%20Home%20Services" target="_blank" rel="noopener noreferrer" aria-label="Message us on WhatsApp"
        style={{ flex: 1, padding: '15px 18px', fontSize: 16, gap: 9,
          background: scrolled ? 'var(--espresso)' : 'var(--blue-grad)', color: '#fff',
          boxShadow: scrolled ? '0 12px 26px rgba(39,26,17,.40), 0 2px 6px rgba(39,26,17,.30)' : '0 12px 26px rgba(14,90,160,.42), 0 2px 6px rgba(14,90,160,.30)',
          transition: 'background .45s ease, box-shadow .45s ease' }}>
          <WA s={20} /> Message us on WhatsApp
        </a>
        <a href="tel:+919570009000" aria-label="Call us on +91 95700 09000"
        style={{ flexShrink: 0, width: 54, height: 54, borderRadius: '50%', border: 'none', cursor: 'pointer', display: 'grid', placeItems: 'center', textDecoration: 'none',
          background: scrolled ? 'var(--blue-grad)' : 'var(--espresso)', color: '#fff',
          boxShadow: scrolled ? '0 12px 26px rgba(14,90,160,.42), 0 2px 6px rgba(14,90,160,.30)' : '0 12px 26px rgba(39,26,17,.40), 0 2px 6px rgba(39,26,17,.30)',
          transition: 'background .45s ease, box-shadow .45s ease' }}>
          <Ic n="Phone" size={22} color="#fff" stroke={2} />
        </a>
      </div>
    </div>);

}

Object.assign(window, { FullPage, SecHead, CareGoal, Pricing, HowItWorks, CareTeam, Stories, LabBand, Coverage, FAQ, FinalCTA, Footer });