// PELSKIN — shared components, products, bottle silhouettes
const { useState, useEffect, useRef, useMemo, createContext, useContext } = React;

// ---------- Payments (Paystack, Ghana) ----------
// Test-Modus: pk_test-Key ist öffentlich (client-seitig by design).
// Für den Livegang: durch pk_live ersetzen. Der Secret Key gehört NIE hierher.
const PAYSTACK_PUBLIC_KEY = "pk_test_ea5c74cf579c740d783929e887c223e8dc9b792f";
// Preise werden in USD angezeigt, abgerechnet wird in GHS (Paystack-Ghana-Konto).
// Kurs vor Livegang mit Esther abstimmen und hier pflegen:
const USD_TO_GHS = 15;
const toGHS = (usd) => Math.round(usd * USD_TO_GHS);

// ---------- Products ----------
const PRODUCTS = [
  {
    slug: "silk-wash",
    name: "Silk Wash",
    tagline: "Gentle Cleanser",
    accent: "Brighten + Balance",
    subhead: "Cleanses gently while maintaining balance.",
    priceUSD: 20,
    size: "100 ml / 3.4 fl oz",
    keyIngredients: ["Niacinamide", "Sodium PCA"],
    claims: ["Sulfate free", "Barrier safe", "Daily use"],
    description: "A gentle pH balanced cleanser that respects the skin barrier. Removes impurities without stripping. Suitable for all skin types, especially sensitive and reactive.",
    howToUse: "Massage onto damp skin morning and evening. Rinse with lukewarm water.",
    bottleType: "pump",
    bottleTone: "warm",
  },
  {
    slug: "clarity-serum",
    name: "Clarity Serum",
    tagline: "Brighten + Clarify",
    accent: "Tone Evening Treatment",
    subhead: "Targets dullness for clearer, radiant skin.",
    priceUSD: 28,
    size: "30 ml / 1.0 fl oz",
    keyIngredients: ["Niacinamide", "Tone-evening actives"],
    claims: ["Tone evening", "Lightweight", "Daily or evening"],
    description: "Not brighter. Clearer. There's a difference. A lightweight serum for a clearer, more even looking complexion over time.",
    howToUse: "Apply 3 to 4 drops to clean skin before moisturizer. Start once daily in the evening, build up to twice daily.",
    bottleType: "dropper",
    bottleTone: "frosted",
  },
  {
    slug: "barrier-repair-cream",
    name: "Barrier Repair Cream",
    tagline: "Nourish + Protect",
    accent: "Barrier Support Moisturizer",
    subhead: "Nourishes deeply and supports the skin barrier.",
    priceUSD: 30,
    size: "50 ml / 1.69 fl oz",
    keyIngredients: ["Ceramides", "Peptides", "Panthenol"],
    claims: ["Hydrates", "Calms", "Strengthens barrier"],
    description: "A rich yet weightless moisturizer that calms, restores and supports the skin barrier for a smooth balanced glow.",
    howToUse: "Apply morning and evening as the final step.",
    bottleType: "airless",
    bottleTone: "warm",
  },
];

const BUNDLE = {
  slug: "the-system",
  name: "The System",
  tagline: "The Complete Ritual",
  accent: "Cleanse. Correct. Restore.",
  subhead: "Cleanse. Correct. Restore.",
  type: "bundle",
  includes: ["silk-wash", "clarity-serum", "barrier-repair-cream"],
  priceUSDIndividual: 78,
  priceUSDBundle: 70,
  discountPercent: 10,
  savingsCopy: "Save 10% when you buy the full system.",
  description: "The 3 step ritual designed to work together. Silk Wash to cleanse, Clarity Serum to correct, Barrier Repair Cream to restore. One ritual. Skin that reflects care.",
  howToUse: "Morning: Silk Wash, then Barrier Repair Cream. Evening: Silk Wash, then Clarity Serum, then Barrier Repair Cream.",
  badge: "Best value",
};

const ALL_PRODUCTS = [...PRODUCTS, BUNDLE];

const productBySlug = (slug) => ALL_PRODUCTS.find((p) => p.slug === slug);

