/* eslint-disable */
// Shared brand data + the recreated HTML pack component.

const SPORTS = [
  { id: "cricket",    label: "Cricket",    short: "Cricket",    icon: "🏏" },
  { id: "football",   label: "Football",   short: "Football",   icon: "⚽" },
  { id: "hockey",     label: "Hockey",     short: "Hockey",     icon: "🏑" },
  { id: "tennis",     label: "Tennis",     short: "Tennis",     icon: "🎾" },
  { id: "gymnastics", label: "Gymnastics", short: "Gymnastics", icon: "🤸" },
];

// Real product lineup, mapped to the supplied photographs.
const PACKS = [
  {
    id: "cricket-1", sport: "cricket", edition: "First Edition",
    img: "uploads/C1-1.jpg", price: 19.95, isNew: false, cardCount: 52,
    lede: "The original deck. Goal-setting, feedback, session structure and player development.",
    audience: "Grassroots & academy",
    description: "Cricket Coach 365 are delighted to offer you a range of coaching cards suitable for all standards of junior players to be used by coaches, teachers, parents and most importantly the players themselves.\n\nOur first edition and original pack encompass 52 cards with a coaching question on each split evenly across four suits: Technical, Tactical, Personal and Psychological. These cards are designed to help in 1:2:1 as well as group coaching/practice sessions indoors or out.\n\nOverall, these cards are there to help encourage youngsters to really enjoy the game of cricket to the maximum and in doing so to stay in the game longer.",
  },
  {
    id: "cricket-2", sport: "cricket", edition: "Second Edition",
    img: "uploads/C2-1.jpg", price: 19.95, isNew: true, cardCount: 47,
    lede: "47 new question prompts. Builds on the First Edition with sharper game-day cues.",
    audience: "Club & academy",
    description: "Cricket Coach 365 are delighted to offer you a range of coaching cards suitable for all standards of junior players to be used by coaches, teachers, parents and most importantly the players themselves.\n\nOur second edition follows the same principle as the first only this time the questions relate to the following suits: Batting, Bowling, Fielding, Keeping and Mindset. This edition also contains a set of suggested instructions as to how to get the best use from the cards.\n\nOverall, these cards are there to help encourage youngsters to really enjoy the game of cricket to the maximum and in doing so to stay in the game longer.",
  },
  {
    id: "cricket-sp", sport: "cricket", edition: "Stay-at-Home · Special",
    img: "uploads/C3-1.jpg", price: 16.95, special: true,
    lede: "28 stay-at-home cricket games. Keep active with your cricket — indoors or out.",
    audience: "Family · all ages",
    description: "A special edition designed to keep players connected to the game when they can't get out on the pitch. This pack contains 28 stay-at-home cricket games and activities suitable for all ages, most best enjoyed outside but some playable indoors — just get permission first!\n\nIdeal for parents, coaches and teachers looking to keep young players engaged and active between seasons or during downtime. A fun and creative way to stay close to cricket all year round.",
  },
  {
    id: "football-1", sport: "football", edition: "First Edition",
    img: "uploads/F1-1.jpg", price: 19.95, cardCount: 50,
    lede: "Question cards for the football coach. Shape sessions around the player, not the drill.",
    audience: "Grassroots & academy",
    description: "CoachingCards365 are delighted to offer you a range of coaching cards suitable for all standards of junior players, designed to be used by coaches, teachers, parents and the players themselves.\n\nThis first edition football pack contains 50 cards, each carrying a coaching question split across four suits: Technical, Tactical, Physical and Psychological. The cards are designed to support both 1:2:1 and group coaching sessions, indoors or on the pitch.\n\nOverall, these cards are there to help encourage young footballers to get more from every session — asking better questions, thinking more deeply about their game, and staying engaged with football for longer.",
  },
  {
    id: "hockey-1", sport: "hockey", edition: "First Edition",
    img: "uploads/H1-1.jpg", price: 19.95, cardCount: 46,
    lede: "46 conversation cards built for hockey coaches — feedback, structure, development.",
    audience: "Club & schools",
    description: "CoachingCards365 are delighted to offer you a range of coaching cards suitable for all standards of junior players, designed to be used by coaches, teachers, parents and the players themselves.\n\nThis first edition hockey pack contains 46 cards, each carrying a coaching question split across four suits: Technical, Tactical, Physical and Psychological. The cards work equally well in 1:2:1 settings and group sessions, whether you're on the astro or working indoors.\n\nOverall, these cards are there to help young hockey players think more deeply about their game, get more from every session, and build a lasting love of the sport.",
  },
  {
    id: "tennis-1", sport: "tennis", edition: "First Edition",
    img: "uploads/T1-1.jpg", price: 19.95, cardCount: 42,
    lede: "Coaching prompts for the tennis coach. Goal-setting, mid-set feedback, post-match review.",
    audience: "Lessons & academy",
    description: "CoachingCards365 are delighted to offer you a range of coaching cards suitable for all standards of junior players, designed to be used by coaches, teachers, parents and the players themselves.\n\nThis first edition tennis pack contains 42 cards, each carrying a coaching question split across four suits: Technical, Tactical, Mental and Physical. The cards are designed to support lessons, squad sessions and academy environments — pulling a card before or after a set can change the entire conversation.\n\nOverall, these cards are there to help young tennis players develop more self-awareness on and off the court, get more from their coaching time, and stay in the game longer.",
  },
  {
    id: "gymnastics-1", sport: "gymnastics", edition: "First Edition",
    img: "uploads/G1-1.jpg", price: 19.95, cardCount: 51,
    lede: "Question prompts for the gymnastics coach — supports gymnasts' all-round development.",
    audience: "Club & performance",
    description: "CoachingCards365 are delighted to offer you a range of coaching cards suitable for all standards of junior gymnasts, designed to be used by coaches, teachers, parents and the gymnasts themselves.\n\nThis first edition gymnastics pack contains 51 cards, each carrying a coaching question split across four suits: Technical, Artistic, Physical and Psychological. The cards support both individual and group coaching environments, helping gymnasts reflect on their training and take ownership of their development.\n\nOverall, these cards are there to help young gymnasts build confidence, think more carefully about their craft, and develop the mindset to keep progressing.",
  },
];

