Spaces:
Running

File size: 33,827 Bytes
c4075c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ViralToon - AI Animation Creator</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
        
        body {
            font-family: 'Poppins', sans-serif;
            background-color: #f8f9fa;
        }
        
        .gradient-bg {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
        }
        
        .animation-preview {
            aspect-ratio: 9/16;
            background: linear-gradient(45deg, #f3f4f6, #e5e7eb);
        }
        
        .character-option:hover, .scene-option:hover {
            transform: scale(1.05);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        
        .progress-bar {
            height: 4px;
            transition: width 0.3s ease;
        }
        
        .tab-active {
            border-bottom: 3px solid #6e8efb;
            color: #6e8efb;
        }
        
        .voice-wave {
            animation: wave 1.5s infinite ease-in-out;
        }
        
        @keyframes wave {
            0%, 100% { height: 60%; }
            50% { height: 100%; }
        }
        
        .voice-wave:nth-child(2) {
            animation-delay: 0.2s;
        }
        
        .voice-wave:nth-child(3) {
            animation-delay: 0.4s;
        }
        
        .voice-wave:nth-child(4) {
            animation-delay: 0.6s;
        }
        
        .voice-wave:nth-child(5) {
            animation-delay: 0.8s;
        }
        
        .template-card {
            transition: all 0.3s ease;
        }
        
        .template-card:hover {
            transform: translateY(-5px);
        }
        
        .download-btn {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }
        
        .fade-in {
            animation: fadeIn 0.5s ease-in;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
    </style>
</head>
<body class="text-gray-800">
    <!-- Mobile App Container -->
    <div class="max-w-md mx-auto bg-white min-h-screen relative overflow-hidden">
        <!-- Header -->
        <header class="gradient-bg text-white p-4 flex justify-between items-center">
            <button class="p-2 rounded-full bg-white bg-opacity-20" onclick="goBack()">
                <i class="fas fa-arrow-left text-white"></i>
            </button>
            <h1 class="text-xl font-bold">ViralToon</h1>
            <button class="p-2 rounded-full bg-white bg-opacity-20">
                <i class="fas fa-user text-white"></i>
            </button>
        </header>
        
        <!-- Main Content -->
        <main class="pb-20">
            <!-- Animation Preview Section -->
            <div class="relative animation-preview w-full flex items-center justify-center">
                <div id="preview-placeholder" class="absolute inset-0 flex flex-col items-center justify-center text-center p-4">
                    <div class="w-32 h-32 rounded-full bg-blue-100 flex items-center justify-center mb-4">
                        <i class="fas fa-play text-blue-500 text-4xl"></i>
                    </div>
                    <p class="text-gray-600">Your animation will appear here</p>
                </div>
                <div id="generated-preview" class="hidden absolute inset-0 bg-black">
                    <!-- Generated animation would appear here -->
                    <div class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 text-white p-3">
                        <div id="subtitles" class="text-center text-sm font-medium">This is an example of auto-generated subtitles that sync with the voice</div>
                    </div>
                </div>
                <div class="absolute bottom-4 left-4 bg-black bg-opacity-50 text-white px-3 py-1 rounded-full text-sm">
                    <span id="animation-time">0:15</span>
                </div>
            </div>
            
            <!-- Creation Tabs -->
            <div class="flex border-b">
                <button class="flex-1 py-3 font-medium tab-active" onclick="switchTab('input')">
                    <i class="fas fa-keyboard mr-1"></i> Input
                </button>
                <button class="flex-1 py-3 font-medium" onclick="switchTab('templates')">
                    <i class="fas fa-th-large mr-1"></i> Templates
                </button>
                <button class="flex-1 py-3 font-medium" onclick="switchTab('customize')">
                    <i class="fas fa-sliders-h mr-1"></i> Customize
                </button>
            </div>
            
            <!-- Tab Content -->
            <div class="p-4">
                <!-- Input Tab -->
                <div id="input-tab" class="tab-content">
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-1">Enter Your Script</label>
                        <textarea id="script-input" class="w-full p-3 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" rows="4" placeholder="Type what you want your character to say... (e.g. 'Hey there! Did you know this animation was made with AI?')"></textarea>
                    </div>
                    
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-1">Or Record Your Voice</label>
                        <div class="flex items-center justify-center p-4 border-2 border-dashed rounded-lg">
                            <button id="record-btn" class="w-12 h-12 rounded-full bg-red-500 flex items-center justify-center text-white">
                                <i class="fas fa-microphone"></i>
                            </button>
                            <div id="voice-waves" class="hidden ml-4 h-8 flex items-center space-x-1">
                                <div class="voice-wave w-1 bg-blue-500 rounded-full"></div>
                                <div class="voice-wave w-1 bg-blue-500 rounded-full"></div>
                                <div class="voice-wave w-1 bg-blue-500 rounded-full"></div>
                                <div class="voice-wave w-1 bg-blue-500 rounded-full"></div>
                                <div class="voice-wave w-1 bg-blue-500 rounded-full"></div>
                            </div>
                            <span id="record-status" class="ml-4 text-sm">Press to record</span>
                        </div>
                    </div>
                    
                    <button onclick="generateAnimation()" class="w-full gradient-bg text-white py-3 rounded-lg font-medium flex items-center justify-center">
                        <i class="fas fa-magic mr-2"></i> Generate Animation
                    </button>
                </div>
                
                <!-- Templates Tab (Hidden by default) -->
                <div id="templates-tab" class="tab-content hidden">
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-2">Trending Templates</label>
                        <div class="grid grid-cols-2 gap-3">
                            <div class="template-card bg-gray-100 rounded-lg overflow-hidden cursor-pointer" onclick="selectTemplate('meme')">
                                <div class="aspect-video bg-yellow-100 flex items-center justify-center">
                                    <i class="fas fa-laugh-squint text-3xl text-yellow-500"></i>
                                </div>
                                <div class="p-2">
                                    <h4 class="font-medium text-sm">Meme Reaction</h4>
                                    <p class="text-xs text-gray-500">Popular meme formats</p>
                                </div>
                            </div>
                            
                            <div class="template-card bg-gray-100 rounded-lg overflow-hidden cursor-pointer" onclick="selectTemplate('story')">
                                <div class="aspect-video bg-purple-100 flex items-center justify-center">
                                    <i class="fas fa-book-open text-3xl text-purple-500"></i>
                                </div>
                                <div class="p-2">
                                    <h4 class="font-medium text-sm">Story Time</h4>
                                    <p class="text-xs text-gray-500">Narrative animations</p>
                                </div>
                            </div>
                            
                            <div class="template-card bg-gray-100 rounded-lg overflow-hidden cursor-pointer" onclick="selectTemplate('tutorial')">
                                <div class="aspect-video bg-blue-100 flex items-center justify-center">
                                    <i class="fas fa-chalkboard-teacher text-3xl text-blue-500"></i>
                                </div>
                                <div class="p-2">
                                    <h4 class="font-medium text-sm">Tutorial</h4>
                                    <p class="text-xs text-gray-500">How-to explanations</p>
                                </div>
                            </div>
                            
                            <div class="template-card bg-gray-100 rounded-lg overflow-hidden cursor-pointer" onclick="selectTemplate('emotional')">
                                <div class="aspect-video bg-pink-100 flex items-center justify-center">
                                    <i class="fas fa-heart text-3xl text-pink-500"></i>
                                </div>
                                <div class="p-2">
                                    <h4 class="font-medium text-sm">Emotional</h4>
                                    <p class="text-xs text-gray-500">Heartfelt stories</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-2">Recently Popular</label>
                        <div class="flex overflow-x-auto pb-2 space-x-3">
                            <div class="flex-shrink-0 w-24 h-32 bg-gray-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectTemplate('dance')">
                                <i class="fas fa-music text-2xl text-purple-500"></i>
                                <span class="absolute bottom-2 text-xs font-medium">Dance Trend</span>
                            </div>
                            <div class="flex-shrink-0 w-24 h-32 bg-gray-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectTemplate('challenge')">
                                <i class="fas fa-trophy text-2xl text-yellow-500"></i>
                                <span class="absolute bottom-2 text-xs font-medium">Challenge</span>
                            </div>
                            <div class="flex-shrink-0 w-24 h-32 bg-gray-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectTemplate('prank')">
                                <i class="fas fa-surprise text-2xl text-red-500"></i>
                                <span class="absolute bottom-2 text-xs font-medium">Prank</span>
                            </div>
                            <div class="flex-shrink-0 w-24 h-32 bg-gray-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectTemplate('food')">
                                <i class="fas fa-utensils text-2xl text-orange-500"></i>
                                <span class="absolute bottom-2 text-xs font-medium">Food Review</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Customize Tab (Hidden by default) -->
                <div id="customize-tab" class="tab-content hidden">
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-2">Character</label>
                        <div class="flex overflow-x-auto pb-2 space-x-3">
                            <div class="character-option flex-shrink-0 w-20 h-20 bg-gray-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectCharacter('human')">
                                <i class="fas fa-user text-3xl text-gray-400"></i>
                            </div>
                            <div class="character-option flex-shrink-0 w-20 h-20 bg-blue-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectCharacter('robot')">
                                <i class="fas fa-robot text-3xl text-blue-500"></i>
                            </div>
                            <div class="character-option flex-shrink-0 w-20 h-20 bg-purple-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectCharacter('cat')">
                                <i class="fas fa-cat text-3xl text-purple-500"></i>
                            </div>
                            <div class="character-option flex-shrink-0 w-20 h-20 bg-yellow-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectCharacter('dog')">
                                <i class="fas fa-dog text-3xl text-yellow-500"></i>
                            </div>
                            <div class="character-option flex-shrink-0 w-20 h-20 bg-green-100 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectCharacter('alien')">
                                <i class="fas fa-user-astronaut text-3xl text-green-500"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-2">Voice Style</label>
                        <div class="grid grid-cols-2 gap-2">
                            <button class="py-2 px-1 bg-gray-100 rounded text-sm flex items-center justify-center" onclick="selectVoice('male')">
                                <i class="fas fa-male text-blue-500 mr-1"></i> Male
                            </button>
                            <button class="py-2 px-1 bg-gray-100 rounded text-sm flex items-center justify-center" onclick="selectVoice('female')">
                                <i class="fas fa-female text-pink-500 mr-1"></i> Female
                            </button>
                            <button class="py-2 px-1 bg-gray-100 rounded text-sm flex items-center justify-center" onclick="selectVoice('child')">
                                <i class="fas fa-child text-yellow-500 mr-1"></i> Child
                            </button>
                            <button class="py-2 px-1 bg-gray-100 rounded text-sm flex items-center justify-center" onclick="selectVoice('robot')">
                                <i class="fas fa-robot text-purple-500 mr-1"></i> Robot
                            </button>
                        </div>
                    </div>
                    
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-2">Background Music</label>
                        <div class="grid grid-cols-3 gap-2">
                            <button class="py-2 px-1 bg-gray-100 rounded text-xs" onclick="selectMusic('upbeat')">
                                <i class="fas fa-music text-blue-500 mr-1"></i> Upbeat
                            </button>
                            <button class="py-2 px-1 bg-gray-100 rounded text-xs" onclick="selectMusic('chill')">
                                <i class="fas fa-music text-green-500 mr-1"></i> Chill
                            </button>
                            <button class="py-2 px-1 bg-gray-100 rounded text-xs" onclick="selectMusic('dramatic')">
                                <i class="fas fa-music text-purple-500 mr-1"></i> Dramatic
                            </button>
                            <button class="py-2 px-1 bg-gray-100 rounded text-xs" onclick="selectMusic('none')">
                                <i class="fas fa-ban text-gray-500 mr-1"></i> None
                            </button>
                        </div>
                    </div>
                    
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-2">Scene</label>
                        <div class="grid grid-cols-3 gap-2">
                            <div class="scene-option aspect-square bg-gray-200 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectScene('office')">
                                <i class="fas fa-building text-gray-600"></i>
                            </div>
                            <div class="scene-option aspect-square bg-blue-200 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectScene('beach')">
                                <i class="fas fa-umbrella-beach text-blue-600"></i>
                            </div>
                            <div class="scene-option aspect-square bg-green-200 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectScene('park')">
                                <i class="fas fa-tree text-green-600"></i>
                            </div>
                            <div class="scene-option aspect-square bg-yellow-200 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectScene('home')">
                                <i class="fas fa-home text-yellow-600"></i>
                            </div>
                            <div class="scene-option aspect-square bg-purple-200 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectScene('space')">
                                <i class="fas fa-meteor text-purple-600"></i>
                            </div>
                            <div class="scene-option aspect-square bg-red-200 rounded-lg flex items-center justify-center cursor-pointer" onclick="selectScene('party')">
                                <i class="fas fa-glass-cheers text-red-600"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Download Section (Hidden by default) -->
            <div id="download-section" class="hidden p-4 border-t">
                <div class="flex items-center justify-between mb-4">
                    <div>
                        <h3 class="font-bold">Your Animation is Ready!</h3>
                        <p class="text-sm text-gray-500">Share it with the world</p>
                    </div>
                    <button id="play-btn" class="w-12 h-12 rounded-full bg-blue-500 text-white flex items-center justify-center">
                        <i class="fas fa-play"></i>
                    </button>
                </div>
                
                <div class="grid grid-cols-4 gap-2 mb-4">
                    <button class="p-2 bg-gray-100 rounded flex flex-col items-center">
                        <i class="fab fa-tiktok text-xl"></i>
                        <span class="text-xs mt-1">TikTok</span>
                    </button>
                    <button class="p-2 bg-gray-100 rounded flex flex-col items-center">
                        <i class="fab fa-instagram text-xl text-pink-600"></i>
                        <span class="text-xs mt-1">Instagram</span>
                    </button>
                    <button class="p-2 bg-gray-100 rounded flex flex-col items-center">
                        <i class="fab fa-youtube text-xl text-red-600"></i>
                        <span class="text-xs mt-1">YouTube</span>
                    </button>
                    <button class="p-2 bg-gray-100 rounded flex flex-col items-center">
                        <i class="fas fa-link text-xl"></i>
                        <span class="text-xs mt-1">Copy Link</span>
                    </button>
                </div>
                
                <button id="download-btn" class="w-full download-btn text-white py-3 rounded-lg font-medium flex items-center justify-center">
                    <i class="fas fa-download mr-2"></i> Download HD Video
                </button>
            </div>
        </main>
        
        <!-- Bottom Navigation -->
        <nav class="fixed bottom-0 w-full max-w-md bg-white border-t flex justify-around py-3">
            <button class="p-2 text-blue-500">
                <i class="fas fa-home text-xl"></i>
            </button>
            <button class="p-2 text-gray-500">
                <i class="fas fa-compass text-xl"></i>
            </button>
            <button class="p-2 gradient-bg text-white rounded-full px-4">
                <i class="fas fa-plus text-xl"></i>
            </button>
            <button class="p-2 text-gray-500">
                <i class="fas fa-heart text-xl"></i>
            </button>
            <button class="p-2 text-gray-500">
                <i class="fas fa-user text-xl"></i>
            </button>
        </nav>
        
        <!-- Generate Modal -->
        <div id="generate-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
            <div class="bg-white rounded-lg p-6 w-4/5 max-w-sm">
                <h3 class="font-bold text-lg mb-4">Generating Animation</h3>
                <div class="mb-4">
                    <div class="h-2 bg-gray-200 rounded-full overflow-hidden">
                        <div id="generation-progress" class="progress-bar bg-blue-500 w-1/4"></div>
                    </div>
                    <div class="text-xs text-gray-500 mt-1" id="generation-status">Processing your input...</div>
                </div>
                <div class="text-center py-4">
                    <i class="fas fa-cog fa-spin text-blue-500 text-3xl"></i>
                </div>
                <p class="text-sm text-gray-600 mb-4">Our AI is creating your viral animation with lip-sync and expressive actions...</p>
            </div>
        </div>
    </div>

    <script>
        // Current animation settings
        const animationSettings = {
            character: 'human',
            voice: 'male',
            music: 'upbeat',
            scene: 'office',
            template: null,
            script: ''
        };
        
        // Tab switching
        function switchTab(tabName) {
            // Hide all tab contents
            document.querySelectorAll('.tab-content').forEach(tab => {
                tab.classList.add('hidden');
            });
            
            // Show selected tab content
            document.getElementById(`${tabName}-tab`).classList.remove('hidden');
            
            // Update active tab indicator
            document.querySelectorAll('.flex.border-b button').forEach(btn => {
                btn.classList.remove('tab-active');
                if (btn.textContent.includes(tabName.charAt(0).toUpperCase() + tabName.slice(1))) {
                    btn.classList.add('tab-active');
                }
            });
        }
        
        // Record button functionality
        const recordBtn = document.getElementById('record-btn');
        const voiceWaves = document.getElementById('voice-waves');
        const recordStatus = document.getElementById('record-status');
        let isRecording = false;
        
        recordBtn.addEventListener('click', function() {
            isRecording = !isRecording;
            
            if (isRecording) {
                this.innerHTML = '<i class="fas fa-stop"></i>';
                this.classList.add('bg-blue-500');
                this.classList.remove('bg-red-500');
                voiceWaves.classList.remove('hidden');
                recordStatus.textContent = 'Recording...';
                
                // Get the script from voice recording (simulated)
                setTimeout(() => {
                    document.getElementById('script-input').value = "This is a simulated voice recording being converted to text by our AI.";
                }, 2000);
                
                // Simulate progress
                let progress = 0;
                const progressInterval = setInterval(() => {
                    progress += 5;
                    if (progress >= 100) {
                        clearInterval(progressInterval);
                        stopRecording();
                    }
                }, 300);
            } else {
                stopRecording();
            }
        });
        
        function stopRecording() {
            recordBtn.innerHTML = '<i class="fas fa-microphone"></i>';
            recordBtn.classList.remove('bg-blue-500');
            recordBtn.classList.add('bg-red-500');
            voiceWaves.classList.add('hidden');
            recordStatus.textContent = 'Press to record';
            isRecording = false;
        }
        
        // Template selection
        function selectTemplate(template) {
            animationSettings.template = template;
            document.getElementById('script-input').value = getTemplateScript(template);
            showToast(`"${template.charAt(0).toUpperCase() + template.slice(1)}" template selected`);
        }
        
        function getTemplateScript(template) {
            const templates = {
                'meme': "When you realize this animation was made with AI...\n\n*record scratch*\n\nYep, that's me. You're probably wondering how I got here.",
                'story': "Let me tell you a story about the time I tried to make breakfast...\n\nIt was a normal Tuesday morning. The sun was shining. Birds were singing. And then... disaster struck.",
                'tutorial': "Here's how to make the perfect cup of coffee:\n\n1. Boil water\n2. Add coffee grounds\n3. Wait patiently\n4. Enjoy!\n\nPro tip: Don't forget the mug!",
                'emotional': "Sometimes the smallest things take up the most room in your heart.\n\nLike when someone remembers how you take your coffee, or saves you the last slice of pizza.",
                'dance': "When that beat drops...\n\n*starts dancing*\n\nNo one:\n\nAbsolutely no one:\n\nMe: *still dancing*",
                'challenge': "I challenge you to try this for 7 days!\n\n1. Smile at a stranger\n2. Compliment someone\n3. Do something kind\n\nTag 3 friends to join!",
                'prank': "POV: You're about to prank your best friend\n\n*carefully sets up the prank*\n\n*waits patiently*\n\n*BAM!* Gotcha!",
                'food': "This is the BEST burger I've ever had!\n\nLook at that cheese pull!\n\n*shows close-up*\n\n10/10 would recommend!"
            };
            return templates[template] || "This is a custom animation script. Edit me to create your own viral content!";
        }
        
        // Character selection
        function selectCharacter(character) {
            animationSettings.character = character;
            showToast(`${character.charAt(0).toUpperCase() + character.slice(1)} character selected`);
        }
        
        // Voice selection
        function selectVoice(voice) {
            animationSettings.voice = voice;
            showToast(`${voice.charAt(0).toUpperCase() + voice.slice(1)} voice selected`);
        }
        
        // Music selection
        function selectMusic(music) {
            animationSettings.music = music;
            showToast(`${music.charAt(0).toUpperCase() + music.slice(1)} music selected`);
        }
        
        // Scene selection
        function selectScene(scene) {
            animationSettings.scene = scene;
            showToast(`${scene.charAt(0).toUpperCase() + scene.slice(1)} scene selected`);
        }
        
        // Generate animation
        function generateAnimation() {
            const script = document.getElementById('script-input').value;
            if (!script.trim()) {
                showToast("Please enter a script or record your voice", true);
                return;
            }
            
            animationSettings.script = script;
            
            const modal = document.getElementById('generate-modal');
            const progressBar = document.getElementById('generation-progress');
            const statusText = document.getElementById('generation-status');
            
            modal.classList.remove('hidden');
            
            // Simulate generation progress
            let progress = 25;
            progressBar.style.width = '25%';
            statusText.textContent = 'Processing script...';
            
            const interval1 = setTimeout(() => {
                progress = 50;
                progressBar.style.width = '50%';
                statusText.textContent = 'Generating character...';
            }, 1500);
            
            const interval2 = setTimeout(() => {
                progress = 75;
                progressBar.style.width = '75%';
                statusText.textContent = 'Animating scenes...';
            }, 3000);
            
            const interval3 = setTimeout(() => {
                progress = 100;
                progressBar.style.width = '100%';
                statusText.textContent = 'Finalizing animation...';
                
                setTimeout(() => {
                    modal.classList.add('hidden');
                    showPreview();
                }, 1000);
            }, 4500);
        }
        
        // Show preview after generation
        function showPreview() {
            document.getElementById('preview-placeholder').classList.add('hidden');
            document.getElementById('generated-preview').classList.remove('hidden');
            document.getElementById('download-section').classList.remove('hidden');
            
            // Animate subtitles
            const subtitles = document.getElementById('subtitles');
            const words = animationSettings.script.split(' ');
            let i = 0;
            
            const subtitleInterval = setInterval(() => {
                if (i < words.length) {
                    subtitles.textContent = words.slice(0, i+1).join(' ');
                    i++;
                } else {
                    clearInterval(subtitleInterval);
                }
            }, 200);
            
            showToast("Animation generated successfully!");
        }
        
        // Download functionality
        document.getElementById('download-btn').addEventListener('click', function() {
            showToast("Downloading HD video...");
            // In a real app, this would trigger the actual download
            setTimeout(() => {
                showToast("Video downloaded successfully!");
            }, 2000);
        });
        
        // Play button functionality
        document.getElementById('play-btn').addEventListener('click', function() {
            this.innerHTML = '<i class="fas fa-pause"></i>';
            showToast("Playing animation...");
            // In a real app, this would play the animation
        });
        
        // Back button functionality
        function goBack() {
            if (document.getElementById('download-section').classList.contains('hidden')) {
                showToast("Going back...");
                // In a real app, this would navigate back
            } else {
                document.getElementById('download-section').classList.add('hidden');
                document.getElementById('generated-preview').classList.add('hidden');
                document.getElementById('preview-placeholder').classList.remove('hidden');
            }
        }
        
        // Show toast messages
        function showToast(message, isError = false) {
            const toast = document.createElement('div');
            toast.className = `fixed bottom-20 left-1/2 transform -translate-x-1/2 bg-${isError ? 'red' : 'gray'}-800 text-white px-4 py-2 rounded-lg shadow-lg text-sm fade-in`;
            toast.textContent = message;
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.remove();
            }, 3000);
        }
        
        // Animation time counter
        let seconds = 15;
        setInterval(() => {
            seconds = seconds < 59 ? seconds + 1 : 0;
            document.getElementById('animation-time').textContent = `0:${seconds < 10 ? '0' + seconds : seconds}`;
        }, 1000);
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Filimon1/animation" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>