/* WinAstro Mobile kit — shared data, money fmt, and atoms (icons, compass
   mark, zodiac medallion, avatar). Icons are Lucide line glyphs (MIT),
   inlined so the mockup is self-contained. Exported to window. */

(() => {
const MD = {
  signs: {
    leo: { name: "Leo", symbol: "♌", element: "Fire", modality: "Fixed", accent: "#de7d42", dates: "Jul 23 – Aug 22", guidance: "Visibility, confidence, creative leadership" },
    scorpio: { name: "Scorpio", symbol: "♏", element: "Water", modality: "Fixed", accent: "#7b3f5c" },
    libra: { name: "Libra", symbol: "♎", element: "Air", modality: "Cardinal", accent: "#ba6f8f" },
    taurus: { name: "Taurus", symbol: "♉", element: "Earth", modality: "Fixed", accent: "#6f8f4e" },
  },
  grahas: [
    { name: "Sun", symbol: "☉" }, { name: "Moon", symbol: "☽" }, { name: "Saturn", symbol: "♄" },
    { name: "Venus", symbol: "♀" }, { name: "Jupiter", symbol: "♃" }, { name: "Mars", symbol: "♂" },
  ],
  categories: [
    { value: "career", label: "Career", glyph: "♄" },
    { value: "relationship", label: "Relationship", glyph: "♀" },
    { value: "compatibility", label: "Compatibility", glyph: "☽" },
    { value: "relocation", label: "Relocation", glyph: "♃" },
    { value: "business", label: "Business", glyph: "☉" },
  ],
  packages: [
    { id: "quick", name: "Quick Decision Read", min: 10, price: 99900, desc: "One decision, a focused read and concise recap.", label: "Fixed fee" },
    { id: "deep", name: "Deep Decision Session", min: 30, price: 249900, desc: "Live consult for context, timing windows, next steps.", label: "Most booked", featured: true },
    { id: "plan", name: "Relationship / Career Plan", min: 45, price: 499900, desc: "Longer consult with written post-session guidance.", label: "Fixed fee" },
  ],
  advisors: [
    { id: "maya", name: "Maya Iyer", title: "Vedic career timing specialist", specialties: ["career", "relocation", "business"], methods: ["Vedic", "Dasha", "Transit"], languages: ["English", "Hindi", "Tamil"], rating: 4.9, sessions: 1840, perMin: 8500, availability: "online", reasons: ["Strong fit for career decisions", "Consults in Hindi", "Available now"] },
    { id: "sara", name: "Sara Kapoor", title: "Modern relationship astrologer", specialties: ["relationship", "compatibility", "career"], methods: ["Western", "Tarot"], languages: ["English", "Punjabi"], rating: 4.9, sessions: 1288, perMin: 7500, availability: "online", reasons: ["Adjacent specialty match", "Available now"] },
    { id: "arjun", name: "Arjun Mehta", title: "Diaspora transitions & business timing", specialties: ["career", "business", "relocation"], methods: ["Western", "Vedic", "Electional"], languages: ["English"], rating: 4.7, sessions: 940, perMin: 12500, availability: "busy", reasons: ["Strong fit for business timing", "Short wait"] },
  ],
  trust: ["KYC verified", "Sample reading passed", "Ethics pledge signed"],
};

function mINR(cents) {
  return new Intl.NumberFormat("en-IN", { style: "currency", currency: "INR", maximumFractionDigits: 0 }).format(cents / 100);
}

/* ---- Lucide line icons (24-grid, currentColor stroke) ---- */
const ICONS = {
  home: ["M3 9.5 12 3l9 6.5V20a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1z"],
  compass: ["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z", "m16.2 7.8-2.1 6.3-6.3 2.1 2.1-6.3 6.3-2.1z"],
  users: ["M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", "M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z", "M22 21v-2a4 4 0 0 0-3-3.87", "M16 3.13a4 4 0 0 1 0 7.75"],
  wallet: ["M21 12V7H5a2 2 0 0 1 0-4h14v4", "M3 5v14a2 2 0 0 0 2 2h16v-5", "M18 12a2 2 0 0 0 0 4h4v-4z"],
  user: ["M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", "M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z"],
  chevronRight: ["m9 18 6-6-6-6"],
  chevronLeft: ["m15 18-6-6 6-6"],
  arrowRight: ["M5 12h14", "m12 5 7 7-7 7"],
  clock: ["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z", "M12 6v6l4 2"],
  bell: ["M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9", "M10.3 21a1.94 1.94 0 0 0 3.4 0"],
  search: ["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z", "m21 21-4.3-4.3"],
  plus: ["M5 12h14", "M12 5v14"],
  check: ["M20 6 9 17l-5-5"],
  shield: ["M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z", "m9 12 2 2 4-4"],
  globe: ["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z", "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", "M2 12h20"],
  sliders: ["M10 5H3", "M21 5h-7", "M7 5v0", "M14 12H3", "M21 12h-3", "M18 12v0", "M9 19H3", "M21 19h-7"],
  briefcase: ["M2 9a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2z", "M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"],
  heart: ["M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.29 1.5 4.04 3 5.5l7 7z"],
  message: ["M7.9 20A9 9 0 1 0 4 16.1L2 22z"],
  spark: ["M12 3l1.6 4.9L18.5 9.5l-4.9 1.6L12 16l-1.6-4.9L5.5 9.5l4.9-1.6z"],
  arrowLeft: ["m12 19-7-7 7-7", "M19 12H5"],
};
const STAR_FILL = "M12 2.5l2.6 5.27 5.82.85-4.21 4.1.99 5.79L12 15.77 6.8 18.5l.99-5.79L3.58 8.62l5.82-.85z";

function MIcon({ name, className = "ic", fill = false }) {
  if (name === "star") {
    return <svg className={className} viewBox="0 0 24 24" fill="currentColor"><path d={STAR_FILL} /></svg>;
  }
  const paths = ICONS[name] || [];
  return (
    <svg className={className} viewBox="0 0 24 24" fill={fill ? "currentColor" : "none"} stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      {paths.map((d, i) => <path key={i} d={d} />)}
    </svg>
  );
}

/* ---- Compass mark (inline) ---- */
function MCompass({ size = 26, ivory = "#fff8e8", gold = "#c8a96a" }) {
  return (
    <svg width={size} height={size} viewBox="0 0 256 256" aria-hidden="true">
      <path d="M128 20a108 108 0 1 0 96.4 156.6l-16.5-8.5A89.5 89.5 0 1 1 128 38.5c27.2 0 51.5 12.1 68 31.2l-19.6 5.6 52.8 30.1-7.8-60.3-10.5 16.9A107.6 107.6 0 0 0 128 20Z" fill={gold} />
      <path d="M128 45 151 119 128 102 105 119 128 45Z" fill={ivory} />
      <path d="M128 211 92 128 119 146 128 126 137 146 164 128 128 211Z" fill={gold} />
      <path d="M77 83 83 97 97 103 83 109 77 123 71 109 57 103 71 97 77 83Z" fill={ivory} />
      <circle cx="183" cy="151" r="8" fill={ivory} />
      <circle cx="179" cy="84" r="5" fill={gold} />
      <circle cx="70" cy="164" r="5" fill={gold} />
    </svg>
  );
}

/* ---- Zodiac medallion ---- */
function MMedallion({ sign, size = 52 }) {
  return (
    <span className="m-medallion m-glyph" style={{ width: size, height: size, fontSize: Math.round(size * 0.5), "--mz": sign.accent }} aria-hidden="true">
      {sign.symbol}
    </span>
  );
}

/* ---- Avatar (initials) ---- */
function MAvatar({ name, size = 44, accent }) {
  const initials = name.trim().split(/\s+/).slice(0, 2).map((p) => p[0]).join("").toUpperCase();
  return (
    <span className="m-avatar" style={{ width: size, height: size, fontSize: Math.round(size * 0.36), ...(accent ? { background: accent } : {}) }}>{initials}</span>
  );
}

Object.assign(window, { MD, mINR, MIcon, MCompass, MMedallion, MAvatar });
})();
