/* How it Works + Why 360 + UGC + Final CTA + Footer + Modal */
const { useState: u4S, useEffect: u4E, useRef: u4R } = React;

/* ---------- How it works ---------- */
function HowItWorks() {
  const steps = [
    { n: "01", t: "Your dentist fits your trays", b: "Custom-made to your mouth from a PVS impression or digital scan. These are yours to keep, and they last for years." },
    { n: "02", t: "You're prescribed your gel", b: "16% carbamide peroxide for overnight wear, or 6% hydrogen peroxide for a one-hour daytime protocol. Your dentist chooses what's right for you." },
    { n: "03", t: "The app runs your journey", b: "Daily routine, a built-in timer, and session reminders. It keeps you on track from day one to day fourteen." },
    { n: "04", t: "You top up through your dentist", b: "When your gel runs low, one tap sends a request to your practice. No faff, no going back to the start." },
  ];
  return (
    <section id="how" className="section" style={{ background: "var(--ink-2)", overflow: "hidden", position: "relative" }}>
      <ShatterLines stroke="rgba(246,239,227,0.05)" lines={22} seed={5} />
      <div className="wrap" style={{ position: "relative", zIndex: 1 }}>
        <div style={{
          display: "flex", justifyContent: "space-between", alignItems: "baseline",
          flexWrap: "wrap", gap: 16, marginBottom: "clamp(40px, 5vw, 64px)",
        }}>
          <Reveal><span className="eyebrow">— How it actually works</span></Reveal>
          <Reveal delay={120}><span className="eyebrow" style={{ color: "var(--accent)" }}>Trays · gel · app</span></Reveal>
        </div>
        <Reveal delay={80}>
          <h2 className="h-section" style={{
            fontSize: "clamp(48px, 7vw, 116px)",
            margin: "0 0 clamp(48px, 6vw, 80px)",
            color: "var(--pearl)", maxWidth: 1100,
          }}>
            Done properly,<br/>
            <em style={{ color: "var(--accent)" }}>it's transformative.</em>
          </h2>
        </Reveal>

        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(4, 1fr)",
          gap: "clamp(16px, 2vw, 32px)",
        }}>
          {steps.map((s, i) => (
            <Reveal key={s.n} delay={i * 130}>
              <Step {...s} />
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

function Step({ n, t, b }) {
  return (
    <div style={{
      borderTop: "1px solid var(--on-dark-15)",
      paddingTop: 24, display: "flex", flexDirection: "column",
      gap: 20, height: "100%",
      transition: "border-color .4s ease",
    }}
      onMouseEnter={(e) => e.currentTarget.style.borderTopColor = "var(--accent)"}
      onMouseLeave={(e) => e.currentTarget.style.borderTopColor = "var(--on-dark-15)"}
    >
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline" }}>
        <span style={{
          fontFamily: "var(--font-mono)", fontSize: 12,
          letterSpacing: "0.2em", color: "var(--accent)",
        }}>{n}</span>
        <span style={{
          width: 36, height: 36, borderRadius: 999,
          border: "1px solid var(--on-dark-15)",
          display: "grid", placeItems: "center",
          color: "var(--on-dark-60)",
        }}><I.Arrow /></span>
      </div>
      <h3 style={{
        fontFamily: "var(--font-display)", fontWeight: 360,
        fontSize: "clamp(28px, 2.6vw, 38px)", margin: 0, lineHeight: 1.05,
        letterSpacing: "-0.015em",
        color: "var(--pearl)",
      }}>{t}</h3>
      <p style={{ color: "var(--on-dark-60)", margin: 0, fontSize: 15, lineHeight: 1.55 }}>{b}</p>
    </div>
  );
}

/* ---------- Why 360 ---------- */
function Why360() {
  const rows = [
    ["Prescription-strength peroxide", true,  false, false],
    ["Applied through a dentist",       true,  false, false],
    ["Custom-fit trays",               true,  false, false],
    ["Near-zero sensitivity",          true,  false, false],
    ["App-guided routine",             true,  false, false],
    ["Only through your dentist",      true,  false, false],
  ];
  const cols = [
    { label: "360", em: true, sub: "Trays + gel + app" },
    { label: "Strips", sub: "Boots, Amazon, eBay" },
    { label: "Salon", sub: "In-chair light" },
  ];
  return (
    <section id="why" className="section section--pearl-2 on-light">
      <div className="wrap" style={{
        display: "grid",
        gridTemplateColumns: "minmax(0, 0.8fr) minmax(0, 1.2fr)",
        gap: "clamp(40px, 6vw, 96px)",
        alignItems: "start",
      }}>
        <div>
          <Reveal><span className="eyebrow">— Why 360</span></Reveal>
          <Reveal delay={120}>
            <h2 className="h-section" style={{
              fontSize: "clamp(44px, 5.6vw, 88px)",
              margin: "20px 0 24px", color: "var(--ink)",
            }}>
              Better than strips.<br/>
              <em style={{ color: "var(--accent-deep)" }}>Half the price</em> of the salon.
            </h2>
          </Reveal>
          <Reveal delay={200}>
            <p className="lead" style={{ maxWidth: 380, color: "var(--on-light-60)" }}>
              We checked — every other whitening system we could find was on Amazon, eBay
              or the high street. Ours isn't, and never will be. The only place to get 360
              is through a dental professional, because it's the only way to do this legally
              and properly. 20 years of whitening, five years formulating our own gel.
            </p>
          </Reveal>
        </div>

        <Reveal delay={180}>
          <div style={{
            border: "1px solid var(--on-light-15)",
            borderRadius: 8, overflow: "hidden",
            background: "rgba(246, 239, 227, 0.6)",
          }}>
            {/* Header */}
            <div style={{
              display: "grid",
              gridTemplateColumns: "1.5fr repeat(3, 1fr)",
              padding: "16px 18px",
              borderBottom: "1px solid var(--on-light-15)",
              background: "var(--ink)", color: "var(--pearl)",
            }}>
              <span className="eyebrow" style={{ color: "var(--on-dark-60)" }}>Feature</span>
              {cols.map(c => (
                <div key={c.label} style={{ textAlign: "center" }}>
                  <div style={{
                    fontFamily: "var(--font-display)",
                    fontStyle: c.em ? "italic" : "normal",
                    fontSize: 22,
                    color: c.em ? "var(--accent)" : "var(--pearl)",
                    letterSpacing: "-0.01em",
                    fontVariationSettings: c.em ? '"opsz" 120, "SOFT" 100, "WONK" 1' : 'normal',
                  }}>{c.label}</div>
                  <div className="eyebrow" style={{ color: "var(--on-dark-60)", fontSize: 9 }}>{c.sub}</div>
                </div>
              ))}
            </div>
            {/* Rows */}
            {rows.map(([feature, a, b, c], i) => (
              <div key={feature} style={{
                display: "grid",
                gridTemplateColumns: "1.5fr repeat(3, 1fr)",
                padding: "18px",
                borderBottom: i < rows.length - 1 ? "1px solid var(--on-light-15)" : "none",
                alignItems: "center",
              }}>
                <span style={{ fontSize: 14.5, color: "var(--ink)" }}>{feature}</span>
                <CheckCell on={a} accent />
                <CheckCell on={b} />
                <CheckCell on={c} />
              </div>
            ))}
          </div>
        </Reveal>
      </div>
    </section>
  );
}

function CheckCell({ on, accent }) {
  return (
    <div style={{ display: "grid", placeItems: "center" }}>
      {on ? (
        <span style={{
          width: 26, height: 26, borderRadius: 999,
          background: accent ? "var(--accent)" : "var(--ink)",
          color: accent ? "var(--ink)" : "var(--pearl)",
          display: "grid", placeItems: "center",
        }}>
          <svg width="12" height="12" viewBox="0 0 12 12" fill="none">
            <path d="M2 6.5 5 9.5 10 3" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/>
          </svg>
        </span>
      ) : (
        <span style={{
          width: 26, height: 26, borderRadius: 999,
          border: "1px solid var(--on-light-15)",
          color: "var(--on-light-40)",
          display: "grid", placeItems: "center",
        }}>
          <svg width="10" height="10" viewBox="0 0 10 10" fill="none">
            <path d="M2 2l6 6M8 2 2 8" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/>
          </svg>
        </span>
      )}
    </div>
  );
}

/* ---------- UGC reels grid ---------- */
function Reels({ onOpenModal }) {
  const tiles = [
    { handle: "@stassie", caption: "fourteen days. that's it.", tone: 1 },
    { handle: "@charlotted", caption: "i'm never going back.", tone: 2 },
    { handle: "@emmacgallagher", caption: "side by side w/ veneers. unreal.", tone: 3 },
    { handle: "@taliarobinson", caption: "the kit unboxing.", tone: 1 },
    { handle: "@aliyahbah", caption: "no sensitivity. promise.", tone: 2 },
    { handle: "@noellebanno", caption: "before bed routine, day 9.", tone: 3 },
  ];
  return (
    <section id="watch" className="section" style={{ background: "var(--ink)", paddingBottom: "calc(var(--sec-y) + 24px)" }}>
      <div className="wrap">
        <div style={{
          display: "flex", justifyContent: "space-between", alignItems: "baseline",
          flexWrap: "wrap", gap: 16, marginBottom: "clamp(32px, 4vw, 56px)",
        }}>
          <div>
            <Reveal>
              <span className="eyebrow" style={{ display: "block", marginBottom: 16 }}>— The letters page</span>
            </Reveal>
            <Reveal delay={80}>
              <h2 className="h-section" style={{
                fontSize: "clamp(44px, 5.6vw, 92px)", margin: 0, color: "var(--pearl)",
              }}>
                Or take it from <em style={{ color: "var(--accent)" }}>everyone&nbsp;else.</em>
              </h2>
            </Reveal>
          </div>
          <Reveal delay={180} style={{ display: "flex", gap: 12, paddingTop: 16 }}>
            <a href="#" className="btn btn--ghost"><I.Star style={{ color: "var(--accent)" }} /> 4.9 · 1,824 reviews</a>
          </Reveal>
        </div>

        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(6, 1fr)",
          gap: "clamp(8px, 1vw, 14px)",
        }}>
          {tiles.map((t, i) => (
            <Reveal key={i} delay={i * 90}>
              <ReelTile {...t} index={i} />
            </Reveal>
          ))}
        </div>

        <Reveal delay={500}>
          <div style={{
            marginTop: "clamp(56px, 7vw, 96px)",
            textAlign: "center",
            display: "flex", flexDirection: "column", alignItems: "center", gap: 28,
          }}>
            <span className="eyebrow">Ready when you are</span>
            <h3 className="h-display" style={{
              fontSize: "clamp(56px, 8vw, 132px)",
              margin: 0, color: "var(--pearl)", maxWidth: 1100,
            }}>
              <em style={{ color: "var(--accent)" }}>Your turn,</em><br/>then.
            </h3>
            <div style={{ display: "flex", gap: 12, flexWrap: "wrap", justifyContent: "center" }}>
              <button onClick={onOpenModal} className="btn btn--gold btn--big">Find your dentist <I.Arrow /></button>
              <a href="#how" className="btn btn--ghost btn--big">See how it works</a>
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

function ReelTile({ handle, caption, tone, index }) {
  const [hover, setHover] = u4S(false);
  const palettes = [
    "linear-gradient(180deg, #2A1F18 0%, #5C3F2A 100%)",
    "linear-gradient(180deg, #3D2920 0%, #8C6442 100%)",
    "linear-gradient(180deg, #1F1612 0%, #4A3528 100%)",
  ];
  return (
    <div
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{
        position: "relative",
        aspectRatio: "9 / 16",
        borderRadius: 6, overflow: "hidden",
        cursor: "pointer",
        background: palettes[(tone - 1) % palettes.length],
        transition: "transform .5s cubic-bezier(.2,.7,.2,1)",
        transform: hover ? "translateY(-4px)" : "translateY(0)",
      }}
    >
      <Slot caption={`REEL ${String(index + 1).padStart(2, "0")} — ${handle}`} ratio="auto" style={{
        position: "absolute", inset: 0, background: "transparent",
      }} />
      {/* Play icon */}
      <div style={{
        position: "absolute", inset: 0, display: "grid", placeItems: "center",
        color: "var(--pearl)",
        opacity: hover ? 1 : 0.85, transition: "opacity .3s ease",
      }}>
        <div style={{
          width: 52, height: 52, borderRadius: 999,
          background: "rgba(246,239,227,0.92)", color: "var(--ink)",
          display: "grid", placeItems: "center",
          transform: hover ? "scale(1.08)" : "scale(1)",
          transition: "transform .3s ease",
        }}><I.Play /></div>
      </div>
      {/* Bottom caption */}
      <div style={{
        position: "absolute", left: 0, right: 0, bottom: 0,
        padding: "16px 14px",
        background: "linear-gradient(180deg, transparent, rgba(14,11,7,0.7))",
        color: "var(--pearl)",
      }}>
        <div style={{
          fontFamily: "var(--font-mono)", fontSize: 10,
          letterSpacing: "0.18em", marginBottom: 4,
          color: "var(--accent)",
        }}>{handle}</div>
        <div style={{
          fontFamily: "var(--font-display)", fontStyle: "italic",
          fontSize: 16, lineHeight: 1.15, letterSpacing: "-0.01em",
          fontVariationSettings: '"opsz" 120, "SOFT" 100, "WONK" 1',
        }}>{caption}</div>
      </div>
    </div>
  );
}

/* ---------- Footer with quiet 'For Dentists' rail ---------- */
function Footer({ onOpenModal }) {
  return (
    <footer style={{ background: "var(--ink-2)", paddingTop: 80, paddingBottom: 32, color: "var(--pearl)" }}>
      <div className="wrap">
        {/* For Dentists rail */}
        <div style={{
          display: "grid",
          gridTemplateColumns: "auto minmax(0, 1fr) auto",
          gap: 24, alignItems: "center",
          padding: "28px 32px",
          border: "1px solid var(--on-dark-15)",
          borderRadius: 8,
          marginBottom: 64,
          background: "linear-gradient(120deg, rgba(212,176,122,0.05), transparent 80%)",
          overflow: "hidden",
          position: "relative",
        }}>
          <div style={{
            width: 96, height: 96, position: "relative",
            display: "grid", placeItems: "center",
            filter: "drop-shadow(0 12px 18px rgba(0,0,0,0.4))",
          }}>
            <img src="uploads/001-web.png" alt="" aria-hidden="true"
              style={{ width: "140%", maxWidth: "none", height: "auto", transform: "rotate(-6deg)" }} />
          </div>
          <div>
            <span className="eyebrow" style={{ color: "var(--accent)" }}>— For dentists</span>
            <p style={{
              fontFamily: "var(--font-display)", fontSize: "clamp(22px, 2.3vw, 32px)",
              margin: "10px 0 0", lineHeight: 1.1, letterSpacing: "-0.015em",
              maxWidth: 640,
            }}>
              Run a practice? See the clinical pack, the margin maths, and the wholesale terms.
            </p>
          </div>
          <a href="dentists.html" className="btn btn--ghost btn--big" style={{ whiteSpace: "nowrap" }}>
            Visit the dentist site <I.Arrow />
          </a>
        </div>

        {/* Main footer */}
        <div style={{
          display: "grid",
          gridTemplateColumns: "minmax(0, 1.4fr) repeat(3, minmax(0, 1fr))",
          gap: "clamp(24px, 4vw, 64px)",
          paddingBottom: 56,
          borderBottom: "1px solid var(--on-dark-15)",
        }}>
          <div>
            <Wordmark size={22} color="var(--pearl)" />
            <p style={{
              fontFamily: "var(--font-display)", fontStyle: "italic",
              fontSize: 22, color: "var(--on-dark-60)", lineHeight: 1.2,
              maxWidth: 320, margin: "20px 0 24px", letterSpacing: "-0.01em",
              fontVariationSettings: '"opsz" 120, "SOFT" 100, "WONK" 1',
            }}>Cult-status whitening,<br/>delivered through your dentist.</p>
            <button onClick={onOpenModal} className="btn btn--gold">Find your dentist <I.Arrow /></button>
          </div>
          <FCol title="The Kit" links={["What's in the box", "The shade ladder", "Results", "FAQ"]} />
          <FCol title="The Brand" links={["About 360", "Press", "Careers", "Sustainability"]} />
          <FCol title="Stay in touch" links={["Instagram", "TikTok", "Newsletter", "hello@360whitening"]} 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-dark-40)",
          }}>© 2026 · 360 Whitening · Part of the 360 Dental family</div>
          <div style={{ display: "flex", gap: 16, fontSize: 11,
            fontFamily: "var(--font-mono)", letterSpacing: "0.18em",
            textTransform: "uppercase", color: "var(--on-dark-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, color: "var(--accent)" }}>{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-dark-60)" : "var(--pearl)" }}>{l}</a>
          </li>
        ))}
      </ul>
    </div>
  );
}

