import { adaptive } from './adaptive';

/**
 * Archetype-FirstSpark 게임 전용 색상 시스템
 * @see docs/color-system.md
 */
export const gameColors = {
  // ── 재화 ──────────────────────────────────────────────
  goldPrimary:    '#FFD700',
  goldSecondary:  '#FFAA00',
  goldBg:         '#FFF8E1',
  goldText:       '#5A3200',

  // ── 등급 ──────────────────────────────────────────────
  rarityCommon:    '#9E9E9E',
  rarityUncommon:  '#4CAF50',
  rarityRare:      '#2196F3',
  rarityEpic:      '#9C27B0',
  rarityLegendary: '#FF9800',

  // ── 이벤트 ────────────────────────────────────────────
  fusionPrimary:   '#7C4DFF',
  fusionGlow:      '#B388FF',
  enhancePrimary:  '#3182F6',
  enhanceGlow:     '#90CAF9',

  // ── 원소별 주요 색 ─────────────────────────────────────
  elements: {
    fire:         '#FF4500',
    water:        '#1E90FF',
    wind:         '#87CEEB',
    earth:        '#8B4513',
    steam:        '#C0C0C0',
    firestorm:    '#FF6347',
    lava:         '#FF2200',
    storm:        '#4169E1',
    mud:          '#8B6914',
    desert:       '#DEB887',
    cloud:        '#87CEEB',
    fog:          '#DCDCDC',
    volcano:      '#CC2200',
    rainbow:      '#FF69B4',
    obsidian:     '#1C1C1C',
    ash:          '#696969',
    lightning:    '#FFD700',
    tsunami:      '#006994',
    ceramic:      '#D2691E',
    dust:         '#BC8F5F',
    oasis:        '#228B22',
    glass:        '#E0FFFF',
    thunderstorm: '#191970',
    island:       '#3CB371',
    crystal:      '#9400D3',
    life:         '#00FF7F',
    magnet:       '#A9A9A9',
    aurora:       '#7DF9FF',
    creation:     '#FFFFFF',
    spirit:       '#FFD700',
  },

  // ── TDS Adaptive 색 ──────────────────────────────────
  bg:        adaptive.background,
  greyBg:    adaptive.greyBackground,
  grey200:   adaptive.grey200,
  grey300:   adaptive.grey300,
  grey400:   adaptive.grey400,
  grey500:   adaptive.grey500,
  grey700:   adaptive.grey700,
  grey900:   adaptive.grey900,
  blue500:   adaptive.blue500,
} as const;

/** 등급 → 색상 매핑 */
export function rarityColor(rarity: string): string {
  const map: Record<string, string> = {
    common:    gameColors.rarityCommon,
    uncommon:  gameColors.rarityUncommon,
    rare:      gameColors.rarityRare,
    epic:      gameColors.rarityEpic,
    legendary: gameColors.rarityLegendary,
  };
  return map[rarity] ?? gameColors.rarityCommon;
}

/** 등급 → 그라디언트 배경 */
export function rarityGradient(rarity: string): string {
  const map: Record<string, string> = {
    common:    'linear-gradient(135deg, #616161, #9E9E9E)',
    uncommon:  'linear-gradient(135deg, #2E7D32, #4CAF50)',
    rare:      'linear-gradient(135deg, #1565C0, #2196F3)',
    epic:      'linear-gradient(135deg, #7B1FA2, #9C27B0)',
    legendary: 'linear-gradient(135deg, #FF6F00, #FFD700)',
  };
  return map[rarity] ?? map.common;
}

/** 원소 ID → 주요 색상 */
export function elementColor(id: string): string {
  return gameColors.elements[id as keyof typeof gameColors.elements] ?? '#888888';
}

/** 발견률(0~1) → 진행 바 그라디언트 */
export function discoveryGradient(ratio: number): string {
  if (ratio >= 1.0) return 'linear-gradient(90deg, #FF6F00, #FF69B4, #7C4DFF, #1E90FF, #4CAF50)';
  if (ratio >= 0.67) return 'linear-gradient(90deg, #7B1FA2, #9C27B0)';
  if (ratio >= 0.34) return 'linear-gradient(90deg, #1565C0, #3182F6)';
  return 'linear-gradient(90deg, #424242, #757575)';
}