const SPORT_BY_ID = (id) => SPORTS.find((s) => s.id === id) || SPORTS[0];
const PACK_BY_SPORT = (id) => PACKS.find((p) => p.sport === id) || PACKS[0];
const FIRST_ED_BY_SPORT = (id) => PACKS.find((p) => p.sport === id && p.edition.startsWith("First")) || PACK_BY_SPORT(id);

// The recreated HTML "deck box" — same layout as the photographs so it can swap, animate and recolor.
function PackHTML({ sport, edition = "First Edition", special = false, size = "regular", swapKey }) {
  const s = SPORT_BY_ID(sport);
  return (
    <div className={`pack ${size === "lg" ? "lg" : size === "sm" ? "sm" : ""} pack--${sport} ${swapKey ? "pack-swap-enter" : ""}`} key={swapKey}>
      <div className="pack-edge" />
      {special && <div className="pack-ribbon">Special Edition</div>}
      <div className="pack-panel">
        <div className="pack-badge">
          <div className="pack-badge-stars">★ ★ ★</div>
          <div className="pack-badge-icon" aria-hidden>{s.icon}</div>
          <div className="pack-badge-name">{s.label}<span className="y">365</span></div>
        </div>
        <div className="pack-title">Coaching Cards<sup>™</sup></div>
        <div className="pack-edition">{special ? "Stay-at-Home Games" : edition}</div>
        {special ? (
          <div className="pack-copy">
            <p>28 stay-at-home cricket games.</p>
            <p>Keep active with your cricket.</p>
            <p>Most games are best suited for outside.</p>
            <p>Some can be played inside — but get permission!</p>
          </div>
        ) : (
          <div className="pack-copy">
            <p>Questions that will help shape goal setting</p>
            <p>Questions that will help coaches provide better feedback</p>
            <p>Questions that will help coaches structure their sessions with more confidence</p>
            <p>Questions that will help coaches support their players' all round development better</p>
          </div>
        )}
      </div>
    </div>
  );
}

// Reveal-on-scroll hook
function useReveal() {
  React.useEffect(() => {
    const trigger = (el) => { el.classList.add("in"); io.unobserve(el); };
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting) trigger(e.target); });
    }, { rootMargin: "0px 0px 0px 0px", threshold: 0 });
    const els = document.querySelectorAll(".reveal");
    els.forEach((el) => {
      const rect = el.getBoundingClientRect();
      if (rect.top < window.innerHeight) { trigger(el); }
      else { io.observe(el); }
    });
    return () => io.disconnect();
  }, []);
}

Object.assign(window, { SPORTS, PACKS, SPORT_BY_ID, PACK_BY_SPORT, FIRST_ED_BY_SPORT, PackHTML, useReveal });