/* ---------- Find Your Dentist modal ---------- */
function FindDentistModal({ open, onClose }) {
  const [step, setStep] = u4S(0);
  const [form, setForm] = u4S({ name: "", email: "", postcode: "" });
  const [busy, setBusy] = u4S(false);
  const [err, setErr] = u4S("");
  const upd = (k) => (e) => setForm((f) => ({ ...f, [k]: e.target.value }));

  u4E(() => {
    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("");
    if (!form.postcode.trim() || !form.email.trim()) {
      setErr("Please add your postcode and email so we can match you.");
      return;
    }
    setBusy(true);
    try {
      await window.submitEnquiry({
        name: form.name.trim(),
        email: form.email.trim(),
        postcode: form.postcode.trim(),
        message: "Patient enquiry — requesting a nearby 360 Whitening dentist.",
      });
      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" style={{ color: "var(--on-light-60)" }}>— Find your dentist</span>
            <h3 style={{
              fontFamily: "var(--font-display)", fontWeight: 360,
              fontSize: "clamp(28px, 3vw, 40px)", letterSpacing: "-0.015em",
              margin: "12px 0 8px", color: "var(--ink)",
            }}>
              Where shall we <em style={{ color: "var(--accent-deep)" }}>look?</em>
            </h3>
            <p style={{ color: "var(--on-light-60)", margin: "0 0 24px", fontSize: 15 }}>
              Drop your postcode and an email. We'll match you to a 360-trained dentist nearby
              and book you a free 15-minute fit visit.
            </p>
            <div className="field">
              <label className="field__label" htmlFor="pc">Postcode</label>
              <input id="pc" className="field__input" placeholder="e.g. SW3 4RY"
                value={form.postcode} onChange={upd("postcode")} />
            </div>
            <div className="field">
              <label className="field__label" htmlFor="em">Email</label>
              <input id="em" className="field__input" placeholder="you@example.com" type="email"
                value={form.email} onChange={upd("email")} />
            </div>
            <div className="field">
              <label className="field__label" htmlFor="nm">Name (optional)</label>
              <input id="nm" className="field__input" placeholder="First name"
                value={form.name} onChange={upd("name")} />
            </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--gold btn--big"
              style={{ width: "100%", justifyContent: "center", marginTop: 12, opacity: busy ? 0.7 : 1 }}>
              {busy ? "Matching…" : <>Match me <I.Arrow /></>}
            </button>
            <p style={{ fontSize: 11, color: "var(--on-light-40)", marginTop: 14,
              fontFamily: "var(--font-mono)", letterSpacing: "0.14em", textTransform: "uppercase" }}>
              No card. No spam. Unsubscribe any time.
            </p>
          </>
        ) : (
          <div style={{ textAlign: "center", padding: "8px 0" }}>
            <div style={{
              width: 64, height: 64, borderRadius: 999,
              background: "var(--accent)", color: "var(--ink)",
              display: "grid", placeItems: "center", margin: "0 auto 20px",
            }}>
              <I.Pin />
            </div>
            <h3 style={{
              fontFamily: "var(--font-display)", fontWeight: 360,
              fontSize: "clamp(26px, 3vw, 36px)", letterSpacing: "-0.015em",
              margin: "0 0 10px", color: "var(--ink)",
            }}>
              <em style={{ color: "var(--accent-deep)" }}>Found you</em> three.
            </h3>
            <p style={{ color: "var(--on-light-60)", margin: "0 0 24px", fontSize: 15 }}>
              We've sent the practice list and a booking link to your inbox.
              Expect it inside two minutes.
            </p>
            <button onClick={onClose} className="btn btn--ghost btn--big" style={{ width: "100%", justifyContent: "center" }}>
              Close
            </button>
          </div>
        )}
      </div>
    </div>
  );
}

