/* pricing-personas.jsx — Sections 8 & 9 */

const ppStyles = `
  .pricing-grid {
    margin-top: 44px;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
    align-items: stretch;
  }
  @media (max-width: 980px) { .pricing-grid { grid-template-columns: 1fr; } }

  .tier {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    padding: 30px 28px 28px;
    display: flex; flex-direction: column; gap: 16px;
    position: relative;
    transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
  }
  .tier:hover { transform: translateY(-3px); border-color: var(--terracotta); box-shadow: 0 24px 60px -32px rgba(44,42,34,0.3); }
  .tier.featured {
    background: var(--ink); color: var(--cream); border-color: var(--ink);
    transform: translateY(-8px);
  }
  .tier.featured:hover { transform: translateY(-12px); }
  .tier.featured h3 { color: var(--cream); }
  .tier.featured .anchor { color: color-mix(in oklab, var(--cream) 65%, transparent); }
  .tier.featured .features li { color: color-mix(in oklab, var(--cream) 85%, transparent); }
  .tier.featured .features li::before { color: var(--terracotta-soft); }

  .tier-tag {
    position: absolute; top: -14px; left: 24px;
    padding: 5px 12px;
    background: var(--terracotta);
    color: #fff;
    border-radius: 999px;
    font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  }
  .tier h3 { font-size: 26px; font-weight: 500; }
  .tier .price {
    display: flex; align-items: baseline; gap: 8px;
    font-family: var(--font-head);
    margin-top: 6px;
  }
  .tier .price .num { font-size: 56px; font-weight: 300; line-height: 1; letter-spacing: -0.03em; }
  .tier .price .was { font-family: var(--font-head); font-size: 24px; font-weight: 300; color: var(--ink-soft); text-decoration: line-through; }
  .tier .price .per { color: var(--ink-soft); font-family: var(--font-body); font-size: 14px; font-weight: 400; }
  .tier.featured .price .per { color: color-mix(in oklab, var(--cream) 70%, transparent); }
  .tier .anchor {
    font-size: 13.5px; color: var(--ink-soft); font-style: italic;
    border-top: 1px solid var(--line); padding-top: 14px;
  }
  .tier.featured .anchor { border-top-color: rgba(255,255,255,0.12); }
  .tier .features { list-style: none; padding: 0; margin: 8px 0 4px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
  .tier .features li {
    padding-left: 22px; position: relative;
    color: var(--ink); font-size: 14.5px; line-height: 1.45;
  }
  .tier .features li::before {
    content: ""; position: absolute; left: 0; top: 7px;
    width: 12px; height: 7px;
    border-left: 1.5px solid var(--terracotta-deep);
    border-bottom: 1.5px solid var(--terracotta-deep);
    transform: rotate(-45deg);
  }
  .tier .cta {
    margin-top: 10px;
    width: 100%; justify-content: center;
  }
  .pricing-disclaimer {
    margin-top: 28px; text-align: center;
    color: var(--ink-soft); font-size: 13px; font-style: italic;
  }
  .price-label {
    margin-top: 48px;
    display: flex; align-items: center; gap: 16px;
    font-family: var(--font-body);
    font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--ink-soft);
  }
  .price-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
  .price-label + .pricing-grid { margin-top: 22px; }
  .pricing-grid.hw { grid-template-columns: repeat(2, 1fr); }
  @media (max-width: 980px) { .pricing-grid.hw { grid-template-columns: 1fr; } }

  /* Section 9 — Personas + B2B2C */
  .personas-grid {
    margin-top: 44px;
    display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px;
    align-items: stretch;
  }
  @media (max-width: 880px) { .personas-grid { grid-template-columns: 1fr; gap: 24px; } }

  .persona-list {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 36px 32px;
  }
  .persona-list h3 { font-size: 26px; line-height: 1.2; }
  .persona-list .who-list { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-direction: column; gap: 14px; }
  .persona-list .who-list li {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 14px;
    font-size: 15px;
    color: var(--ink);
  }
  .persona-list .who-list .av {
    width: 36px; height: 36px; border-radius: 50%;
    background: color-mix(in oklab, var(--terracotta-soft) 55%, var(--cream));
    color: var(--terracotta-deep);
    display: grid; place-items: center;
    flex-shrink: 0;
  }

  .b2b2c-card {
    background: linear-gradient(155deg, color-mix(in oklab, var(--terracotta-soft) 55%, var(--cream)) 0%, color-mix(in oklab, var(--cream-2) 55%, var(--cream)) 100%);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 36px 32px;
    display: flex; flex-direction: column; gap: 16px;
    position: relative;
    overflow: hidden;
  }
  .b2b2c-card .pin {
    align-self: flex-start;
    padding: 5px 12px; border-radius: 999px;
    background: var(--ink); color: var(--cream);
    font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
    white-space: nowrap;
  }
  .b2b2c-card h3 { font-size: 26px; line-height: 1.2; }
  .b2b2c-card p { font-size: 15.5px; color: var(--ink-soft); line-height: 1.55; }
  .b2b2c-card .pillar {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    margin-top: 4px;
  }
  .b2b2c-card .pillar div {
    background: rgba(255,255,255,0.5);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 13px;
    color: var(--ink);
  }
  .b2b2c-card .pillar div b { display: block; font-weight: 600; margin-bottom: 2px; }
`;

