-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.html
More file actions
726 lines (702 loc) · 39 KB
/
tools.html
File metadata and controls
726 lines (702 loc) · 39 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wellness Tools — MindLift</title>
<meta name="description" content="Free mental health tools: guided breathing exercises, mood tracker, gratitude journal, self-assessment quiz, and AI companion chat.">
<meta name="robots" content="index, follow">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="shared.css">
<style>
/* ─── PAGE HERO ─── */
.page-hero {
padding: 72px 5vw 56px;
background: linear-gradient(135deg, var(--bg2), var(--bg));
border-bottom: 1px solid var(--border);
text-align: center;
}
.page-hero h1 { font-family: var(--font-d); font-size: clamp(2.2rem,6vw,4rem); font-weight: 300; }
.page-hero h1 em { font-style: italic; color: var(--accent); }
.page-hero p { color: var(--text2); font-size: 1.05rem; font-weight: 300; max-width: 540px; margin: 14px auto 0; }
/* ─── TOOL TABS ─── */
.tool-tabs {
display: flex; gap: 8px;
padding: 0 5vw;
background: var(--bg2);
border-bottom: 1px solid var(--border);
overflow-x: auto;
max-width: 100%;
-webkit-overflow-scrolling: touch;
scrollbar-width: none;
position: sticky; top: var(--nav-h); z-index: 50;
}
.tool-tabs::-webkit-scrollbar { display: none; }
.tool-tab {
display: flex; align-items: center; gap: 7px;
padding: 14px 16px;
color: var(--text3); font-size: 0.87rem; font-weight: 600;
text-decoration: none; white-space: nowrap;
border-bottom: 2px solid transparent;
transition: all 0.2s;
}
.tool-tab:hover { color: var(--text); }
.tool-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
/* ─── TOOL SECTIONS ─── */
.tool-section {
padding: 64px 5vw;
max-width: var(--max-w); margin: 0 auto;
border-bottom: 1px solid var(--border);
}
.tool-section:last-child { border-bottom: none; }
.tool-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 36px; }
.tool-header-text .tag { margin-bottom: 10px; }
.tool-header-text h2 { font-family: var(--font-d); font-size: clamp(1.6rem,4vw,2.4rem); font-weight: 400; }
.tool-header-text p { color: var(--text2); font-size: 0.95rem; max-width: 460px; margin-top: 8px; font-weight: 300; }
/* ─── BREATHING ─── */
.breathe-layout {
display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center;
}
@media(max-width:700px){.breathe-layout{grid-template-columns:1fr;}}
.breathe-visual {
display: flex; flex-direction: column; align-items: center; justify-content: center;
min-height: 340px; position: relative;
}
.breath-rings-wrap {
position: relative; width: 260px; height: 260px;
display: flex; align-items: center; justify-content: center;
}
.b-ring {
position: absolute; border-radius: 50%; border: 1px solid;
top: 50%; left: 50%; transition: none;
animation: spin-slow var(--sp,20s) linear infinite;
}
.b-ring:nth-child(1) { width: 100%; height: 100%; transform: translate(-50%,-50%); border-color: rgba(94,155,255,0.15); --sp:30s; }
.b-ring:nth-child(2) { width: 75%; height: 75%; transform: translate(-50%,-50%); border-color: rgba(94,255,216,0.12); --sp:20s; animation-direction: reverse; }
.b-ring:nth-child(3) { width: 50%; height: 50%; transform: translate(-50%,-50%); border-color: rgba(192,132,252,0.15); --sp:14s; }
@keyframes spin-slow { to { transform: translate(-50%,-50%) rotate(360deg); } }
.breath-main-circle {
width: 110px; height: 110px; border-radius: 50%; z-index:2;
background: linear-gradient(135deg, var(--accent), #3a6ecc);
display: flex; flex-direction: column; align-items: center; justify-content: center;
cursor: pointer; user-select: none;
box-shadow: 0 0 40px rgba(94,155,255,0.4);
transition: transform 4s cubic-bezier(0.4,0,0.2,1), box-shadow 0.5s;
position: relative; z-index: 3;
}
.breath-main-circle.inhale { transform: scale(1.65); box-shadow: 0 0 80px rgba(94,155,255,0.6); }
.breath-main-circle.hold { transform: scale(1.65); }
.breath-main-circle.exhale { transform: scale(1); }
.breath-main-circle:hover { box-shadow: 0 0 60px rgba(94,155,255,0.5); }
.breath-main-label { font-size: 0.8rem; font-weight: 700; color: white; letter-spacing: 0.08em; text-transform: uppercase; }
.breath-main-count { font-family: var(--font-d); font-size: 1.8rem; color: white; line-height: 1; }
.breath-status { margin-top: 20px; text-align: center; min-height: 28px; }
.breath-phase-label { font-size: 1.1rem; font-weight: 500; color: var(--text); }
.breath-cycle-info { font-size: 0.82rem; color: var(--text3); margin-top: 4px; }
.breathe-controls { display: flex; flex-direction: column; gap: 20px; }
.technique-card {
border: 2px solid var(--border);
border-radius: 14px; padding: 18px 20px; cursor: pointer;
transition: all 0.2s; background: var(--surface);
}
.technique-card:hover { border-color: var(--border2); }
.technique-card.active { border-color: var(--accent); background: rgba(94,155,255,0.06); }
.technique-card h4 { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.technique-card p { font-size: 0.82rem; color: var(--text2); }
.technique-card .pattern { font-size: 0.78rem; color: var(--accent); font-weight: 700; margin-top: 6px; letter-spacing: 0.05em; }
.breathe-cta { display: flex; gap: 10px; margin-top: 8px; }
/* ─── MOOD ─── */
.mood-layout { display: grid; grid-template-columns: 1fr 1.2fr; gap: 28px; }
@media(max-width:700px){.mood-layout{grid-template-columns:1fr;}}
.mood-emojis { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.mood-opt {
flex: 1; min-width: 80px;
background: var(--bg3); border: 2px solid transparent;
border-radius: 14px; padding: 14px 10px;
cursor: pointer; transition: all 0.2s;
display: flex; flex-direction: column; align-items: center; gap: 6px;
font-family: var(--font-b); color: var(--text3);
font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em;
}
.mood-opt .emoji { font-size: 2rem; line-height: 1; }
.mood-opt:hover { border-color: var(--border2); color: var(--text); transform: translateY(-2px); }
.mood-opt.active { border-color: var(--accent); background: rgba(94,155,255,0.1); color: var(--text); }
.chart-container { background: var(--bg3); border-radius: 14px; padding: 20px; margin-top: 20px; }
.mood-history { margin-top: 20px; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.mood-log-item {
display: flex; align-items: center; justify-content: space-between;
background: var(--bg3); border-radius: 10px; padding: 10px 14px;
font-size: 0.85rem;
}
.mood-log-item .emoji { font-size: 1.2rem; }
.mood-log-date { color: var(--text3); font-size: 0.78rem; }
.mood-log-note { color: var(--text2); font-size: 0.82rem; margin-top: 2px; font-style: italic; }
/* ─── JOURNAL ─── */
.journal-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media(max-width:700px){.journal-layout{grid-template-columns:1fr;}}
.streak-card {
background: linear-gradient(135deg, rgba(255,140,107,0.12), rgba(255,140,107,0.04));
border: 1px solid rgba(255,140,107,0.2);
border-radius: 14px; padding: 20px 24px;
display: flex; align-items: center; gap: 18px;
margin-bottom: 20px;
}
.streak-num { font-family: var(--font-d); font-size: 3.5rem; color: var(--accent2); line-height: 1; }
.streak-info { flex: 1; }
.streak-info h4 { font-weight: 700; font-size: 0.95rem; }
.streak-info p { font-size: 0.82rem; color: var(--text2); margin-top: 2px; }
.journal-history { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.journal-entry-item {
background: var(--bg3); border-radius: 12px; padding: 14px 16px;
border-left: 3px solid var(--accent3);
}
.journal-entry-date { font-size: 0.75rem; color: var(--text3); font-weight: 700; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.journal-entry-text { font-size: 0.88rem; color: var(--text2); line-height: 1.6; }
/* ─── QUIZ ─── */
.quiz-layout { max-width: 640px; }
.quiz-prog-wrap { margin-bottom: 28px; }
.quiz-prog-bar { background: var(--bg3); border-radius: 100px; height: 6px; overflow: hidden; }
.quiz-prog-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent3)); border-radius: 100px; transition: width 0.5s ease; }
.quiz-prog-text { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text3); margin-top: 8px; }
.quiz-q-text { font-size: 1.1rem; font-weight: 500; margin-bottom: 20px; line-height: 1.55; }
.quiz-opt {
width: 100%; text-align: left;
background: var(--bg3); border: 2px solid transparent;
border-radius: 12px; padding: 14px 18px;
font-family: var(--font-b); font-size: 0.92rem; font-weight: 400;
color: var(--text); cursor: pointer; transition: all 0.2s;
margin-bottom: 10px; display: block;
}
.quiz-opt:hover { border-color: var(--border2); background: var(--surface); }
.quiz-opt.chosen { border-color: var(--accent); background: rgba(94,155,255,0.1); }
.quiz-actions { display: flex; gap: 10px; margin-top: 16px; }
.quiz-result-card {
background: var(--surface); border: 1px solid var(--border);
border-radius: 18px; padding: 36px; text-align: center;
}
.quiz-result-score { font-family: var(--font-d); font-size: 5rem; font-weight: 300; line-height: 1; margin-bottom: 8px; }
.quiz-result-level { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.quiz-result-advice { color: var(--text2); font-size: 0.9rem; max-width: 420px; margin: 0 auto 24px; line-height: 1.7; }
.quiz-result-bar { display: flex; height: 10px; border-radius: 100px; overflow: hidden; margin: 0 auto 28px; max-width: 300px; }
.quiz-result-bar-fill { border-radius: 100px; transition: width 1s ease; }
/* ─── CHAT ─── */
.chat-layout { display: grid; grid-template-columns: 1fr 320px; gap: 28px; }
@media(max-width:800px){.chat-layout{grid-template-columns:1fr;}}
.chat-window {
background: var(--bg3); border: 1px solid var(--border);
border-radius: 18px;
height: 440px; overflow-y: auto;
padding: 24px; display: flex; flex-direction: column; gap: 14px;
scroll-behavior: smooth;
}
.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-track { background: transparent; }
.chat-window::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.msg-wrap { display: flex; gap: 10px; }
.msg-wrap.user { flex-direction: row-reverse; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; margin-top: 2px; }
.msg-avatar.ai { background: rgba(94,155,255,0.15); }
.msg-avatar.user { background: rgba(94,255,216,0.15); }
.msg-bubble {
max-width: 78%; padding: 12px 16px;
border-radius: 16px; font-size: 0.91rem; line-height: 1.65;
animation: fadeUp 0.3s ease;
}
.msg-bubble.ai { background: var(--surface); color: var(--text); border-bottom-left-radius: 4px; }
.msg-bubble.user { background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.msg-bubble.typing { color: var(--text3); font-style: italic; }
.chat-input-area { margin-top: 14px; display: flex; gap: 10px; }
.chat-input-area .field-input { flex: 1; margin: 0; }
.chat-send-btn { background: var(--accent); color: white; border: none; border-radius: 10px; padding: 0 22px; font-family: var(--font-b); font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: opacity 0.2s; white-space: nowrap; }
.chat-send-btn:disabled { opacity: 0.4; cursor: default; }
.chat-disclaimer { font-size: 0.76rem; color: var(--text3); text-align: center; margin-top: 10px; }
.chat-sidebar { display: flex; flex-direction: column; gap: 16px; }
.chat-tip-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.chat-tip-card h4 { font-size: 0.85rem; font-weight: 700; margin-bottom: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; }
.prompt-chip {
display: block; width: 100%;
text-align: left; background: var(--bg3);
border: 1px solid var(--border); border-radius: 9px;
padding: 9px 13px; font-size: 0.83rem; color: var(--text2);
font-family: var(--font-b); cursor: pointer; transition: all 0.2s;
margin-bottom: 7px;
}
.prompt-chip:hover { color: var(--text); border-color: var(--border2); background: var(--surface2); }
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }
</style>
</head>
<body>
<main id="main">
<div class="page-hero">
<div class="tag mint">Interactive Wellness Tools</div>
<h1>Your personal <em>toolkit</em> for mental health.</h1>
<p>Science-backed, always free, always private. Choose a tool and begin whenever you're ready.</p>
</div>
<!-- TOOL TABS -->
<div class="tool-tabs" role="tablist" aria-label="Tool navigation">
<a href="#breathe" class="tool-tab active">🫁 Breathe</a>
<a href="#mood" class="tool-tab">📊 Mood</a>
<a href="#journal" class="tool-tab">📔 Journal</a>
<a href="#quiz" class="tool-tab">📝 Assessment</a>
<a href="#chat" class="tool-tab">💬 AI Companion</a>
</div>
<!-- ═══════════════ BREATHING ═══════════════ -->
<section class="tool-section" id="breathe" aria-labelledby="breathe-heading">
<div class="tool-header reveal">
<div class="tool-header-text">
<div class="tag">Instant Calm</div>
<h2 id="breathe-heading">Guided Breathing</h2>
<p>Click the circle to start. Your nervous system will begin to calm within 60 seconds.</p>
</div>
</div>
<div class="breathe-layout reveal">
<div class="breathe-visual">
<div class="breath-rings-wrap">
<div class="b-ring"></div>
<div class="b-ring"></div>
<div class="b-ring"></div>
<div class="breath-main-circle" id="breathCircle" onclick="toggleBreath()" role="button" tabindex="0" aria-label="Start breathing exercise" onkeydown="if(event.key==='Enter')toggleBreath()">
<span class="breath-main-label" id="bLabel">Start</span>
<span class="breath-main-count" id="bCount"></span>
</div>
</div>
<div class="breath-status">
<div class="breath-phase-label" id="bPhase" aria-live="polite">Click to begin</div>
<div class="breath-cycle-info" id="bCycles"></div>
</div>
</div>
<div class="breathe-controls">
<div class="technique-card active" onclick="selectTech('478',this)" id="tech478">
<h4>4-7-8 Breathing</h4>
<p>Best for anxiety and falling asleep. Exhale fully, inhale 4, hold 7, exhale 8.</p>
<div class="pattern">INHALE 4s · HOLD 7s · EXHALE 8s</div>
</div>
<div class="technique-card" onclick="selectTech('box',this)" id="techbox">
<h4>Box Breathing</h4>
<p>Used by Navy SEALs. Equal sides activate the parasympathetic nervous system.</p>
<div class="pattern">INHALE 4s · HOLD 4s · EXHALE 4s · HOLD 4s</div>
</div>
<div class="technique-card" onclick="selectTech('calm',this)" id="techcalm">
<h4>Calm Breathing</h4>
<p>A simple, gentle ratio for beginners or panic situations.</p>
<div class="pattern">INHALE 4s · EXHALE 6s</div>
</div>
<div class="breathe-cta">
<button class="btn btn-ghost btn-sm" onclick="stopBreath()">⏹ Stop</button>
<span id="breathComplete" style="font-size:0.85rem;color:var(--accent3);display:none;align-items:center;gap:6px">✓ Complete! Great work 🌿</span>
</div>
</div>
</div>
</section>
<!-- ═══════════════ MOOD TRACKER ═══════════════ -->
<section class="tool-section" id="mood" aria-labelledby="mood-heading">
<div class="tool-header reveal">
<div class="tool-header-text">
<div class="tag violet">Daily Check-In</div>
<h2 id="mood-heading">Mood Tracker</h2>
<p>Log how you feel each day. Patterns reveal insights you can share with a therapist or just understand yourself better.</p>
</div>
</div>
<div class="mood-layout reveal">
<div class="card" style="border-radius:var(--radius-lg)">
<label class="field-label">How are you feeling right now?</label>
<div class="mood-emojis" role="group" aria-label="Select your mood">
<button class="mood-opt" onclick="selectMood(this,'😊','Happy',5)" aria-label="Happy"><span class="emoji">😊</span>Happy</button>
<button class="mood-opt" onclick="selectMood(this,'😌','Calm',4)" aria-label="Calm"><span class="emoji">😌</span>Calm</button>
<button class="mood-opt" onclick="selectMood(this,'😐','Neutral',3)" aria-label="Neutral"><span class="emoji">😐</span>Neutral</button>
<button class="mood-opt" onclick="selectMood(this,'😔','Sad',2)" aria-label="Sad"><span class="emoji">😔</span>Sad</button>
<button class="mood-opt" onclick="selectMood(this,'😰','Anxious',2)" aria-label="Anxious"><span class="emoji">😰</span>Anxious</button>
<button class="mood-opt" onclick="selectMood(this,'😡','Angry',1)" aria-label="Angry"><span class="emoji">😡</span>Angry</button>
</div>
<div class="field">
<label class="field-label" for="moodNote">Add a note (optional)</label>
<input type="text" class="field-input" id="moodNote" placeholder="What's contributing to this feeling?">
</div>
<button class="btn btn-primary btn-full" onclick="saveMood()">💾 Save Today's Mood</button>
<div class="toast" id="moodToast"></div>
</div>
<div>
<div class="chart-container">
<div style="font-size:0.78rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--text3);margin-bottom:12px">Mood History (Last 14 Days)</div>
<canvas id="moodChart" height="160" aria-label="Mood history chart"></canvas>
</div>
<div class="mood-history" id="moodHistory" aria-label="Mood log" aria-live="polite"></div>
</div>
</div>
</section>
<!-- ═══════════════ JOURNAL ═══════════════ -->
<section class="tool-section" id="journal" aria-labelledby="journal-heading">
<div class="tool-header reveal">
<div class="tool-header-text">
<div class="tag coral">Positive Psychology</div>
<h2 id="journal-heading">Gratitude Journal</h2>
<p>Research shows 3 minutes of daily gratitude rewires neural pathways associated with negative thinking.</p>
</div>
</div>
<div class="journal-layout reveal">
<div>
<div class="streak-card">
<div class="streak-num" id="streakNum">0</div>
<div style="font-size:1.8rem">🔥</div>
<div class="streak-info">
<h4>Day Streak</h4>
<p id="streakMsg">Start your first entry to begin your streak!</p>
</div>
</div>
<div class="card" style="border-radius:var(--radius-lg)">
<div class="field">
<label class="field-label" for="journalEntry">Today's gratitude entry</label>
<textarea class="field-textarea" id="journalEntry" rows="6" placeholder="Three things I'm grateful for today: 1. 2. 3. "></textarea>
</div>
<div class="field">
<label class="field-label" for="journalMood">Today's intention</label>
<input type="text" class="field-input" id="journalIntention" placeholder="One thing I want to focus on today…">
</div>
<div style="display:flex;gap:10px;flex-wrap:wrap">
<button class="btn btn-primary" style="flex:1" onclick="saveJournal()">💾 Save Entry</button>
<button class="btn btn-ghost" style="flex:1" onclick="downloadJournal()">⬇️ Download</button>
</div>
<div class="toast" id="journalToast"></div>
</div>
</div>
<div>
<div style="font-size:0.78rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--text3);margin-bottom:12px">Past Entries</div>
<div class="journal-history" id="journalHistory" aria-label="Journal entries" aria-live="polite">
<p style="color:var(--text3);font-size:0.88rem">Your saved entries will appear here.</p>
</div>
</div>
</div>
</section>
<!-- ═══════════════ QUIZ ═══════════════ -->
<section class="tool-section" id="quiz" aria-labelledby="quiz-heading">
<div class="tool-header reveal">
<div class="tool-header-text">
<div class="tag">Self-Assessment</div>
<h2 id="quiz-heading">How Are You Doing?</h2>
<p>Based on PHQ-9 and GAD-7 — validated tools used by mental health professionals worldwide. Not diagnostic.</p>
</div>
</div>
<div class="quiz-layout reveal">
<div class="quiz-prog-wrap">
<div class="quiz-prog-bar"><div class="quiz-prog-fill" id="quizFill" style="width:0%"></div></div>
<div class="quiz-prog-text"><span id="quizProgLabel">Question 1 of 7</span><span id="quizPct">0%</span></div>
</div>
<div id="quizBody"></div>
</div>
</section>
<!-- ═══════════════ AI CHAT ═══════════════ -->
<section class="tool-section" id="chat" aria-labelledby="chat-heading">
<div class="tool-header reveal">
<div class="tool-header-text">
<div class="tag violet">AI Companion</div>
<h2 id="chat-heading">Talk It Out</h2>
<p>A compassionate, empathetic AI companion. It listens, helps you process feelings, and offers evidence-based coping strategies.</p>
</div>
</div>
<div class="chat-layout reveal">
<div>
<div class="chat-window" id="chatWindow" role="log" aria-label="Chat" aria-live="polite">
<div class="msg-wrap ai">
<div class="msg-avatar ai">🌿</div>
<div class="msg-bubble ai">Hi, I'm here with you 💙 This is a safe, judgment-free space. How are you feeling today, and what's on your mind?</div>
</div>
</div>
<div class="chat-input-area">
<input type="text" class="field-input" id="chatInput" placeholder="Type something… I'm listening" onkeydown="if(event.key==='Enter'&&!event.shiftKey)sendChat()" aria-label="Message">
<button class="chat-send-btn" id="chatSendBtn" onclick="sendChat()">Send →</button>
</div>
<p class="chat-disclaimer">⚠️ This AI is not a therapist. In crisis, call <strong>988</strong> (US) or <a href="resources.html">find your local line</a>.</p>
</div>
<div class="chat-sidebar">
<div class="chat-tip-card">
<h4>Conversation starters</h4>
<button class="prompt-chip" onclick="usePrompt(this)">I've been feeling really anxious lately…</button>
<button class="prompt-chip" onclick="usePrompt(this)">I can't seem to get out of a low mood</button>
<button class="prompt-chip" onclick="usePrompt(this)">I need a breathing or grounding exercise</button>
<button class="prompt-chip" onclick="usePrompt(this)">I'm overwhelmed and don't know where to start</button>
<button class="prompt-chip" onclick="usePrompt(this)">How can I improve my sleep?</button>
<button class="prompt-chip" onclick="usePrompt(this)">I want to try a CBT thought record</button>
</div>
<div class="chat-tip-card">
<h4>Quick Resources</h4>
<p style="font-size:0.83rem;color:var(--text2);margin-bottom:10px">Need immediate help?</p>
<a href="resources.html" class="btn btn-coral btn-sm btn-full" style="text-align:center">🆘 View Helplines</a>
</div>
</div>
</div>
</section>
</main>
<script src="nav.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
/* ═══ BREATHING ═══ */
const TECHS = {
'478': { phases:['Inhale','Hold','Exhale'], durs:[4,7,8], classes:['inhale','hold','exhale'] },
'box': { phases:['Inhale','Hold','Exhale','Hold'], durs:[4,4,4,4], classes:['inhale','hold','exhale','hold'] },
'calm':{ phases:['Inhale','Exhale'], durs:[4,6], classes:['inhale','exhale'] },
};
let activeTech = '478', breathRunning = false, breathTimeout = null, breathTickInterval = null;
let breathPhase = 0, breathCycles = 0;
function selectTech(key, el) {
activeTech = key;
document.querySelectorAll('.technique-card').forEach(c => c.classList.remove('active'));
el.classList.add('active');
stopBreath();
}
function toggleBreath() { breathRunning ? stopBreath() : startBreath(); }
function startBreath() {
breathRunning = true; breathPhase = 0; breathCycles = 0;
document.getElementById('breathComplete').style.display = 'none';
document.getElementById('bLabel').textContent = '';
runPhase();
}
function runPhase() {
if (!breathRunning) return;
const t = TECHS[activeTech];
const idx = breathPhase % t.phases.length;
const phase = t.phases[idx], dur = t.durs[idx], cls = t.classes[idx];
const circle = document.getElementById('breathCircle');
circle.className = 'breath-main-circle ' + cls;
document.getElementById('bPhase').textContent = phase;
let s = dur;
document.getElementById('bCount').textContent = s;
clearInterval(breathTickInterval);
breathTickInterval = setInterval(() => { s--; document.getElementById('bCount').textContent = s > 0 ? s : ''; if (s <= 0) clearInterval(breathTickInterval); }, 1000);
breathTimeout = setTimeout(() => {
breathPhase++;
if (breathPhase % t.phases.length === 0) {
breathCycles++;
document.getElementById('bCycles').textContent = `Cycle ${breathCycles} of 3 complete`;
if (breathCycles >= 3) { finishBreath(); return; }
}
runPhase();
}, dur * 1000);
}
function stopBreath() {
breathRunning = false;
clearTimeout(breathTimeout); clearInterval(breathTickInterval);
document.getElementById('breathCircle').className = 'breath-main-circle';
document.getElementById('bLabel').textContent = 'Start';
document.getElementById('bCount').textContent = '';
document.getElementById('bPhase').textContent = 'Click to begin';
document.getElementById('bCycles').textContent = '';
}
function finishBreath() {
breathRunning = false;
clearTimeout(breathTimeout); clearInterval(breathTickInterval);
document.getElementById('breathCircle').className = 'breath-main-circle';
document.getElementById('bLabel').textContent = '✓';
document.getElementById('bCount').textContent = '';
document.getElementById('bPhase').textContent = '3 cycles complete 🌿';
document.getElementById('bCycles').textContent = '';
document.getElementById('breathComplete').style.display = 'flex';
}
/* ═══ MOOD ═══ */
let selMood = null;
function selectMood(el, emoji, label, val) {
selMood = { emoji, label, val };
document.querySelectorAll('.mood-opt').forEach(b => b.classList.remove('active'));
el.classList.add('active');
}
function saveMood() {
if (!selMood) { showToast('moodToast', 'Please select a mood first', 'warn'); return; }
const note = document.getElementById('moodNote').value;
let moods = getMoods();
moods.push({ date: new Date().toLocaleDateString(), time: new Date().toLocaleTimeString([], {hour:'2-digit',minute:'2-digit'}), ...selMood, note });
if (moods.length > 14) moods = moods.slice(-14);
localStorage.setItem('ml_moods', JSON.stringify(moods));
showToast('moodToast', selMood.emoji + ' ' + selMood.label + ' saved!', 'success');
document.getElementById('moodNote').value = '';
selMood = null;
document.querySelectorAll('.mood-opt').forEach(b => b.classList.remove('active'));
renderMoodChart(); renderMoodHistory();
}
function getMoods() { return JSON.parse(localStorage.getItem('ml_moods') || '[]'); }
let moodChart = null;
function renderMoodChart() {
const moods = getMoods();
const ctx = document.getElementById('moodChart').getContext('2d');
if (moodChart) moodChart.destroy();
if (!moods.length) return;
moodChart = new Chart(ctx, {
type: 'line',
data: {
labels: moods.map(m => m.date),
datasets: [{ label: 'Mood', data: moods.map(m => m.val), borderColor: '#5e9bff', backgroundColor: 'rgba(94,155,255,0.08)', pointBackgroundColor: moods.map(m => ['#f87171','#fbbf24','#94a3b8','#5effd8','#5e9bff','#c084fc'][m.val-1] || '#5e9bff'), pointRadius: 6, borderWidth: 2, tension: 0.4, fill: true }]
},
options: { responsive: true, plugins: { legend: { display: false }, tooltip: { callbacks: { label: ctx => { const m = moods[ctx.dataIndex]; return m.emoji + ' ' + m.label + (m.note ? ' — ' + m.note : ''); } } } }, scales: { y: { min: 0, max: 6, ticks: { stepSize: 1, callback: v => ['','😡','😔/😰','😐','😌','😊',''][v] || '', color: '#5a6285' }, grid: { color: 'rgba(255,255,255,0.04)' } }, x: { ticks: { color: '#5a6285', font: { size: 10 } }, grid: { color: 'rgba(255,255,255,0.04)' } } } }
});
}
function renderMoodHistory() {
const moods = getMoods().slice().reverse();
const el = document.getElementById('moodHistory');
if (!moods.length) { el.innerHTML = '<p style="color:var(--text3);font-size:0.88rem">No mood logs yet.</p>'; return; }
el.innerHTML = moods.map(m => `<div class="mood-log-item"><span class="emoji">${m.emoji}</span><div style="flex:1"><div style="font-weight:600;font-size:0.88rem">${m.label}</div>${m.note ? `<div class="mood-log-note">${m.note}</div>` : ''}</div><div class="mood-log-date">${m.date}</div></div>`).join('');
}
renderMoodChart(); renderMoodHistory();
/* ═══ JOURNAL ═══ */
function getJournals() { return JSON.parse(localStorage.getItem('ml_journal') || '[]'); }
function updateStreak() {
const j = getJournals(); let streak = 0;
const dates = [...new Set(j.map(e => e.date))].reverse();
for (let i = 0; i < dates.length; i++) {
const expected = new Date(); expected.setDate(expected.getDate() - i);
if (dates[i] === expected.toLocaleDateString()) streak++;
else break;
}
document.getElementById('streakNum').textContent = streak;
document.getElementById('streakMsg').textContent = streak === 0 ? 'Start your first entry to begin your streak!' : streak === 1 ? '1 day — great start!' : `${streak} days — you're building a habit! 🔥`;
}
function saveJournal() {
const entry = document.getElementById('journalEntry').value.trim();
const intention = document.getElementById('journalIntention').value.trim();
if (!entry) { showToast('journalToast', 'Please write something first', 'warn'); return; }
const j = getJournals();
j.push({ date: new Date().toLocaleDateString(), time: new Date().toLocaleTimeString(), entry, intention });
localStorage.setItem('ml_journal', JSON.stringify(j));
showToast('journalToast', '✨ Entry saved!', 'success');
document.getElementById('journalEntry').value = '';
document.getElementById('journalIntention').value = '';
updateStreak(); renderJournalHistory();
}
function downloadJournal() {
const j = getJournals();
if (!j.length) { showToast('journalToast', 'No entries to download yet', 'warn'); return; }
const text = 'MindLift Gratitude Journal\n' + '═'.repeat(40) + '\n\n' + j.map(e => `[${e.date} ${e.time}]\n${e.entry}${e.intention ? '\n\nToday\'s intention: ' + e.intention : ''}`).join('\n\n' + '─'.repeat(30) + '\n\n');
const a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([text], { type: 'text/plain' }));
a.download = 'MindLift_Journal.txt'; a.click();
}
function renderJournalHistory() {
const j = getJournals().slice().reverse();
const el = document.getElementById('journalHistory');
if (!j.length) { el.innerHTML = '<p style="color:var(--text3);font-size:0.88rem">Your saved entries will appear here.</p>'; return; }
el.innerHTML = j.slice(0,10).map(e => `<div class="journal-entry-item"><div class="journal-entry-date">${e.date}</div><div class="journal-entry-text">${e.entry.substring(0,180)}${e.entry.length > 180 ? '…' : ''}</div></div>`).join('');
}
updateStreak(); renderJournalHistory();
/* ═══ QUIZ ═══ */
const QUIZ_QS = [
{ q: "Over the past 2 weeks, how often have you felt little interest or pleasure in doing things?", opts: ["Not at all", "Several days", "More than half the days", "Nearly every day"] },
{ q: "How often have you felt down, depressed, or hopeless?", opts: ["Not at all", "Several days", "More than half the days", "Nearly every day"] },
{ q: "How often have you felt nervous, anxious, or on edge?", opts: ["Not at all", "Several days", "More than half the days", "Nearly every day"] },
{ q: "How often have you been unable to stop or control worrying?", opts: ["Not at all", "Several days", "More than half the days", "Nearly every day"] },
{ q: "How often have you felt tired or had little energy?", opts: ["Not at all", "Several days", "More than half the days", "Nearly every day"] },
{ q: "How often have you had trouble sleeping, or slept too much?", opts: ["Not at all", "Several days", "More than half the days", "Nearly every day"] },
{ q: "How often have you had trouble concentrating on things?", opts: ["Not at all", "Several days", "More than half the days", "Nearly every day"] },
];
let qStep = 0, qScore = 0, qAnswered = false;
function renderQuiz() {
const pct = Math.round((qStep / QUIZ_QS.length) * 100);
document.getElementById('quizFill').style.width = pct + '%';
document.getElementById('quizPct').textContent = pct + '%';
if (qStep >= QUIZ_QS.length) {
document.getElementById('quizProgLabel').textContent = 'Complete';
let level, color, advice, nextSteps;
if (qScore <= 5) { level = 'Low Distress'; color = 'var(--accent3)'; advice = "Your responses suggest you're managing relatively well. Continue your self-care practices and check in regularly."; nextSteps = 'Keep journaling and using the breathing tools to maintain your wellbeing.'; }
else if (qScore <= 12) { level = 'Mild Symptoms'; color = '#fbbf24'; advice = "You may be experiencing some symptoms of anxiety or depression. This is common and there are many things that can help."; nextSteps = 'Consider talking to a trusted person, trying therapy, or using our tools daily.'; }
else { level = 'Significant Distress'; color = 'var(--accent2)'; advice = "Your responses suggest significant distress. Please consider reaching out to a mental health professional — you deserve support."; nextSteps = 'We strongly encourage you to contact a professional or one of our crisis resources.'; }
const barW = Math.min(100, Math.round((qScore / 21) * 100));
document.getElementById('quizBody').innerHTML = `
<div class="quiz-result-card">
<div class="quiz-result-score" style="color:${color}">${qScore}<span style="font-size:1.5rem;color:var(--text3)">/21</span></div>
<div class="quiz-result-level" style="color:${color}">${level}</div>
<div class="quiz-result-bar"><div class="quiz-result-bar-fill" style="width:${barW}%;background:${color}"></div></div>
<p class="quiz-result-advice">${advice}</p>
<p style="font-size:0.85rem;color:var(--text3);margin-bottom:24px">${nextSteps}</p>
<div style="display:flex;gap:10px;justify-content:center;flex-wrap:wrap">
<a href="resources.html" class="btn btn-coral btn-sm">🆘 Professional Resources</a>
<button class="btn btn-ghost btn-sm" onclick="resetQuiz()">↩ Retake</button>
</div>
</div>`;
return;
}
document.getElementById('quizProgLabel').textContent = `Question ${qStep + 1} of ${QUIZ_QS.length}`;
qAnswered = false;
const q = QUIZ_QS[qStep];
document.getElementById('quizBody').innerHTML = `
<p class="quiz-q-text">${q.q}</p>
${q.opts.map((o, i) => `<button class="quiz-opt" onclick="answerQ(this,${i})">${o}</button>`).join('')}
<div class="quiz-actions"><button class="btn btn-primary btn-sm" id="qNext" onclick="nextQ()" disabled>Next →</button></div>`;
}
function answerQ(el, i) {
if (qAnswered) return; qAnswered = true; qScore += i;
document.querySelectorAll('.quiz-opt').forEach((b, idx) => { if (idx === i) b.classList.add('chosen'); });
document.getElementById('qNext').disabled = false;
}
function nextQ() { if (qAnswered) { qStep++; renderQuiz(); } }
function resetQuiz() { qStep = 0; qScore = 0; renderQuiz(); }
renderQuiz();
/* ═══ AI CHAT ═══ */
const SYSTEM = `You are MindLift Companion, a warm, compassionate mental health support AI. You use CBT principles, motivational interviewing, and trauma-informed language. You: (1) validate feelings first, (2) ask gentle open questions, (3) offer concrete coping strategies when asked, (4) never diagnose, (5) always encourage professional help for serious concerns, (6) immediately provide 988 (US) or befrienders.org if suicide/self-harm is mentioned. Keep replies concise (3-5 sentences max), warm, and hopeful. You are not a substitute for therapy.`;
let chatHistory = [];
async function sendChat() {
const input = document.getElementById('chatInput');
const msg = input.value.trim();
if (!msg) return;
input.value = '';
document.getElementById('chatSendBtn').disabled = true;
appendMsg(msg, 'user');
chatHistory.push({ role: 'user', content: msg });
const typing = appendMsg('Thinking…', 'ai typing');
try {
const res = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ model: 'claude-sonnet-4-20250514', max_tokens: 1000, system: SYSTEM, messages: chatHistory })
});
const data = await res.json();
const reply = data.content?.map(b => b.text || '').join('') || "I'm here with you. Could you tell me a little more about what you're experiencing?";
typing.remove();
appendMsg(reply, 'ai');
chatHistory.push({ role: 'assistant', content: reply });
if (chatHistory.length > 24) chatHistory = chatHistory.slice(-24);
} catch (e) {
typing.remove();
appendMsg("I'm having trouble connecting. If you're in crisis, please call 988 (US) or visit resources.html for your local line.", 'ai');
}
document.getElementById('chatSendBtn').disabled = false;
}
function appendMsg(text, role) {
const win = document.getElementById('chatWindow');
const wrap = document.createElement('div');
wrap.className = 'msg-wrap ' + (role.includes('user') ? 'user' : 'ai');
const avatar = document.createElement('div');
avatar.className = 'msg-avatar ' + (role.includes('user') ? 'user' : 'ai');
avatar.textContent = role.includes('user') ? '🧑' : '🌿';
const bubble = document.createElement('div');
bubble.className = 'msg-bubble ' + role;
bubble.textContent = text;
if (!role.includes('user')) wrap.appendChild(avatar);
wrap.appendChild(bubble);
if (role.includes('user')) wrap.appendChild(avatar);
win.appendChild(wrap);
win.scrollTop = win.scrollHeight;
return bubble;
}
function usePrompt(el) {
document.getElementById('chatInput').value = el.textContent;
document.getElementById('chatInput').focus();
}
/* ═══ TOAST ═══ */
function showToast(id, msg, type) {
const el = document.getElementById(id);
el.textContent = type === 'success' ? '✓ ' + msg : '⚠ ' + msg;
el.className = 'toast toast-' + type + ' show';
setTimeout(() => el.classList.remove('show'), 3200);
}
/* ─── Update active tab on scroll ─── */
const sections = ['breathe','mood','journal','quiz','chat'];
const tabLinks = document.querySelectorAll('.tool-tab');
window.addEventListener('scroll', () => {
let current = 'breathe';
sections.forEach(id => {
const el = document.getElementById(id);
if (el && el.getBoundingClientRect().top < 160) current = id;
});
tabLinks.forEach(t => {
t.classList.toggle('active', t.getAttribute('href') === '#' + current);
});
}, { passive: true });
</script>
</body>
</html>