// data.jsx — products and content data for LittleGrains

const PRODUCTS = [
  {
    id: 'original',
    name: 'Everyday Superseeds',
    tagline: 'Small-batch energy bites for everyday nourishment.',
    phase: 'everyday',
    phaseLabel: 'Everyday',
    image: 'assets/products/everyday-product-polished.jpg',
    gallery: [
      'assets/products/everyday-product-polished.jpg',
      'assets/products/everyday-real-hand.jpg',
      'assets/products/everyday-anatomy.jpg',
    ],
    price: 12,
    priceLabel: 'From $15',
    weight: 'Boxes of 6, 15, or 30 bites',
    variants: [
      { id: 'box-6', label: 'Box of 6', shortLabel: '6 bites', price: 15, count: 6, purchaseType: 'one-time' },
      { id: 'box-15', label: 'Box of 15', shortLabel: '15 bites', price: 30, count: 15, purchaseType: 'one-time' },
      { id: 'box-30', label: 'Box of 30', shortLabel: '30 bites', price: 55, count: 30, purchaseType: 'one-time' },
    ],
    subscriptionVariants: [
      { id: 'sub-box-30', label: 'Box of 30 monthly', shortLabel: '30 bites', price: 50, count: 30, purchaseType: 'subscription', frequency: 'Monthly subscription' },
    ],
    color: '#C77B5C',
    accent: '#7A8B5C',
    ingredients: ['Almond flour', 'Pumpkin seeds', 'Ground flax seeds', 'Hemp seeds', 'Sunflower seeds', 'Sesame seeds', 'Medjool dates', 'Jaggery', 'A2 cow ghee'],
    benefits: ['About 6g protein per serving', 'Five-seed whole-food recipe', 'Small-batch and hand-rolled'],
    tags: ['protein-rich', 'seed-rich'],
    nutrition: {
      perBite: 'per serving',
      calories: 120,
      protein: 6.0,
      fibre: 2.4,
      sugars: 7.7,
      fat: 8.4,
      carbs: 10.2,
      highlights: [
        { label: 'Protein', value: '~6g', daily: '12%' },
        { label: 'Fibre', value: '2.4g', daily: '9%' },
        { label: 'Magnesium', value: '55mg', daily: '13%' },
        { label: 'Iron', value: '1.3mg', daily: '7%' },
        { label: 'Vit. E', value: '3mg', daily: '20%' },
      ],
      sellingPoints: [
        'About 6g whole-food protein per serving, close to a small egg.',
        'Seeds bring magnesium, iron, vitamin E, fibre, and satisfying fats.',
        'A compact snack for kids, adults, and older family members who can safely eat nuts and sesame.',
        'Dense nutrition in a soft, familiar energy bite.',
      ],
    },
    description: 'Everyday Superseeds is our first LittleGrains energy bite: soft almond flour, five mineral-rich seeds, Medjool dates, a touch of jaggery, and A2 ghee rolled slowly by hand. It is dense, gently sweet, and made to feel like real food, not a bar pretending to be a meal.',
    detailCopy: [
      'Built for the 4pm tea break, the school-run snack, or the small energy bite you keep in your bag when lunch was too light.',
      'Each batch stays seed-forward and kitchen-simple: pumpkin, flax, hemp, sunflower, and sesame, balanced with dates, jaggery, almond flour, and A2 ghee.',
      'Soft enough for kids, satisfying enough for adults, and simple enough for older family members who can safely eat nuts and sesame.',
    ],
  },
];

const ALL_TAGS = ['protein-rich', 'seed-rich', 'small-batch'];

const PHASES = [
  { id: 'everyday', label: 'Everyday', desc: 'For any day, any energy' },
];

const INGREDIENTS_GLOSSARY = [
  { name: 'Almond flour', from: 'Soft base', note: 'The gentle base for structure, richness, and a clean bite.', benefit: 'Protein and healthy fats in a soft, neutral base.' },
  { name: 'Pumpkin seeds', from: 'Green mineral seed', note: 'A familiar seed with deep flavor after a light roast.', benefit: 'Rich in magnesium and zinc.' },
  { name: 'Ground flax', from: 'Added gently', note: 'Kept away from high heat so the delicate fats stay fresh.', benefit: 'A good source of omega-3s and fibre.' },
  { name: 'Hemp seeds', from: 'Soft seed', note: 'Adds a mellow, nutty note and rounds out the seed blend.', benefit: 'A complete plant protein with all essential amino acids.' },
  { name: 'Sunflower seeds', from: 'Mellow seed', note: 'Adds gentle nuttiness and helps round out the texture.', benefit: 'A good source of vitamin E.' },
  { name: 'Sesame seeds', from: 'Mineral seed', note: 'A small seed with deep flavor and a familiar pantry feel.', benefit: 'One of the better plant sources of calcium.' },
  { name: 'Dates', from: 'Natural binder', note: 'Dates bind the bite and add a caramel-like sweetness.', benefit: 'Natural sweetness with fibre and trace minerals.' },
  { name: 'Jaggery', from: 'Unrefined sweetener', note: 'Used only when the batch needs its warm caramel note.', benefit: 'Unrefined sweetener with trace minerals — no refined sugar.' },
  { name: 'A2 ghee', from: 'Traditional fat', note: 'Carries the roast and brings the bite together.', benefit: 'Carries flavor and fat-soluble vitamins; a traditional cooking fat.' },
];