function PricingSection({ productName, selectedTier, setSelectedTier, scrollToSurvey }) {
  return (
    <section id="pricing" className="band-paper" data-screen-label="08 Pricing">
      <div className="wrap">
        <SectionHead
          eyebrow="Pricing · early access"
          title={<>Simple pricing.<br /><span style={{ fontStyle: 'italic', color: 'var(--terracotta-deep)' }}>Pay less than a false alarm.</span></>}
          lead={`Two parts: a camera, and a plan. Use a camera you already own, or add the ${productName} Cam. Cancel the plan any time.`}
        />

        <div className="price-label">First, the camera</div>
        <div className="pricing-grid hw">
          <div className="tier">
            <h3>Use an old phone</h3>
            <div className="price"><span className="num">$0</span><span className="per">no new hardware</span></div>
            <div className="anchor">Reuse a phone you already have at home.</div>
            <ul className="features">
              <li>Works with most recent iPhone &amp; Android models</li>
              <li>Check your model in the {productName} app first</li>
              <li>Mount it, plug it in, you're live</li>
              <li>Ready in a few minutes</li>
            </ul>
            <a href="#survey" className="btn ghost cta" onClick={() => scrollToSurvey && scrollToSurvey()}>Set up with my phone</a>
          </div>

          <div className="tier">
            <h3>{productName} Cam</h3>
            <div className="price"><span className="num" style={{ color: 'var(--terracotta)' }}>$299</span><span className="was">$359</span><span className="per">one-time</span></div>
            <div className="anchor">Optional. Built around {productName}.</div>
            <ul className="features">
              <li>Wide 2K lens, tuned for {productName}</li>
              <li>On-device processing built in</li>
              <li>One-cable setup, no hub</li>
              <li>Reserve now, pay when it ships</li>
            </ul>
            <a href="#survey" className="btn ghost cta" onClick={() => scrollToSurvey && scrollToSurvey()}>Reserve a {productName} Cam</a>
          </div>
        </div>

        <div className="price-label">Then, the plan</div>
        <div className="pricing-grid hw">
          <div className="tier featured" onMouseEnter={() => setSelectedTier && setSelectedTier('plus')}>
            <span className="tier-tag">Most popular</span>
            <h3>{productName}+</h3>
            <div className="price"><span className="num">$29</span><span className="per">/ month</span></div>
            <div className="anchor">Less than a dollar a day.</div>
            <ul className="features">
              <li>Live view + smart alerts</li>
              <li>Conversational rule setup</li>
              <li>30-day cloud archive</li>
              <li>Family sharing</li>
            </ul>
            <a href="#survey" className="btn accent cta" onClick={() => scrollToSurvey && scrollToSurvey({ tier: 'plus' })}>Request beta access <svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M3 7h8M7 3l4 4-4 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/></svg></a>
          </div>

          <div className="tier" onMouseEnter={() => setSelectedTier && setSelectedTier('pro')}>
            <h3>{productName} Pro</h3>
            <div className="price"><span className="num">$39</span><span className="per">/ month</span></div>
            <div className="anchor">For homes with a lot to keep an eye on.</div>
            <ul className="features">
              <li>Everything in {productName}+</li>
              <li>Up to 5 cameras</li>
              <li>Multi-camera spatial awareness</li>
              <li>90-day clip history</li>
            </ul>
            <a href="#survey" className="btn ghost cta" onClick={() => scrollToSurvey && scrollToSurvey({ tier: 'pro' })}>For serious setups</a>
          </div>
        </div>
        <div className="pricing-disclaimer">Final pricing may shift with early access feedback.<br />Beta members get <b style={{ color: 'var(--terracotta-deep)', fontStyle: 'normal' }}>50% off {productName}+ for the first year.</b></div>
      </div>
      <style dangerouslySetInnerHTML={{ __html: ppStyles }} />
    </section>
  );
}

