File size: 43,460 Bytes
41a36d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NeuroMind Explorer | Cognitive Mapping Tool</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>
        /* Background animation based on cognitive load theory */
        @keyframes bgPulse {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .bg-cognitive-load {
            background-size: 400% 400%;
            animation: bgPulse 15s ease infinite;
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        
        .node {
            transition: all 0.3s ease;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        
        .node:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        
        .connector {
            stroke-dasharray: 1000;
            stroke-dashoffset: 1000;
            animation: dash 1.5s ease-in-out forwards;
        }
        
        @keyframes dash {
            to {
                stroke-dashoffset: 0;
            }
        }
        
        .glow {
            animation: glow 2s infinite alternate;
        }
        
        @keyframes glow {
            from {
                box-shadow: 0 0 5px -5px rgba(59, 130, 246, 0.5);
            }
            to {
                box-shadow: 0 0 20px 5px rgba(59, 130, 246, 0.5);
            }
        }
        
        .thought-bubble {
            position: relative;
            border-radius: 50%;
            animation: float 6s ease-in-out infinite;
        }
        
        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-15px); }
            100% { transform: translateY(0px); }
        }
        
        .thought-bubble::after {
            content: '';
            position: absolute;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.3);
            bottom: -10px;
            left: 20px;
        }
        
        .thought-bubble::before {
            content: '';
            position: absolute;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            bottom: -20px;
            left: 40px;
        }
    </style>
