import 'package:flutter/material.dart';

import '../../game/models/season.dart';

/// Season-themeable color set. Season 1 default: vivid candy tones on a
/// deep navy board.
class GamePalette {
  static const boardBackground = Color(0xFF151A2E);
  static const emptyCell = Color(0xFF222A45);
  static const boardBorder = Color(0xFF2E3858);

  static const tileColors = <Color>[
    Color(0xFF5B7FFF), // blue
    Color(0xFFFF6B6B), // red
    Color(0xFFFFC94D), // yellow
    Color(0xFF4DD599), // green
    Color(0xFFB980FF), // purple
    Color(0xFFFF8FAB), // pink
    Color(0xFF4DC9E6), // cyan
    Color(0xFFFF9A5B), // orange
  ];

  static Color tile(int colorId) => tileColors[colorId % tileColors.length];

  static const lockedNode = Color(0xFF232B4A);
  static const gem = Color(0xFF7CF5FF);
  static const ghostLegal = Color(0x66FFFFFF);
  static const ghostIllegal = Color(0x55FF5252);
}

/// Resolved per-season colors for the UI layer. Built from a SeasonTheme;
/// falls back to the GamePalette constants.
class ThemeColors {
  ThemeColors(SeasonTheme theme)
      : gradient = [for (final c in theme.backgroundGradient) Color(c)],
        accent = Color(theme.accentColor),
        particleType = theme.particleType,
        board = theme.boardTint != null
            ? Color(theme.boardTint!)
            : GamePalette.boardBackground,
        tiles = theme.tilePalette != null
            ? [for (final c in theme.tilePalette!) Color(c)]
            : GamePalette.tileColors;

  final List<Color> gradient;
  final Color accent;
  final String particleType;
  final Color board;
  final List<Color> tiles;

  Color tile(int colorId) => tiles[colorId % tiles.length];
}
