// app.jsx — Coyote Emplumado website
const { useState, useEffect, useMemo, useRef } = React;

// ─────────────────────────────────────────────────────────────────────────────
// Bilingual copy (ES primary, EN secondary)
// ─────────────────────────────────────────────────────────────────────────────
const COPY = {
  nav: {
    home: ["Inicio", "Home"],
    agaves: ["Agaves", "Agaves"],
    blog: ["Bitácora", "Journal"],
    contact: ["Contacto", "Contact"],
  },
  hero: {
    eyebrow: ["Atl · Tlachinolli — Mezcal artesanal · Puebla", "Atl · Tlachinolli — Artisanal mezcal · Puebla"],
    titleA: ["Agua", "Water"],
    titleB: ["que arde.", "that burns."],
    titleSub: ["Fuego que fluye.", "Fire that flows."],
    body: [
      "Atlichinoli — el difrasismo nahua para el momento exacto en que el agua y el fuego se tocan y crean algo que ninguno podía crear solo. El mezcal es atlichinoli destilado.",
      "Atlichinoli — the Nahua difrasismo for the precise moment when water and fire touch and create something neither could create alone. Mezcal is atlichinoli distilled.",
    ],
    cta1: ["Los tres agaves", "The three agaves"],
    cta2: ["El espíritu", "The spirit"],
  },
  story: {
    eyebrow: ["El espíritu · 01", "The spirit · 01"],
    title: [
      "El encuentro de Mayahuel y Huehuecóyotl.",
      "Mayahuel meets Huehuecóyotl.",
    ],
    body1: [
      "Mayahuel es la diosa del maguey. Su cuerpo destruido se convirtió en las primeras plantas de agave: destrucción que crea vida. Es el agua, la tierra, lo que fluye y nutre. Es el polo Atl.",
      "Mayahuel is the goddess of maguey. Her destroyed body became the first agave plants: destruction that creates life. She is water, earth, that which flows and nurtures. She is the Atl pole.",
    ],
    body2: [
      "Huehuecóyotl es el Coyote Viejo Emplumado. Dios de la fiesta, del deseo, del caos creador. Es el fuego que transforma, la ruptura, el movimiento. Es el polo Tlachinolli. Su encuentro produce el mezcal — y nosotros somos su resultado.",
      "Huehuecóyotl is the Old Feathered Coyote. God of the feast, of desire, of creative chaos. He is the fire that transforms, the rupture, the movement. He is the Tlachinolli pole. Their encounter produces mezcal — and we are its result.",
    ],
    pull: [
      "“No elijas un lado. El mezcal tampoco lo hace.”",
      "“Don't choose a side. Mezcal doesn't either.”",
    ],
  },
  agaves: {
    eyebrow: ["Los tres agaves · 02", "The three agaves · 02"],
    title: ["Tres puntos en el eje agua–fuego.", "Three points on the water–fire axis."],
    sub: ["Cada agave de la línea Coyote Emplumado vive en un punto distinto del eje atlichinoli. Esta tensión es el sistema.", "Each agave in the Coyote Emplumado line lives at a distinct point on the atlichinoli axis. This tension is the system."],
    items: [
      {
        key: "espadilla",
        latin: "Agave angustifolia var. Puebla",
        name: ["Espadilla", "Espadilla"],
        pole: ["Tlachinolli — fuego puro", "Tlachinolli — pure fire"],
        notes: [
          "Herbal, ahumado, cítrico, mineral.",
          "Herbal, smoky, citrus, mineral.",
        ],
        body: [
          "El más extendido del Altiplano Poblano. Seco y directo como la tierra volcánica donde crece. El fuego es evidente, la destrucción es honesta.",
          "The most widespread of the Altiplano Poblano. Dry and direct as the volcanic earth it grows in. The fire is plain, the destruction is honest.",
        ],
        abv: "47% Alc. Vol.",
        symbol: "fire",
      },
      {
        key: "papalometl",
        latin: "Agave potatorum",
        name: ["Papalometl", "Papalometl"],
        pole: ["Atl — agua", "Atl — water"],
        notes: [
          "Frutal, floral, mineral, dulzura contenida.",
          "Fruity, floral, mineral, restrained sweetness.",
        ],
        body: [
          "El agave mariposa del Altiplano. La construcción es lenta, la vida es larga: veinticinco años bajo el sol antes de la jima. Este es el agave de Mayahuel.",
          "The butterfly agave of the Altiplano. Construction is slow, life is long: twenty-five years under the sun before harvest. This is Mayahuel's agave.",
        ],
        abv: "47% Alc. Vol.",
        symbol: "water",
      },
      {
        key: "coyote",
        latin: "Agave marmorata",
        name: ["Coyote", "Coyote"],
        pole: ["Atlichinoli — los dos a la vez", "Atlichinoli — both at once"],
        notes: [
          "Terroso, floral, ahumado, salvaje.",
          "Earthy, floral, smoky, wild.",
        ],
        body: [
          "El más silvestre. Crece libre en riscos y peñascos. No se siembra — se encuentra. Cosecha artesanal en temporada. Raro como un encuentro místico.",
          "The wildest of the three. Grows freely on cliffs and crags. It isn't planted — it's found. Harvested by hand in season. Rare as a mystical encounter.",
        ],
        abv: "Edición limitada",
        symbol: "both",
      },
    ],
  },
  process: {
    eyebrow: ["Proceso · 03", "Process · 03"],
    title: ["Cuatro manos. Sin prisa.", "Four hands. No rush."],
    steps: [
      {
        n: "I",
        t: ["Jima", "Harvest"],
        d: ["A machete, sólo cuando la planta está madura. Nunca antes.", "By machete, only when the plant is ready. Never before."],
      },
      {
        n: "II",
        t: ["Horno", "Roast"],
        d: ["Cocción en horno cónico de tierra, leña de encino, cinco días.", "Conical earthen oven, oak wood, five days."],
      },
      {
        n: "III",
        t: ["Molienda", "Crush"],
        d: ["Tahona de piedra, jalada por mula. La fibra abre, no se rompe.", "Stone tahona, mule-drawn. The fibre opens, never breaks."],
      },
      {
        n: "IV",
        t: ["Alambique", "Still"],
        d: ["Doble destilación en alambique de cobre. Cabezas y colas separadas a oído.", "Double distillation in copper still. Heads and tails parted by ear."],
      },
    ],
  },
  ritual: {
    eyebrow: ["Ritual · 04", "Ritual · 04"],
    title: ["Cómo se bebe.", "How it's drunk."],
    body: [
      "A temperatura ambiente, en jícara de barro o copita de vidrio. Acompañado de sal de gusano, naranja, y una rebanada de pan dulce. Sin prisa, sin hielo, sin coctel.",
      "At room temperature, in a clay jícara or glass copita. Pair with sal de gusano, orange, and a slice of pan dulce. No rush, no ice, no cocktail.",
    ],
  },
  blog: {
    eyebrow: ["Bitácora", "Journal"],
    title: ["Cuadernos del coyote.", "Coyote's notebooks."],
    sub: ["Notas de campo, conversaciones, recetas y la cosecha que viene.", "Field notes, conversations, recipes, and the harvest to come."],
    posts: [
      {
        cat: ["Cosecha", "Harvest"],
        date: "Abr 2026",
        readtime: "6 min",
        title: ["La jima de marzo: cuándo el papalometl está listo", "March jima: knowing when the papalometl is ready"],
        excerpt: ["Don Macario lleva treinta años leyendo la planta. Pasamos un día con él en el cerro.", "Don Macario has read the plant for thirty years. We spent a day with him on the hillside."],
      },
      {
        cat: ["Receta", "Recipe"],
        date: "Mar 2026",
        readtime: "3 min",
        title: ["Sal de gusano casera", "Home-made sal de gusano"],
        excerpt: ["Tres ingredientes, un molcajete y la paciencia de quien tuesta sin distraerse.", "Three ingredients, a molcajete, and the patience of someone who toasts without distraction."],
      },
      {
        cat: ["Cosmovisión", "Cosmovision"],
        date: "Feb 2026",
        readtime: "9 min",
        title: ["Mayahuel y los 400 conejos del pulque", "Mayahuel and the 400 rabbits of pulque"],
        excerpt: ["La diosa del maguey y la borrachera —una breve introducción a las deidades del agave.", "The goddess of maguey and drunkenness —a brief introduction to the agave deities."],
      },
      {
        cat: ["Conversación", "Conversation"],
        date: "Ene 2026",
        readtime: "12 min",
        title: ["Una tarde con la palenquera de Tecali", "An afternoon with the palenquera of Tecali"],
        excerpt: ["Sobre el oficio en manos de mujeres, el cobre, y por qué el mezcal no se apura.", "On the craft in women's hands, copper, and why mezcal can't be rushed."],
      },
      {
        cat: ["Maridaje", "Pairing"],
        date: "Dic 2025",
        readtime: "5 min",
        title: ["Mezcal y mole poblano: notas de una cena", "Mezcal & mole poblano: notes from a dinner"],
        excerpt: ["El mole es complejo, el mezcal también. Acompañarlos es una conversación.", "Mole is complex, mezcal too. Pairing them is a conversation."],
      },
      {
        cat: ["Edición", "Release"],
        date: "Nov 2025",
        readtime: "4 min",
        title: ["Coyote 2025: edición de 218 botellas", "Coyote 2025: a release of 218 bottles"],
        excerpt: ["Sobre la cosecha de este año, las notas, y por qué casi no hay.", "On this year's harvest, the notes, and why there's almost none."],
      },
    ],
  },
  contact: {
    eyebrow: ["Contacto · Salud", "Contact · Salud"],
    title: ["Escríbenos.", "Get in touch."],
    sub: ["Para distribución, prensa, reservaciones de palenque, o para conversar sobre mezcal sin prisa.", "For distribution, press, palenque reservations, or to talk mezcal slowly."],
    fields: {
      name: ["Nombre", "Name"],
      email: ["Correo", "Email"],
      subject: ["Asunto", "Subject"],
      message: ["Mensaje", "Message"],
    },
    subjects: [
      ["Distribución / mayoreo", "Distribution / wholesale"],
      ["Prensa", "Press"],
      ["Visita al palenque", "Palenque visit"],
      ["Pregunta general", "General inquiry"],
    ],
    send: ["Enviar", "Send"],
    sent: ["Recibido. Te contestamos en máximo 48 horas.", "Received. We'll be in touch within 48 hours."],
  },
};

// language helper
const useLang = () => {
  const [lang, setLang] = useState("es");
  return [lang, setLang, (pair) => Array.isArray(pair) ? pair[lang === "es" ? 0 : 1] : pair];
};

Object.assign(window, { COPY, useLang });
