/**
 * Tutorial Steps Database
 * Guided onboarding for new players
 */

export const tutorialSteps = [
  {
    id: 'welcome',
    trigger: 'game_start',
    title: 'Welcome to Suno Music Adventure!',
    content: 'Explore an infinite world, travel through time, and learn from legendary musicians. Let me show you how to play!',
    highlight: null,
    position: 'center',
    nextTrigger: 'manual',
    canSkip: true // Always allow skip
  },

  {
    id: 'movement',
    trigger: 'after_welcome',
    title: 'Movement Controls',
    content: 'Use WASD or Arrow Keys to move your character around the map. Try moving now!',
    highlight: '.game-map',
    position: 'center',
    nextTrigger: 'player_moved',
    canSkip: true // Changed: Allow skip
  },

  {
    id: 'explore_rooms',
    trigger: 'after_movement',
    title: 'Exploring New Rooms',
    content: 'Walk to the edges of the room (dashed borders) to explore new areas. The world is infinite!',
    highlight: '.game-map',
    position: 'center',
    nextTrigger: 'room_changed',
    canSkip: true // Changed: Allow skip
  },

  {
    id: 'musician_challenge',
    trigger: 'first_musician_spawn',
    title: 'Musician Challenges',
    content: 'See that music note? That is a musician challenge! Walk to it and press SPACE to interact.',
    highlight: '.challenge',
    position: 'top',
    nextTrigger: 'challenge_started',
    canSkip: true // Changed: Allow skip
  },

  {
    id: 'time_travel',
    trigger: 'level_2',
    title: 'Time Travel',
    content: 'Click on different time periods in the left sidebar to travel through music history! Each era has unique musicians.',
    highlight: '.time-selector',
    position: 'right',
    nextTrigger: 'era_changed',
    canSkip: true // Always allow skip
  },

  {
    id: 'genre_mastery',
    trigger: 'first_challenge_complete',
    title: 'Genre Mastery',
    content: 'You earned Genre XP! Complete challenges to level up genres and unlock skills. Check your genre mastery panel!',
    highlight: '.sidebar-button-genres',
    position: 'left',
    nextTrigger: 'manual',
    canSkip: true // Always allow skip
  },

  {
    id: 'equipment',
    trigger: 'level_3',
    title: 'Instruments & Equipment',
    content: 'Collect instruments from defeated musicians and craft new ones! Equipment provides bonuses to your performances.',
    highlight: '.sidebar-button-inventory',
    position: 'left',
    nextTrigger: 'manual',
    canSkip: true // Always allow skip
  },

  {
    id: 'reputation',
    trigger: 'first_quest_start',
    title: 'Reputation System',
    content: 'Your choices in quests affect your reputation with genres, musicians, and eras. Build relationships to unlock content!',
    highlight: null,
    position: 'center',
    nextTrigger: 'manual',
    canSkip: true // Always allow skip
  },

  {
    id: 'events',
    trigger: 'first_event_spawn',
    title: 'World Events',
    content: 'Time-limited events appear based on your era and location! Complete them for big rewards.',
    highlight: '.event-notification',
    position: 'right',
    nextTrigger: 'manual',
    canSkip: true // Always allow skip
  },

  {
    id: 'tutorial_complete',
    trigger: 'manual',
    title: 'Tutorial Complete!',
    content: 'You are ready to explore! Remember: visit the Help panel (📖) anytime for more information. Good luck!',
    highlight: null,
    position: 'center',
    nextTrigger: null,
    canSkip: true, // Changed: Allow skip/close
    isFinale: true
  }
];

/**
 * Get tutorial step by ID
 */
export const getTutorialStepById = (id) => {
  return tutorialSteps.find(s => s.id === id);
};

/**
 * Get next tutorial step
 */
export const getNextTutorialStep = (currentStepId) => {
  const currentIndex = tutorialSteps.findIndex(s => s.id === currentStepId);
  if (currentIndex === -1 || currentIndex === tutorialSteps.length - 1) {
    return null;
  }
  return tutorialSteps[currentIndex + 1];
};

