// Companion types
export type CompanionType = "fee" | "einhorn" | "fuchs" | "eule";
export type KeyboardLayout = "de" | "ch";

// Level status for the forest map
export type LevelStatus = "locked" | "current" | "completed";

// Progress store
export interface Progress {
	id: 1; // singleton row
	currentLevel: number;
	completedLevels: number[];
	totalSessions: number;
	sessionDates: string[]; // ISO date strings (days only)
	selectedCharacter: CompanionType;
	selectedLayout: KeyboardLayout;
	totalCorrect: number;
	totalErrors: number;
	errorKeyCounts: Record<string, number>;
	lastPlayedLevels: number[]; // last 3 played levels for review mechanic
	currentForestPage: number; // 0-indexed, default 0
}

export type LessonPhase = "discover" | "practice" | "words";

// Companion assets store
export interface CompanionAssets {
	characterType: CompanionType;
	characterSheet: Blob;
	avatarImage: Blob;
	generatedAt: string; // ISO date
}

// Style reference store
export interface StyleReference {
	id: 1; // singleton
	imageBlob: Blob;
	generatedAt: string;
}

// Forest element store
export interface ForestElement {
	id?: number; // auto-increment
	levelCompleted: number;
	imageBlob: Blob;
	imagePrompt: string;
	description: string;
	companionText: string;
	position: { x: number; y: number };
	createdAt: string;
}

// Settings store
export interface Settings {
	id: 1; // singleton
	audioEnabled: boolean;
	speechEnabled: boolean;
	apiKey: string;
	apiCallsToday: { text: number; image: number };
	lastApiCallDate: string; // ISO date "YYYY-MM-DD"
}

// Level definition (used in game/levels.ts)
export interface Level {
	level: number;
	newKeys: string[];
	allKeys: string[]; // cumulative keys up to this level
	fingerMap: Record<string, string>; // key -> CSS variable name for finger color
}

// Typing exercise state
export interface TypingExerciseState {
	currentLetterIndex: number;
	letters: string[];
	intervalMs: number;
	correctStreak: number;
	totalCorrect: number;
	totalErrors: number;
	mode: "letters" | "words";
	words?: string[];
	wordBoundaries?: number[];
}

// Screen names
export type ScreenName = "welcome" | "forest" | "lesson" | "reward" | "parent";
