/* Shared data — used by the main site (app.js) and the Console page (console.js). */
window.CHAI_SONGS = [
    'Chai Why I Do Dis',
    'Reset the Table',
    'A Revolution ft. Goala Girls',
    'Never Wanted to be Queen',
    'Time in a Jungle',
    'Sticking Her Neck Out',
    'Days for the Girls',
    'Head Above the Claudes',
    'Wear Out Your Words',
    '27 Zebras',
  ];

window.CHAI_POSTS = [
    { u:'Stripe Queen',    h:'stripe_queen',   v:true,  c:'#e6ad63', t:'2m',  text:'Just saw CHAI ZEBRA live and I am NEVER the same. Sticking her neck out like a QUEEN 🦓🔥 #ChaiZebra', likes:4821, cm:312 },
    { u:'Jungle Vibes',    h:'jungle_vibes',   v:false, c:'#9a5a2c', t:'6m',  text:'Time in a Jungle on repeat ALL day. Chai really said stripes on stripes on stripes 🖤 #StickingHerNeckOut', likes:982, cm:47 },
    { u:'Bronze Baddie',   h:'bronze_baddie',  v:true,  c:'#c8864e', t:'11m', text:'Head Above the Claudes is the anthem of the summer. CHAI ZEBRA we love you forever 👑 #ZebraNation', likes:6730, cm:521 },
    { u:'Neck Out Nina',   h:'neck_out_nina',  v:false, c:'#ffb13c', t:'14m', text:'27 ZEBRAS?? this album is pure FIRE. every single song hits different 🦓🔥 #ChaiZebra', likes:1503, cm:88 },
    { u:'Mic Drop Mara',   u2:'',h:'micdrop_mara', v:true, c:'#e6ad63', t:'20m', text:'Reset the Table changed my whole MOOD. Chai is a VIBE. stripes forever 🔥🔥 #StickingHerNeckOut', likes:3340, cm:210 },
    { u:'Wild One Wes',    h:'wildone_wes',    v:false, c:'#9a5a2c', t:'25m', text:'nobody is sticking their neck out like CHAI. the queen of the jungle is HERE 🦓 #ZebraNation', likes:771, cm:33 },
    { u:'Savanna Sky',     h:'savanna_sky',    v:false, c:'#c8864e', t:'31m', text:'Days for the Girls had me CRYING in the club. Chai why you do dis to us 😭🔥 #ChaiZebra', likes:2218, cm:140 },
    { u:'Golden Goss',     h:'golden_goss',    v:true,  c:'#ffb13c', t:'38m', text:'the stripes. the gold. the VOICE. CHAI ZEBRA is a whole movement 👑🦓 #StickingHerNeckOut', likes:5104, cm:402 },
    { u:'Hoof & Heart',    h:'hoof_heart',     v:false, c:'#e6ad63', t:'44m', text:'Wear Out Your Words is my villain origin anthem. queen behaviour only 🔥 #ZebraNation', likes:640, cm:29 },
    { u:'Beep Boop Bri',   h:'beepboop_bri',   v:false, c:'#9a5a2c', t:'51m', text:'BOUNCE ON A BIDDY BEEP is stuck in my head forever send help 🦓🔥 #ChaiZebra', likes:1899, cm:97 },
    { u:'Lux Lioness',     h:'lux_lioness',    v:true,  c:'#c8864e', t:'1h',  text:'the way Chai sticks her neck out for the GIRLS every time. icon. legend. the queen 👑 #StickingHerNeckOut', likes:7420, cm:610 },
    { u:'Stripe Therapy',  h:'stripe_therapy', v:false, c:'#ffb13c', t:'1h',  text:'Skin a Bookmark is so underrated?? this whole album is FIRE no skips 🦓 #ZebraNation', likes:512, cm:24 },
    { u:'Mane Character',  h:'mane_character', v:false, c:'#e6ad63', t:'2h',  text:'me explaining to my mom why CHAI ZEBRA is the most important artist alive rn 🔥🦓 #ChaiZebra', likes:3061, cm:188 },
    { u:'Velvet Veldt',    h:'velvet_veldt',   v:true,  c:'#9a5a2c', t:'3h',  text:'Sticking Her Neck Out the title track?? chills. stripes. tears. a QUEEN 👑🔥 #StickingHerNeckOut', likes:8890, cm:744 },
    { u:'Echo Estelle',    h:'echo_estelle',   v:false, c:'#c8864e', t:'4h',  text:'streaming CHAI ZEBRA until the jungle hears me. stripes up forever 🦓🔥 #ZebraNation', likes:1340, cm:66 },
  ];

  /* ---------------------------------------------------------------
     FAN ROSTER — shared by the Subscribe form (main page, app.js)
     and the Console's Fan Tracker (console.js). Seeded once into
     localStorage, then grown as new fans subscribe.
     --------------------------------------------------------------- */
  (() => {
    const KEY = 'chaiFans_v2';
    const z = n => String(n).padStart(2, '0');
    const todayISO = () => { const d = new Date(); return `${d.getFullYear()}-${z(d.getMonth() + 1)}-${z(d.getDate())}`; };

    /* 12 hand-built fans... */
    const HAND = [
      { id:'fan-01', name:'Marisol Vega',     email:'stripe.queen@gmail.com',    x:'@stripequeen',   added:'2023-08-14', labels:{ great:true,  super:true,  concerning:false } },
      { id:'fan-02', name:'Devon Mwangi',     email:'jungle.vibes@outlook.com',  x:'@junglevibes',   added:'2024-01-09', labels:{ great:true,  super:false, concerning:false } },
      { id:'fan-03', name:'Priya Anand',      email:'bronze.baddie@yahoo.com',   x:'@bronzebaddie',  added:'2023-11-02', labels:{ great:false, super:true,  concerning:false } },
      { id:'fan-04', name:'Nina Okafor',      email:'neckout.nina@icloud.com',   x:'@neckoutnina',   added:'2024-03-21', labels:{ great:false, super:false, concerning:false } },
      { id:'fan-05', name:'Mara Lindqvist',   email:'micdrop.mara@gmail.com',    x:'@micdropmara',   added:'2024-06-30', labels:{ great:true,  super:false, concerning:false } },
      { id:'fan-06', name:'Wes Carter',       email:'wildone.wes@proton.me',     x:'@wildonewes',    added:'2023-05-17', labels:{ great:false, super:false, concerning:false } },
      { id:'fan-07', name:'Savanna Cole',     email:'savanna.sky@gmail.com',     x:'@savannasky',    added:'2025-02-11', labels:{ great:false, super:false, concerning:true  } },
      { id:'fan-08', name:'Goss Adeyemi',     email:'golden.goss@outlook.com',   x:'@goldengoss',    added:'2024-09-05', labels:{ great:true,  super:true,  concerning:false } },
      { id:'fan-09', name:'Hollis Reed',      email:'hoof.heart@gmail.com',      x:'@hoofnheart',    added:'2025-07-19', labels:{ great:false, super:false, concerning:false } },
      { id:'fan-10', name:'Bri Castellano',   email:'beepboop.bri@yahoo.com',    x:'@beepboopbri',   added:'2026-01-28', labels:{ great:false, super:false, concerning:true  } },
      { id:'fan-11', name:'Lux Mbeki',        email:'lux.lioness@icloud.com',    x:'@luxlioness',    added:'2024-12-12', labels:{ great:false, super:true,  concerning:false } },
      { id:'fan-12', name:'Theo Marsh',       email:'mane.character@outlook.com',x:'@manecharacter', added:'2025-04-08', labels:{ great:true,  super:false, concerning:false } },
    ];

    /* ...plus 100 generated ones (stable per install via a fixed-seed PRNG). */
    const rng = (() => { let s = 0x9e3779b9; return () => { s = (s + 0x6d2b79f5) | 0; let t = Math.imul(s ^ (s >>> 15), 1 | s); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; })();
    const pick = arr => arr[Math.floor(rng() * arr.length)];
    const FIRST = ['Aria','Liam','Zoe','Noah','Mia','Ethan','Luna','Kai','Nova','Eli','Ivy','Omar','Tara','Dax','Remy','Sage','Cleo','Wren','Jada','Bo','Nia','Indi','Rumi','Suki','Vance','Esme','Cruz','Lena','Otis','Maya','Finn','Cora','Hugo','Dela','Pax','Yuna','Reza','Gia','Beau','Anya','Niko','Tess','Rico','Soraya','Marlo','Dion','Faye','Quinn','Zara','Idris'];
    const LAST  = ['Nakamura','Silva','Hassan','Park','Diallo','Romano','Petrov','Khan','Flores','Bauer','Ortega','Sato','Mensah','Dubois','Russo','Haddad','Lund','Ferraro','Osei','Tan','Reyes','Novak','Bianchi','Acosta','Greer','Fontaine','Hale','Sterling','Brooks','Wolfe','Quill','Frost','Mercer','Vale','Storm','Okonkwo','Beck','Cano','Day','Ibarra','Singh','Moss','Pham','Ali','Cruz','Yoon','Abara','Stone','Vossen','Marin'];
    const DOMAINS = ['gmail.com','outlook.com','yahoo.com','icloud.com','proton.me','hey.com'];
    const slug = s => s.toLowerCase().replace(/[^a-z]/g, '');

    const generate = (n) => {
      const out = [];
      for (let i = 0; i < n; i++) {
        const fn = pick(FIRST), ln = pick(LAST), r = rng();
        const d = new Date(Date.now() - Math.floor(rng() * 980) * 86400000);
        out.push({
          id: 'fan-g' + (i + 13),
          name: `${fn} ${ln}`,
          email: `${slug(fn)}.${slug(ln)}${rng() < .3 ? Math.floor(rng() * 90 + 10) : ''}@${pick(DOMAINS)}`,
          x: rng() < .82 ? '@' + slug(fn) + (rng() < .5 ? slug(ln).slice(0, 4) : '') + (rng() < .35 ? Math.floor(rng() * 90 + 10) : '') : '',
          added: `${d.getFullYear()}-${z(d.getMonth() + 1)}-${z(d.getDate())}`,
          labels: { great: r < .22, super: r >= .22 && r < .40, concerning: rng() < .07 },
        });
      }
      return out;
    };

    const seed = () => HAND.concat(generate(100));

    const load = () => {
      try { const r = localStorage.getItem(KEY); if (r) return JSON.parse(r); } catch {}
      const s = seed(); save(s); return s;
    };
    const save = (list) => { try { localStorage.setItem(KEY, JSON.stringify(list)); } catch {} };

    window.CHAI_FANS = {
      KEY,
      todayISO,
      load,
      save,
      newId: () => 'fan-' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6),
      /** Prepend a freshly-subscribed fan (dedupes on email). */
      add(fan) {
        const list = load();
        const i = list.findIndex(f => f.email.toLowerCase() === fan.email.toLowerCase());
        if (i >= 0) list[i] = { ...list[i], ...fan, id: list[i].id };
        else list.unshift(fan);
        save(list);
        return fan;
      },
    };
  })();

  /* ---------------------------------------------------------------
     SEEDED FAV VOTES — 100 demo votes layered on top of real clicks
     in the Console only (kept OUT of localStorage so the album's track
     badges still reflect just genuine clicks).
     --------------------------------------------------------------- */
  window.CHAI_VOTE_SEED = {
    'Never Wanted to be Queen': 22,
    'A Revolution ft. Goala Girls': 18,
    'Sticking Her Neck Out': 15,
    'Head Above the Claudes': 11,
    '27 Zebras': 9,
    'Days for the Girls': 8,
    'Time in a Jungle': 6,
    'Reset the Table': 5,
    'Chai Why I Do Dis': 4,
    'Wear Out Your Words': 2,
  }; // = 100 votes

  /* ---------------------------------------------------------------
     WORD BOOST — 100 extra word occurrences merged into the Feed
     Word Analyzer (themed words, so they blend with the real feed).
     --------------------------------------------------------------- */
  window.CHAI_WORD_BOOST = {
    chai: 14, zebra: 12, stripes: 11, queen: 10, fire: 9, herd: 8,
    jungle: 7, gold: 6, neck: 6, stripe: 5, album: 4, sticking: 4, bronze: 4,
  }; // = 100 occurrences