Object.assign(window, { HowItWorks, Why360, Reels, Footer, FindDentistModal, TheApp });

/* ---------- The 360 App — patient side ---------- */
function TheApp({ onOpenModal }) {
  return (
    <section id="app" className="section" style={{ background: "var(--ink-2)", overflow: "hidden", position: "relative" }}>
      <ShatterLines mode="dark" />
      <div className="wrap" style={{ position: "relative", zIndex: 1 }}>
        <div style={{
          display: "grid",
          gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1.05fr)",
          gap: "clamp(40px, 6vw, 96px)",
          alignItems: "center",
        }}>
          <Reveal delay={120} style={{ display: "grid", placeItems: "center" }}>
            <PatientPhone />
          </Reveal>

          <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(44px, 6vw, 92px)",
                margin: "0 0 24px",
                color: "var(--pearl)",
              }}>
                Your glow-up,<br/>
                <em style={{ color: "var(--accent)" }}>on autopilot.</em>
              </h2>
            </Reveal>
            <Reveal delay={220}>
              <p className="lead" style={{ maxWidth: 460, marginBottom: 32 }}>
                Included free with your kit. It's the difference between a course you forget
                about after week one and a result you can actually see and prove. Open it,
                follow the routine, take your photos, and stay on track to day fourteen.
              </p>
            </Reveal>
            <Reveal delay={320}>
              <div style={{ display: "flex", flexDirection: "column", gap: 0, marginBottom: 32 }}>
                {[
                  ["01", "Daily routine", "Your session for today, your formulation, your wear time. Just follow along."],
                  ["02", "Progress photos", "Snap a photo through the app to see the change for yourself, week by week."],
                  ["03", "Session reminders", "A nudge when it's time — so a 14-day course doesn't drift into a six-week one."],
                  ["04", "One-tap top-ups", "Running low? Tap Top-up. Your dentist arranges the refill."],
                ].map(([n, t, b]) => (
                  <div key={n} style={{
                    display: "grid", gridTemplateColumns: "auto 1fr",
                    gap: 18, padding: "18px 0",
                    borderTop: "1px solid var(--on-dark-15)",
                    alignItems: "baseline",
                  }}>
                    <span style={{ fontFamily: "var(--font-mono)", fontSize: 11, letterSpacing: "0.18em", color: "var(--accent)", width: 24 }}>{n}</span>
                    <div>
                      <div style={{ fontFamily: "var(--font-display)", fontSize: 22, letterSpacing: "-0.01em", marginBottom: 4, color: "var(--pearl)" }}>{t}</div>
                      <div style={{ fontSize: 14, color: "var(--on-dark-60)" }}>{b}</div>
                    </div>
                  </div>
                ))}
              </div>
            </Reveal>
            <Reveal delay={420} style={{ display: "flex", gap: 12, flexWrap: "wrap", alignItems: "center" }}>
              <a href="#" className="btn btn--ghost" style={{ display: "inline-flex", alignItems: "center", gap: 10 }}>
                <span style={{ fontSize: 16, lineHeight: 1 }}></span>
                <span style={{ display: "flex", flexDirection: "column", alignItems: "flex-start", textTransform: "none", letterSpacing: 0 }}>
                  <span style={{ fontSize: 9, opacity: 0.7, letterSpacing: "0.1em", textTransform: "uppercase" }}>Download on the</span>
                  <span style={{ fontSize: 14, fontFamily: "var(--font-display)", fontStyle: "italic" }}>App Store</span>
                </span>
              </a>
              <a href="#" className="btn btn--ghost" style={{ display: "inline-flex", alignItems: "center", gap: 10 }}>
                <span style={{ fontSize: 14, lineHeight: 1 }}>▶</span>
                <span style={{ display: "flex", flexDirection: "column", alignItems: "flex-start", textTransform: "none", letterSpacing: 0 }}>
                  <span style={{ fontSize: 9, opacity: 0.7, letterSpacing: "0.1em", textTransform: "uppercase" }}>Get it on</span>
                  <span style={{ fontSize: 14, fontFamily: "var(--font-display)", fontStyle: "italic" }}>Google Play</span>
                </span>
              </a>
            </Reveal>
          </div>
        </div>
      </div>
    </section>
  );
}

