/* Bristol Academy — App data + helpers (shared) */

// Skill access model:
//   ALL exams free (no paid skills).
const PAID_SKILLS = new Set();
const FULLY_FREE_EXAMS = new Set([1,2,3,4,5,6,7,8,9,10]);
function isSkillUnlocked(examNum, skillKey, hasPlanForExam = false) {
  return true;
}
window.isSkillUnlocked = isSkillUnlocked;
window.PAID_SKILLS = PAID_SKILLS;
window.FULLY_FREE_EXAMS = FULLY_FREE_EXAMS;


const BA = (() => {
  const SKILLS = [
    { key: 'gv', name: 'Grammar & Vocabulary', short: 'Grammar', meta: '30 preguntas · 25 min' },
    { key: 'rd', name: 'Reading', short: 'Reading', meta: '29 preguntas · 35 min' },
    { key: 'ls', name: 'Listening', short: 'Listening', meta: '25 preguntas · 50 min' },
    { key: 'wr', name: 'Writing', short: 'Writing', meta: '4 tareas · 50 min' },
    { key: 'sp', name: 'Speaking', short: 'Speaking', meta: '4 tareas · 12 min' },
  ];

  const EXAMS = Array.from({ length: 5 }, (_, i) => ({
    num: i + 1,
    name: `Exam ${i + 1}`,
    title: `Aptis General Practice Test`,
    free: i === 0,
  }));

  const PLANS = [
    {
      id: 'starter',
      name: 'Starter Pack',
      tagline: 'Empieza con los primeros simulacros para coger ritmo y seguridad.',
      price: 25,
      originalPrice: null,
      exams: [2, 3, 4],
      featured: false,
    },
    {
      id: 'progress',
      name: 'Progress Pack',
      tagline: 'Seis simulacros para una preparación estructurada y completa.',
      price: 35,
      originalPrice: 45,
      exams: [2, 3, 4, 5, 6, 7],
      featured: true,
      featuredLabel: 'Más popular',
      saveLabel: 'Ahorra 10€',
    },
    {
      id: 'complete',
      name: 'Complete Pack',
      tagline: 'Los 9 simulacros restantes. La preparación más completa.',
      price: 50,
      originalPrice: 89,
      exams: [2, 3, 4, 5, 6, 7, 8, 9, 10],
      featured: false,
      saveLabel: 'Ahorra 39€',
    },
  ];

  return { SKILLS, EXAMS, PLANS };
})();

// Icon set (inline SVG, 1.6 stroke, lucide-ish)
const Icon = ({ name, size = 18, ...rest }) => {
  const common = {
    width: size, height: size,
    viewBox: '0 0 24 24',
    fill: 'none', stroke: 'currentColor', strokeWidth: 1.7,
    strokeLinecap: 'round', strokeLinejoin: 'round',
    ...rest,
  };
  const P = {
    arrow:     <path d="M5 12h14M13 6l6 6-6 6" />,
    check:     <path d="M20 6 9 17l-5-5" />,
    lock:      <><rect x="4" y="11" width="16" height="10" rx="2" /><path d="M8 11V8a4 4 0 0 1 8 0v3" /></>,
    unlock:    <><rect x="4" y="11" width="16" height="10" rx="2" /><path d="M8 11V8a4 4 0 0 1 7.5-2" /></>,
    play:      <path d="m8 5 12 7-12 7V5z" />,
    book:      <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20V3H6.5A2.5 2.5 0 0 0 4 5.5v14zM4 5.5V19.5" />,
    headphones:<><path d="M3 18v-6a9 9 0 0 1 18 0v6" /><path d="M21 19a2 2 0 0 1-2 2h-1v-7h3v5zM3 19a2 2 0 0 0 2 2h1v-7H3v5z" /></>,
    edit:      <><path d="M12 20h9" /><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z" /></>,
    mic:       <><rect x="9" y="2" width="6" height="13" rx="3" /><path d="M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8" /></>,
    target:    <><circle cx="12" cy="12" r="9" /><circle cx="12" cy="12" r="5" /><circle cx="12" cy="12" r="1.5" fill="currentColor" /></>,
    bolt:      <path d="m13 2-9 12h7l-1 8 9-12h-7l1-8z" />,
    clock:     <><circle cx="12" cy="12" r="9" /><path d="M12 7v5l3 2" /></>,
    chart:     <><path d="M3 3v18h18" /><path d="m7 14 3-3 4 4 5-6" /></>,
    user:      <><circle cx="12" cy="8" r="4" /><path d="M4 21a8 8 0 0 1 16 0" /></>,
    plus:      <path d="M12 5v14M5 12h14" />,
    star:      <path d="m12 2 3 7 7 .8-5.2 5L18 22l-6-3.5L6 22l1.2-7.2L2 9.8 9 9z" />,
    sparkle:   <path d="M12 3v5M12 16v5M3 12h5M16 12h5M5 5l3.5 3.5M15.5 15.5 19 19M5 19l3.5-3.5M15.5 8.5 19 5" />,
    shield:    <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" />,
    clipboard: <><rect x="8" y="3" width="8" height="4" rx="1" /><path d="M16 5h2a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2" /></>,
    badge:     <><circle cx="12" cy="8" r="6" /><path d="m8.5 13-1 8L12 18l4.5 3-1-8" /></>,
    rocket:    <path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09zM12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2zM9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0" />,
    download:  <><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><path d="M7 10l5 5 5-5M12 15V3" /></>,
    mail:      <><rect x="3" y="5" width="18" height="14" rx="2" /><path d="m3 7 9 6 9-6" /></>,
    phone:     <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" />,
    pin:       <><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z" /><circle cx="12" cy="10" r="3" /></>,
  };
  return <svg {...common}>{P[name] || P.arrow}</svg>;
};

const SkillIconForKey = (k) => {
  const map = { gv: 'edit', rd: 'book', ls: 'headphones', wr: 'clipboard', sp: 'mic' };
  return map[k] || 'book';
};

window.BA = BA;
window.Icon = Icon;
window.SkillIconForKey = SkillIconForKey;
