/* ============================================================
   Wonderwild — reusable layout sections (Rosewood-style devices)
   Depends on ww-core.jsx + ww-chrome.jsx
   ============================================================ */

/* ---------- Reveal on scroll (gentle fade/drift) ---------- */
function Reveal({ children, delay = 0, y = 24, as = "div", style }) {
  const ref = React.useRef(null);
  const [shown, setShown] = React.useState(false);
  React.useEffect(() => {
    if (window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches) { setShown(true); return; }
    const el = ref.current; if (!el) return;
    const io = new IntersectionObserver((es) => es.forEach((e) => { if (e.isIntersecting) { setShown(true); io.disconnect(); } }), { threshold: 0.12 });
    io.observe(el); return () => io.disconnect();
  }, []);
  const Tag = as;
  return <Tag ref={ref} style={{ opacity: shown ? 1 : 0, transform: shown ? "none" : `translateY(${y}px)`, transition: `opacity var(--dur-reveal) var(--ease-out) ${delay}ms, transform var(--dur-reveal) var(--ease-out) ${delay}ms`, ...style }}>{children}</Tag>;
}

/* ---------- Section wrapper ---------- */
function Band({ children, bg = "white", py = "var(--space-7)", pt, pb, id, style }) {
  const bgs = { white: "#ffffff", cream: "var(--cream-100)", alt: "var(--cream-200)", paper: "var(--cream-50)", ink: "var(--green-700)", "ink-deep": "var(--green-900)" };
  const padding = (pt || pb) ? { paddingTop: pt || py, paddingBottom: pb || py } : { padding: `${py} 0` };
  return <section id={id} style={{ background: bgs[bg], ...padding, ...style }}>{children}</section>;
}
function Container({ children, width = "1180px", style }) {
  return <div style={{ maxWidth: width, margin: "0 auto", padding: "0 36px", ...style }}>{children}</div>;
}

/* ---------- Section heading ---------- */
function SectionHeading({ eyebrow, title, lede, align = "left", onInk, max = "60ch", style }) {
  const center = align === "center";
  return (
    <div style={{ textAlign: align, display: "flex", flexDirection: "column", alignItems: center ? "center" : "flex-start", ...style }}>
      {eyebrow && <Eyebrow color={onInk ? "on-ink" : "accent"} style={{ marginBottom: "16px" }}>{eyebrow}</Eyebrow>}
      <h2 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.13em", lineHeight: 1.1, color: onInk ? "var(--cream-100)" : "var(--text-strong)", fontSize: "clamp(1.9rem, 3.2vw, 2.7rem)", margin: 0 }}>{title}</h2>
      <div style={{ width: "56px", height: "1px", background: "var(--accent)", margin: center ? "22px auto 0" : "22px 0 0" }} />
      {lede && <p style={{ font: "var(--serif-lg)", color: onInk ? "var(--green-200)" : "var(--text-body)", margin: "24px 0 0", maxWidth: max }}>{lede}</p>}
    </div>
  );
}

/* ---------- Interior page hero ---------- */
function PageHero({ eyebrow, title, lede, image, icon = "lotus", height = "66vh", align = "center" }) {
  return (
    <section style={{ position: "relative", minHeight: height, overflow: "hidden", display: "flex", alignItems: "flex-end", justifyContent: align === "center" ? "center" : "flex-start" }}>
      <Img src={image} icon={icon} style={{ position: "absolute", inset: 0 }} />
      <div style={{ position: "absolute", inset: 0, background: "linear-gradient(180deg, rgba(28,46,36,0.5) 0%, rgba(28,46,36,0.28) 45%, rgba(22,38,29,0.72) 100%)" }} />
      <div style={{ position: "relative", textAlign: align, padding: "0 32px 84px", maxWidth: align === "center" ? "760px" : "1180px", width: align === "center" ? "auto" : "100%", margin: align === "center" ? 0 : "0 auto", display: "flex", flexDirection: "column", alignItems: align === "center" ? "center" : "flex-start" }}>
        {eyebrow && <Eyebrow color="cream" style={{ marginBottom: "18px", opacity: 0.92 }}>{eyebrow}</Eyebrow>}
        <h1 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.13em", color: "var(--cream-100)", fontSize: "clamp(2.2rem, 5.2vw, 4rem)", lineHeight: 1.04, margin: 0 }}>{title}</h1>
        {lede && <p style={{ font: "var(--serif-lg)", color: "var(--cream-100)", opacity: 0.95, margin: "22px 0 0", maxWidth: "52ch" }}>{lede}</p>}
      </div>
    </section>
  );
}

