/**
 * Shared constants for the Riichi Mahjong Tutorial
 */

// ============ Canvas Constants ============
export const CANVAS = {
  WIDTH: 1000,
  HEIGHT: 1000,
  GAME_AREA: {
    X: 0,
    Y: 0,
    WIDTH: 1050,
    HEIGHT: 1050,
  },
} as const;

// ============ Colors ============
export const COLORS = {
  // Main theme
  PRIMARY: '#1a7f4b',
  PRIMARY_LIGHT: '#22a861',
  PRIMARY_DARK: '#0d5c34',
  
  // Game board
  TABLE_GREEN: '#007730',
  TABLE_DARK: '#005520',
  
  // Tiles
  TILE_FRONT: '#FFFFFF',
  TILE_BACK: '#4A90D9',
  TILE_SHADOW: 'rgba(0, 0, 0, 0.3)',
  TILE_HIGHLIGHT: 'rgba(255, 215, 0, 0.5)',
  
  // Buttons
  BUTTON_PASS: '#FF9030',
  BUTTON_CALL: '#FFCC33',
  BUTTON_WIN: '#FF3060',
  BUTTON_RIICHI: '#66ccff',
  
  // Text
  TEXT_LIGHT: '#FFFFFF',
  TEXT_DARK: '#1A1A1A',
  TEXT_MUTED: '#6B7280',
  
  // Status
  SUCCESS: '#22C55E',
  WARNING: '#F59E0B',
  ERROR: '#EF4444',
  INFO: '#3B82F6',
} as const;

// ============ Tile Constants ============
export const TILE = {
  // Base dimensions (at scale 1)
  WIDTH: 75,
  HEIGHT: 100,
  
  // Families
  FAMILY: {
    MAN: 1,
    PIN: 2,
    SOU: 3,
    WIND: 4,
    DRAGON: 5,
  },
  
  // Wind values
  WIND: {
    EAST: 1,
    SOUTH: 2,
    WEST: 3,
    NORTH: 4,
  },
  
  // Dragon values
  DRAGON: {
    RED: 1,    // Chun
    GREEN: 2,  // Hatsu
    WHITE: 3,  // Haku
  },
  
  // Image paths
  IMAGE_PATH: 'img/Regular/',
  
  // Families for numbered tiles
  SUIT_FAMILIES: [1, 2, 3] as const,
  HONOR_FAMILIES: [4, 5] as const,
} as const;

// ============ Game Constants ============
export const GAME = {
  // Players
  PLAYER_COUNT: 4,
  
  // Hand sizes
  HAND_SIZE: 13,
  WINNING_HAND_SIZE: 14,
  
  // Wall
  WALL_SIZE: 136,
  DEAD_WALL_SIZE: 14,
  DORA_INDICATOR_COUNT: 5,
  
  // Timing (in ms)
  TIMING: {
    MIN_WAIT: 500,
    DEFAULT_WAIT: 700,
    MAX_WAIT: 2000,
    ANIMATION_DURATION: 300,
  },
  
  // Display sizes (scale factors)
  DISPLAY: {
    HAND: 0.7,
    HIDDEN_HAND: 0.6,
    DISCARD: 0.6,
    GROUP: 0.6,
  },
} as const;

// ============ Math Constants ============
export const MATH = {
  PI: Math.PI,
  HALF_PI: Math.PI / 2,
  TWO_PI: Math.PI * 2,
  DEG_TO_RAD: Math.PI / 180,
  RAD_TO_DEG: 180 / Math.PI,
} as const;

// ============ Animation Constants ============
export const ANIMATION = {
  FPS: 60,
  FRAME_INTERVAL: 1000 / 60,
  TIME_STEP: 1 / 60,
} as const;

// ============ Physics Constants ============
export const PHYSICS = {
  GRAVITY: 100,
  FALLING_TILE: {
    INITIAL_Y: -150,
    INITIAL_VELOCITY: 50,
    SPAWN_CHANCE: 0.75,
    ROTATION_FACTOR: Math.PI,
    MOMENTUM_RANGE: 1,
    MAX_Y: 1100,
  },
} as const;

// ============ Button Constants ============
export const BUTTON = {
  RADIUS: 8,
  WIDTH: 110,
  HEIGHT: 50,
  SPACING: 120,
  MARGIN: 10,
  AREA: {
    Y_MIN: 838,
    Y_MAX: 888,
  },
  BASE_X: 850,
} as const;

// ============ Score Constants ============
export const SCORE = {
  // Base points for different limits
  MANGAN: 2000,
  HANEMAN: 3000,
  BAIMAN: 4000,
  SANBAIMAN: 6000,
  YAKUMAN: 8000,
  
  // Han thresholds
  HAN_LIMITS: {
    MANGAN: 5,
    HANEMAN: 6,
    BAIMAN: 8,
    SANBAIMAN: 11,
    YAKUMAN: 13,
  },
  
  // Starting score
  STARTING_POINTS: 25000,
  TARGET_POINTS: 30000,
  
  // Riichi
  RIICHI_COST: 1000,
} as const;

// ============ Wind Rotations ============
export const ROTATIONS = [
  0,                        // East (bottom)
  -MATH.HALF_PI,           // South (right)
  -MATH.PI,                // West (top)
  MATH.HALF_PI,            // North (left)
] as const;

// ============ Keyboard Keys ============
export const KEYS = {
  ENTER: 'Enter',
  ESCAPE: 'Escape',
  SPACE: ' ',
  ARROW_LEFT: 'ArrowLeft',
  ARROW_RIGHT: 'ArrowRight',
  ARROW_UP: 'ArrowUp',
  ARROW_DOWN: 'ArrowDown',
} as const;

// ============ CSS Class Names ============
export const CSS_CLASSES = {
  CANVAS_WRAPPER: 'canvas-wrapper',
  ANIMATE_FADE_IN: 'animate-fadeIn',
  ANIMATE_SLIDE_IN: 'animate-slideIn',
  HIDDEN: 'hidden',
  VISIBLE: 'visible',
} as const;