</head>
<body class="bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 min-h-screen text-white bg-cognitive-load">
    <div class="container mx-auto px-4 py-12">
        <div class="text-center mb-16">
            <h1 class="text-5xl font-bold mb-4 glow">NeuroMind Explorer</h1>
            <p class="text-xl text-gray-300 max-w-3xl mx-auto">
                Map your unique cognitive patterns through interactive neuroscience challenges. Discover how your brain processes information in different situations.
            </p>
        </div>
        
        <div class="relative">
            <!-- Main flowchart container -->
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-12">
                <!-- Question Node -->
                <div id="question-node" class="node bg-blue-600 rounded-2xl p-6 flex flex-col items-center justify-center text-center">
                    <div class="thought-bubble bg-blue-500 w-24 h-24 flex items-center justify-center mb-4">
                        <i class="fas fa-question text-4xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold mb-4">Initial Question</h2>
                    <p id="current-question" class="mb-6">When faced with uncertainty, do you tend to rely more on intuition or systematic analysis?</p>
                    <div class="flex space-x-4">
                        <button onclick="processAnswer('intuition')" class="bg-indigo-700 hover:bg-indigo-600 px-6 py-2 rounded-full transition">Intuition</button>
                        <button onclick="processAnswer('analysis')" class="bg-purple-700 hover:bg-purple-600 px-6 py-2 rounded-full transition">Analysis</button>
                        <button onclick="processAnswer('both')" class="bg-pink-700 hover:bg-pink-600 px-6 py-2 rounded-full transition">Both</button>
                    </div>
                </div>
                
                <!-- Algorithm Node (center) -->
                <div id="algorithm-node" class="node bg-gray-800 rounded-2xl p-6 flex flex-col items-center justify-center text-center border-2 border-blue-500">
                    <div class="thought-bubble bg-gray-700 w-24 h-24 flex items-center justify-center mb-4">
                        <i class="fas fa-brain text-4xl text-blue-400"></i>
                    </div>
                    <h2 class="text-2xl font-bold mb-4">Cognitive Algorithm</h2>
                    <p class="mb-4 text-gray-300">Processing your thought patterns...</p>
                    <div class="w-full bg-gray-700 rounded-full h-2.5">
                        <div id="progress-bar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
                
                <!-- Insight Node -->
                <div id="insight-node" class="node bg-green-700 rounded-2xl p-6 flex flex-col items-center justify-center text-center opacity-50">
                    <div class="thought-bubble bg-green-600 w-24 h-24 flex items-center justify-center mb-4">
                        <i class="fas fa-lightbulb text-4xl"></i>
                    </div>
                    <h2 class="text-2xl font-bold mb-4">Personal Insight</h2>
                    <p id="insight-text" class="mb-6">Complete the questions to reveal your cognitive insight</p>
                </div>
            </div>
            
            <!-- Connector lines (SVG) -->
            <svg class="absolute top-0 left-0 w-full h-full pointer-events-none" xmlns="http://www.w3.org/2000/svg">
                <path id="connector1" class="connector" d="M300,150 Q450,150 600,150" stroke="#3B82F6" stroke-width="3" fill="none" stroke-dasharray="5,5"/>
                <path id="connector2" class="connector" d="M600,150 Q750,150 900,150" stroke="#3B82F6" stroke-width="3" fill="none" stroke-dasharray="5,5"/>
            </svg>
            
            <!-- Hidden response nodes that will appear -->
            <div id="response-nodes" class="hidden grid grid-cols-1 md:grid-cols-3 gap-8 mt-8">
                <!-- These will be populated dynamically -->
            </div>
        </div>
        
        <!-- Depth selector -->
        <div class="max-w-md mx-auto bg-gray-800 p-6 rounded-xl mb-12">
            <h3 class="text-xl font-semibold mb-4 text-center">Select Exploration Depth</h3>
            <div class="flex justify-between mb-2">
                <span>Surface</span>
                <span>Profound</span>
            </div>
            <input type="range" id="depth-slider" min="1" max="5" value="3" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
            <div class="flex justify-between text-xs text-gray-400 mt-1">
                <span>1</span>
                <span>2</span>
                <span>3</span>
                <span>4</span>
                <span>5</span>
            </div>
        </div>
        
        <!-- Stats panel -->
        <div id="stats-panel" class="bg-gray-800 bg-opacity-50 backdrop-blur-sm rounded-xl p-6 mt-12 hidden">
            <h3 class="text-2xl font-bold mb-4 text-center">Your Cognitive Profile</h3>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <div class="bg-gray-700 p-4 rounded-lg">
                    <div class="flex items-center mb-2">
                        <div class="w-8 h-8 bg-blue-500 rounded-full flex items-center justify-center mr-2">
                            <i class="fas fa-bolt text-sm"></i>
                        </div>
                        <h4 class="font-semibold">Intuition Score</h4>
                    </div>
                    <div class="w-full bg-gray-600 rounded-full h-2.5">
                        <div id="intuition-score" class="bg-blue-500 h-2.5 rounded-full" style="width: 0%"></div>
                    </div>
                    <p id="intuition-text" class="text-sm text-gray-300 mt-2">Not yet calculated</p>
                </div>
                <div class="bg-gray-700 p-4 rounded-lg">
                    <div class="flex items-center mb-2">
                        <div class="w-8 h-8 bg-purple-500 rounded-full flex items-center justify-center mr-2">
                            <i class="fas fa-calculator text-sm"></i>
                        </div>
                        <h4 class="font-semibold">Analysis Score</h4>
                    </div>
                    <div class="w-full bg-gray-600 rounded-full h-2.5">
                        <div id="analysis-score" class="bg-purple-500 h-2.5 rounded-full" style="width: 0%"></div>
                    </div>
                    <p id="analysis-text" class="text-sm text-gray-300 mt-2">Not yet calculated</p>
                </div>
                <div class="bg-gray-700 p-4 rounded-lg">
                    <div class="flex items-center mb-2">
                        <div class="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center mr-2">
                            <i class="fas fa-balance-scale text-sm"></i>
                        </div>
                        <h4 class="font-semibold">Balance Index</h4>
                    </div>
                    <div class="w-full bg-gray-600 rounded-full h-2.5">
                        <div id="balance-score" class="bg-green-500 h-2.5 rounded-full" style="width: 0%"></div>
                    </div>
                    <p id="balance-text" class="text-sm text-gray-300 mt-2">Not yet calculated</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Algorithm configuration
        const questions = [
            {
                id: 1,
                text: "When you wake up with a strong feeling about an important decision, what do you typically do?",
                options: {
                    "Act on it immediately": { next: 2, intuition: 30, analysis: -20 },
                    "Analyze why you feel that way": { next: 3, intuition: -10, analysis: 25 },
                    "Wait to see if the feeling persists": { next: 4, intuition: 10, analysis: 10 }
                }
            },
            {
                id: 2,
                text: "Your quick action suggests strong intuition. When has this approach failed you most dramatically?",
                options: {
                    "Personal relationships": { next: 5, intuition: 15, analysis: -10 },
                    "Financial decisions": { next: 5, intuition: -5, analysis: 15 },
                    "Career choices": { next: 5, intuition: 5, analysis: 5 },
                    "I don't recall major failures": { next: 5, intuition: 25, analysis: -15 }
                }
            },
            {
                id: 3,
                text: "Your tendency to analyze feelings reveals something interesting. What emotion is hardest for you to analyze?",
                options: {
                    "Fear": { next: 6, intuition: 5, analysis: 20 },
                    "Love/Attraction": { next: 6, intuition: 15, analysis: 5 },
                    "Anger": { next: 6, intuition: 10, analysis: 10 },
                    "Guilt": { next: 6, intuition: -5, analysis: 25 }
                }
            },
            {
                id: 4,
                text: "Your wait-and-see approach is telling. What's the longest you've delayed an important decision due to uncertainty?",
                options: {
                    "Days": { next: 7, intuition: 15, analysis: 5 },
                    "Weeks": { next: 7, intuition: 5, analysis: 15 },
                    "Months": { next: 7, intuition: -5, analysis: 25 },
                    "Years": { next: 7, intuition: -15, analysis: 30 }
                }
            },
            {
                id: 5,
                text: "Reflect on this: When you're wrong about someone's character, is it usually because you...",
                options: {
                    "Trusted them too quickly": { next: 8, intuition: 25, analysis: -15 },
                    "Overanalyzed their motives": { next: 8, intuition: -15, analysis: 25 },
                    "Ignored red flags": { next: 8, intuition: 10, analysis: -5 },
                    "Relied too much on others' opinions": { next: 8, intuition: -5, analysis: 10 }
                }
            },
            {
                id: 6,
                text: "This emotional blind spot is revealing. How does it typically manifest in your life?",
                options: {
                    "Unexpected outbursts": { next: 8, intuition: 20, analysis: -10 },
                    "Prolonged confusion": { next: 8, intuition: 5, analysis: 15 },
                    "Avoidance behaviors": { next: 8, intuition: -5, analysis: 20 },
                    "Physical symptoms": { next: 8, intuition: 15, analysis: 5 }
                }
            },
            {
                id: 7,
                text: "Your hesitation pattern suggests something deeper. What are you most afraid might happen if you choose wrong?",
                options: {
                    "Looking foolish": { next: 8, intuition: -10, analysis: 15 },
                    "Missing opportunities": { next: 8, intuition: 15, analysis: -5 },
                    "Hurting others": { next: 8, intuition: 5, analysis: 10 },
                    "Losing self-respect": { next: 8, intuition: 10, analysis: 5 }
                }
            },
            {
                id: 8,
                text: "Final deep reflection: When you're completely alone, what voice is louder - your inner critic or your inner guide?",
                options: {
                    "Inner critic": { next: "end", intuition: -20, analysis: 30 },
                    "Inner guide": { next: "end", intuition: 30, analysis: -20 },
                    "They alternate": { next: "end", intuition: 15, analysis: 15 },
                    "I don't hear either clearly": { next: "end", intuition: -5, analysis: -5 }
                }
            }
        ];

        const insights = {
            initial: [
                "Your neural response patterns show optimal integration between cognitive flexibility and stability. This balance suggests resilience against rumination - your brain naturally shifts between focused attention and diffuse thinking modes. Maintain this through regular mindfulness practice.",
                "Your cognitive rhythm indicates strong executive function with occasional creative bursts. This pattern correlates with high workplace performance but may lead to mental fatigue if not balanced with adequate rest. Consider scheduling 'brain breaks' every 90 minutes.",
                "Your decision-making latency falls within the optimal range - neither impulsive nor over-analyzing. However, your response variance suggests some situations trigger disproportionate deliberation. These may indicate areas of subconscious stress worth exploring.",
                "Your cognitive-emotional interface shows healthy differentiation - you can separate facts from feelings while still considering both. This is a protective factor against anxiety disorders and correlates with emotional intelligence.",
                "Your neural efficiency patterns suggest good neurotransmitter balance. The slight right-hemisphere preference indicates strong intuitive processing - valuable for social cognition and creative problem solving."
            ],
            mentalHealthFlags: {
                anxiety: [
                    "Your response patterns show heightened sensitivity to uncertainty - a common trait among top performers that can also indicate subconscious stress. Consider practicing 'uncertainty tolerance' through small, controlled experiments.",
                    "Your cognitive processing shows occasional 'threat bias' - a tendency to allocate more attention to potential problems. While evolutionarily adaptive, this can lead to unnecessary stress if unchecked.",
                    "Your neural vigilance levels are slightly elevated - great for detail-oriented work but potentially fatiguing. The amygdala (stress center) appears moderately active even in neutral decisions."
                ],
                depression: [
                    "Your response latency patterns show occasional cognitive 'heaviness' - typical during high-stress periods. This doesn't indicate clinical depression but suggests benefit from mood-brightening activities.",
                    "Your reward-system responses are muted in pleasure-predicting scenarios. This could reflect temporary stress or suggest exploring activities that naturally boost dopamine.",
                    "Your cognitive flexibility shows slight rigidity in positive scenarios - a pattern that sometimes correlates with low mood states. Consider experimenting with novel positive experiences."
                ],
                adhd: [
                    "Your attention switching occurs at above-average frequency - a trait common in creative thinkers. While not indicative of ADHD, it suggests you may benefit from structured focus techniques.",
                    "Your response speed variance shows bursts of hyperfocus alternating with diffuse attention - a pattern seen in many successful innovators. Channel this productively with clear goal-setting.",
                    "Your cognitive rhythm includes frequent micro-shifts in attention allocation. This 'butterfly mind' pattern can be harnessed for creative work with proper environmental structuring."
                ]
            },
            followup: {
                intuitive: [
                    "Given your intuitive dominance, let's explore how you process ambiguous information...",
                    "Your intuitive responses suggest strong pattern recognition. How do you handle conflicting patterns?",
                    "Your gut reactions seem highly attuned. When has this served you best?"
                ],
                analytical: [
                    "Your analytical approach is evident. How do you handle information overload?",
                    "Given your systematic thinking, what's your process for incomplete data?",
                    "Your preference for structure is clear. How do you adapt to chaotic situations?"
                ],
                balanced: [
                    "Your balanced approach is interesting. How do you resolve intuition-analysis conflicts?",
                    "With your flexible thinking, what's your strategy for high-stakes decisions?",
                    "Your ability to toggle between modes is notable. When do you consciously switch?"
                ]
            }
        };

        // State management
        let currentQuestion = 1;
        let intuitionScore = 0;
        let analysisScore = 0;
        let anxietyScore = 0;
        let depressionScore = 0;
        let adhdScore = 0;
        let responseTimes = [];
        let questionHistory = [];
        let depth = 3;
        let assessmentPhase = 1;
        let cognitiveType = '';
        let startTime = Date.now();

        // DOM elements
        const questionElement = document.getElementById('current-question');
        const insightElement = document.getElementById('insight-text');
        const insightNode = document.getElementById('insight-node');
        const statsPanel = document.getElementById('stats-panel');
        const depthSlider = document.getElementById('depth-slider');
        const progressBar = document.getElementById('progress-bar');
        const responseNodes = document.getElementById('response-nodes');

        // Initialize
        updateQuestion();
        depthSlider.addEventListener('input', updateDepth);

        function updateDepth() {
            depth = parseInt(depthSlider.value);
        }

        function processAnswer(answer) {
            const question = questions.find(q => q.id === currentQuestion);
            const option = question.options[answer];
            
            // Track response time
            const now = Date.now();
            responseTimes.push({
                questionId: currentQuestion,
                time: now - startTime
            });
            startTime = now;
            
            // Update all scores
            intuitionScore += option.intuition || 0;
            analysisScore += option.analysis || 0;
            anxietyScore += option.anxiety || 0;
            depressionScore += option.depression || 0;
            adhdScore += option.adhd || 0;
            
            // Record history
            questionHistory.push({
                questionId: question.id,
                answer: answer,
                intuitionDelta: option.intuition,
                analysisDelta: option.analysis
            });
            
            // Update progress
            const progress = (questionHistory.length / questions.length) * 100;
            progressBar.style.width = `${progress}%`;
            
            // Animate the algorithm node
            const algorithmNode = document.getElementById('algorithm-node');
            algorithmNode.classList.add('animate-pulse');
            
            setTimeout(() => {
                algorithmNode.classList.remove('animate-pulse');
                
                if (option.next === "end") {
                    concludeAssessment();
                } else {
                    currentQuestion = option.next;
                    updateQuestion();
                    
                    // Show response nodes if depth > 3
                    if (depth > 3) {
                        showResponseNodes(question.id, answer);
                    }
                }
            }, 1000);
        }

        function updateQuestion() {
            const question = questions.find(q => q.id === currentQuestion);
            questionElement.textContent = question.text;
            
            // Update buttons
            const buttons = document.querySelectorAll('#question-node button');
            buttons.forEach((button, index) => {
                const optionKey = Object.keys(question.options)[index];
                button.textContent = optionKey.charAt(0).toUpperCase() + optionKey.slice(1);
                button.onclick = function() { processAnswer(optionKey); };
            });
        }

        function showResponseNodes(questionId, answer) {
            responseNodes.innerHTML = '';
            responseNodes.classList.remove('hidden');
            
            const question = questions.find(q => q.id === questionId);
            const option = question.options[answer];
            
            // Create response nodes based on depth
            const responses = generateResponses(questionId, answer, depth);
            
            responses.forEach(response => {
                const node = document.createElement('div');
                node.className = 'node bg-indigo-800 rounded-2xl p-6 flex flex-col items-center justify-center text-center';
                node.innerHTML = `
                    <div class="thought-bubble bg-indigo-700 w-16 h-16 flex items-center justify-center mb-3">
                        <i class="fas fa-comment-alt text-xl"></i>
                    </div>
                    <h3 class="text-lg font-semibold mb-2">${response.title}</h3>
                    <p class="text-sm text-gray-200">${response.text}</p>
                `;
                responseNodes.appendChild(node);
            });
        }

        function generateResponses(questionId, answer, depthLevel) {
            // This is where the algorithmic response generation happens
            const responses = [];
            
            // Base response
            responses.push({
                title: "Immediate Interpretation",
                text: getBaseResponse(questionId, answer)
            });
            
            // Depth-based additional responses
            if (depthLevel >= 2) {
                responses.push({
                    title: "Pattern Recognition",
                    text: getPatternResponse(questionHistory)
                });
            }
            
            if (depthLevel >= 4) {
                responses.push({
                    title: "Cognitive Implications",
                    text: getCognitiveResponse(questionId, answer)
                });
            }
            
            return responses;
        }

        function getBaseResponse(questionId, answer) {
            const responses = {
                1: {
                    intuition: "Choosing intuition suggests comfort with ambiguity and trust in subconscious processing.",
                    analysis: "Selecting analysis indicates preference for structured, deliberate decision-making.",
                    both: "Your balanced approach shows cognitive flexibility but may indicate some indecision."
                },
                2: {
                    always: "High confidence in intuition suggests strong trust in subconscious pattern recognition.",
                    often: "Regular validation of intuition builds self-trust in non-linear thinking.",
                    sometimes: "Mixed accuracy may lead to second-guessing intuitive impulses.",
                    rarely: "Poor intuitive accuracy might stem from overestimating pattern recognition abilities."
                },
                3: {
                    quantitative: "Numerical preference suggests comfort with concrete, measurable reality.",
                    qualitative: "Narrative preference indicates comfort with subjective, contextual understanding.",
                    both: "Ability to synthesize both shows advanced integrative thinking capacity."
                },
                4: {
                    "trusting intuition": "Difficulty trusting intuition may stem from over-reliance on external validation.",
                    "setting aside intuition": "Challenges ignoring intuition suggest deep-seated pattern recognition instincts.",
                    neither: "Lack of difficulty may indicate either true balance or lack of self-awareness."
                },
                5: {
                    absolutely: "Viewing intuition as intelligence suggests belief in non-linear cognition.",
                    somewhat: "Qualified acceptance may reflect experiences with both hits and misses.",
                    "not really": "Rejecting intuition as intelligence privileges conscious, deliberate thought."
                },
                6: {
                    always: "Constant framework creation suggests highly structured mental organization.",
                    often: "Regular structuring indicates systematic tendencies with some flexibility.",
                    sometimes: "Selective structuring shows ability to toggle between modes situationally."
                },
                7: {
                    yes: "Recalling adaptive switching demonstrates metacognitive awareness.",
                    no: "Lack of recall may indicate either rigid thinking or untested flexibility.",
                    unsure: "Uncertainty suggests either infrequent switching or lack of reflection."
                },
                8: {
                    "inner wisdom": "Final trust in intuition confirms primary reliance on subconscious processing.",
                    "reasoned conclusions": "Final trust in analysis confirms primary reliance on conscious deliberation.",
                    both: "Final trust in both suggests genuine integrative thinking capacity."
                }
            };
            
            return responses[questionId][answer];
        }

        function getPatternResponse(history) {
            if (history.length < 2) return "Insufficient data for pattern analysis";
            
            const intuitionTrend = history[history.length-1].intuitionDelta > history[history.length-2].intuitionDelta ? "increasing" : "decreasing";
            const analysisTrend = history[history.length-1].analysisDelta > history[history.length-2].analysisDelta ? "increasing" : "decreasing";
            
            return `Your recent responses show ${intuitionTrend} reliance on intuition and ${analysisTrend} reliance on analysis. This ${intuitionTrend === analysisTrend ? 'parallel' : 'divergent'} pattern suggests ${intuitionTrend === analysisTrend ? 'consistent' : 'evolving'} cognitive tendencies.`;
        }

        function getCognitiveResponse(questionId, answer) {
            // This would be more sophisticated in a real implementation
            return "Deep analysis suggests this response pattern correlates with enhanced creative problem-solving but potential challenges in purely logical domains. Consider exploring complementary strategies to leverage your cognitive strengths.";
        }

        function updateBackground(scores) {
            // Change background based on cognitive type (priming effect)
            const body = document.querySelector('body');
            const diff = Math.abs(scores.intuition - scores.analysis);
            
            if (diff > 30) { // Strong type
                if (scores.intuition > scores.analysis) {
                    body.className = 'bg-gradient-to-br from-blue-900 via-indigo-900 to-purple-900 min-h-screen text-white bg-cognitive-load';
                } else {
                    body.className = 'bg-gradient-to-br from-gray-900 via-gray-800 to-gray-700 min-h-screen text-white bg-cognitive-load';
                }
            } else { // Balanced
                body.className = 'bg-gradient-to-br from-teal-900 via-gray-800 to-blue-900 min-h-screen text-white bg-cognitive-load';
            }
        }

        function concludeAssessment() {
            // Calculate all scores (normalized to 0-100)
            const maxPossible = questions.length * 25;
            const normalizedIntuition = Math.max(0, Math.min(100, (intuitionScore + maxPossible) / (maxPossible * 2) * 100));
            const normalizedAnalysis = Math.max(0, Math.min(100, (analysisScore + maxPossible) / (maxPossible * 2) * 100));
            const normalizedAnxiety = Math.max(0, Math.min(100, (anxietyScore + maxPossible) / (maxPossible * 2) * 100));
            const normalizedDepression = Math.max(0, Math.min(100, (depressionScore + maxPossible) / (maxPossible * 2) * 100));
            const normalizedADHD = Math.max(0, Math.min(100, (adhdScore + maxPossible) / (maxPossible * 2) * 100));
            const balanceIndex = 100 - Math.abs(normalizedIntuition - normalizedAnalysis);
            
            // Calculate response time metrics
            const avgResponseTime = responseTimes.reduce((sum, rt) => sum + rt.time, 0) / responseTimes.length;
            const responseTimeVariance = Math.sqrt(
                responseTimes.reduce((sum, rt) => sum + Math.pow(rt.time - avgResponseTime, 2), 0) / responseTimes.length
            );
            
            // Determine cognitive type
            const diff = normalizedIntuition - normalizedAnalysis;
            if (diff > 20) {
                cognitiveType = 'intuitive';
            } else if (diff < -20) {
                cognitiveType = 'analytical';
            } else {
                cognitiveType = 'balanced';
            }

            // Update background based on type (visual priming)
            updateBackground({
                intuition: normalizedIntuition,
                analysis: normalizedAnalysis
            });

            // Update insight
            const insightIndex = Math.min(Math.floor(Math.abs(diff) / 20), insights.initial.length - 1);
            insightElement.textContent = insights.initial[insightIndex];
            insightNode.classList.remove('opacity-50');
            insightNode.classList.add('glow');
            
            // Update all stats
            const stats = [
                {id: 'intuition-score', value: normalizedIntuition, prefix: 'Cognitive Style: '},
                {id: 'analysis-score', value: normalizedAnalysis, prefix: 'Processing Mode: '},
                {id: 'balance-score', value: balanceIndex, prefix: 'Mental Flexibility: '},
                {id: 'anxiety-indicator', value: normalizedAnxiety, prefix: 'Stress Sensitivity: '},
                {id: 'depression-indicator', value: normalizedDepression, prefix: 'Mood Baseline: '},
                {id: 'focus-indicator', value: normalizedADHD, prefix: 'Attention Style: '}
            ];
            
            stats.forEach(stat => {
                const element = document.getElementById(stat.id);
                if (element) {
                    element.style.width = `${stat.value}%`;
                    const textElement = document.getElementById(stat.id.replace('-score', '-text').replace('-indicator', '-text'));
                    if (textElement) {
                        textElement.textContent = stat.prefix + (
                            stat.value > 75 ? "High" :
                            stat.value > 45 ? "Moderate" : "Low"
                        );
                    }
                }
            });
            
            // Add response time insights
            const timeInsight = document.createElement('div');
            timeInsight.className = 'bg-gray-700 p-4 rounded-lg col-span-3';
            timeInsight.innerHTML = `
                <div class="flex items-center mb-2">
                    <div class="w-8 h-8 bg-yellow-500 rounded-full flex items-center justify-center mr-2">
                        <i class="fas fa-clock text-sm"></i>
                    </div>
                    <h4 class="font-semibold">Cognitive Tempo Analysis</h4>
                </div>
                <p class="text-sm text-gray-300">
                    Your average response time was ${(avgResponseTime/1000).toFixed(1)}s with 
                    ${responseTimeVariance > 2000 ? 'high' : responseTimeVariance > 1000 ? 'moderate' : 'low'} variability.
                    ${responseTimeVariance > 2000 ? 'This fluctuating tempo suggests adaptive thinking but may indicate mental fatigue.' : ''}
                </p>
            `;
            document.querySelector('#stats-panel .grid').appendChild(timeInsight);
            
            // Show stats panel
            statsPanel.classList.remove('hidden');
            
            // Prepare for follow-up questions
            document.getElementById('question-node').classList.remove('opacity-50', 'pointer-events-none');
            document.getElementById('current-question').textContent = "Based on your results, let's explore deeper...";
            
            // Change buttons for follow-up
            const buttons = document.querySelectorAll('#question-node button');
            buttons.forEach((button, index) => {
                button.textContent = ["Continue", "See Details", "Explore"][index];
                button.onclick = function() { 
                    assessmentPhase = 2;
                    startFollowupQuestions();
                };
            });
            
            // Show final response nodes if depth > 3
            if (depth > 3) {
                showFinalInsights(normalizedIntuition, normalizedAnalysis, balanceIndex);
            }
        }

        function startFollowupQuestions() {
            // Load follow-up questions based on cognitive type
            const followupQuestions = {
                intuitive: [
                    "When you have a strong gut feeling that contradicts evidence, what do you do?",
                    "Describe a time your intuition warned you about something before you had concrete evidence.",
                    "How do you distinguish between genuine intuition and wishful thinking?"
                ],
                analytical: [
                    "When facing a complex problem, what's your step-by-step approach?",
                    "How do you handle situations where data is incomplete or contradictory?",
                    "What safeguards do you use to prevent analysis paralysis?"
                ],
                balanced: [
                    "How do you decide when to trust your gut versus doing more research?",
                    "Describe your process for making important decisions under time pressure.",
                    "How do you balance speed and accuracy in your thinking?"
                ]
            };

            // Reset for follow-up phase
            currentQuestion = 0;
            const questionsContainer = document.getElementById('question-node');
            questionsContainer.innerHTML = `
                <div class="thought-bubble bg-blue-500 w-24 h-24 flex items-center justify-center mb-4">
                    <i class="fas fa-question text-4xl"></i>
                </div>
                <h2 class="text-2xl font-bold mb-4">Deeper Exploration</h2>
                <p id="current-question" class="mb-6">${followupQuestions[cognitiveType][0]}</p>
                <div class="flex space-x-4">
                    ${followupQuestions[cognitiveType].slice(1).map((q, i) => 
                        `<button onclick="processFollowupAnswer(${i + 1})" class="bg-indigo-700 hover:bg-indigo-600 px-6 py-2 rounded-full transition">
                            ${["Option 1", "Option 2", "Option 3"][i]}
                        </button>`
                    ).join('')}
                </div>
            `;
        }

        function processFollowupAnswer(index) {
            // Process follow-up answers differently
            const followupQuestions = {
                intuitive: [
                    "When you have a strong gut feeling that contradicts evidence, what do you do?",
                    "Describe a time your intuition warned you about something before you had concrete evidence.",
                    "How do you distinguish between genuine intuition and wishful thinking?"
                ],
                analytical: [
                    "When facing a complex problem, what's your step-by-step approach?",
                    "How do you handle situations where data is incomplete or contradictory?",
                    "What safeguards do you use to prevent analysis paralysis?"
                ],
                balanced: [
                    "How do you decide when to trust your gut versus doing more research?",
                    "Describe your process for making important decisions under time pressure.",
                    "How do you balance speed and accuracy in your thinking?"
                ]
            };

            currentQuestion++;
            if (currentQuestion < followupQuestions[cognitiveType].length) {
                document.getElementById('current-question').textContent = 
                    followupQuestions[cognitiveType][currentQuestion];
            } else {
                concludeFollowup();
            }
        }

        function concludeFollowup() {
            insightElement.textContent = insights.followup[cognitiveType][Math.floor(Math.random() * insights.followup[cognitiveType].length)];
            document.getElementById('question-node').classList.add('opacity-50', 'pointer-events-none');
        }

        function showFinalInsights(intuition, analysis, balance) {
            responseNodes.innerHTML = '';
            responseNodes.classList.remove('hidden');
            
            const insights = [
                {
                    title: "Cognitive Signature",
                    text: `Your unique blend: ${intuition.toFixed(0)}% intuition, ${analysis.toFixed(0)}% analysis creates a ${balance > 80 ? 'harmonious' : balance > 60 ? 'dynamic' : 'specialized'} thinking style.`
                },
                {
                    title: "Strengths Analysis",
                    text: intuition > analysis ? 
                        "Neuroimaging suggests your intuitive processing engages both the insula (interoception) and temporal lobe (pattern recognition) simultaneously - a rare synchronization that explains your uncanny 'gut feelings'. This manifests as rapid somatic markers preceding conscious awareness of decisions." :
                        "fMRI studies would likely reveal your analytical processing creates unique cross-talk between the dorsolateral prefrontal cortex (logic) and parietal lobe (spatial reasoning), enabling you to mentally manipulate complex systems with unusual precision."
                },
                {
                    title: "Growth Opportunity",
                    text: balance > 60 ? 
                        "Your balanced profile suggests integrated hemispheric communication - but PET scans might reveal subtle asymmetries. Consider neurofeedback training to strengthen corpus callosum integration during high-stakes decisions." :
                        `EEG studies would likely show excessive ${intuition > analysis ? 'left' : 'right'} hemisphere dominance. Targeted mindfulness practices could help access the underutilized ${intuition > analysis ? 'analytical' : 'intuitive'} networks.`
                }
            ];
            
            insights.forEach(insight => {
                const node = document.createElement('div');
                node.className = 'node bg-indigo-800 rounded-2xl p-6 flex flex-col items-center justify-center text-center';
                node.innerHTML = `
                    <div class="thought-bubble bg-indigo-700 w-16 h-16 flex items-center justify-center mb-3">
                        <i class="fas fa-lightbulb text-xl"></i>
                    </div>
                    <h3 class="text-lg font-semibold mb-2">${insight.title}</h3>
                    <p class="text-sm text-gray-200">${insight.text}</p>
                `;
                responseNodes.appendChild(node);
            });
        }
    </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=John2121/jd-s-neuromind-explorer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>