// ---------- Product images (cropped from real product shots, with SVG fallback) ----------
const PRODUCT_IMG = {
  "silk-wash": "images/silk-wash-cutout.png",
  "clarity-serum": "images/clarity-serum-cutout.png",
  "barrier-repair-cream": "images/barrier-repair-cream-cutout.png",
};

function Bottle({ type = "pump", tone = "warm", label = "PELSKIN", sub = "", slug }) {
  // Resolve slug from sub if not provided
  if (!slug) {
    if (sub.includes("Cleanser") || type === "pump") slug = "silk-wash";
    else if (sub.includes("Clarity") || type === "dropper") slug = "clarity-serum";
    else if (type === "airless") slug = "barrier-repair-cream";
  }
  const src = PRODUCT_IMG[slug];
  if (src) {
    return (
      <img
        src={src}
        alt={slug}
        style={{
          display: "block",
          width: "auto",
          maxWidth: "85%",
          height: "100%",
          maxHeight: "100%",
          objectFit: "contain",
          objectPosition: "center bottom",
        }}
      />
    );
  }
  const fill = tone === "frosted" ? "#F2EBE0" : tone === "deep" ? "#C4A485" : "#D4B894";
  const stroke = "#A8896A";
  const text = "#5C4033";

  if (type === "pump") {
    return (
      <svg className="bottle" viewBox="0 0 120 220" xmlns="http://www.w3.org/2000/svg">
        {/* nozzle */}
        <rect x="46" y="6" width="28" height="6" fill={fill} stroke={stroke} strokeWidth="0.5" />
        <rect x="56" y="0" width="22" height="14" fill={fill} stroke={stroke} strokeWidth="0.5" />
        {/* collar */}
        <rect x="40" y="12" width="40" height="22" rx="2" fill={fill} stroke={stroke} strokeWidth="0.5" />
        {/* body */}
        <rect x="20" y="34" width="80" height="180" rx="4" fill={fill} stroke={stroke} strokeWidth="0.5" />
        <text x="60" y="92" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="11" letterSpacing="2">{label}</text>
        <line x1="36" y1="108" x2="84" y2="108" stroke={stroke} strokeWidth="0.5" />
        <text x="60" y="138" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="9">{sub.split(" ")[0]}</text>
        <text x="60" y="150" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="9">{sub.split(" ").slice(1).join(" ")}</text>
        <text x="60" y="200" textAnchor="middle" fill={text} fontFamily="Inter, sans-serif" fontSize="6" letterSpacing="0.5">100 ml / 3.4 fl oz</text>
      </svg>
    );
  }
  if (type === "dropper") {
    return (
      <svg className="bottle" viewBox="0 0 120 220" xmlns="http://www.w3.org/2000/svg">
        {/* dropper bulb */}
        <ellipse cx="60" cy="14" rx="14" ry="10" fill="#EDE4D7" stroke={stroke} strokeWidth="0.5" />
        <rect x="56" y="22" width="8" height="22" fill="#EDE4D7" stroke={stroke} strokeWidth="0.5" />
        {/* cap */}
        <rect x="38" y="44" width="44" height="20" rx="2" fill={fill} stroke={stroke} strokeWidth="0.5" />
        {/* body — frosted */}
        <rect x="26" y="64" width="68" height="148" rx="4" fill={fill} stroke={stroke} strokeWidth="0.5" opacity="0.9" />
        <text x="60" y="116" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="11" letterSpacing="2">{label}</text>
        <line x1="40" y1="130" x2="80" y2="130" stroke={stroke} strokeWidth="0.5" />
        <text x="60" y="156" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="9">{sub.split(" ")[0]}</text>
        <text x="60" y="168" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="9">{sub.split(" ").slice(1).join(" ")}</text>
        <text x="60" y="200" textAnchor="middle" fill={text} fontFamily="Inter, sans-serif" fontSize="6" letterSpacing="0.5">30 ml / 1.0 fl oz</text>
      </svg>
    );
  }
  // airless
  return (
    <svg className="bottle" viewBox="0 0 120 220" xmlns="http://www.w3.org/2000/svg">
      <rect x="22" y="6" width="76" height="40" rx="3" fill={fill} stroke={stroke} strokeWidth="0.5" />
      <circle cx="80" cy="22" r="2" fill={stroke} />
      <line x1="22" y1="46" x2="98" y2="46" stroke={stroke} strokeWidth="0.5" />
      <rect x="22" y="46" width="76" height="168" rx="3" fill={fill} stroke={stroke} strokeWidth="0.5" />
      <text x="60" y="100" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="11" letterSpacing="2">{label}</text>
      <line x1="38" y1="116" x2="82" y2="116" stroke={stroke} strokeWidth="0.5" />
      <text x="60" y="142" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="9">Barrier Repair</text>
      <text x="60" y="154" textAnchor="middle" fill={text} fontFamily="Cormorant Garamond, serif" fontSize="9">Cream</text>
      <text x="60" y="200" textAnchor="middle" fill={text} fontFamily="Inter, sans-serif" fontSize="6" letterSpacing="0.5">50 ml / 1.69 fl oz</text>
    </svg>
  );
}

