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
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Color Mixing Fun!</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>
        .color-droplet {
            width: 80px;
            height: 80px;
            border-radius: 50% 50% 60% 40% / 70% 70% 30% 30%;
            cursor: pointer;
            transition: transform 0.3s, box-shadow 0.3s;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        .color-droplet:hover {
            transform: scale(1.1);
            box-shadow: 0 6px 12px rgba(0,0,0,0.3);
        }
        .mixing-bowl {
            width: 200px;
            height: 200px;
            border-radius: 50% 50% 60% 40% / 70% 70% 30% 30%;
            background-color: #f0f0f0;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
            position: relative;
            overflow: hidden;
        }
        .mixing-bowl::after {
            content: '';
            position: absolute;
            top: 10px;
            left: 10px;
            right: 10px;
            bottom: 10px;
            border-radius: 50% 50% 60% 40% / 70% 70% 30% 30%;
            border: 2px dashed rgba(255,255,255,0.5);
            pointer-events: none;
        }
        .result-color {
            width: 150px;
            height: 150px;
            border-radius: 50%;
            transition: background-color 0.5s;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-weight: bold;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        }
        .color-splash {
            position: absolute;
            width: 100%;
            height: 100%;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20,20 Q30,10 40,20 T60,20 T80,20" stroke="white" fill="none" stroke-width="2"/><path d="M30,30 Q40,20 50,30 T70,30 T90,30" stroke="white" fill="none" stroke-width="2"/></svg>');
            background-size: 200px 200px;
            opacity: 0.3;
            animation: splash 2s infinite linear;
        }
        @keyframes splash {
            0% { background-position: 0 0; }
            100% { background-position: 200px 200px; }
        }
        .color-palette {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 20px;
            margin-top: 20px;
        }
        .color-card {
            border-radius: 10px;
            padding: 15px;
            text-align: center;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            transition: transform 0.3s;
        }
        .color-card:hover {
            transform: translateY(-5px);
        }
        .shake {
            animation: shake 0.5s;
        }
        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            20%, 60% { transform: translateX(-5px); }
            40%, 80% { transform: translateX(5px); }
        }
        .bounce {
            animation: bounce 0.5s;
        }
        @keyframes bounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }
        .tab-button {
            transition: all 0.3s;
        }
        .tab-button.active {
            background-color: #6b46c1;
            color: white;
        }
    </style>
