/**
 * VideoScript Types
 *
 * Schema for generating TikTok/Reels videos from Expert Discovery Interface conversations.
 * Copied from docs/specs/expert-conversation-video.md
 */

export type VideoScript = {
  id: string;
  atomId: string;
  demographicSliceId: string;

  meta: {
    title: string;
    duration: number; // Total duration in ms
    aspectRatio: '9:16' | '16:9' | '1:1';
    platform: 'tiktok' | 'instagram_reels' | 'youtube_shorts';
  };

  expert: {
    name: string;
    title: string;
    avatarUrl: string;
    voiceId: string; // ElevenLabs voice ID
  };

  scenes: Scene[];

  audio: {
    voiceover: VoiceoverConfig;
    music?: MusicConfig;
  };
};

export type Scene =
  | HookScene
  | QuestionScene
  | ExpertMessageScene
  | ProductScene
  | TransitionScene
  | CTAScene
  | EndCardScene;

export type HookScene = {
  type: 'hook';
  id: string;
  startMs: number;
  durationMs: number;
  text: string;
  visual: 'fade-in' | 'cut' | 'zoom';
};

export type QuestionScene = {
  type: 'question';
  id: string;
  startMs: number;
  durationMs: number;
  question: string;
  options: string[];
  selectedOption: string;
  selectionDelayMs: number;
  voiceoverText: string;
};

export type ExpertMessageScene = {
  type: 'expert-message';
  id: string;
  startMs: number;
  durationMs: number;
  text: string;
  voiceoverText: string;
  emphasis?: string[];
  diagram?: 'spine' | 'pressure-points' | 'foam-layers' | null;
};

export type ProductScene = {
  type: 'product';
  id: string;
  startMs: number;
  durationMs: number;
  product: {
    name: string;
    tagline: string;
    price: string;
    imageUrl: string;
    highlights: string[];
  };
  voiceoverText: string;
  scrollBehavior: 'none' | 'reveal-details' | 'scroll-features';
};

export type TransitionScene = {
  type: 'transition';
  id: string;
  startMs: number;
  durationMs: number;
  text: string;
  voiceoverText: string;
};

export type CTAScene = {
  type: 'cta';
  id: string;
  startMs: number;
  durationMs: number;
  buttonText: string;
  subtext: string;
  voiceoverText: string;
  animation: 'pulse' | 'glow' | 'none';
};

export type EndCardScene = {
  type: 'end-card';
  id: string;
  startMs: number;
  durationMs: number;
  showExpert: boolean;
  text: string;
};

export type VoiceoverConfig = {
  provider: 'elevenlabs' | 'playht' | 'manual';
  voiceId?: string;
  audioUrl?: string;
  settings?: {
    stability: number;
    similarity: number;
    speed: number;
  };
};

export type MusicConfig = {
  trackUrl: string;
  volume: number;
  fadeInMs: number;
  fadeOutMs: number;
};