function BottleTrio() {
  return (
    <img
      src="images/the-system.jpg"
      alt="The Pelskin System"
      style={{ display: "block", width: "100%", height: "100%", objectFit: "cover" }}
    />
  );
}

// ---------- Icons (minimal line icons) ----------
const Icon = {
  Cart: (p) => (
    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" {...p}>
      <path d="M5 7h14l-1.4 11.2a2 2 0 0 1-2 1.8H8.4a2 2 0 0 1-2-1.8L5 7Z"/>
      <path d="M9 7V5a3 3 0 0 1 6 0v2"/>
    </svg>
  ),
  Menu: (p) => (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" {...p}>
      <path d="M4 7h16M4 12h16M4 17h16"/>
    </svg>
  ),
  Close: (p) => (
    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" {...p}>
      <path d="M6 6l12 12M18 6L6 18"/>
    </svg>
  ),
  ArrowRight: (p) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M5 12h14M13 6l6 6-6 6"/>
    </svg>
  ),
  ArrowLeft: (p) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M19 12H5M11 6l-6 6 6 6"/>
    </svg>
  ),
  Plus: (p) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" {...p}>
      <path d="M12 5v14M5 12h14"/>
    </svg>
  ),
  Check: (p) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M5 12l5 5L20 7"/>
    </svg>
  ),
  Instagram: (p) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" {...p}>
      <rect x="3" y="3" width="18" height="18" rx="4"/>
      <circle cx="12" cy="12" r="4"/>
      <circle cx="17.5" cy="6.5" r="0.6" fill="currentColor"/>
    </svg>
  ),
};

// ---------- App context ----------
const AppCtx = createContext(null);
const useApp = () => useContext(AppCtx);

// ---------- Header ----------
function Header({ onOpenMenu, onOpenCart, onOpenWaitlist }) {
  const { route, navigate, mode, cart } = useApp();
  const [scrolled, setScrolled] = useState(false);

  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 8);
    window.addEventListener("scroll", onScroll, { passive: true });
    onScroll();
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  const cartCount = cart.reduce((s, i) => s + i.qty, 0);
  const navItems = [
    { label: "Shop", route: "shop", liveOnly: true },
    { label: "The System", route: "system" },
    { label: "Journal", route: "journal" },
    { label: "Quiz", route: "quiz" },
    { label: "About", route: "about" },
  ];

  return (
    <header className={"header " + (scrolled ? "scrolled" : "transparent")}>
      <button className="wordmark" onClick={() => navigate("home")} aria-label="Pelskin home">PELSKIN</button>
      <nav className="nav-desktop">
        {navItems.filter(n => mode === "live" || !n.liveOnly).map(n => (
          <a key={n.route} className={route === n.route ? "active" : ""} onClick={() => navigate(n.route)}>{n.label}</a>
        ))}
      </nav>
      <div className="nav-right">
        {mode === "waitlist" ? (
          <button className="btn btn-secondary" style={{padding: "10px 18px", fontSize: 11}} onClick={onOpenWaitlist}>Waitlist</button>
        ) : (
          <button className="icon-btn" onClick={onOpenCart} aria-label="Open cart">
            <Icon.Cart />
            {cartCount > 0 && <span className="cart-badge">{cartCount}</span>}
          </button>
        )}
        <button className="icon-btn hamburger" onClick={onOpenMenu} aria-label="Open menu"><Icon.Menu /></button>
      </div>
    </header>
  );
}

