// ─── Quest System Types ───────────────────────────────────────────────────────
// Swap dummy data for API responses later — shape stays the same.

export type RequirementType =
  | "QUESTIONS_ANSWERED"
  | "SESSIONS_COMPLETED"
  | "MIN_ACCURACY"
  | "DAILY_STREAK"
  | "LIFETIME_XP"
  | "LEADERBOARD_RANK";

export type NodeStatus = "LOCKED" | "ACTIVE" | "CLAIMABLE" | "COMPLETED";

export type RewardItem = "streak_shield" | "xp_boost" | "title";

export interface QuestNode {
  node_id: string;
  name: string;
  description: string;
  sequence_order: number;
  req_type: RequirementType;
  req_target: number;
  reward_coins: number;
  reward_xp: number;
  reward_title: {
    name: string;
    description: string;
    id: string;
  };
  reward_items: InventoryItem[];
  status: string;
  current_value: 0;
}

export interface QuestArc {
  id: string;
  name: string;
  description: string;
  image_url: string;
  sequence_order: number;
  nodes: QuestNode[];
}

export type Title = {
  name: string;
  description: string;
  id: string;
};

export interface ClaimedRewardResponse {
  message: string;
  xp_awarded: 0;
  coins_awarded: 0;
  title_unlocked: Title[];
  items_awarded: InventoryItem[];
}

// ─── Crew Rank ladder (shown on profile / leaderboard) ───────────────────────
export const CREW_RANKS = [
  { id: "cabin_boy", label: "Cabin Boy", emoji: "⚓", xpRequired: 0 },
  { id: "navigator", label: "Navigator", emoji: "🗺️", xpRequired: 500 },
  { id: "first_mate", label: "First Mate", emoji: "⚔️", xpRequired: 1500 },
  { id: "warlord", label: "Warlord", emoji: "🔱", xpRequired: 3000 },
  { id: "emperor", label: "Emperor", emoji: "👑", xpRequired: 6000 },
  { id: "pirate_king", label: "Pirate King", emoji: "🏴‍☠️", xpRequired: 10000 },
] as const;

export type UserTitle = {
  title_id: string;
  title: {
    name: string;
    description: string;
    id: string;
  };
  unlocked_at: string;
  is_active: false;
};

export type InventoryItem = {
  id: string;
  item: {
    name: string;
    description: string;
    type: string;
    effect_type: string;
    effect_value: number;
    id: string;
  };
  quantity: number;
};
export type ActiveEffect = {
  id: string;
  item: {
    name: string;
    description: string;
    type: string;
    effect_type: string;
    effect_value: number;
    id: string;
  };
  expires_at: string;
};

export interface UserInventory {
  items: InventoryItem[];
  active_effects: ActiveEffect[];
}
