// How it works, Pricing, For Families sections

function HowItWorks() {
  const steps = [
    { n: '01', title: 'Sign up', body: "Tell us your name, phone, the time you'd like the morning call, and whether you want family on the loop." },
    { n: '02', title: 'Try free for 7 days', body: 'Clara calls every morning for a week. No card, no setup fee, no commitment.' },
    { n: '03', title: 'Continue or stop, anytime', body: "Like it? Pick a plan. Don't? Just text STOP, or tell Clara on a call. No fuss." },
  ];
  return (
    <section className="section" id="how" style={{ background: 'var(--cream-200)' }}>
      <div className="container">
        <Reveal>
          <SectionHeader eyebrow="How it works" title="Three small steps. That's the whole thing." align="center" maxWidth={640} />
        </Reveal>
        <div className="steps-grid">
          {steps.map((s, i) => (
            <Reveal key={s.n} delay={i * 100}>
              <div className="step-card">
                <div className="step-num">{s.n}</div>
                <h3 style={{ marginTop: 28 }}>{s.title}</h3>
                <p style={{ marginTop: 14, color: 'var(--ink-700)', fontSize: 17, lineHeight: 1.5 }}>{s.body}</p>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
      <style>{`
        .steps-grid {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 24px;
          margin-top: 64px;
        }
        .step-card {
          background: var(--cream-100);
          border: 1px solid var(--cream-300);
          border-radius: var(--radius-lg);
          padding: 36px;
          height: 100%;
          position: relative;
          transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
        }
        .step-card:hover {
          transform: translateY(-6px) scale(1.02);
          box-shadow: 0 12px 40px oklch(from var(--accent) l c h / 0.15);
          border-color: var(--accent-soft);
        }
        .step-connector {
          position: absolute;
          top: 70px;
          right: -24px;
          width: 24px;
          height: 2px;
          background: linear-gradient(to right, var(--accent) 0%, var(--accent) 70%, transparent 100%);
          z-index: 1;
        }
        .step-connector::after {
          content: '→';
          position: absolute;
          right: -8px;
          top: -10px;
          font-size: 16px;
          color: var(--accent);
          animation: arrow-bounce 2s ease-in-out infinite;
        }
        @keyframes arrow-bounce {
          0%, 100% { transform: translateX(0); opacity: 1; }
          50% { transform: translateX(4px); opacity: 0.6; }
        }
        .step-num {
          font-family: var(--font-display);
          font-size: 36px;
          color: var(--accent-deep);
          font-variation-settings: 'opsz' 144, 'SOFT' 80;
        }
        @media (max-width: 820px) {
          .steps-grid { grid-template-columns: 1fr; }
          .step-connector { display: none; }
        }
      `}</style>
    </section>
  );
}

function Pricing({ onSignup, emphasizeStarter = true }) {
  const features = [
    'Daily morning check-in call',
    'Medication reminders',
    'Friendly chat & info lookup',
    'Family text alerts if no answer',
    'Crisis escalation to 911',
    'Cancel anytime',
  ];
  return (
    <section className="section" id="pricing">
      <div className="container">
        <Reveal>
          <SectionHeader eyebrow="Pricing" title="Simple pricing. Free first week." intro="No setup fees, no contracts, no surprise charges. The first seven days are on us — no card needed." align="center" maxWidth={640} />
        </Reveal>

        <div className="price-grid">
          <Reveal delay={80}>
            <div className={`price-card ${emphasizeStarter ? 'price-featured' : ''}`}>
              {emphasizeStarter && <div className="price-badge">Most folks pick this</div>}
              <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between' }}>
                <h3 style={{ fontSize: 26 }}>Starter</h3>
                <div className="price-time">30 min/day</div>
              </div>
              <div className="price-amount"><span className="price-num">$59</span><span className="price-per">/month</span></div>
              <p style={{ color: 'var(--ink-700)', fontSize: 16, lineHeight: 1.5, marginTop: 4 }}>
                Up to 30 minutes a day with Clara. The morning call, reminders, friendly chat, and info lookup. Most folks find this is plenty.
              </p>
              <ul className="price-list">
                {features.map((f, i) => (
                  <li key={i}><Icon.Check style={{ color: 'var(--accent)' }} /> {f}</li>
                ))}
              </ul>
              <button className="btn btn-primary price-cta" onClick={onSignup}>Start Free Trial</button>
              <p style={{ fontSize: 13, color: 'var(--ink-500)', marginTop: 14, textAlign: 'center' }}>Then $59/mo. Cancel anytime.</p>
            </div>
          </Reveal>

          <Reveal delay={160}>
            <div className={`price-card ${!emphasizeStarter ? 'price-featured' : ''}`}>
              <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between' }}>
                <h3 style={{ fontSize: 26 }}>Maximum</h3>
                <div className="price-time">60 min/day</div>
              </div>
              <div className="price-amount"><span className="price-num">$189</span><span className="price-per">/month</span></div>
              <p style={{ color: 'var(--ink-700)', fontSize: 16, lineHeight: 1.5, marginTop: 4 }}>
                Up to 60 minutes a day. Same Clara, more time together — for folks who want longer conversations and more company throughout the day.
              </p>
              <ul className="price-list">
                {features.map((f, i) => (
                  <li key={i}><Icon.Check style={{ color: 'var(--accent)' }} /> {f}</li>
                ))}
                <li><Icon.Check style={{ color: 'var(--accent)' }} /> Optional afternoon call</li>
              </ul>
              <button className="btn btn-secondary price-cta" onClick={onSignup}>Start Free Trial</button>
              <p style={{ fontSize: 13, color: 'var(--ink-500)', marginTop: 14, textAlign: 'center' }}>Then $189/mo. Cancel anytime.</p>
            </div>
          </Reveal>
        </div>

        <p style={{ textAlign: 'center', fontSize: 16, color: 'var(--ink-500)', marginTop: 32 }}>
          First 7 days free, no card needed. No setup fees. Cancel by text, voice, or phone.
        </p>
      </div>

      <style>{`
        .price-grid {
          display: grid;
          grid-template-columns: 1fr 1fr;
          gap: 24px;
          margin-top: 56px;
          max-width: 880px;
          margin-left: auto;
          margin-right: auto;
        }
        .price-card {
          position: relative;
          background: var(--cream-100);
          border: 1.5px solid var(--cream-300);
          border-radius: var(--radius-lg);
          padding: 40px 36px;
          transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
        }
        .price-card:hover {
          transform: translateY(-8px) scale(1.03);
          box-shadow: 0 16px 48px oklch(from var(--accent) l c h / 0.2);
          border-color: var(--accent);
        }
        .price-featured {
          border-color: var(--accent);
          box-shadow: 0 4px 12px oklch(from var(--accent) l c h / 0.12), 0 16px 40px oklch(from var(--accent) l c h / 0.18);
        }
        .price-badge {
          position: absolute;
          top: -12px;
          left: 36px;
          background: var(--accent);
          color: var(--accent-text);
          font-size: 13px;
          font-weight: 500;
          padding: 5px 14px;
          border-radius: 999px;
          letter-spacing: 0.02em;
        }
        .price-time {
          font-size: 13px;
          color: var(--ink-500);
          background: var(--cream-200);
          padding: 4px 12px;
          border-radius: 999px;
          letter-spacing: 0.04em;
          text-transform: uppercase;
        }
        .price-amount {
          margin-top: 18px;
          margin-bottom: 14px;
          display: flex;
          align-items: baseline;
          gap: 4px;
        }
        .price-num {
          font-family: var(--font-display);
          font-size: 64px;
          line-height: 1;
          letter-spacing: -0.03em;
          font-variation-settings: 'opsz' 144, 'SOFT' 80;
        }
        .price-per {
          color: var(--ink-500);
          font-size: 18px;
        }
        .price-list {
          list-style: none;
          padding: 0;
          margin: 26px 0 32px;
          display: flex;
          flex-direction: column;
          gap: 12px;
        }
        .price-list li {
          display: flex;
          align-items: center;
          gap: 12px;
          font-size: 16px;
          color: var(--ink-700);
        }
        .price-cta { width: 100%; }
        @media (max-width: 820px) {
          .price-grid { grid-template-columns: 1fr; }
        }
      `}</style>
    </section>
  );
}

function ForFamilies({ onSignup }) {
  const benefits = [
    'A daily SMS update with how the morning call went',
    "A text the moment your parent doesn't pick up",
    'Crisis alerts if Clara hears mention of a fall, chest pain, or distress',
    'Choose how much you want to be notified — daily, only-if-needed, or off',
  ];
  return (
    <section className="section" id="families" style={{ background: 'var(--accent-soft)' }}>
      <div className="container">
        <div className="fam-grid">
          <Reveal>
            <Photo
              label="three generations: adult son and wife, grandchildren around senior grandparents"
              ratio="5/4"
              tint="dusk"
              src="images/family-multigen.png"
              style={{ borderRadius: 'var(--radius-lg)', backgroundPosition: 'center center' }}
            />
          </Reveal>
          <Reveal delay={120}>
            <div>
              <div className="eyebrow">For families</div>
              <h2>Worried about your parents?</h2>
              <p style={{ marginTop: 22, fontSize: 19, color: 'var(--ink-700)', lineHeight: 1.55 }}>
                If your parent lives far, or alone, the not-knowing can be exhausting. Clara calls every morning — and texts you the moment she doesn't get an answer. You stay informed without hovering.
              </p>
              <ul className="fam-list">
                {benefits.map((b, i) => (
                  <li key={i}>
                    <Icon.Check style={{ color: 'var(--accent-deep)' }} />
                    <span>{b}</span>
                  </li>
                ))}
              </ul>
              <button className="btn btn-primary" style={{ marginTop: 32 }} onClick={onSignup}>
                Set up a trial for your parent <Icon.ArrowRight />
              </button>
            </div>
          </Reveal>
        </div>
      </div>
      <style>{`
        .fam-grid {
          display: grid;
          grid-template-columns: 1fr 1.1fr;
          gap: 80px;
          align-items: center;
        }
        .fam-list {
          list-style: none;
          padding: 0;
          margin: 28px 0 0;
          display: flex;
          flex-direction: column;
          gap: 14px;
        }
        .fam-list li {
          display: flex;
          align-items: flex-start;
          gap: 12px;
          font-size: 17px;
          line-height: 1.45;
          color: var(--ink-900);
        }
        .fam-list li svg { margin-top: 4px; flex-shrink: 0; }
        @media (max-width: 920px) {
          .fam-grid { grid-template-columns: 1fr; gap: 48px; }
        }
      `}</style>
    </section>
  );
}

Object.assign(window, { HowItWorks, Pricing, ForFamilies });