// ---------- Mobile Menu ----------
function MobileMenu({ open, onClose }) {
  const { navigate, mode } = useApp();
  const items = [
    { label: "Home", route: "home" },
    ...(mode === "live" ? [{ label: "Shop", route: "shop" }] : []),
    { label: "The System", route: "system" },
    { label: "Journal", route: "journal" },
    { label: "Quiz", route: "quiz" },
    { label: "About", route: "about" },
    { label: "FAQ", route: "faq" },
    { label: "Waitlist", route: "waitlist" },
  ];
  return (
    <>
      <div className={"sheet-overlay " + (open ? "open" : "")} onClick={onClose} />
      <div className={"mobile-menu " + (open ? "open" : "")}>
        <div style={{display:"flex", justifyContent:"space-between", alignItems:"center", marginBottom: 8}}>
          <span className="smallcaps">Menu</span>
          <button className="icon-btn" onClick={onClose}><Icon.Close /></button>
        </div>
        {items.map(i => (
          <button key={i.route} className="mobile-link" onClick={() => { navigate(i.route); onClose(); }}>{i.label}</button>
        ))}
      </div>
    </>
  );
}

// ---------- Footer ----------
function Footer() {
  const { navigate } = useApp();
  return (
    <footer className="footer">
      <div className="container">
        <div className="footer-grid">
          <div>
            <div className="wordmark" style={{marginBottom: 16}}>PELSKIN</div>
            <p style={{fontSize: 14, color: "var(--text-secondary)", maxWidth: 320, lineHeight: 1.7}}>
              Three essentials. One ritual. Skin that reflects care.
            </p>
            <p style={{fontSize: 12, color: "var(--text-muted)", marginTop: 16, letterSpacing: "0.04em"}}>Made simple. Made in Ghana.</p>
          </div>
          <div>
            <h5>Shop</h5>
            <div className="footer-links">
              <a onClick={() => navigate("shop")}>The System</a>
              <a onClick={() => navigate("product:silk-wash")}>Silk Wash</a>
              <a onClick={() => navigate("product:clarity-serum")}>Clarity Serum</a>
              <a onClick={() => navigate("product:barrier-repair-cream")}>Barrier Repair Cream</a>
            </div>
          </div>
          <div>
            <h5>Help</h5>
            <div className="footer-links">
              <a onClick={() => navigate("shipping")}>Shipping</a>
              <a onClick={() => navigate("faq")}>FAQ</a>
              <a onClick={() => navigate("about")}>About</a>
              <a href="mailto:hallo@pelskin.co">Contact</a>
            </div>
          </div>
          <div>
            <h5>Stay close</h5>
            <p style={{fontSize: 14, color: "var(--text-secondary)", marginBottom: 14}}>
              Quiet emails. New essentials. Routine notes.
            </p>
            <FooterSubscribe />
            <a href="https://instagram.com/pelskin.co" target="_blank" rel="noreferrer" style={{display:"inline-flex", alignItems:"center", gap: 8, marginTop: 18, fontSize: 12, color: "var(--text-secondary)", letterSpacing: "0.16em", textTransform: "uppercase"}}>
              <Icon.Instagram /> @pelskin.co
            </a>
          </div>
        </div>
        <div className="footer-bottom">
          <span>© Pelskin 2026 · Accra, Ghana</span>
          <span>Visa · Mastercard · MTN MoMo</span>
        </div>
      </div>
    </footer>
  );
}

