"""
CLI entry point for the 'jyoti' command.
Orchestrates: image opening, audio playback, and terminal animations.
"""

import sys
import time
from jyoti.image import open_image
from jyoti.audio import play_birthday_audio
from jyoti.animations import run_celebration


def main():
    """Main entry point - triggered when user types 'jyoti' in terminal."""
    try:
        # Step 1: Open the birthday image immediately
        open_image()

        # Step 2: Start birthday audio in background
        play_birthday_audio()

        # Small delay so image viewer launches before terminal takes over
        time.sleep(0.3)

        # Step 3: Run the full terminal celebration animation
        run_celebration()

    except KeyboardInterrupt:
        # Graceful exit on Ctrl+C
        print("\n\n🎂 Happy Birthday Jyoti! See you! 🎉\n")
        sys.exit(0)
    except Exception as e:
        # Fallback: at minimum show the birthday message
        print("\n")
        print("=" * 60)
        print("   🎂  HAPPY BIRTHDAY JYOTI!  🎂")
        print("=" * 60)
        print()
        print("   With love from:")
        print("   Sindhu, Akaash, Neha, Rajat, Ujjwal, Leena,")
        print("   Anubha, Partho, Sumit, Rudraksh, Kavita, Muskan, Ishika")
        print()
        print("   🌟 TEAM TONGADIVE 🌟")
        print("   Take care - Love yourself Always 💕")
        print("=" * 60)
        print()


if __name__ == "__main__":
    main()
