// ─── Element Definitions ─────────────────────────────────────────────────────
import type { ElementDef } from '../types';

// Helper function for creating raw mana cost
export function rawCost(amount: number): { type: 'raw'; amount: number } {
  return { type: 'raw', amount };
}

// Helper function for creating elemental mana cost
export function elemCost(element: string, amount: number): { type: 'element'; element: string; amount: number } {
  return { type: 'element', element, amount };
}

// Mana constants
export const MANA_PER_ELEMENT = 100;

export const ELEMENTS: Record<string, ElementDef> = {
  // Base Elements
  fire:   { name: "Fire",   sym: "🔥", color: "#FF6B35", glow: "#FF6B3540", cat: "base" },
  water:  { name: "Water",  sym: "💧", color: "#4ECDC4", glow: "#4ECDC440", cat: "base" },
  air:    { name: "Air",    sym: "🌬️", color: "#00D4FF", glow: "#00D4FF40", cat: "base" },
  earth:  { name: "Earth",  sym: "⛰️", color: "#F4A261", glow: "#F4A26140", cat: "base" },
  light:  { name: "Light",  sym: "☀️", color: "#FFD700", glow: "#FFD70040", cat: "base" },
  dark:   { name: "Dark",   sym: "🌑", color: "#9B59B6", glow: "#9B59B640", cat: "base" },
  death:  { name: "Death",  sym: "💀", color: "#778CA3", glow: "#778CA340", cat: "base" },
  
  // Utility Elements
  transference: { name: "Transference", sym: "🔗", color: "#1ABC9C", glow: "#1ABC9C40", cat: "utility" },
  
  // Composite Elements
  metal:     { name: "Metal",     sym: "⚙️", color: "#BDC3C7", glow: "#BDC3C740", cat: "composite", recipe: ["fire", "earth"] },
  sand:      { name: "Sand",      sym: "⏳", color: "#D4AC0D", glow: "#D4AC0D40", cat: "composite", recipe: ["earth", "water"] },
  lightning: { name: "Lightning", sym: "⚡", color: "#FFEB3B", glow: "#FFEB3B40", cat: "composite", recipe: ["fire", "air"] },
  
  frost:     { name: "Frost",     sym: "❄️", color: "#A8D8EA", glow: "#A8D8EA40", cat: "composite", recipe: ["air", "water"] },
  blackflame: { name: "BlackFlame", sym: "🌋", color: "#8B2500", glow: "#8B250040", cat: "composite", recipe: ["dark", "fire"] },
  radiantflames: { name: "Radiant Flames", sym: "🌟", color: "#FFAA33", glow: "#FFAA3340", cat: "composite", recipe: ["light", "fire"] },
  miasma:    { name: "Miasma",    sym: "☁️", color: "#6B8E23", glow: "#6B8E2340", cat: "composite", recipe: ["air", "death"] },
  shadowglass: { name: "Shadow Glass", sym: "🖤", color: "#2C2C54", glow: "#2C2C5440", cat: "composite", recipe: ["earth", "dark"] },
  // Exotic Elements
  crystal: { name: "Crystal", sym: "💎", color: "#85C1E9", glow: "#85C1E940", cat: "exotic", recipe: ["sand", "sand", "light"] },
  stellar: { name: "Stellar", sym: "⭐", color: "#F0E68C", glow: "#F0E68C40", cat: "exotic", recipe: ["plasma", "light", "fire"] },
  void:    { name: "Void",   sym: "🕳️", color: "#4A235A", glow: "#4A235A40", cat: "exotic", recipe: ["dark", "dark", "death"] },
  soul:    { name: "Soul",    sym: "💫", color: "#E8D5F5", glow: "#E8D5F540", cat: "exotic", recipe: ["light", "dark", "transference"] },
  time:     { name: "Time",    sym: "⏱️", color: "#C5B99A", glow: "#C5B99A40", cat: "exotic", recipe: ["soul", "sand", "transference"] },
  plasma:   { name: "Plasma",  sym: "🔴", color: "#FF6B9D", glow: "#FF6B9D40", cat: "exotic", recipe: ["lightning", "fire", "transference"] },
};

// NOTE: Life, Blood, Wood, Mental, and Force mana types have been removed.
// Lifesteal and healing are BANNED from player abilities - see AGENTS.md
// Crystal recipe updated to use light instead of mental.

export const FLOOR_ELEM_CYCLE = ["fire", "water", "air", "earth", "light", "dark", "death"];

// ─── Element Opposites for Damage Calculation ────────────────────────────────
// Element Opposites for Damage Calculation
// Semantics: ELEMENT_OPPOSITES[X] = list of elements that X is weak to (counters of X)
// In getElementalBonus(spellElem, floorElem):
//   - If spellElem is in ELEMENT_OPPOSITES[floorElem] → super effective (1.5x)
//   - If floorElem is in ELEMENT_OPPOSITES[spellElem] → weak (0.75x)
// Bidirectional pairs: if A counters B, then B counters A (both can be super effective against each other)
// Directional counters:
//   earth → lightning (earth counters lightning, so lightning is weak to earth)
//   lightning → water (lightning counters water, so water is weak to lightning)
export const ELEMENT_OPPOSITES: Record<string, string[]> = {
  // Base opposites (bidirectional)
  fire: ['water', 'frost'],    water: ['fire', 'lightning', 'blackflame', 'radiantflames'],
  air: ['earth', 'miasma'],   earth: ['air'],
  light: ['dark', 'blackflame', 'shadowglass'], dark: ['light', 'radiantflames'],

  // Directional counters
  lightning: ['earth'],  // lightning is weak to earth (earth counters lightning)

  // Composite element counters (bidirectional per spec §4.2)
  frost: ['fire', 'blackflame', 'radiantflames'],
  blackflame: ['frost', 'water', 'light'],
  radiantflames: ['frost', 'water', 'dark'],
  miasma: ['air'],
  shadowglass: ['light'],
};

// ─── Element Icon Mapping (Lucide Icons) ──────────────────────────────────────
// Note: These are string identifiers for dynamic icon loading
// The actual Lucide icons are imported in the components
export const ELEMENT_ICON_NAMES: Record<string, string> = {
  fire: 'Flame',
  water: 'Droplet',
  air: 'Wind',
  earth: 'Mountain',
  light: 'Sun',
  dark: 'Moon',
  death: 'Skull',
  transference: 'Link',
  metal: 'Target',
  sand: 'Hourglass',
  lightning: 'Zap',
  crystal: 'Gem',
  stellar: 'Star',
  void: 'CircleDot',
  raw: 'Circle',
  frost: 'Snowflake',
  blackflame: 'Flame',
  radiantflames: 'Sun',
  miasma: 'Cloud',
  shadowglass: 'EyeOff',
  soul: 'Ghost',
  time: 'Clock',
  plasma: 'Zap',
};

// ─── Base Unlocked Elements ───────────────────────────────────────────────────
export const BASE_UNLOCKED_ELEMENTS = ['transference'];

// ─── Base Element IDs (7 base elements only — NOT composite/exotic/utility) ──
export const BASE_ELEMENTS = ['fire', 'water', 'air', 'earth', 'light', 'dark', 'death'] as const;