/* ---------- Alternating image + editorial text band ---------- */
function ImageTextBand({ eyebrow, title, body = [], image, icon = "lotus", reverse, tag, cta, bg = "white", ratio = "4/5" }) {
  const imgEl = (
    <Reveal style={{ flex: "1 1 0", minWidth: 0 }}>
      <div style={{ position: "relative", boxShadow: "var(--shadow-image)", borderRadius: "var(--radius-md)", overflow: "hidden" }}>
        <Img src={image} icon={icon} ratio={ratio} />
        {tag && <span style={{ position: "absolute", top: "16px", left: "16px" }}><Tag tone="on-ink">{tag}</Tag></span>}
      </div>
    </Reveal>
  );
  const txtEl = (
    <Reveal delay={120} style={{ flex: "1 1 0", minWidth: 0, display: "flex", flexDirection: "column", justifyContent: "center" }}>
      {eyebrow && <Eyebrow style={{ marginBottom: "16px" }}>{eyebrow}</Eyebrow>}
      <h2 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.12em", lineHeight: 1.1, color: "var(--text-strong)", fontSize: "clamp(1.8rem, 3vw, 2.5rem)", margin: "0 0 8px" }}>{title}</h2>
      <div style={{ width: "48px", height: "1px", background: "var(--accent)", margin: "16px 0 24px" }} />
      {body.map((p, i) => <p key={i} style={{ font: i === 0 ? "var(--serif-lg)" : "var(--serif-body)", color: "var(--text-body)", margin: "0 0 18px" }}>{p}</p>)}
      {cta && <div style={{ marginTop: "10px", display: "flex", gap: "14px", flexWrap: "wrap" }}>{cta}</div>}
    </Reveal>
  );
  return (
    <Band bg={bg}>
      <Container width="1200px">
        <div className="ww-split" style={{ display: "flex", gap: "72px", alignItems: "stretch", flexDirection: reverse ? "row-reverse" : "row" }}>
          {imgEl}{txtEl}
        </div>
      </Container>
    </Band>
  );
}