function PatientPhone() {
  const notifs = [
    { title: "Time for tonight's session", body: "Pop in your trays · 30-min timer ready.", flag: "ROUTINE" },
    { title: "Day 9 · You're on a streak", body: "Nine nights down, five to go. Keep it going.", flag: "PROGRESS" },
    { title: "Running low?", body: "One gel left. Tap to re-order through your dentist.", flag: "TOP-UP" },
  ];
  return (
    <div style={{
      width: "min(320px, 100%)",
      aspectRatio: "9 / 19",
      borderRadius: 44,
      border: "1.5px solid rgba(246,239,227,0.18)",
      background: "linear-gradient(180deg, #0E0B07, #1A130E)",
      padding: 11,
      boxShadow: "0 60px 100px -40px rgba(0,0,0,0.65), 0 0 80px -20px rgba(212,176,122,0.18)",
      position: "relative",
    }}>
      <div style={{
        position: "relative",
        width: "100%", height: "100%",
        borderRadius: 34,
        background: "radial-gradient(120% 80% at 50% 0%, #2B201A 0%, #0E0B07 80%)",
        padding: "44px 12px 14px",
        display: "flex", flexDirection: "column", gap: 12,
        overflow: "hidden", isolation: "isolate",
      }}>
        <div aria-hidden="true" style={{
          position: "absolute", inset: 0,
          backgroundImage: "url(\"uploads/black-box-web.png\")",
          backgroundSize: "cover", backgroundPosition: "center",
          opacity: 0.26, mixBlendMode: "screen",
        }} />
        <div style={{
          position: "absolute", left: "50%", top: 14,
          transform: "translateX(-50%)",
          width: 100, height: 24, borderRadius: 999,
          background: "#0A0805",
        }} />
        <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",
          }}>Tuesday · 22:38</div>
          <div style={{
            fontFamily: "var(--font-display)", fontWeight: 360,
            fontSize: 48, letterSpacing: "-0.03em", lineHeight: 1,
            color: "var(--pearl)", marginTop: 2,
          }}>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)",
              }}>360°/360 Whitening</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, PatientPhone });