function PersonasSection({ productName, openFamilyModal }) {
  return (
    <section id="personas" data-screen-label="09 Personas">
      <div className="wrap">
        <SectionHead
          eyebrow="Who Care is for"
          title={<>For people whose cameras<br /><span style={{ fontStyle: 'italic', color: 'var(--terracotta-deep)' }}>let them down.</span></>}
        />
        <div className="personas-grid">
          <Reveal className="persona-list">
            <h3>If any of these sounds like you, we built this for you.</h3>
            <ul className="who-list">
              <li>
                <span className="av"><svg width="18" height="18" viewBox="0 0 18 18" fill="none"><path d="M9 1l3 5 5 1-4 4 1 5-5-2-5 2 1-5-4-4 5-1z" stroke="currentColor" strokeWidth="1.4" strokeLinejoin="round"/></svg></span>
                Adult children watching over aging parents at home
              </li>
              <li>
                <span className="av"><svg width="18" height="18" viewBox="0 0 18 18" fill="none"><path d="M2 14V8h3l4-4v10l-4-4H2z" stroke="currentColor" strokeWidth="1.4" strokeLinejoin="round"/><path d="M13 6c1 1 1.5 2 1.5 3s-.5 2-1.5 3" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg></span>
                Parents who want to catch the moments that matter (without being woken every hour)
              </li>
              <li>
                <span className="av"><svg width="18" height="18" viewBox="0 0 18 18" fill="none"><circle cx="6" cy="5" r="1.5" stroke="currentColor" strokeWidth="1.4"/><circle cx="12" cy="5" r="1.5" stroke="currentColor" strokeWidth="1.4"/><path d="M4 12c0-2.7 2.2-5 5-5s5 2.3 5 5v3H4v-3z" stroke="currentColor" strokeWidth="1.4"/></svg></span>
                Pet owners gone for the day
              </li>
              <li>
                <span className="av"><svg width="18" height="18" viewBox="0 0 18 18" fill="none"><path d="M3 4h12v10H3z" stroke="currentColor" strokeWidth="1.4"/><path d="M6 9l3-3 3 3" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/></svg></span>
                Anyone who's turned off camera notifications in frustration
              </li>
            </ul>
          </Reveal>

          <Reveal className="b2b2c-card" delay={120}>
            <span className="pin">For family caregivers</span>
            <h3>Are you buying this for someone else?</h3>
            <p>
              Watching over a family member from afar?<br />
              You're not the user. They are.<br />
              That changes everything about how a camera should work.
            </p>
            <div className="pillar">
              <div><b>Privacy-first</b>Dignity by default.</div>
              <div><b>Smart escalation</b>Knows who to alert when.</div>
              <div><b>Care-coordinated</b>Whole family on the same page.</div>
            </div>
            <button type="button" className="btn" onClick={openFamilyModal} style={{ alignSelf: 'flex-start', marginTop: 6 }}>
              Family caregiver path
              <svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M3 7h8M7 3l4 4-4 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/></svg>
            </button>
          </Reveal>
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { PricingSection, PersonasSection });