/* ---------- Pull quote (dark divider) ---------- */
function PullQuote({ quote, attribution, bg = "white", noIcon, py = "var(--space-9)" }) {
  return (
    <Band bg={bg} py={py}>
      <Container width="900px" style={{ textAlign: "center" }}>
        {!noIcon && <img src={WW.ICON + "lotus-green.png"} alt="" width="48" height="48" style={{ opacity: 0.85, marginBottom: "28px" }} />}
        <Reveal>
          <p style={{ font: "var(--serif-hero)", fontSize: "clamp(1.6rem, 3.4vw, 2.6rem)", lineHeight: 1.28, color: "var(--text-strong)", margin: 0, textWrap: "balance" }}>"{quote}"</p>
          {attribution && <div style={{ fontFamily: "var(--font-label)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "var(--track-eyebrow)", fontSize: "0.72rem", color: "var(--clay-500)", marginTop: "28px" }}>{attribution}</div>}
        </Reveal>
      </Container>
    </Band>
  );
}

/* ---------- Feature band (woodcut icons) ---------- */
function FeatureBand({ eyebrow = "Immersed in nature", title = "Find Your Wonder", items }) {
  const data = items || [
    { name: "tent", label: "Bell Tents", cap: "Spacious canvas with fire pit & hanging grill." },
    { name: "swim", label: "Wild Swim", cap: "Open water, no motor cruisers — just reeds & birdsong." },
    { name: "paddle", label: "Paddleboard", cap: "Drift the broad at your own gentle pace." },
    { name: "sauna", label: "Wood-Fired Sauna", cap: "Broadside heat to relax and recharge." },
  ];
  return (
    <Band bg="white">
      <Container width="1180px">
        <div style={{ marginBottom: "var(--space-8)" }}><SectionHeading eyebrow={eyebrow} title={title} align="center" /></div>
        <div className="ww-feat-grid" style={{ display: "grid", gridTemplateColumns: `repeat(${data.length}, 1fr)`, gap: "30px" }}>
          {data.map((it) => (
            <Reveal key={it.label} style={{ textAlign: "center", display: "flex", flexDirection: "column", alignItems: "center", gap: "16px" }}>
              <img src={WW.ICON + it.name + "-green.png"} alt="" width="64" height="64" />
              <div style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.14em", fontSize: "0.95rem", color: "var(--text-strong)" }}>{it.label}</div>
              <p style={{ font: "var(--serif-sm)", color: "var(--text-body)", margin: 0, maxWidth: "24ch" }}>{it.cap}</p>
            </Reveal>
          ))}
        </div>
      </Container>
    </Band>
  );
}

/* ---------- Tabbed carousel (Rosewood signature) ---------- */
function TabbedCarousel({ eyebrow, heading, tabs, pt, bg = "cream" }) {
  const [active, setActive] = React.useState(0);
  const t = tabs[active];
  const book = useBook();
  return (
    <Band bg={bg} pt={pt}>
      <Container width="1240px">
        <div style={{ marginBottom: "var(--space-7)" }}><SectionHeading eyebrow={eyebrow} title={heading} align="center" /></div>
        {/* tab strip */}
        <div style={{ display: "flex", justifyContent: "center", flexWrap: "wrap", gap: "8px", marginBottom: "var(--space-7)", borderBottom: "1px solid var(--cream-300)" }}>
          {tabs.map((tab, i) => (
            <button key={tab.label} onClick={() => setActive(i)} style={{ background: "none", border: "none", cursor: "pointer", padding: "14px 22px", marginBottom: "-1px", borderBottom: `2px solid ${i === active ? "var(--accent)" : "transparent"}`, fontFamily: "var(--font-label)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.16em", fontSize: "0.74rem", color: i === active ? "var(--green-800)" : "var(--text-muted)", transition: "color var(--dur-fast), border-color var(--dur-fast)" }}>{tab.label}</button>
          ))}
        </div>
        {/* panel */}
        <div className="ww-split" key={active} style={{ display: "flex", gap: "64px", alignItems: "center", animation: "wwFade var(--dur-slow) var(--ease-out)" }}>
          <div className="ww-tab-img-wrap" style={{ flex: "1.05 1 0", minWidth: 0, boxShadow: "var(--shadow-image)", borderRadius: "var(--radius-md)", overflow: "hidden" }}>
            <Img src={t.image} icon={t.icon} ratio="3/2" />
          </div>
          <div style={{ flex: "1 1 0", minWidth: 0 }}>
            {t.tag && <div style={{ marginBottom: "16px" }}><Tag tone="clay">{t.tag}</Tag></div>}
            <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.12em", color: "var(--text-strong)", fontSize: "clamp(1.6rem, 2.6vw, 2.2rem)", lineHeight: 1.12, margin: "0 0 18px" }}>{t.title}</h3>
            {t.body.map((p, i) => <p key={i} style={{ font: i === 0 ? "var(--serif-lg)" : "var(--serif-body)", color: "var(--text-body)", margin: "0 0 16px" }}>{p}</p>)}
            <div style={{ display: "flex", gap: "14px", flexWrap: "wrap", marginTop: "10px" }}>
              {t.href && <Button variant="primary" size="md" href={t.href}>{t.ctaLabel || "Discover"}</Button>}
              {t.bookKey && <Button variant="secondary" size="md" onClick={() => book(t.bookKey)}>{t.bookLabel || "Book"}</Button>}
            </div>
          </div>
        </div>
      </Container>
    </Band>
  );
}

/* ---------- Includes / checklist grid ---------- */
function IncludesGrid({ eyebrow, title, lede, items, columns = 2, bg = "white", pt, pb }) {
  return (
    <Band bg={bg} pt={pt} pb={pb}>
      <Container width="1080px">
        {(title || eyebrow) && <div style={{ marginBottom: "var(--space-7)" }}><SectionHeading eyebrow={eyebrow} title={title} lede={lede} align="center" max="56ch" style={{ alignItems: "center" }} /></div>}
        <div style={{ display: "grid", gridTemplateColumns: `repeat(${columns}, 1fr)`, columnGap: "40px" }} className="ww-inc-grid">
          {items.map((it, i) => (
            <React.Fragment key={i}>
              {i % columns === 0 && i > 0 && (
                <div style={{ gridColumn: "1 / -1", height: "1px", background: "var(--cream-300)" }} />
              )}
              <Reveal delay={i * 40} style={{ display: "flex", gap: "16px", alignItems: "flex-start", padding: "18px 0" }}>
                <span style={{ flexShrink: 0, width: "30px", height: "30px", borderRadius: "999px", background: "var(--green-100)", color: "var(--green-700)", display: "inline-flex", alignItems: "center", justifyContent: "center" }}>{React.cloneElement(Icons.check, { size: 16 })}</span>
                <div>
                  <div style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.1em", fontSize: "0.82rem", color: "var(--text-strong)", marginBottom: "5px" }}>{it.label}</div>
                  {it.desc && <p style={{ font: "var(--serif-sm)", color: "var(--text-body)", margin: 0 }}>{it.desc}</p>}
                </div>
              </Reveal>
            </React.Fragment>
          ))}
        </div>
      </Container>
    </Band>
  );
}

/* ---------- Accordion (FAQ) ---------- */
function Accordion({ items, defaultOpen = -1 }) {
  const [open, setOpen] = React.useState(defaultOpen);
  return (
    <div style={{ display: "flex", flexDirection: "column" }}>
      {items.map((it, i) => {
        const isOpen = open === i;
        return (
          <div key={i} style={{ borderBottom: "1px solid var(--cream-300)" }}>
            <button onClick={() => setOpen(isOpen ? -1 : i)} style={{ width: "100%", background: "none", border: "none", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "space-between", gap: "20px", padding: "26px 4px", textAlign: "left" }}>
              <span style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.08em", fontSize: "1rem", color: isOpen ? "var(--green-700)" : "var(--text-strong)", transition: "color var(--dur-fast)" }}>{it.q}</span>
              <span style={{ flexShrink: 0, color: "var(--accent)" }}>{isOpen ? Icons.minus({ size: 20 }) : Icons.plus({ size: 20 })}</span>
            </button>
            <div style={{ maxHeight: isOpen ? "440px" : "0", overflow: "hidden", transition: "max-height var(--dur-base) var(--ease-out)" }}>
              <div style={{ padding: "0 4px 28px", maxWidth: "62ch" }}>
                {(Array.isArray(it.a) ? it.a : [it.a]).map((p, j) => <p key={j} style={{ font: "var(--serif-body)", color: "var(--text-body)", margin: j === 0 ? "0 0 14px" : "0 0 14px" }}>{p}</p>)}
              </div>
            </div>
          </div>
        );
      })}
    </div>
  );
}

/* ---------- Closing CTA band ---------- */
function CtaBand({ eyebrow, title, body, primary, secondary, bg = "white", icon = "lotus", noIcon }) {
  const onInk = bg === "ink" || bg === "ink-deep";
  return (
    <Band bg={bg} py="var(--space-9)">
      <Container width="800px" style={{ textAlign: "center" }}>
        {!noIcon && <img src={WW.ICON + icon + (onInk ? "-cream.png" : "-green.png")} alt="" width="52" height="52" style={{ opacity: 0.9, marginBottom: "24px" }} />}
        {eyebrow && <Eyebrow color={onInk ? "on-ink" : "accent"} style={{ marginBottom: "16px" }}>{eyebrow}</Eyebrow>}
        <h2 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.13em", lineHeight: 1.1, color: onInk ? "var(--cream-100)" : "var(--text-strong)", fontSize: "clamp(1.9rem, 3.2vw, 2.7rem)", margin: "0 0 20px" }}>{title}</h2>
        {body && <p style={{ font: "var(--serif-lg)", color: onInk ? "var(--green-200)" : "var(--text-body)", margin: "0 auto 32px", maxWidth: "48ch" }}>{body}</p>}
        <div style={{ display: "flex", gap: "16px", justifyContent: "center", flexWrap: "wrap" }}>{primary}{secondary}</div>
      </Container>
    </Band>
  );
}

/* ---------- Newsletter / Follow our story ---------- */
function Newsletter() {
  const [done, setDone] = React.useState(false);
  return (
    <Band bg="white">
      <Container width="1100px">
        <div className="ww-story-grid" style={{ display: "grid", gridTemplateColumns: "1.1fr 0.9fr", gap: "72px", alignItems: "center" }}>
          <div>
            <Eyebrow>One season at a time</Eyebrow>
            <h2 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.12em", color: "var(--text-strong)", fontSize: "clamp(1.9rem, 3.2vw, 2.7rem)", lineHeight: 1.1, margin: "16px 0 22px" }}>Follow Our Story</h2>
            <p style={{ font: "var(--serif-lg)", color: "var(--text-body)", margin: "0 0 18px" }}>We're softly bringing this place to life — one tent, one path, one season at a time.</p>
            <p style={{ font: "var(--serif-body)", color: "var(--text-body)", margin: "0 0 28px" }}>Follow along as our nature-led escape takes shape, and be the first to hear about new dates, sessions and retreats.</p>
            <div style={{ display: "flex", gap: "16px" }}>
              <a href="https://www.instagram.com/wewonderwild" target="_blank" rel="noreferrer" style={{ color: "var(--green-700)", display: "inline-flex" }}>{Icons.instagram}</a>
              <a href="#" onClick={(e) => e.preventDefault()} style={{ color: "var(--green-700)", display: "inline-flex" }}>{Icons.facebook}</a>
            </div>
          </div>
          <div style={{ background: "var(--cream-50)", border: "1px solid var(--cream-300)", borderRadius: "var(--radius-lg)", padding: "34px", boxShadow: "var(--shadow-sm)" }}>
            {done ? (
              <div style={{ textAlign: "center", padding: "20px 0" }}>
                <div style={{ width: "48px", height: "48px", borderRadius: "999px", background: "var(--green-100)", color: "var(--green-700)", display: "inline-flex", alignItems: "center", justifyContent: "center", marginBottom: "16px" }}>{Icons.check}</div>
                <h4 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.12em", fontSize: "1.05rem", color: "var(--text-strong)", margin: "0 0 8px" }}>You're on the list</h4>
                <p style={{ font: "var(--serif-sm)", color: "var(--text-muted)", margin: 0 }}>We'll be in touch as the site takes shape.</p>
              </div>
            ) : (
              <>
                <h4 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.12em", fontSize: "1rem", color: "var(--text-strong)", margin: "0 0 6px" }}>Be the first to know</h4>
                <p style={{ font: "var(--sans-sm)", color: "var(--text-muted)", margin: "0 0 22px" }}>Latest dates, sessions, discounts and more.</p>
                <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "18px", marginBottom: "20px" }}>
                  <Field label="First Name" required />
                  <Field label="Last Name" required />
                </div>
                <div style={{ marginBottom: "26px" }}><Field label="Email" type="email" required /></div>
                <Button variant="primary" size="md" onClick={() => setDone(true)} style={{ width: "100%" }}>Sign Up</Button>
              </>
            )}
          </div>
        </div>
      </Container>
    </Band>
  );
}

/* ---------- Price rows (bordered list: title · desc · meta · price · cta) ---------- */
function PriceRows({ items, note }) {
  return (
    <div>
      <div style={{ display: "flex", flexDirection: "column", border: "1px solid var(--cream-300)", borderRadius: "var(--radius-md)", overflow: "hidden", background: "var(--surface-card)" }}>
        {items.map((s, i) => (
          <Reveal key={i} className="ww-split" style={{ display: "flex", alignItems: "center", gap: "24px", padding: "22px 28px", borderBottom: "1px solid var(--cream-300)" }}>
            <div style={{ flex: 1, minWidth: 0 }}>
              <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.1em", color: "var(--text-strong)", fontSize: "1.02rem", margin: "0 0 5px" }}>{s.title}</h3>
              {s.desc && <p style={{ font: "var(--serif-sm)", color: "var(--text-body)", margin: "0 0 4px", maxWidth: "60ch" }}>{s.desc}</p>}
              {s.meta && <span style={{ fontFamily: "var(--font-label)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.14em", fontSize: "0.64rem", color: "var(--text-muted)" }}>{s.meta}</span>}
            </div>
            <div style={{ textAlign: "right", display: "flex", flexDirection: "column", alignItems: "flex-end", gap: "10px", flexShrink: 0 }}>
              {s.price && <span style={{ fontFamily: "var(--font-serif)", fontSize: "1.4rem", lineHeight: 1, color: "var(--green-700)", whiteSpace: "nowrap" }}>{s.price}</span>}
              {s.cta}
            </div>
          </Reveal>
        ))}
      </div>
      {note && <p style={{ font: "var(--serif-sm)", color: "var(--text-muted)", textAlign: "center", margin: "26px auto 0", maxWidth: "64ch" }}>{note}</p>}
    </div>
  );
}

/* ---------- Price / membership cards ---------- */
function PriceCards({ items, columns = 3, note }) {
  return (
    <div>
      <div className={"ww-cards-" + columns} style={{ display: "grid", gridTemplateColumns: `repeat(${columns}, 1fr)`, gap: "22px", alignItems: "stretch" }}>
        {items.map((t) => (
          <Reveal key={t.name}>
            <article style={{ height: "100%", display: "flex", flexDirection: "column", background: t.featured ? "var(--green-700)" : "var(--surface-card)", border: "1px solid " + (t.featured ? "var(--green-700)" : "var(--cream-300)"), borderRadius: "var(--radius-lg)", padding: "32px 28px", boxShadow: t.featured ? "var(--shadow-md)" : "var(--shadow-sm)" }}>
              {t.feature && <Eyebrow color={t.featured ? "on-ink" : "accent"} style={{ marginBottom: "12px" }}>{t.feature}</Eyebrow>}
              <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.11em", color: t.featured ? "var(--cream-100)" : "var(--text-strong)", fontSize: "1.18rem", margin: "0 0 12px" }}>{t.name}</h3>
              <div style={{ display: "flex", alignItems: "baseline", gap: "6px", marginBottom: "8px" }}>
                <span style={{ fontFamily: "var(--font-serif)", fontSize: "2.3rem", lineHeight: 1, color: t.featured ? "var(--cream-100)" : "var(--green-700)" }}>{t.price}</span>
                {t.per && <span style={{ font: "var(--serif-sm)", color: t.featured ? "var(--green-200)" : "var(--text-muted)" }}>{t.per}</span>}
              </div>
              {t.tagline && <p style={{ font: "var(--serif-sm)", color: t.featured ? "var(--green-200)" : "var(--text-muted)", margin: "0 0 18px" }}>{t.tagline}</p>}
              <div style={{ display: "flex", flexDirection: "column", gap: "11px", margin: "8px 0 24px", flex: 1 }}>
                {(t.points || []).map((p) => (
                  <div key={p} style={{ display: "flex", gap: "10px", alignItems: "flex-start" }}>
                    <span style={{ color: t.featured ? "var(--clay-300)" : "var(--green-500)", flexShrink: 0, marginTop: "1px" }}>{React.cloneElement(Icons.check, { size: 15 })}</span>
                    <span style={{ font: "var(--serif-sm)", color: t.featured ? "var(--cream-100)" : "var(--text-body)" }}>{p}</span>
                  </div>
                ))}
              </div>
              {t.cta}
              {t.footnote && <p style={{ font: "var(--serif-xs)", color: t.featured ? "var(--green-200)" : "var(--text-muted)", margin: "12px 0 0", textAlign: "center" }}>{t.footnote}</p>}
            </article>
          </Reveal>
        ))}
      </div>
      {note && <p style={{ font: "var(--serif-sm)", color: "var(--text-muted)", textAlign: "center", margin: "26px auto 0", maxWidth: "64ch" }}>{note}</p>}
    </div>
  );
}

/* ---------- Event rows (What's On) ---------- */
function EventRows({ items }) {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
      {items.map((e, i) => (
        <Reveal key={i} delay={i * 50} className="ww-split" style={{ display: "flex", gap: "26px", alignItems: "center", background: "var(--surface-card)", border: "1px solid var(--cream-300)", borderRadius: "var(--radius-md)", padding: "22px 26px", boxShadow: "var(--shadow-sm)" }}>
          <div style={{ flexShrink: 0, width: "78px", textAlign: "center", borderRight: "1px solid var(--cream-300)", paddingRight: "20px" }}>
            <div style={{ fontFamily: "var(--font-display)", fontWeight: 700, fontSize: "1.7rem", color: "var(--green-700)", lineHeight: 1 }}>{e.date}</div>
            <div style={{ fontFamily: "var(--font-label)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.16em", fontSize: "0.66rem", color: "var(--clay-500)", marginTop: "6px" }}>{e.month}</div>
          </div>
          <div style={{ flex: 1, minWidth: 0 }}>
            {e.tag && <div style={{ marginBottom: "8px" }}><Tag tone="soft">{e.tag}</Tag></div>}
            <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.1em", color: "var(--text-strong)", fontSize: "1.05rem", margin: "0 0 6px" }}>{e.title}</h3>
            <p style={{ font: "var(--serif-sm)", color: "var(--text-body)", margin: "0 0 4px", maxWidth: "62ch" }}>{e.text}</p>
            {e.meta && <span style={{ fontFamily: "var(--font-label)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.14em", fontSize: "0.64rem", color: "var(--text-muted)" }}>{e.meta}</span>}
          </div>
          {e.cta && <div style={{ flexShrink: 0 }}>{e.cta}</div>}
        </Reveal>
      ))}
    </div>
  );
}