const NUTRIENTS = [
  {
    key: 'protein',
    label: 'Protein',
    tagline: 'Close to a small egg',
    body: 'About 6g protein in one serving, coming from almond flour, pumpkin seeds, hemp, sunflower and sesame.',
    icon: 'P',
    headline: '~6g',
    unit: 'per serving',
    sources: ['Almond flour', 'Pumpkin seeds', 'Hemp seeds', 'Sunflower seeds'],
  },
  {
    key: 'magnesium',
    label: 'Magnesium',
    tagline: 'A seed-led mineral story',
    body: 'Pumpkin, sesame, sunflower and almond bring the mineral backbone in simple ingredient form for a snack that feels small but works hard.',
    icon: 'Mg',
    headline: '55mg',
    unit: 'per bite',
    sources: ['Pumpkin seeds', 'Sesame seeds', 'Sunflower seeds', 'Almond flour'],
  },
  {
    key: 'iron',
    label: 'Iron',
    tagline: 'From familiar ingredients',
    body: 'Pumpkin, sesame and dates add plant-based iron without turning the product into a supplement claim.',
    icon: 'Fe',
    headline: '1.3mg',
    unit: 'per bite',
    sources: ['Pumpkin seeds', 'Sesame seeds', 'Dates'],
  },
  {
    key: 'fibre',
    label: 'Fibre',
    tagline: 'From flax, seeds, and dates',
    body: 'Fibre comes from the ingredients themselves: ground flax, seeds, dates, and almond flour.',
    icon: 'Fb',
    headline: '2.4g',
    unit: 'per bite',
    sources: ['Ground flax', 'Dates', 'Almond flour', 'Seeds'],
  },
  {
    key: 'healthy-fats',
    label: 'Healthy fats',
    tagline: 'Ghee, nuts, and seeds',
    body: 'A2 ghee, almonds and seeds give the bite richness, texture, and staying power.',
    icon: 'F',
    headline: '8.4g',
    unit: 'per bite',
    sources: ['A2 ghee', 'Hemp seeds', 'Sesame seeds', 'Sunflower seeds'],
  },
  {
    key: 'vit-e',
    label: 'Vitamin E',
    tagline: 'From almond and sunflower',
    body: 'Almond flour and sunflower seeds carry the vitamin E story in simple ingredient language.',
    icon: 'E',
    headline: '3mg',
    unit: 'per bite',
    sources: ['Almond flour', 'Sunflower seeds', 'Pumpkin seeds'],
  },
];

const NUTRITION_NOTES = {
  reference: 'Daily values are based on a 2,000-calorie reference diet. Your needs may vary by age and activity.',
  testing: 'Nutrition values are recipe-based estimates for the fixed ingredient list.',
};

const LOCAL_DELIVERY = {
  originZip: '98011',
  radiusMiles: 25,
  zips: [
    '98004', '98005', '98006', '98007', '98008', '98011', '98012', '98014',
    '98019', '98020', '98021', '98024', '98026', '98027', '98028', '98029',
    '98030', '98031', '98032', '98033', '98034', '98036', '98037', '98039',
    '98040', '98042', '98043', '98052', '98053', '98055', '98056', '98057',
    '98058', '98059', '98065', '98072', '98074', '98075', '98077', '98087',
    '98101', '98102', '98103', '98104', '98105', '98106', '98107', '98108',
    '98109', '98112', '98115', '98116', '98117', '98118', '98119', '98121',
    '98122', '98125', '98126', '98133', '98134', '98136', '98144', '98146',
    '98155', '98164', '98174', '98177', '98195', '98201', '98203', '98204',
    '98208', '98275', '98296',
  ],
};

function getProductVariants(product, purchaseType = 'all') {
  const oneTime = product.variants || [{ id: product.weight, label: product.weight, shortLabel: product.weight, price: product.price, purchaseType: 'one-time' }];
  const subscriptions = product.subscriptionVariants || [];
  if (purchaseType === 'one-time') return oneTime;
  if (purchaseType === 'subscription') return subscriptions.length ? subscriptions : oneTime;
  return [...oneTime, ...subscriptions];
}

function getVariantOption(product, variantId) {
  return getProductVariants(product).find((v) => v.id === variantId) || getProductVariants(product)[0];
}

function getVariantPrice(product, variantId) {
  return getVariantOption(product, variantId)?.price || product.price || 0;
}

function getVariantLabel(product, variantId) {
  return getVariantOption(product, variantId)?.label || variantId || product.weight;
}

function getVariantUnitPrice(product, variantId) {
  const variant = getVariantOption(product, variantId);
  if (!variant?.count) return null;
  return variant.price / variant.count;
}

function isLocalDeliveryZip(zip) {
  return LOCAL_DELIVERY.zips.includes(String(zip || '').trim().slice(0, 5));
}

Object.assign(window, {
  PRODUCTS, ALL_TAGS, PHASES, INGREDIENTS_GLOSSARY, NUTRIENTS, NUTRITION_NOTES,
  LOCAL_DELIVERY, getProductVariants, getVariantOption, getVariantPrice, getVariantLabel, getVariantUnitPrice, isLocalDeliveryZip,
});
