/* Sweet Haven — site data + shared Lucide icon helper */

// Lucide icon component — renders <i data-lucide> and triggers createIcons.
function Icon({ name, size = 20, stroke = 1.75, color, style, className }) {
  const ref = React.useRef(null);
  React.useEffect(() => {
    if (window.lucide && ref.current) {
      ref.current.innerHTML = "";
      const i = document.createElement("i");
      i.setAttribute("data-lucide", name);
      ref.current.appendChild(i);
      window.lucide.createIcons({
        attrs: { width: size, height: size, "stroke-width": stroke },
        nameAttr: "data-lucide",
      });
    }
  });
  return (
    <span
      ref={ref}
      className={className}
      style={{ display: "inline-flex", color: color || "currentColor", lineHeight: 0, ...style }}
    />
  );
}

// Naira pricing: "₦3,500" — whole-number, thousands separated. No kobo.
function money(n) {
  return "₦" + Math.round(n).toLocaleString("en-NG");
}

const SH_CATEGORIES = ["All", "Cakes", "Cookies"];

// Cakes are finished with buttercream, whipped cream, or left plain.
const CREAM_OPTIONS = ["Buttercream", "Whipped cream", "Plain"];

// Cakes: a regular round/loaf, or a bigger loaf pan at ₦7,000.
const cakeSizes = (base) => [
  { id: "reg",  label: "Regular",          note: "round or loaf", price: base },
  { id: "loaf", label: "Bigger loaf pan",  note: "feeds a crowd", price: 7000 },
];
// Cookies are priced purely by size.
const cookieSizes = [
  { id: "s", label: "Small",  note: "box of 4",  price: 1000 },
  { id: "m", label: "Medium", note: "box of 6",  price: 1500 },
  { id: "l", label: "Large",  note: "box of 12", price: 2000 },
];

const SH_PRODUCTS = [
  // — Cakes (finish: buttercream / whipped / plain) —
  { id: "redvelvet", name: "Red velvet", cat: "Cakes", img: "images/redvelvet.jpg",
    cream: true, sizes: cakeSizes(3500), tags: [],
    desc: "Soft cocoa-kissed crumb, crimson through and through." },
  { id: "chocolate", name: "Chocolate", cat: "Cakes", img: "images/chocolate.jpg",
    cream: true, sizes: cakeSizes(3500), tags: [],
    desc: "Deep, fudgy layers for the chocolate-hearted." },
  { id: "vanilla", name: "Vanilla", cat: "Cakes", img: "images/vanilla.jpg",
    cream: true, sizes: cakeSizes(3500), tags: [],
    desc: "Light golden sponge, simple and lovely." },
  { id: "coconut", name: "Coconut", cat: "Cakes", img: "images/coconut.jpg",
    cream: true, sizes: cakeSizes(4000), tags: [],
    desc: "Tender sponge under a drift of fresh coconut." },
  { id: "carrot", name: "Carrot", cat: "Cakes", img: "images/carrot.jpg",
    cream: true, sizes: cakeSizes(4000), tags: [],
    desc: "Warm spice, toasted pecans, a little indulgent." },
  { id: "banana", name: "Banana bread", cat: "Cakes", img: "images/banana.jpg",
    cream: true, sizes: cakeSizes(4000), tags: [],
    desc: "Slow-baked with ripe bananas — moist and golden." },

  // — Cookies (priced by size) —
  { id: "chocchip", name: "Chocolate chip cookies", cat: "Cookies", img: "images/chocchip.jpg",
    sizes: cookieSizes, tags: [],
    desc: "Crisp edges, soft middle, pools of dark chocolate." },
  { id: "biscoff", name: "Biscoff chocolate chip cookies", cat: "Cookies", img: "images/biscoff.jpg",
    sizes: cookieSizes, tags: ["New"],
    desc: "Chocolate chip with a swirl of spiced Biscoff." },
  { id: "oreo", name: "Oreo chocolate chip cookies", cat: "Cookies", img: "images/oreo.jpg",
    sizes: cookieSizes, tags: ["New"],
    desc: "Chocolate chip loaded with crushed Oreo." },
];

// the cheapest size — shown as the "from" price on cards
const fromPrice = (p) => Math.min(...p.sizes.map((s) => s.price));

// Home — "why Sweet Haven" values strip
const SH_VALUES = [
  { icon: "croissant", title: "Made this morning", text: "Everything is baked from scratch the day you collect it — never sat overnight." },
  { icon: "wheat", title: "Small-batch, by hand", text: "No factory line. Folded, proofed and finished by the same hands every day." },
  { icon: "leaf", title: "Real, simple things", text: "Good butter, real chocolate, ripe fruit. Nothing you can't pronounce." },
];

// Home — testimonials
const SH_REVIEWS = [
  { quote: "The coconut cake disappeared in minutes. I ordered two more the next week.", name: "Mara L.", note: "Regular since 2021" },
  { quote: "Those Biscoff cookies are dangerous. Worth every naira.", name: "Devon R.", note: "Saturday fixture" },
  { quote: "They built my anniversary bento exactly how I pictured it. Magic.", name: "The Okonkwos", note: "Custom order" },
];

// Custom cakes — order options
const OCCASIONS = ["Birthday", "Anniversary", "Bento"];
const SIZES = [
  { id: "bento", label: "Bento", serves: "serves 1–2", price: 5000 },
  { id: "6", label: '6" round', serves: "serves 6–8", price: 8000 },
  { id: "8", label: '8" round', serves: "serves 12–16", price: 12000 },
];
// flavour → menu photo (reused so the builder always shows a real cake)
const FLAVOURS = [
  { name: "Vanilla", img: "images/vanilla.jpg" },
  { name: "Chocolate", img: "images/chocolate.jpg" },
  { name: "Red velvet", img: "images/redvelvet.jpg" },
  { name: "Carrot", img: "images/carrot.jpg" },
  { name: "Coconut", img: "images/coconut.jpg" },
];

Object.assign(window, {
  Icon, money, SH_CATEGORIES, SH_PRODUCTS, CREAM_OPTIONS,
  fromPrice, SH_VALUES, SH_REVIEWS, OCCASIONS, SIZES, FLAVOURS,
});