/* ---------- Story timeline (Our Story) ---------- */
function StoryTimeline({ items }) {
  return (
    <div style={{ display: "flex", flexDirection: "column" }}>
      {items.map((it, i) => (
        <Reveal key={i} delay={i * 60} style={{ display: "flex", gap: "32px", alignItems: "flex-start", paddingBottom: i === items.length - 1 ? 0 : "var(--space-7)" }} className="ww-split">
          <div style={{ flexShrink: 0, width: "120px", textAlign: "right" }}>
            <div style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.12em", fontSize: "1.05rem", color: "var(--clay-500)" }}>{it.year}</div>
          </div>
          <div style={{ flex: 1, minWidth: 0, borderLeft: "1px solid var(--cream-300)", paddingLeft: "32px", paddingBottom: "8px" }}>
            <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.1em", color: "var(--text-strong)", fontSize: "1.1rem", margin: "0 0 12px" }}>{it.title}</h3>
            {(Array.isArray(it.body) ? it.body : [it.body]).map((p, j) => <p key={j} style={{ font: "var(--serif-body)", color: "var(--text-body)", margin: "0 0 14px", maxWidth: "60ch" }}>{p}</p>)}
          </div>
        </Reveal>
      ))}
    </div>
  );
}

Object.assign(window, { Reveal, Band, Container, SectionHeading, PageHero, ImageTextBand, PullQuote, FeatureBand, TabbedCarousel, IncludesGrid, Accordion, CtaBand, Newsletter, PriceRows, PriceCards, EventRows, StoryTimeline });
