/* Dentist site — Onboarding + Commercial + Proof + FAQ + Final CTA + Footer + Modal */
const { useState: d2S, useEffect: d2E, useMemo: d2M } = React;

/* ---------- Onboarding ---------- */
function Onboarding() {
  const steps = [
    { n: "01", t: "Request your free sample", b: "A full trial kit on us — four gels, custom trays, and a fit-pack. No card, no obligation. Dispatched in 48 hours." },
    { n: "02", t: "Try it on yourself", b: "Run a course on yourself or a willing partner. See the shade lift. Feel the comfort. Decide which strengths to start with." },
    { n: "03", t: "Stock your practice", b: "30-minute onboarding for principal + lead nurse. Marketing pack, patient leaflets, and protocols included. Order direct, dispatched same week." },
  ];
  return (
    <section id="onboarding" className="section section--cream-2">
      <div className="wrap">
        <div style={{
          display: "flex", justifyContent: "space-between", alignItems: "baseline",
          flexWrap: "wrap", gap: 16, marginBottom: "clamp(40px, 5vw, 64px)",
        }}>
          <Reveal><span className="eyebrow">— Onboarding</span></Reveal>
          <Reveal delay={100}><span className="eyebrow" style={{ color: "var(--accent)" }}>Three steps · sample to stocked in under a fortnight</span></Reveal>
        </div>

        <Reveal delay={80}>
          <h2 className="h-section" style={{
            fontSize: "clamp(40px, 5.4vw, 84px)", margin: "0 0 clamp(48px, 6vw, 80px)", maxWidth: 1000,
          }}>
            From <em style={{ color: "var(--accent)" }}>sample to stocked shelf,</em><br/>
            in under a fortnight.
          </h2>
        </Reveal>

        <div style={{
          display: "grid", gridTemplateColumns: "repeat(3, 1fr)",
          gap: "clamp(20px, 3vw, 48px)", position: "relative",
        }}>
          <div aria-hidden="true" style={{
            position: "absolute", left: 0, right: 0, top: 28, height: 1,
            background: "var(--on-light-15)",
          }} />
          {steps.map((s, i) => (
            <Reveal key={s.n} delay={i * 160} style={{ position: "relative" }}>
              <div style={{
                width: 56, height: 56, borderRadius: 999,
                background: "var(--pearl)", border: "1px solid var(--on-light-15)",
                display: "grid", placeItems: "center",
                fontFamily: "var(--font-mono)", fontSize: 11,
                letterSpacing: "0.16em", color: "var(--on-light-60)",
                marginBottom: 28, position: "relative", zIndex: 1,
              }}>{s.n}</div>
              <h3 style={{
                fontFamily: "var(--font-display)", fontWeight: 380,
                fontSize: "clamp(24px, 2.2vw, 32px)", margin: "0 0 14px",
                letterSpacing: "-0.015em", lineHeight: 1.1,
              }}>{s.t}</h3>
              <p style={{ color: "var(--on-light-60)", margin: 0, fontSize: 15, lineHeight: 1.55, maxWidth: 320 }}>{s.b}</p>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ---------- Commercial case: patient retention + LTV story (no public £) ---------- */
function Commercial({ onOpenModal }) {
  const tiers = [
    { label: "One-off course", sub: "Patient whitens, leaves, forgets.", mult: 1.0, index: 18 },
    { label: "Returning patient", sub: "They come back, maybe, when they remember.", mult: 2.4, index: 42 },
    { label: "Returning + 360 app", sub: "App reminds them. They re-order. Through you.", mult: 5.4, index: 100, highlight: true },
  ];
  return (
    <section id="commercial" className="section section--dark" style={{ overflow: "hidden", position: "relative" }}>
      <ShatterLines mode="dark" />
      <div className="wrap" style={{ position: "relative", zIndex: 1 }}>
        <div style={{
          display: "grid",
          gridTemplateColumns: "minmax(0, 0.95fr) minmax(0, 1.05fr)",
          gap: "clamp(40px, 5vw, 88px)",
          alignItems: "start",
        }}>
          <div>
            <Reveal>
              <div style={{ display: "flex", alignItems: "center", gap: 14, marginBottom: 24 }}>
                <span style={{ width: 28, height: 1, background: "var(--accent-tint)" }} />
                <span className="eyebrow">— The maths that matters</span>
              </div>
            </Reveal>
            <Reveal delay={120}>
              <h2 className="h-section" style={{
                fontSize: "clamp(40px, 5.2vw, 80px)", margin: "0 0 28px", color: "var(--pearl)",
              }}>
                Whitening is the gift<br/>
                that <em style={{ color: "var(--accent-tint)" }}>keeps giving</em> —<br/>
                if you keep them coming back.
              </h2>
            </Reveal>
            <Reveal delay={220}>
              <p className="lead" style={{ maxWidth: 460, marginBottom: 24 }}>
                The real prize isn't the first course. It's the seven years that follow.
                Our app puts a top-up reminder in your patient's pocket, and routes every
                re-order back to <em style={{ color: "var(--accent-tint)", fontStyle: "italic" }}>your</em> practice — not ours, not the high street.
              </p>
              <p className="lead" style={{ maxWidth: 460, marginBottom: 36 }}>
                We keep specific pricing and margin terms private. Request the
                commercial pack and we'll walk you through it on a call.
              </p>
            </Reveal>
            <Reveal delay={320}>
              <div style={{ display: "flex", gap: 12, flexWrap: "wrap" }}>
                <button onClick={onOpenModal} className="btn btn--gold btn--big">
                  <I.Download /> Request commercial pack
                </button>
                <a href="#" className="btn btn--ghost btn--big">Talk to the team</a>
              </div>
            </Reveal>
          </div>

          {/* LTV visual */}
          <Reveal delay={200}>
            <div style={{
              border: "1px solid var(--on-dark-15)",
              borderRadius: 6,
              padding: "28px 28px 22px",
              background: "rgba(246,239,227,0.025)",
            }}>
              <div style={{
                display: "flex", justifyContent: "space-between", alignItems: "baseline",
                paddingBottom: 16, borderBottom: "1px solid var(--on-dark-15)",
              }}>
                <span className="eyebrow" style={{ color: "var(--on-dark-60)" }}>Patient lifetime value</span>
                <span className="eyebrow" style={{ color: "var(--accent-tint)" }}>Indexed · 7 years</span>
              </div>
              <div style={{ display: "flex", flexDirection: "column", gap: 22, paddingTop: 22 }}>
                {tiers.map((t, i) => (
                  <div key={t.label}>
                    <div style={{
                      display: "flex", justifyContent: "space-between",
                      alignItems: "baseline", gap: 16, marginBottom: 10,
                    }}>
                      <div>
                        <div style={{
                          fontFamily: "var(--font-display)", fontSize: 22,
                          color: t.highlight ? "var(--accent-tint)" : "var(--pearl)",
                          fontStyle: t.highlight ? "italic" : "normal",
                          letterSpacing: "-0.01em",
                        }}>{t.label}</div>
                        <div style={{ fontSize: 13, color: "var(--on-dark-60)", marginTop: 2 }}>{t.sub}</div>
                      </div>
                      <div style={{
                        fontFamily: "var(--font-display)", fontSize: 32,
                        color: t.highlight ? "var(--accent-tint)" : "var(--pearl)",
                        letterSpacing: "-0.02em",
                        fontStyle: t.highlight ? "italic" : "normal",
                        whiteSpace: "nowrap",
                      }}>{t.mult.toFixed(1)}<span style={{ fontSize: 18, opacity: 0.7 }}>×</span></div>
                    </div>
                    <div style={{
                      height: 8, background: "var(--on-dark-08)",
                      borderRadius: 2, overflow: "hidden",
                    }}>
                      <div style={{
                        width: `${t.index}%`, height: "100%",
                        background: t.highlight
                          ? "linear-gradient(90deg, #B5904F, #D4B07A 60%, #E8C893)"
                          : "var(--on-dark-40)",
                        transition: "width .5s ease",
                      }} />
                    </div>
                  </div>
                ))}
              </div>
              <div style={{
                fontFamily: "var(--font-mono)", fontSize: 10,
                letterSpacing: "0.14em", textTransform: "uppercase",
                color: "var(--on-dark-40)", paddingTop: 22,
                borderTop: "1px solid var(--on-dark-15)", marginTop: 26,
              }}>
                * Indicative LTV multipliers from internal pilot data.<br/>Specifics shared in the commercial pack.
              </div>
            </div>
          </Reveal>
        </div>
      </div>
    </section>
  );
}

/* ---------- Testimonial ---------- */
function SocialProof() {
  return (
    <section className="section">
      <div className="wrap" style={{
        display: "grid",
        gridTemplateColumns: "minmax(0, 0.95fr) minmax(0, 1.05fr)",
        gap: "clamp(32px, 5vw, 88px)",
        alignItems: "center",
      }}>
        <Reveal>
          <Slot caption="DENTIST — portrait, soft daylight" ratio="3 / 4"
            style={{ borderRadius: 4 }} />
        </Reveal>
        <Reveal delay={140}>
          <span className="eyebrow" style={{ display: "block", marginBottom: 24 }}>— Trusted by</span>
          <blockquote style={{
            fontFamily: "var(--font-display)", fontWeight: 380,
            fontSize: "clamp(28px, 3.6vw, 48px)", lineHeight: 1.18,
            letterSpacing: "-0.015em", margin: "0 0 32px",
            textWrap: "pretty",
          }}>
            <span style={{ color: "var(--accent)", fontStyle: "italic" }}>“</span>
            We switched from one of the big names and our patients haven't noticed a thing —
            except the price we charge them, and the fact that
            <em style={{ fontStyle: "italic", color: "var(--accent)" }}> nobody is complaining about sensitivity anymore.</em>
            <span style={{ color: "var(--accent)", fontStyle: "italic" }}>”</span>
          </blockquote>
          <div style={{ display: "flex", alignItems: "center", gap: 14 }}>
            <div style={{ width: 42, height: 42, borderRadius: 999, background: "var(--pearl-3)" }} aria-hidden="true" />
            <div>
              <div style={{ fontWeight: 500, fontSize: 14 }}>Dr Naomi Whitcombe</div>
              <div style={{ fontSize: 13, color: "var(--on-light-60)" }}>Principal · Whitcombe & Hale, Marylebone</div>
            </div>
          </div>

          <div style={{ marginTop: 48, paddingTop: 32, borderTop: "1px solid var(--on-light-15)" }}>
            <div className="eyebrow" style={{ marginBottom: 18 }}>Stocked by practices across the UK</div>
            <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 14 }}>
              {["Whitcombe & Hale", "The Marlow Dental Studio", "Penrose Aesthetics", "Ashbury Dental"].map(p => (
                <div key={p} style={{
                  height: 44, borderRadius: 4,
                  border: "1px dashed var(--on-light-15)",
                  display: "grid", placeItems: "center",
                  fontFamily: "var(--font-mono)", fontSize: 10,
                  letterSpacing: "0.14em", color: "var(--on-light-40)",
                  textTransform: "uppercase",
                }}>{p}</div>
              ))}
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

/* ---------- FAQ ---------- */
function FAQ() {
  const items = [
    { q: "How does 360 compare to the established chair brands?", a: "The best whitening results always come from custom-fit trays worn consistently — not from off-the-shelf or chair systems. That's what 360 delivers, at a wholesale that leaves you a proper margin. The bigger story is retention: our app reminds patients when they're running low and routes top-ups directly to you." },
    { q: "What concentrations are available?", a: "16% carbamide peroxide for overnight wear, and 6% hydrogen peroxide for a one-hour daytime protocol. We supply both — your patient's starting shade and lifestyle determines which is right for them." },
    { q: "What's the commercial model?", a: "We keep specific wholesale and margin terms off the public web — it's not in anyone's interest for patients to know what we charge you. Request the commercial pack and we'll walk you through the model on a call." },
    { q: "How does the 360 app generate repeat revenue?", a: "Every patient you treat gets the app. It guides them through their course, reminds them when their gel is running low, and routes every top-up order back to your practice. You get notified, fulfilled centrally if you prefer, and the patient never has to think about it." },
    { q: "How do I order trays?", a: "Send us PVS impressions or an STL from your scanner. Trays are made in our UK lab on a 5 working day turnaround." },
    { q: "Do you offer training?", a: "Yes — a 30-minute remote onboarding for the principal and lead nurse, plus written protocols for the whole team. CPD-aligned." },
    { q: "What if a patient has sensitivity?", a: "Our gel is buffered to a neutral pH with a built-in desensitiser. For patients who do experience sensitivity, we recommend the 6% HP daytime protocol with shorter wear times, stepping up as they tolerate it." },
  ];
  const [open, setOpen] = d2S(0);
  return (
    <section id="faq" className="section section--cream-2">
      <div className="wrap" style={{
        display: "grid",
        gridTemplateColumns: "minmax(0, 0.7fr) minmax(0, 1.3fr)",
        gap: "clamp(32px, 5vw, 80px)",
      }}>
        <div>
          <Reveal>
            <span className="eyebrow" style={{ display: "block", marginBottom: 24 }}>— Questions, asked</span>
          </Reveal>
          <Reveal delay={120}>
            <h2 className="h-section" style={{ fontSize: "clamp(36px, 4.6vw, 60px)", margin: 0, maxWidth: 360 }}>
              The bits you actually want to&nbsp;know.
            </h2>
          </Reveal>
        </div>
        <div>
          {items.map((it, i) => {
            const isOpen = open === i;
            return (
              <Reveal key={it.q} delay={i * 60}>
                <button onClick={() => setOpen(isOpen ? -1 : i)} style={{
                  width: "100%", textAlign: "left",
                  background: "transparent", border: 0,
                  borderTop: "1px solid var(--on-light-15)",
                  borderBottom: i === items.length - 1 ? "1px solid var(--on-light-15)" : 0,
                  padding: "24px 0",
                  display: "flex", justifyContent: "space-between", alignItems: "center",
                  cursor: "pointer", color: "var(--ink)",
                  fontFamily: "var(--font-display)", fontWeight: 380,
                  fontSize: "clamp(18px, 1.5vw, 22px)",
                  letterSpacing: "-0.01em", gap: 24,
                }}>
                  <span style={{ flex: 1 }}>{it.q}</span>
                  <span style={{
                    width: 32, height: 32, borderRadius: 999,
                    border: "1px solid var(--on-light-15)",
                    display: "grid", placeItems: "center", flexShrink: 0,
                  }}>{isOpen ? <I.Minus /> : <I.Plus />}</span>
                </button>
                <div style={{
                  maxHeight: isOpen ? 280 : 0, overflow: "hidden",
                  transition: "max-height .45s cubic-bezier(.2,.7,.2,1), padding .3s ease",
                  paddingBottom: isOpen ? 20 : 0,
                }}>
                  <p style={{ margin: 0, color: "var(--on-light-60)", fontSize: 15,
                    lineHeight: 1.6, maxWidth: 640, paddingRight: 40 }}>{it.a}</p>
                </div>
              </Reveal>
            );
          })}
        </div>
      </div>
    </section>
  );
}

/* ---------- Final CTA ---------- */
function FinalCTA({ onOpenModal }) {
  return (
    <section className="section section--dark" style={{ paddingBlock: "clamp(96px, 11vw, 160px)", overflow: "hidden", position: "relative" }}>
      <ShatterLines stroke="rgba(246,239,227,0.05)" lines={26} seed={17} />
      <div className="wrap" style={{ textAlign: "center", position: "relative", zIndex: 1 }}>
        <Reveal>
          <span className="eyebrow" style={{ display: "inline-flex", alignItems: "center", gap: 12 }}>
            <span style={{ width: 24, height: 1, background: "var(--accent-tint)" }} />
            Ready when you are
            <span style={{ width: 24, height: 1, background: "var(--accent-tint)" }} />
          </span>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="h-section" style={{
            fontSize: "clamp(48px, 7vw, 112px)",
            margin: "28px auto 32px",
            color: "var(--pearl)", maxWidth: 1100,
          }}>
            Ready to offer your patients <em style={{ fontStyle: "italic", color: "var(--accent-tint)" }}>something better?</em>
          </h2>
        </Reveal>
        <Reveal delay={240}>
          <p className="lead" style={{ maxWidth: 580, margin: "0 auto 36px" }}>
            Start with a free sample kit. Or grab fifteen minutes with the team —
            we'll walk you through pricing, training and the marketing pack.
          </p>
        </Reveal>
        <Reveal delay={320}>
          <div style={{ display: "flex", gap: 12, justifyContent: "center", flexWrap: "wrap" }}>
            <button onClick={onOpenModal} className="btn btn--gold btn--big">Request free sample <I.Arrow /></button>
            <a href="#book" className="btn btn--ghost btn--big">Book a 15-min call</a>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

/* ---------- Footer ---------- */
function Footer({ onOpenModal }) {
  return (
    <footer style={{ background: "var(--pearl)", paddingTop: 80, paddingBottom: 36 }}>
      <div className="wrap">
        {/* For Patients rail */}
        <div style={{
          display: "grid", gridTemplateColumns: "minmax(0, 1fr) auto",
          gap: 24, alignItems: "center",
          padding: "26px 32px", border: "1px solid var(--on-light-15)",
          borderRadius: 6, marginBottom: 56,
          background: "linear-gradient(120deg, rgba(212,176,122,0.05), transparent 80%)",
        }}>
          <div>
            <span className="eyebrow" style={{ color: "var(--accent)" }}>— For patients</span>
            <p style={{
              fontFamily: "var(--font-display)", fontSize: "clamp(22px, 2.2vw, 30px)",
              margin: "10px 0 0", lineHeight: 1.15, letterSpacing: "-0.015em", maxWidth: 640,
            }}>
              Came here looking for whitening for yourself? We'll find you a dentist who stocks us.
            </p>
          </div>
          <a href="index.html" className="btn btn--ghost btn--big">
            Visit the patient site <I.Arrow />
          </a>
        </div>

        <div style={{
          display: "grid", gridTemplateColumns: "minmax(0, 1.4fr) repeat(3, minmax(0, 1fr))",
          gap: "clamp(24px, 4vw, 56px)",
          paddingBottom: 56, borderBottom: "1px solid var(--on-light-15)",
        }}>
          <div>
            <Wordmark size={22} />
            <p style={{
              fontFamily: "var(--font-display)", fontStyle: "italic",
              fontSize: 22, color: "var(--on-light-60)", lineHeight: 1.2,
              maxWidth: 320, margin: "20px 0 24px", letterSpacing: "-0.01em",
              fontVariationSettings: '"opsz" 120, "SOFT" 100, "WONK" 1',
            }}>Pro-strength whitening,<br/>four years in the making.</p>
            <button onClick={onOpenModal} className="btn btn--primary">Request free sample <I.Arrow /></button>
          </div>
          <FCol title="Product" links={["The Gel", "The Trays", "The Kit", "Spec sheet"]} />
          <FCol title="For practices" links={["Marketing pack", "Wholesale price list", "Onboarding", "Book a call"]} />
          <FCol title="Get in touch" links={["+44 (0)1535 642 020", "hello@360whitening.co.uk", "By appointment only", "Office details on request"]} dim />
        </div>

        <div style={{
          display: "flex", justifyContent: "space-between",
          alignItems: "center", flexWrap: "wrap", gap: 16, paddingTop: 28,
        }}>
          <div style={{
            fontFamily: "var(--font-mono)", fontSize: 10,
            letterSpacing: "0.18em", textTransform: "uppercase",
            color: "var(--on-light-40)",
          }}>© 2026 · 360 Whitening Ltd · Part of the 360 Dental family</div>
          <div style={{
            display: "flex", gap: 14, fontSize: 10,
            fontFamily: "var(--font-mono)", letterSpacing: "0.18em",
            textTransform: "uppercase", color: "var(--on-light-40)",
          }}>
            <a href="privacypolicy.html">Privacy</a><a href="#">Terms</a><a href="#">Cookies</a>
          </div>
        </div>
      </div>
    </footer>
  );
}
function FCol({ title, links, dim }) {
  return (
    <div>
      <div className="eyebrow" style={{ marginBottom: 18 }}>{title}</div>
      <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 10 }}>
        {links.map(l => <li key={l}><a href="#" style={{ fontSize: 14, color: dim ? "var(--on-light-60)" : "var(--ink)" }}>{l}</a></li>)}
      </ul>
    </div>
  );
}

/* ---------- Sample-kit modal ---------- */
function SampleModal({ open, onClose }) {
  const [step, setStep] = d2S(0);
  const [form, setForm] = d2S({ firstName: "", lastName: "", practice: "", email: "", postcode: "" });
  const [busy, setBusy] = d2S(false);
  const [err, setErr] = d2S("");
  const upd = (k) => (e) => setForm((f) => ({ ...f, [k]: e.target.value }));

  d2E(() => {
    const onKey = (e) => { if (e.key === "Escape") onClose(); };
    if (open) window.addEventListener("keydown", onKey);
    return () => window.removeEventListener("keydown", onKey);
  }, [open, onClose]);

  const submit = async () => {
    setErr("");
    const name = `${form.firstName} ${form.lastName}`.trim();
    if (!name || !form.email.trim()) {
      setErr("Please add your name and practice email.");
      return;
    }
    setBusy(true);
    try {
      await window.submitEnquiry({
        name,
        practice: form.practice.trim(),
        email: form.email.trim(),
        postcode: form.postcode.trim(),
        message: "Dentist enquiry — free sample kit request.",
      });
      setStep(1);
    } catch (e) {
      setErr("Something went wrong sending that. Please try again, or email hello@360whitening.co.uk.");
    } finally {
      setBusy(false);
    }
  };

  return (
    <div className={`modal-scrim ${open ? "is-on" : ""}`} onClick={onClose} role="dialog" aria-modal="true">
      <div className="modal" onClick={e => e.stopPropagation()}>
        <button className="modal-close" onClick={onClose} aria-label="Close"><I.Close /></button>
        {step === 0 ? (
          <>
            <span className="eyebrow">— Request your free sample</span>
            <h3 style={{
              fontFamily: "var(--font-display)", fontWeight: 380,
              fontSize: "clamp(26px, 2.6vw, 36px)", letterSpacing: "-0.015em",
              margin: "12px 0 8px", lineHeight: 1.1,
            }}>
              A full trial kit, on us. <em style={{ color: "var(--accent)" }}>No card.</em>
            </h3>
            <p style={{ color: "var(--on-light-60)", margin: "0 0 24px", fontSize: 15 }}>
              Tell us where to send it. We'll dispatch in 48 hours and follow up after a week — no harder sell than that.
            </p>
            <div className="field--row">
              <div className="field">
                <label className="field__label" htmlFor="fn">First name</label>
                <input id="fn" className="field__input" value={form.firstName} onChange={upd("firstName")} />
              </div>
              <div className="field">
                <label className="field__label" htmlFor="ln">Last name</label>
                <input id="ln" className="field__input" value={form.lastName} onChange={upd("lastName")} />
              </div>
            </div>
            <div className="field">
              <label className="field__label" htmlFor="pr">Practice name</label>
              <input id="pr" className="field__input" value={form.practice} onChange={upd("practice")} />
            </div>
            <div className="field">
              <label className="field__label" htmlFor="em">Practice email</label>
              <input id="em" className="field__input" type="email" value={form.email} onChange={upd("email")} />
            </div>
            <div className="field">
              <label className="field__label" htmlFor="ad">Practice address (postcode)</label>
              <input id="ad" className="field__input" value={form.postcode} onChange={upd("postcode")} />
            </div>
            {err && (
              <p style={{ fontSize: 13, color: "#B04A2F", margin: "0 0 12px", lineHeight: 1.4 }}>{err}</p>
            )}
            <button onClick={submit} disabled={busy} className="btn btn--primary btn--big"
              style={{ width: "100%", justifyContent: "center", marginTop: 8, opacity: busy ? 0.7 : 1 }}>
              {busy ? "Sending…" : <>Send my sample <I.Arrow /></>}
            </button>
            <p style={{
              fontSize: 10, color: "var(--on-light-40)", marginTop: 12,
              fontFamily: "var(--font-mono)", letterSpacing: "0.14em", textTransform: "uppercase",
            }}>For UK dental professionals only · GDC verification on dispatch</p>
          </>
        ) : (
          <div style={{ textAlign: "center", padding: "8px 0" }}>
            <div style={{
              width: 56, height: 56, borderRadius: 999,
              background: "var(--accent)", color: "var(--ink)",
              display: "grid", placeItems: "center", margin: "0 auto 18px",
            }}><I.Check /></div>
            <h3 style={{
              fontFamily: "var(--font-display)", fontWeight: 380,
              fontSize: "clamp(24px, 2.8vw, 34px)", letterSpacing: "-0.015em",
              margin: "0 0 10px",
            }}>
              On its way <em style={{ color: "var(--accent)" }}>within 48 hours.</em>
            </h3>
            <p style={{ color: "var(--on-light-60)", margin: "0 0 24px", fontSize: 15 }}>
              We've sent a confirmation + tracking link to your inbox.
              In the meantime, the marketing pack is ready to download.
            </p>
            <a href="#" className="btn btn--ghost btn--big" style={{ marginRight: 8 }}>
              <I.Download /> Marketing pack
            </a>
            <button onClick={onClose} className="btn btn--primary btn--big">Close</button>
          </div>
        )}
      </div>
    </div>
  );
}

Object.assign(window, { Onboarding, Commercial, SocialProof, FAQ, FinalCTA, Footer, SampleModal, TheApp });

/* ---------- The 360 App — free recurring revenue ---------- */
function TheApp({ onOpenModal }) {
  return (
    <section id="app" className="section section--cream-2">
      <div className="wrap">
        <div style={{
          display: "grid",
          gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1fr)",
          gap: "clamp(40px, 6vw, 96px)",
          alignItems: "center",
        }}>
          <div>
            <Reveal>
              <div style={{ display: "flex", alignItems: "center", gap: 14, marginBottom: 24 }}>
                <span style={{ width: 28, height: 1, background: "var(--accent)" }} />
                <span className="eyebrow">— The 360 app</span>
              </div>
            </Reveal>
            <Reveal delay={120}>
              <h2 className="h-section" style={{
                fontSize: "clamp(40px, 5.2vw, 80px)", margin: "0 0 28px",
              }}>
                Free recurring revenue.<br/>
                <em style={{ color: "var(--accent)" }}>Built in.</em>
              </h2>
            </Reveal>
            <Reveal delay={220}>
              <p className="lead" style={{ maxWidth: 460, marginBottom: 32 }}>
                Every patient you treat gets the 360 app. It guides them through their course,
                reminds them when they're running low, and routes every top-up order back
                to <em style={{ color: "var(--accent)", fontStyle: "italic" }}>your</em> practice. You set your own
                top-up prices — patients see the price, request the refill, and you get an email.
                No third party. No commission. The revenue is yours.
              </p>
            </Reveal>
            <Reveal delay={300}>
              <div style={{ display: "flex", flexDirection: "column", gap: 0, marginBottom: 32 }}>
                {[
                  ["01", "Retention reminders", "The app nudges patients when gel runs low — they don't forget, because it doesn't let them."],
                  ["02", "Direct-to-practice orders", "Top-up requests come straight to you by email. You fulfil at your own margin. No middleman."],
                  ["03", "Your prices, your terms", "Set a single-syringe and a triple-pack price in your portal. Patients see it before they request."],
                  ["04", "Patient oversight", "See who's using their kit, who's run out, and who's gone quiet — then follow up."],
                ].map(([n, t, b]) => (
                  <div key={n} style={{
                    display: "grid", gridTemplateColumns: "auto 1fr",
                    gap: 18, padding: "18px 0",
                    borderTop: "1px solid var(--on-light-15)",
                    alignItems: "baseline",
                  }}>
                    <span className="num" style={{ width: 24 }}>{n}</span>
                    <div>
                      <div style={{ fontFamily: "var(--font-display)", fontSize: 22, letterSpacing: "-0.01em", marginBottom: 4 }}>{t}</div>
                      <div style={{ fontSize: 14, color: "var(--on-light-60)" }}>{b}</div>
                    </div>
                  </div>
                ))}
              </div>
            </Reveal>
            <Reveal delay={400}>
              <a href="#" className="btn btn--ghost">See the app demo <I.Arrow /></a>
            </Reveal>
          </div>

          <Reveal delay={200} style={{ display: "grid", placeItems: "center" }}>
            <PhoneMock mode="dentist" />
          </Reveal>
        </div>
      </div>
    </section>
  );
}

/* Shared phone mockup — tone-aware */
function PhoneMock({ mode = "dentist" }) {
  const isDentist = mode === "dentist";
  const notifs = isDentist
    ? [
        { app: "360 Whitening", title: "Top-up order received", body: "Sarah J. · Tray refill + 2× 16% CP. Routing to your practice.", flag: "REVENUE" },
        { app: "360 Whitening", title: "Patient finished course", body: "Tom B. · Course complete · Shade lift 6.", flag: "MILESTONE" },
        { app: "360 Whitening", title: "Adherence alert", body: "Emma R. hasn't logged a session in 4 days. Nudge sent.", flag: "INSIGHT" },
      ]
    : [
        { app: "360 Whitening", title: "Time for tonight's session", body: "Pop in your trays, set a timer for 30 minutes.", flag: "ROUTINE" },
        { app: "360 Whitening", title: "Day 9 · You're glowing", body: "You're 2 shades up. Three to go.", flag: "PROGRESS" },
        { app: "360 Whitening", title: "Running low?", body: "One gel left. Order a top-up through your dentist.", flag: "TOP-UP" },
      ];
  return (
    <div style={{
      width: "min(320px, 100%)",
      aspectRatio: "9 / 19",
      borderRadius: 44,
      border: "1.5px solid rgba(14,11,7,0.85)",
      background: "linear-gradient(180deg, #0E0B07, #1A130E)",
      padding: 11,
      boxShadow: "0 50px 90px -40px rgba(0,0,0,0.55), 0 0 0 1px rgba(212,176,122,0.08) inset",
      position: "relative",
    }}>
      <div style={{
        position: "relative",
        width: "100%", height: "100%",
        borderRadius: 34,
        background: "radial-gradient(120% 80% at 50% 0%, #1F1812 0%, #0E0B07 80%)",
        padding: "44px 12px 14px",
        display: "flex", flexDirection: "column", gap: 12,
        overflow: "hidden",
        isolation: "isolate",
      }}>
        {/* shatter pattern */}
        <div aria-hidden="true" style={{
          position: "absolute", inset: 0,
          backgroundImage: "url(\"uploads/black-box-web.png\")",
          backgroundSize: "cover", backgroundPosition: "center",
          opacity: 0.22, mixBlendMode: "screen",
        }} />
        {/* Notch */}
        <div style={{
          position: "absolute", left: "50%", top: 14,
          transform: "translateX(-50%)",
          width: 100, height: 24, borderRadius: 999,
          background: "#0A0805",
        }} />
        {/* Lock-screen time */}
        <div style={{ textAlign: "center", color: "var(--pearl)", position: "relative", zIndex: 1, marginBottom: 4 }}>
          <div style={{
            fontFamily: "var(--font-mono)", fontSize: 10,
            letterSpacing: "0.2em", opacity: 0.55, textTransform: "uppercase",
          }}>{isDentist ? "Tuesday · 09:14" : "Tuesday · 22:38"}</div>
          <div style={{
            fontFamily: "var(--font-display)", fontWeight: 360,
            fontSize: 48, letterSpacing: "-0.03em", lineHeight: 1,
            color: "var(--pearl)", marginTop: 2,
          }}>{isDentist ? "9:14" : "22:38"}</div>
        </div>

        {notifs.map((n, i) => (
          <div key={i} style={{
            borderRadius: 14,
            padding: "11px 12px",
            background: "rgba(246,239,227,0.08)",
            border: "1px solid rgba(246,239,227,0.05)",
            backdropFilter: "blur(8px)",
            WebkitBackdropFilter: "blur(8px)",
            color: "var(--pearl)",
            position: "relative", zIndex: 1,
          }}>
            <div style={{
              display: "flex", justifyContent: "space-between",
              alignItems: "baseline", marginBottom: 4,
            }}>
              <div style={{
                fontFamily: "var(--font-mono)", fontSize: 8,
                letterSpacing: "0.18em", textTransform: "uppercase",
                color: "var(--accent-tint)",
              }}>360°/{n.app}</div>
              <div style={{
                fontFamily: "var(--font-mono)", fontSize: 7,
                letterSpacing: "0.16em", textTransform: "uppercase",
                color: "rgba(246,239,227,0.45)",
              }}>{n.flag}</div>
            </div>
            <div style={{
              fontFamily: "var(--font-display)", fontSize: 13,
              letterSpacing: "-0.005em", marginBottom: 2,
            }}>{n.title}</div>
            <div style={{ fontSize: 10.5, opacity: 0.7, lineHeight: 1.35 }}>{n.body}</div>
          </div>
        ))}
      </div>
    </div>
  );
}

Object.assign(window, { TheApp, PhoneMock });