function FooterSubscribe() {
  const { toast } = useApp();
  const [email, setEmail] = useState("");
  const [done, setDone] = useState(false);
  const submit = (e) => {
    e.preventDefault();
    if (!email.includes("@")) return;
    setDone(true); setEmail("");
    toast("You're on the list. Welcome.");
    setTimeout(() => setDone(false), 4000);
  };
  return (
    <form onSubmit={submit} style={{display:"flex", gap: 0, borderBottom: "1px solid var(--accent-line)"}}>
      <input className="input" style={{padding: "10px 0", fontSize: 15, borderBottom: "none"}} type="email" placeholder={done ? "Thank you." : "Your email"} value={email} onChange={(e)=>setEmail(e.target.value)} />
      <button type="submit" className="icon-btn" style={{flex:"0 0 auto"}}><Icon.ArrowRight /></button>
    </form>
  );
}

// ---------- Cart Sheet ----------
function CartSheet({ open, onClose }) {
  const { cart, updateQty, removeItem, navigate, toast } = useApp();
  const [email, setEmail] = useState("");
  const subtotal = cart.reduce((s, i) => {
    const p = productBySlug(i.slug);
    if (!p) return s;
    const price = p.type === "bundle" ? p.priceUSDBundle : p.priceUSD;
    return s + price * i.qty;
  }, 0);
  const totalGHS = toGHS(subtotal);
  const checkout = () => {
    if (!email.includes("@")) { toast("Please enter your email to continue."); return; }
    if (typeof PaystackPop === "undefined") { toast("Payment is still loading — please try again."); return; }
    const orderSummary = cart
      .map((i) => `${i.qty}x ${productBySlug(i.slug)?.name || i.slug}`)
      .join(", ");
    const handler = PaystackPop.setup({
      key: PAYSTACK_PUBLIC_KEY,
      email,
      amount: totalGHS * 100, // Pesewas
      currency: "GHS",
      metadata: {
        custom_fields: [
          { display_name: "Order", variable_name: "order", value: orderSummary },
          { display_name: "Subtotal USD", variable_name: "subtotal_usd", value: `$${subtotal}` },
        ],
      },
      callback: (resp) => {
        onClose();
        navigate("checkout-success");
        toast("Payment received · Ref " + resp.reference);
      },
      onClose: () => toast("Checkout closed — your bag is saved."),
    });
    handler.openIframe();
  };
  return (
    <>
      <div className={"sheet-overlay " + (open ? "open" : "")} onClick={onClose} />
      <aside className={"sheet " + (open ? "open" : "")} aria-hidden={!open}>
        <div className="sheet-head">
          <span className="smallcaps">Your Ritual</span>
          <button className="icon-btn" onClick={onClose}><Icon.Close /></button>
        </div>
        <div className="sheet-body">
          {cart.length === 0 ? (
            <div style={{textAlign:"center", padding: "40px 0"}}>
              <p className="serif" style={{fontSize: 22, marginBottom: 8}}>Your bag is empty.</p>
              <p className="muted" style={{fontSize: 14, marginBottom: 24}}>Build your ritual, one essential at a time.</p>
              <button className="btn btn-secondary" onClick={() => { onClose(); navigate("shop"); }}>Browse the System</button>
            </div>
          ) : (
            <div style={{display: "flex", flexDirection: "column", gap: 24}}>
              {cart.map(i => {
                const p = productBySlug(i.slug); if (!p) return null;
                const price = p.type === "bundle" ? p.priceUSDBundle : p.priceUSD;
                return (
                  <div key={i.slug} style={{display:"grid", gridTemplateColumns:"80px 1fr auto", gap: 16, alignItems:"flex-start"}}>
                    <div style={{aspectRatio:"4/5", background:"var(--bg-soft)", display:"flex", alignItems:"flex-end", justifyContent:"center", padding: 6, border: "1px solid var(--accent-line)"}}>
                      {p.type === "bundle" ? <BottleTrio /> : <Bottle type={p.bottleType} tone={p.bottleTone} sub={p.tagline} />}
                    </div>
                    <div>
                      <div className="serif" style={{fontSize: 18}}>{p.name}</div>
                      <div className="muted" style={{fontSize: 12, marginTop: 2}}>{p.tagline}</div>
                      {p.type === "bundle" && (
                        <ul style={{fontSize: 11, color: "var(--text-muted)", marginTop: 6, paddingLeft: 14}}>
                          {p.includes.map(s => <li key={s}>{productBySlug(s)?.name}</li>)}
                        </ul>
                      )}
                      <div style={{display:"flex", alignItems:"center", gap: 12, marginTop: 10, fontSize: 12, color: "var(--text-secondary)"}}>
                        <button onClick={() => updateQty(i.slug, i.qty - 1)} style={{padding: 4, border: "1px solid var(--accent-line)", width: 24, height: 24, lineHeight: 1}}>−</button>
                        <span>{i.qty}</span>
                        <button onClick={() => updateQty(i.slug, i.qty + 1)} style={{padding: 4, border: "1px solid var(--accent-line)", width: 24, height: 24, lineHeight: 1}}>+</button>
                        <button onClick={() => removeItem(i.slug)} style={{marginLeft: "auto", textDecoration: "underline", color: "var(--text-muted)", fontSize: 11}}>Remove</button>
                      </div>
                    </div>
                    <div className="serif" style={{fontSize: 18}}>${price * i.qty}</div>
                  </div>
                );
              })}
            </div>
          )}
        </div>
        {cart.length > 0 && (
          <div className="sheet-foot">
            <div style={{display:"flex", justifyContent:"space-between", marginBottom: 6, fontSize: 13, color: "var(--text-secondary)"}}>
              <span>Subtotal</span>
              <span className="serif" style={{fontSize: 18}}>${subtotal} USD</span>
            </div>
            <div style={{fontSize: 11, color: "var(--text-muted)", marginBottom: 14}}>
              Charged in GHS: <strong>GH₵ {totalGHS.toLocaleString()}</strong> · Card, MTN MoMo &amp; Vodafone Cash · Shipping within Ghana only
            </div>
            <input
              className="input"
              type="email"
              placeholder="Your email for the receipt"
              value={email}
              onChange={(e) => setEmail(e.target.value)}
              style={{width: "100%", padding: "12px 0", fontSize: 15, marginBottom: 14}}
            />
            <button className="btn btn-primary w-full" onClick={checkout}>Pay securely · GH₵ {totalGHS.toLocaleString()}</button>
          </div>
        )}
      </aside>
    </>
  );
}