</head>
<body class="bg-gradient-to-b from-blue-50 to-purple-50 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <header class="text-center mb-8">
            <h1 class="text-4xl font-bold text-purple-800 mb-2">Color Mixing Magic!</h1>
            <p class="text-lg text-gray-600">Discover how primary and secondary colors mix together!</p>
        </header>

        <div class="flex justify-center mb-8">
            <div class="inline-flex rounded-full bg-white shadow-md overflow-hidden">
                <button id="primaryTab" class="tab-button px-6 py-2 font-medium active" onclick="showTab('primary')">
                    Primary Colors
                </button>
                <button id="secondaryTab" class="tab-button px-6 py-2 font-medium" onclick="showTab('secondary')">
                    Secondary Colors
                </button>
            </div>
        </div>

        <div id="primaryContent" class="tab-content">
            <div class="flex flex-col lg:flex-row items-center justify-center gap-8 mb-12">
                <div class="text-center">
                    <h2 class="text-2xl font-semibold text-blue-700 mb-4">Primary Colors</h2>
                    <div class="flex gap-6 justify-center">
                        <div class="color-droplet bg-red-500" data-color="red" onclick="selectColor('red')"></div>
                        <div class="color-droplet bg-blue-500" data-color="blue" onclick="selectColor('blue')"></div>
                        <div class="color-droplet bg-yellow-500" data-color="yellow" onclick="selectColor('yellow')"></div>
                    </div>
                    <p class="mt-4 text-gray-600">Click on two primary colors to mix them!</p>
                </div>

                <div class="text-center">
                    <h2 class="text-2xl font-semibold text-purple-700 mb-4">Mixing Bowl</h2>
                    <div class="mixing-bowl mx-auto">
                        <div id="resultColor" class="result-color bg-gray-200 flex flex-col items-center justify-center">
                            <i class="fas fa-question text-gray-500 text-4xl mb-2"></i>
                            <span class="text-sm">Mix colors here!</span>
                        </div>
                        <div class="color-splash"></div>
                    </div>
                    <button id="resetBtn" class="mt-4 px-4 py-2 bg-gray-200 text-gray-700 rounded-full hover:bg-gray-300 transition" onclick="resetColors()">
                        <i class="fas fa-undo mr-2"></i>Start Over
                    </button>
                </div>
            </div>
        </div>

        <div id="secondaryContent" class="tab-content hidden">
            <div class="flex flex-col lg:flex-row items-center justify-center gap-8 mb-12">
                <div class="text-center">
                    <h2 class="text-2xl font-semibold text-green-700 mb-4">Secondary Colors</h2>
                    <div class="flex gap-6 justify-center">
                        <div class="color-droplet bg-green-500" data-color="green" onclick="selectSecondaryColor('green')"></div>
                        <div class="color-droplet bg-orange-500" data-color="orange" onclick="selectSecondaryColor('orange')"></div>
                        <div class="color-droplet bg-purple-500" data-color="purple" onclick="selectSecondaryColor('purple')"></div>
                    </div>
                    <p class="mt-4 text-gray-600">Click on a secondary color to see how it's made!</p>
                </div>

                <div class="text-center">
                    <h2 class="text-2xl font-semibold text-purple-700 mb-4">Color Recipe</h2>
                    <div class="mixing-bowl mx-auto">
                        <div id="secondaryResult" class="result-color bg-gray-200 flex flex-col items-center justify-center">
                            <i class="fas fa-question text-gray-500 text-4xl mb-2"></i>
                            <span class="text-sm">Select a color to see its recipe</span>
                        </div>
                        <div class="color-splash"></div>
                    </div>
                    <div id="recipeDisplay" class="mt-4 hidden">
                        <div class="flex justify-center gap-4 mb-2">
                            <div id="ingredient1" class="color-droplet w-12 h-12"></div>
                            <div class="flex items-center">
                                <i class="fas fa-plus text-gray-600"></i>
                            </div>
                            <div id="ingredient2" class="color-droplet w-12 h-12"></div>
                            <div class="flex items-center">
                                <i class="fas fa-equals text-gray-600 ml-2"></i>
                            </div>
                            <div id="resultPreview" class="color-droplet w-12 h-12"></div>
                        </div>
                        <p id="recipeText" class="text-gray-700"></p>
                    </div>
                </div>
            </div>
        </div>

        <div class="max-w-3xl mx-auto bg-white rounded-xl shadow-lg p-6">
            <h2 class="text-2xl font-bold text-purple-800 mb-4">Color Theory</h2>
            <div class="color-palette">
                <div class="color-card bg-red-500 text-white">
                    <h3 class="font-bold">Red</h3>
                    <p>Primary Color</p>
                </div>
                <div class="color-card bg-blue-500 text-white">
                    <h3 class="font-bold">Blue</h3>
                    <p>Primary Color</p>
                </div>
                <div class="color-card bg-yellow-500 text-black">
                    <h3 class="font-bold">Yellow</h3>
                    <p>Primary Color</p>
                </div>
                <div class="color-card bg-green-500 text-white">
                    <h3 class="font-bold">Green</h3>
                    <p>Blue + Yellow</p>
                </div>
                <div class="color-card bg-orange-500 text-white">
                    <h3 class="font-bold">Orange</h3>
                    <p>Red + Yellow</p>
                </div>
                <div class="color-card bg-purple-500 text-white">
                    <h3 class="font-bold">Purple</h3>
                    <p>Red + Blue</p>
                </div>
            </div>

            <div class="mt-8">
                <h3 class="text-xl font-semibold text-gray-800 mb-3">Understanding Colors</h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-bold text-blue-700 mb-2"><i class="fas fa-paint-brush mr-2"></i>Primary Colors</h4>
                        <p class="text-gray-700">These are the foundation colors that can't be created by mixing other colors. All other colors are derived from these three: red, blue, and yellow.</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-bold text-purple-700 mb-2"><i class="fas fa-blender mr-2"></i>Secondary Colors</h4>
                        <p class="text-gray-700">These are created by mixing equal parts of two primary colors. The three secondary colors are green, orange, and purple.</p>
                    </div>
                </div>
                <div class="mt-6 bg-green-50 p-4 rounded-lg">
                    <h4 class="font-bold text-green-700 mb-2"><i class="fas fa-palette mr-2"></i>Color Wheel</h4>
                    <p class="text-gray-700">When arranged in a circle, primary and secondary colors create a color wheel that shows how colors relate to each other. Colors opposite each other on the wheel are called complementary colors.</p>
                </div>
            </div>
        </div>

        <div class="mt-8 text-center">
            <button id="hintBtn" class="px-6 py-3 bg-yellow-400 text-yellow-900 rounded-full font-bold hover:bg-yellow-500 transition" onclick="showHint()">
                <i class="fas fa-lightbulb mr-2"></i>Need a Hint?
            </button>
            <div id="hintBox" class="hidden mt-4 bg-yellow-100 border-l-4 border-yellow-500 p-4 text-yellow-800 rounded">
                <p>In the Primary Colors tab, try mixing red and blue to make purple. In the Secondary Colors tab, click on green to see it's made from blue and yellow!</p>
            </div>
        </div>
    </div>

    <script>
        let selectedColors = [];
        const colorMixes = {
            'red+blue': 'purple',
            'blue+red': 'purple',
            'red+yellow': 'orange',
            'yellow+red': 'orange',
            'blue+yellow': 'green',
            'yellow+blue': 'green'
        };
        const colorRecipes = {
            'green': { ingredients: ['blue', 'yellow'], text: "Green is made by mixing blue and yellow!" },
            'orange': { ingredients: ['red', 'yellow'], text: "Orange is made by mixing red and yellow!" },
            'purple': { ingredients: ['red', 'blue'], text: "Purple is made by mixing red and blue!" }
        };
        const colorNames = {
            'red': 'Red',
            'blue': 'Blue',
            'yellow': 'Yellow',
            'purple': 'Purple',
            'orange': 'Orange',
            'green': 'Green'
        };
        const colorCodes = {
            'red': 'bg-red-500',
            'blue': 'bg-blue-500',
            'yellow': 'bg-yellow-500',
            'purple': 'bg-purple-500',
            'orange': 'bg-orange-500',
            'green': 'bg-green-500'
        };

        function showTab(tabName) {
            // Update tab buttons
            document.getElementById('primaryTab').classList.toggle('active', tabName === 'primary');
            document.getElementById('secondaryTab').classList.toggle('active', tabName === 'secondary');
            
            // Show/hide content
            document.getElementById('primaryContent').classList.toggle('hidden', tabName !== 'primary');
            document.getElementById('secondaryContent').classList.toggle('hidden', tabName !== 'secondary');
            
            // Reset selections when switching tabs
            if (tabName === 'primary') {
                resetColors();
            } else {
                document.getElementById('recipeDisplay').classList.add('hidden');
            }
        }

        function selectColor(color) {
            if (selectedColors.length >= 2) return;
            
            const droplet = document.querySelector(`.color-droplet[data-color="${color}"]`);
            droplet.classList.add('bounce');
            
            setTimeout(() => {
                droplet.classList.remove('bounce');
            }, 500);
            
            selectedColors.push(color);
            
            if (selectedColors.length === 2) {
                mixColors();
            } else {
                updateMixingBowl();
            }
        }

        function selectSecondaryColor(color) {
            const recipe = colorRecipes[color];
            const resultDiv = document.getElementById('secondaryResult');
            const recipeDisplay = document.getElementById('recipeDisplay');
            
            // Update the main display
            resultDiv.className = `result-color ${colorCodes[color]} flex items-center justify-center`;
            resultDiv.innerHTML = `<span class="text-xl font-bold">${colorNames[color]}</span>`;
            
            // Update the recipe display
            document.getElementById('ingredient1').className = `color-droplet w-12 h-12 ${colorCodes[recipe.ingredients[0]]}`;
            document.getElementById('ingredient2').className = `color-droplet w-12 h-12 ${colorCodes[recipe.ingredients[1]]}`;
            document.getElementById('resultPreview').className = `color-droplet w-12 h-12 ${colorCodes[color]}`;
            document.getElementById('recipeText').textContent = recipe.text;
            
            recipeDisplay.classList.remove('hidden');
            
            // Celebrate!
            resultDiv.classList.add('bounce');
            setTimeout(() => {
                resultDiv.classList.remove('bounce');
            }, 1000);
            
            // Show confetti
            showConfetti();
        }

        function updateMixingBowl() {
            const resultDiv = document.getElementById('resultColor');
            
            if (selectedColors.length === 0) {
                resultDiv.className = 'result-color bg-gray-200 flex flex-col items-center justify-center';
                resultDiv.innerHTML = '<i class="fas fa-question text-gray-500 text-4xl mb-2"></i><span class="text-sm">Mix colors here!</span>';
            } else if (selectedColors.length === 1) {
                const color = selectedColors[0];
                resultDiv.className = `result-color ${colorCodes[color]} flex items-center justify-center`;
                resultDiv.innerHTML = `<i class="fas fa-plus text-white text-4xl"></i>`;
            }
        }

        function mixColors() {
            const color1 = selectedColors[0];
            const color2 = selectedColors[1];
            const mixKey = `${color1}+${color2}`;
            
            const resultDiv = document.getElementById('resultColor');
            
            if (colorMixes[mixKey]) {
                const resultColor = colorMixes[mixKey];
                resultDiv.className = `result-color ${colorCodes[resultColor]} flex items-center justify-center`;
                resultDiv.innerHTML = `
                    <span class="text-xl font-bold">${colorNames[resultColor]}</span>
                    <span class="text-sm">${colorNames[color1]} + ${colorNames[color2]}</span>
                `;
                
                // Celebrate!
                resultDiv.classList.add('bounce');
                setTimeout(() => {
                    resultDiv.classList.remove('bounce');
                }, 1000);
                
                // Show confetti
                showConfetti();
            } else {
                // Same color selected twice
                resultDiv.className = `result-color ${colorCodes[color1]} flex items-center justify-center`;
                resultDiv.innerHTML = `
                    <span class="text-xl font-bold">More ${colorNames[color1]}</span>
                    <span class="text-sm">Try mixing different colors!</span>
                `;
                resultDiv.classList.add('shake');
                setTimeout(() => {
                    resultDiv.classList.remove('shake');
                }, 500);
            }
        }

        function resetColors() {
            selectedColors = [];
            updateMixingBowl();
            
            const btn = document.getElementById('resetBtn');
            btn.classList.add('bg-gray-300');
            setTimeout(() => {
                btn.classList.remove('bg-gray-300');
            }, 300);
        }

        function showHint() {
            const hintBox = document.getElementById('hintBox');
            hintBox.classList.toggle('hidden');
            
            const btn = document.getElementById('hintBtn');
            btn.classList.add('bg-yellow-500');
            setTimeout(() => {
                btn.classList.remove('bg-yellow-500');
            }, 300);
        }

        function showConfetti() {
            // Simple confetti effect
            const colors = ['red', 'blue', 'yellow', 'green', 'orange', 'purple'];
            const container = document.querySelector('.mixing-bowl');
            
            for (let i = 0; i < 20; i++) {
                const confetti = document.createElement('div');
                confetti.className = 'absolute w-2 h-2 rounded-full';
                confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
                confetti.style.left = Math.random() * 180 + 'px';
                confetti.style.top = Math.random() * 180 + 'px';
                confetti.style.transform = `rotate(${Math.random() * 360}deg)`;
                confetti.style.opacity = '0.8';
                
                container.appendChild(confetti);
                
                // Animation
                const animation = confetti.animate([
                    { transform: `translate(0, 0) rotate(0deg)`, opacity: 0.8 },
                    { transform: `translate(${Math.random() * 100 - 50}px, ${Math.random() * 100 - 50}px) rotate(${Math.random() * 360}deg)`, opacity: 0 }
                ], {
                    duration: 1000,
                    easing: 'cubic-bezier(0.1, 0.8, 0.9, 1)'
                });
                
                animation.onfinish = () => confetti.remove();
            }
        }
    </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=pp/primary-and-secondary-colors-k5" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
</html>