/**
 * 캐릭터 비주얼 설정
 * docs/character-design-guide.md 기반으로 각 원소별 시각적 특성 정의
 */

export type ParticleType =
  | 'flame'
  | 'water'
  | 'wind'
  | 'earth'
  | 'crystal'
  | 'spark'
  | 'star'
  | 'smoke'
  | 'rainbow'
  | 'leaf';

export type PatternType = 'swirl' | 'wave' | 'crack' | 'spiral' | 'crystal' | 'none';

export type EyeStyle = 'energetic' | 'calm' | 'playful' | 'steady' | 'mysterious' | 'radiant';

export interface ElementVisualConfig {
  particleType: ParticleType;
  patternType: PatternType;
  eyeStyle: EyeStyle;
  glowColor: string;
  particleColors: string[];
  /** body 가로/세로 비율 [rx, ry] — 기본값 [33, 31] */
  bodyShape?: [number, number];
}

/** 기본 비주얼 (매핑 없는 원소 폴백) */
export const DEFAULT_VISUAL: ElementVisualConfig = {
  particleType: 'star',
  patternType: 'none',
  eyeStyle: 'steady',
  glowColor: '#AAAAAA',
  particleColors: ['#AAAAAA', '#CCCCCC'],
};

export const CHARACTER_VISUAL: Record<string, ElementVisualConfig> = {
  // ───────────── Tier 1 — 기본 4원소 ─────────────
  fire: {
    particleType: 'flame',
    patternType: 'swirl',
    eyeStyle: 'energetic',
    glowColor: '#FF6600',
    particleColors: ['#FF4500', '#FFAA00', '#FF6600'],
    bodyShape: [29, 36],
  },
  water: {
    particleType: 'water',
    patternType: 'wave',
    eyeStyle: 'calm',
    glowColor: '#87CEEB',
    particleColors: ['#1E90FF', '#87CEEB', '#00BFFF'],
    bodyShape: [33, 31],
  },
  wind: {
    particleType: 'wind',
    patternType: 'spiral',
    eyeStyle: 'playful',
    glowColor: '#FFFFFF',
    particleColors: ['#FFFFFF', '#87CEEB', '#B0E2FF'],
    bodyShape: [36, 28],
  },
  earth: {
    particleType: 'earth',
    patternType: 'crack',
    eyeStyle: 'steady',
    glowColor: '#D2691E',
    particleColors: ['#8B4513', '#D2691E', '#A0522D'],
    bodyShape: [35, 30],
  },

  // ───────────── Tier 2 — 2차 원소 ─────────────
  steam: {
    particleType: 'smoke',
    patternType: 'none',
    eyeStyle: 'calm',
    glowColor: '#FFFFFF',
    particleColors: ['#FFFFFF', '#C0C0C0', '#E0E0E0'],
  },
  firestorm: {
    particleType: 'flame',
    patternType: 'swirl',
    eyeStyle: 'energetic',
    glowColor: '#FF6347',
    particleColors: ['#FF6347', '#FF4500', '#FFAA00'],
    bodyShape: [32, 34],
  },
  lava: {
    particleType: 'flame',
    patternType: 'crack',
    eyeStyle: 'steady',
    glowColor: '#FF6600',
    particleColors: ['#FF2200', '#FF6600', '#FFAA00'],
  },
  storm: {
    particleType: 'wind',
    patternType: 'wave',
    eyeStyle: 'playful',
    glowColor: '#6495ED',
    particleColors: ['#4169E1', '#6495ED', '#87CEEB'],
    bodyShape: [35, 30],
  },
  mud: {
    particleType: 'earth',
    patternType: 'crack',
    eyeStyle: 'steady',
    glowColor: '#A0522D',
    particleColors: ['#8B6914', '#A0522D', '#D2691E'],
  },
  desert: {
    particleType: 'earth',
    patternType: 'wave',
    eyeStyle: 'steady',
    glowColor: '#F4A460',
    particleColors: ['#DEB887', '#F4A460', '#D2B48C'],
    bodyShape: [36, 29],
  },
  // ── 신규 Tier 2 ──
  ice: {
    particleType: 'crystal',
    patternType: 'crystal',
    eyeStyle: 'calm',
    glowColor: '#FFFFFF',
    particleColors: ['#87CEEB', '#FFFFFF', '#B0E0FF'],
    bodyShape: [34, 28],
  },
  smoke: {
    particleType: 'smoke',
    patternType: 'swirl',
    eyeStyle: 'calm',
    glowColor: '#A9A9A9',
    particleColors: ['#808080', '#A9A9A9', '#C0C0C0'],
  },

  // ───────────── Tier 3 — 희귀 원소 ─────────────
  cloud: {
    particleType: 'water',
    patternType: 'none',
    eyeStyle: 'playful',
    glowColor: '#FFFFFF',
    particleColors: ['#FFFFFF', '#E0E8F0', '#C8D8E8'],
    bodyShape: [38, 28],
  },
  fog: {
    particleType: 'smoke',
    patternType: 'none',
    eyeStyle: 'mysterious',
    glowColor: '#D3D3D3',
    particleColors: ['#DCDCDC', '#C8C8C8', '#B8B8B8'],
    bodyShape: [36, 29],
  },
  volcano: {
    particleType: 'flame',
    patternType: 'crack',
    eyeStyle: 'energetic',
    glowColor: '#FF4500',
    particleColors: ['#CC2200', '#FF4500', '#FF6600'],
    bodyShape: [31, 35],
  },
  rainbow: {
    particleType: 'star',
    patternType: 'wave',
    eyeStyle: 'playful',
    glowColor: '#FF69B4',
    particleColors: ['#FF0000', '#FF9900', '#FFD700', '#00CC00', '#0000FF', '#8B00FF'],
    bodyShape: [36, 30],
  },
  obsidian: {
    particleType: 'crystal',
    patternType: 'crack',
    eyeStyle: 'mysterious',
    glowColor: '#4A4A8A',
    particleColors: ['#1C1C1C', '#4A4A6A', '#2D2D4A'],
  },
  ash: {
    particleType: 'smoke',
    patternType: 'none',
    eyeStyle: 'steady',
    glowColor: '#808080',
    particleColors: ['#696969', '#808080', '#A0A0A0'],
  },
  lightning: {
    particleType: 'spark',
    patternType: 'crystal',
    eyeStyle: 'energetic',
    glowColor: '#FFFFFF',
    particleColors: ['#FFD700', '#FFFFFF', '#FFA500'],
    bodyShape: [30, 35],
  },
  tsunami: {
    particleType: 'water',
    patternType: 'wave',
    eyeStyle: 'steady',
    glowColor: '#00BFFF',
    particleColors: ['#006994', '#008CB4', '#00BFFF'],
    bodyShape: [36, 30],
  },
  ceramic: {
    particleType: 'earth',
    patternType: 'crack',
    eyeStyle: 'calm',
    glowColor: '#CD853F',
    particleColors: ['#D2691E', '#CD853F', '#DEB887'],
  },
  dust: {
    particleType: 'earth',
    patternType: 'none',
    eyeStyle: 'calm',
    glowColor: '#C8A870',
    particleColors: ['#BC8F5F', '#C8A870', '#D2B48C'],
  },
  oasis: {
    particleType: 'leaf',
    patternType: 'wave',
    eyeStyle: 'calm',
    glowColor: '#32CD32',
    particleColors: ['#228B22', '#32CD32', '#90EE90'],
  },
  glass: {
    particleType: 'crystal',
    patternType: 'none',
    eyeStyle: 'mysterious',
    glowColor: '#AFEEEE',
    particleColors: ['#E0FFFF', '#AFEEEE', '#B0E0E0'],
  },

  // ───────────── Tier 4 — 에픽 원소 ─────────────
  thunderstorm: {
    particleType: 'spark',
    patternType: 'crystal',
    eyeStyle: 'energetic',
    glowColor: '#6666FF',
    particleColors: ['#191970', '#4169E1', '#FFD700'],
    bodyShape: [33, 33],
  },
  island: {
    particleType: 'leaf',
    patternType: 'wave',
    eyeStyle: 'calm',
    glowColor: '#66CC66',
    particleColors: ['#3CB371', '#228B22', '#87CEEB'],
    bodyShape: [35, 32],
  },
  crystal: {
    particleType: 'crystal',
    patternType: 'crystal',
    eyeStyle: 'mysterious',
    glowColor: '#DA70D6',
    particleColors: ['#9400D3', '#DA70D6', '#8B00FF'],
    bodyShape: [30, 36],
  },
  life: {
    particleType: 'star',
    patternType: 'wave',
    eyeStyle: 'radiant',
    glowColor: '#66FF88',
    particleColors: ['#00FF7F', '#7FFF00', '#32CD32'],
    bodyShape: [34, 33],
  },
  magnet: {
    particleType: 'spark',
    patternType: 'spiral',
    eyeStyle: 'mysterious',
    glowColor: '#DCDCDC',
    particleColors: ['#A9A9A9', '#C0C0C0', '#FFD700'],
  },
  aurora: {
    particleType: 'rainbow',
    patternType: 'wave',
    eyeStyle: 'radiant',
    glowColor: '#7DF9FF',
    particleColors: ['#00FFAA', '#7DF9FF', '#9B59B6', '#FF69B4'],
    bodyShape: [35, 33],
  },
  // ── 신규 Tier 4 ──
  glacier: {
    particleType: 'crystal',
    patternType: 'crystal',
    eyeStyle: 'calm',
    glowColor: '#AADDFF',
    particleColors: ['#B8D8E8', '#FFFFFF', '#87CEEB'],
    bodyShape: [35, 29],
  },
  jungle: {
    particleType: 'leaf',
    patternType: 'wave',
    eyeStyle: 'playful',
    glowColor: '#44BB44',
    particleColors: ['#1A6B1A', '#228B22', '#90EE90'],
    bodyShape: [35, 32],
  },
  wasteland: {
    particleType: 'earth',
    patternType: 'crack',
    eyeStyle: 'steady',
    glowColor: '#A08060',
    particleColors: ['#8B7355', '#A08060', '#C2A261'],
    bodyShape: [36, 29],
  },
  maelstrom: {
    particleType: 'wind',
    patternType: 'spiral',
    eyeStyle: 'energetic',
    glowColor: '#4488FF',
    particleColors: ['#1E3A8A', '#3B82F6', '#87CEEB'],
    bodyShape: [34, 34],
  },
  gemstone: {
    particleType: 'crystal',
    patternType: 'crystal',
    eyeStyle: 'mysterious',
    glowColor: '#AA66FF',
    particleColors: ['#6B21A8', '#9333EA', '#C084FC'],
    bodyShape: [31, 35],
  },
  prism: {
    particleType: 'rainbow',
    patternType: 'wave',
    eyeStyle: 'radiant',
    glowColor: '#FF88CC',
    particleColors: ['#FF0066', '#FF9900', '#00FF66', '#0066FF'],
    bodyShape: [34, 32],
  },
  ruins: {
    particleType: 'earth',
    patternType: 'crack',
    eyeStyle: 'steady',
    glowColor: '#B8793A',
    particleColors: ['#92400E', '#B8793A', '#D4A070'],
    bodyShape: [34, 30],
  },
  cyclone: {
    particleType: 'wind',
    patternType: 'spiral',
    eyeStyle: 'energetic',
    glowColor: '#FFB84D',
    particleColors: ['#D97706', '#F59E0B', '#FCD34D'],
    bodyShape: [34, 31],
  },
  deepsea: {
    particleType: 'water',
    patternType: 'wave',
    eyeStyle: 'mysterious',
    glowColor: '#4488BB',
    particleColors: ['#1E3A5F', '#2E5A9F', '#4A8AC4'],
    bodyShape: [34, 32],
  },
  prairie: {
    particleType: 'leaf',
    patternType: 'wave',
    eyeStyle: 'calm',
    glowColor: '#AAFE44',
    particleColors: ['#84CC16', '#A3E635', '#D9F99D'],
    bodyShape: [36, 30],
  },

  // ───────────── Tier 5 — 전설 원소 ─────────────
  creation: {
    particleType: 'rainbow',
    patternType: 'swirl',
    eyeStyle: 'radiant',
    glowColor: '#FFFFFF',
    particleColors: ['#FF0000', '#FF9900', '#FFFF00', '#00FF00', '#0000FF', '#FF00FF'],
    bodyShape: [35, 35],
  },
  spirit: {
    particleType: 'star',
    patternType: 'swirl',
    eyeStyle: 'radiant',
    glowColor: '#FFD700',
    particleColors: ['#FFD700', '#FFF0A0', '#FFFFFF'],
    bodyShape: [34, 34],
  },
};