// ---------- Toast ----------
function Toast({ message }) {
  return <div className={"toast " + (message ? "show" : "")}>{message || " "}</div>;
}

// ---------- Mode toggle (prototype only) ----------
function ModeToggle() {
  const { mode, setMode } = useApp();
  return (
    <div className="mode-toggle" title="Prototype only — toggles NEXT_PUBLIC_LAUNCH_MODE">
      <span style={{opacity:0.6}}>Launch</span>
      <button className={"seg " + (mode === "waitlist" ? "active" : "")} onClick={() => setMode("waitlist")}>Waitlist</button>
      <button className={"seg " + (mode === "live" ? "active" : "")} onClick={() => setMode("live")}>Live</button>
    </div>
  );
}

// ---------- Reusable bits ----------
function StepLabel({ n }) {
  return (
    <div className="step-card-label">
      <div className="smallcaps">Step</div>
      <div className="step-num serif">{n}</div>
    </div>
  );
}

function Accordion({ items }) {
  const [open, setOpen] = useState(null);
  return (
    <div>
      {items.map((it, i) => (
        <div key={i} className="accordion-item">
          <button className={"accordion-trigger " + (open === i ? "open" : "")} onClick={() => setOpen(open === i ? null : i)}>
            <span>{it.q}</span>
            <span className="accordion-icon">+</span>
          </button>
          <div className={"accordion-content " + (open === i ? "open" : "")}>
            <div>{it.a}</div>
          </div>
        </div>
      ))}
    </div>
  );
}

Object.assign(window, {
  PRODUCTS, BUNDLE, ALL_PRODUCTS, productBySlug,
  Bottle, BottleTrio, Icon,
  AppCtx, useApp,
  Header, MobileMenu, Footer, CartSheet, Toast, ModeToggle,
  StepLabel, Accordion,
});
