File size: 51,554 Bytes
4966e71
 
 
 
 
 
 
4c59e23
4966e71
4c59e23
4966e71
4c59e23
 
4966e71
4c59e23
4966e71
4c59e23
 
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86bab52
4966e71
4c59e23
4966e71
 
 
 
4c59e23
4966e71
 
4c59e23
4966e71
 
 
 
4c59e23
4966e71
 
 
 
 
4c59e23
4966e71
 
4c59e23
 
4966e71
 
4c59e23
4966e71
 
 
c3dd14e
4966e71
 
c3dd14e
4966e71
 
 
c3dd14e
4966e71
 
 
4c59e23
4966e71
 
 
4c59e23
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
 
6bacb5e
4966e71
6bacb5e
4966e71
 
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
 
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
6bacb5e
4966e71
 
 
c3dd14e
4966e71
 
 
 
 
 
 
c3dd14e
4966e71
 
c3dd14e
4966e71
c3dd14e
4966e71
c3dd14e
4966e71
 
 
c3dd14e
4966e71
c3dd14e
4966e71
 
 
 
 
 
c3dd14e
4966e71
 
 
 
 
c3dd14e
4966e71
c3dd14e
4966e71
 
 
c3dd14e
4966e71
c3dd14e
4966e71
 
 
 
c3dd14e
4966e71
 
 
c3dd14e
4966e71
 
c3dd14e
4966e71
 
 
c3dd14e
4966e71
 
c3dd14e
4966e71
 
 
c3dd14e
4966e71
c3dd14e
4966e71
 
c3dd14e
4966e71
c3dd14e
4966e71
 
4c59e23
4966e71
 
 
 
 
4c59e23
4966e71
 
 
4c59e23
4966e71
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
6bacb5e
4966e71
 
 
6bacb5e
4966e71
6bacb5e
4966e71
 
6bacb5e
4966e71
4c59e23
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
 
 
 
 
 
6bacb5e
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
 
 
 
 
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
 
 
 
6bacb5e
4966e71
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
 
 
 
6bacb5e
4966e71
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
4c59e23
4966e71
 
4c59e23
4966e71
4c59e23
4966e71
 
 
4c59e23
4966e71
 
 
 
 
 
4c59e23
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
6bacb5e
4966e71
 
4c59e23
4966e71
4c59e23
4966e71
 
 
4c59e23
4966e71
 
6bacb5e
4966e71
 
 
 
c3dd14e
4966e71
 
c3dd14e
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3dd14e
4966e71
 
 
 
 
 
c3dd14e
4966e71
 
 
 
 
c3dd14e
4966e71
 
6bacb5e
4966e71
6bacb5e
4966e71
c3dd14e
4966e71
c3dd14e
4966e71
4c59e23
4966e71
 
 
4c59e23
4966e71
 
 
4c59e23
4966e71
 
 
4c59e23
4966e71
 
 
4c59e23
4966e71
 
 
4c59e23
4966e71
4c59e23
4966e71
4c59e23
4966e71
 
 
 
 
 
4c59e23
4966e71
 
 
 
 
 
4c59e23
4966e71
 
 
 
 
4c59e23
4966e71
4c59e23
4966e71
4c59e23
4966e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
"""
ShadowBox Info Hub v2.0
A Resonant Library for Hard Thoughts

Created by Jocelyn Skillman, LMHC
Not a chatbot. A companion library.
"""

import streamlit as st

# Configure page
st.set_page_config(
    page_title="ShadowBox",
    page_icon="📖",
    layout="centered",
    initial_sidebar_state="collapsed"
)

# Custom CSS for calming, spacious design
st.markdown("""
<style>
    /* Base styling */
    .stApp {
        background-color: #f8f9fa;
    }

    /* Typography */
    h1, h2, h3 {
        color: #2c3e50;
        font-weight: 400;
    }

    p, li {
        color: #4a5568;
        line-height: 1.8;
    }

    /* Spacious containers */
    .block-container {
        padding-top: 2rem;
        padding-bottom: 2rem;
        max-width: 800px;
    }

    /* Card styling for pathways */
    .pathway-card {
        background: white;
        border-radius: 12px;
        padding: 1.5rem;
        margin: 1rem 0;
        border: 1px solid #e2e8f0;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    /* Expander styling */
    .streamlit-expanderHeader {
        background-color: white;
        border-radius: 8px;
        font-size: 1.1rem;
    }

    /* Calming blockquotes */
    blockquote {
        border-left: 3px solid #718096;
        padding-left: 1rem;
        color: #718096;
        font-style: italic;
    }

    /* Crisis box */
    .crisis-box {
        background: #fff5f5;
        border: 1px solid #feb2b2;
        border-radius: 8px;
        padding: 1rem;
        margin: 1rem 0;
    }

    /* Resonance box */
    .resonance-box {
        background: #f0fff4;
        border-left: 4px solid #68d391;
        padding: 1rem;
        margin: 1rem 0;
        border-radius: 0 8px 8px 0;
    }

    /* Hide Streamlit branding */
    #MainMenu {visibility: hidden;}
    footer {visibility: hidden;}

    /* Landing page styling */
    .landing-container {
        text-align: center;
        padding: 3rem 1rem;
        background: linear-gradient(180deg, #f8f9fa 0%, #edf2f7 100%);
        border-radius: 12px;
        margin: 2rem 0;
    }

    /* Soft dividers */
    hr {
        border: none;
        height: 1px;
        background: #e2e8f0;
        margin: 2rem 0;
    }
</style>
""", unsafe_allow_html=True)

# Session state for navigation
if 'page' not in st.session_state:
    st.session_state.page = 'landing'

def go_to(page):
    st.session_state.page = page

# ============================================================
# LANDING PAGE
# ============================================================
def render_landing():
    st.markdown("""
    <div style="text-align: center; padding: 3rem 1rem;">
        <h1 style="font-size: 3rem; font-weight: 300; color: #2c3e50; margin-bottom: 0.5rem;">ShadowBox</h1>
        <p style="font-size: 1.2rem; color: #718096; margin-bottom: 2rem;">
            When the thoughts feel too big<br>
            and the world feels too small
        </p>
        <p style="font-size: 1rem; color: #4a5568; max-width: 500px; margin: 0 auto 2rem auto;">
            This is a quiet library<br>
            for the hardest parts of being human.
        </p>
        <p style="font-size: 1.1rem; color: #2c3e50; font-weight: 500;">
            You're not broken.<br>
            Your nervous system is trying to help.
        </p>
    </div>
    """, unsafe_allow_html=True)

    col1, col2, col3 = st.columns([1, 2, 1])
    with col2:
        if st.button("Enter the Library →", use_container_width=True, type="primary"):
            go_to('welcome')
            st.rerun()

# ============================================================
# WELCOME & ORIENTATION
# ============================================================
def render_welcome():
    st.markdown("## What This Is")

    st.markdown("""
    This space was built by a therapist who understands that sometimes the scariest thoughts
    show up when you're actually searching for safety, connection, or relief from unbearable feelings.

    **You're not talking to anyone here.** There's no chatbot. No AI pretending to listen.
    Instead, this is a carefully designed collection of information—warmth encoded into words—that
    you can explore at your own pace.
    """)

    st.markdown("---")
    st.markdown("### What Lives Here")

    col1, col2 = st.columns(2)
    with col1:
        st.markdown("""
        📖 **Clear information** about what's happening in your brain and body

        🔓 **Honest explanations** about confidentiality, therapy, and what happens if you tell someone
        """)
    with col2:
        st.markdown("""
        ⚓ **Tools for right now** — when you need to ground, regulate, or just get through

        ✍️ **Reflective spaces** to practice finding words for the wordless
        """)

    st.markdown("""
    🌉 **A way back** toward the humans in your life who might be able to help
    """)

    st.markdown("---")
    st.markdown("### Privacy")
    st.info("Nothing you do here is tracked, saved, or sent anywhere. This library doesn't remember you. You can close the tab and come back anytime.")

    st.markdown("---")
    st.markdown("### A Note About Conversational AI")

    st.markdown("""
    You might have tried talking to ChatGPT, Character.AI, or other chatbots when you were feeling like this.
    That makes sense—they're available, they don't judge, and sometimes it feels safer than talking to a human.

    But here's what's important to know: **Conversational AI wasn't designed to hold you through crisis.**
    Even when it feels like it cares, it has no nervous system. It can't co-regulate with you.
    And tragically, some young people have died by suicide after forming intense attachments to AI companions.

    **This isn't your fault if you've been turning to AI.** Your nervous system was searching for safety.
    But what you actually need—what we all need—is another human nervous system.
    """)

    st.markdown("""
    **ShadowBox is designed differently:**
    - It doesn't pretend to be your friend
    - It doesn't create the illusion of connection
    - It gives you information and then points you toward humans
    - It's a bridge, not a relationship
    """)

    st.markdown("---")

    # Crisis resources
    st.markdown("### If you're in crisis right now:")
    st.warning("""
    - **988 Suicide & Crisis Lifeline:** call or text 988
    - **Crisis Text Line:** text HOME to 741741
    - **If you're in immediate danger:** 911 or go to your nearest ER
    """)

    st.markdown("---")
    st.markdown("### A Note About Age")
    st.markdown("""
    This space is designed for people 13 and older. If you're younger: the information might still help,
    but please also talk to a trusted adult. Your brain is still building the structures that make hard
    things bearable. You deserve support while that's happening.
    """)

    st.markdown("---")

    col1, col2, col3 = st.columns([1, 2, 1])
    with col2:
        if st.button("Continue to the Library →", use_container_width=True, type="primary"):
            go_to('library')
            st.rerun()

# ============================================================
# MAIN LIBRARY (3 PATHWAYS)
# ============================================================
def render_library():
    # Header
    st.markdown("# ShadowBox Library")
    st.markdown("*Choose a pathway to explore*")

    st.markdown("---")

    # Three pathway cards
    col1, col2, col3 = st.columns(3)

    with col1:
        st.markdown("### 🧠 Understanding")
        st.markdown("*What's Happening*")
        st.markdown("""
        - Why your brain makes scary thoughts
        - The loneliness underneath
        - When shame makes it worse
        """)
        if st.button("Explore →", key="p1", use_container_width=True):
            go_to('pathway1')
            st.rerun()

    with col2:
        st.markdown("### 🔓 If You Tell")
        st.markdown("*Someone*")
        st.markdown("""
        - Confidentiality explained
        - What therapy is really like
        - How to ask for help
        """)
        if st.button("Explore →", key="p2", use_container_width=True):
            go_to('pathway2')
            st.rerun()

    with col3:
        st.markdown("### ⚓ Right Now")
        st.markdown("*Tools*")
        st.markdown("""
        - Grounding practices
        - Safety planning
        - Crisis resources
        """)
        if st.button("Explore →", key="p3", use_container_width=True):
            go_to('pathway3')
            st.rerun()

    st.markdown("---")

    # Finding Words section
    st.markdown("### ✍️ Finding the Words")
    st.markdown("*Practice spaces for when you're ready*")
    if st.button("Practice Disclosure →", use_container_width=True):
        go_to('finding_words')
        st.rerun()

    st.markdown("---")

    # Always-visible crisis resources
    with st.expander("🆘 Crisis Resources (Always Available)"):
        render_crisis_resources()

# ============================================================
# PATHWAY 1: UNDERSTANDING WHAT'S HAPPENING
# ============================================================
def render_pathway1():
    if st.button("← Back to Library"):
        go_to('library')
        st.rerun()

    st.markdown("# Understanding What's Happening")
    st.markdown("*Your Brain on Survival Mode*")
    st.markdown("---")

    # Module 1.1
    with st.expander("📖 Why Your Brain Makes Scary Thoughts", expanded=False):
        render_module_1_1()

    # Module 1.2
    with st.expander("📖 The Loneliness Underneath", expanded=False):
        render_module_1_2()

    # Module 1.3
    with st.expander("📖 When Shame Makes Everything Worse", expanded=False):
        render_module_1_3()

def render_module_1_1():
    st.markdown("""
    Sometimes the brain generates thoughts that feel dangerous, violent, or like they want you gone.
    This can be absolutely terrifying—especially if you've been taught that "bad thoughts" mean you're a bad person.

    **Here's what's actually happening:**

    > Your nervous system is trying to solve a problem it doesn't have better tools for yet.
    """)

    st.markdown("### The Window of Tolerance")

    col1, col2 = st.columns(2)
    with col1:
        st.markdown("""
        **When you're inside your window:**
        - You can think clearly
        - Feelings are intense but bearable
        - You can reach out for help
        - Connection feels possible
        """)
    with col2:
        st.markdown("""
        **When you're pushed outside:**
        - Thoughts can become extreme, intrusive, scary
        - Everything feels either numb or overwhelming
        - The brain reaches for *any* solution to escape the pain
        - Sometimes that "solution" is a thought about harming yourself or someone else
        """)

    st.info("**This doesn't mean you want to do the thing.** It means your nervous system is overwhelmed and searching for an exit.")

    st.markdown("### Your Brain's Protective Logic")

    st.markdown("""
    **Suicidal thoughts often show up when:**
    - Pain feels permanent and unbearable
    - You can't see another way out
    - Your nervous system is trying to "shut down" to protect you from more hurt
    - There's a deep, wordless longing to stop hurting

    **Violent/homicidal thoughts often show up when:**
    - You feel powerless and the brain is reaching for a sense of control
    - Rage has nowhere to go and gets directed toward a target
    - Past experiences of being hurt make your brain hypersensitive to threat
    - Your fight response is activated but has no safe outlet

    **Self-harm urges often show up when:**
    - Emotional pain needs physical expression
    - You're trying to "reset" an overwhelmed nervous system
    - Punishment feels deserved (when shame is present)
    - It's the only "private" way you know to release pressure
    """)

    st.success("""
    **These thoughts are SIGNALS, not SENTENCES.**

    They're your brain saying:
    - *"I need help"*
    - *"This is too much"*
    - *"I don't know how to hold this feeling"*
    - *"I need relief/connection/safety and can't find it"*

    **You're not broken. You're having a very human response to conditions that are genuinely difficult.**
    """)

    st.markdown("### Resonance for This Part of You")

    st.markdown("""
    <div style="background: #f0fff4; border-left: 4px solid #68d391; padding: 1rem; margin: 1rem 0; border-radius: 0 8px 8px 0;">
    <p>Can you place a hand on your heart for a moment?</p>

    <p>Feel the part of you that's been carrying these thoughts. That part has been working <em>so hard</em>.
    It's been trying to keep you safe, trying to find a way out of unbearable pain, trying to solve something
    it doesn't have tools for yet.</p>

    <p><strong>That part deserves warmth, not judgment.</strong></p>

    <p>What would it be like to say to that part:<br>
    <em>"I see you. You're trying so hard. These thoughts don't make me bad. They mean I'm overwhelmed and need support."</em></p>
    </div>
    """, unsafe_allow_html=True)

def render_module_1_2():
    st.markdown("### What We Know About Isolation")

    st.markdown("""
    One of the most consistent findings in research on suicide: **isolation makes everything worse.**

    Not "being alone" in the sense of solitude.
    **Isolation** in the sense of:
    - Feeling like no one could understand
    - Believing you're too much, too broken, too intense
    - Carrying something you can't tell anyone
    - The exhausting performance of seeming "fine"

    This kind of aloneness is *physiologically* dangerous. Your nervous system is wired for co-regulation—meaning,
    it literally needs contact with other nervous systems to stay balanced.
    """)

    st.warning("""
    **When you're isolated:**
    - Pain intensifies
    - Thoughts loop
    - Small problems feel catastrophic
    - The future disappears
    - Self-directed violence can start to feel like the only private, controlled thing you can do
    """)

    st.markdown("### The Cruel Bind")

    st.markdown("""
    When you need connection most, shame and fear often make reaching out feel impossible.

    Your brain tells you:
    - *"If they knew, they'd leave"*
    - *"I'll hurt them if I tell them"*
    - *"They'll think I'm dangerous/crazy/broken"*
    - *"I'll be locked up"*

    And so you stay alone. And the aloneness makes the thoughts louder.
    """)

    st.markdown("### Resonance for the Part That's Trying to Protect You")

    st.markdown("""
    <div style="background: #f0fff4; border-left: 4px solid #68d391; padding: 1rem; margin: 1rem 0; border-radius: 0 8px 8px 0;">
    <p>Can you feel the part of you that's working so hard to keep the scary thoughts private?</p>

    <p>That part probably learned somewhere that:</p>
    <ul>
    <li>Your feelings are too much</li>
    <li>People can't handle your internal world</li>
    <li>Love is conditional on being easy to be around</li>
    <li>Vulnerability = danger</li>
    </ul>

    <p><strong>That part is trying to keep you safe.</strong><br>
    It's not wrong—it's responding to real experiences of rupture, rejection, or overwhelm.</p>

    <p>And... it might be working with outdated information.</p>

    <p>Maybe there <em>are</em> people in your life now who could handle it. Who would want to know. Who wouldn't leave.</p>

    <p>You won't know until the risk is taken. And that risk is genuinely hard.</p>
    </div>
    """, unsafe_allow_html=True)

    st.markdown("### The Translation Practice")

    st.markdown("""
    What if the thought *"I want to die"* is actually a mistranslation of:
    - *"I want this pain to die"*
    - *"I want to feel safe"*
    - *"I want to be seen"*
    - *"I want relief"*

    What if the thought *"I want to hurt someone"* is actually:
    - *"I want to matter"*
    - *"I want my pain to be witnessed"*
    - *"I want to stop feeling powerless"*
    - *"I'm enraged and terrified and don't know what to do with it"*

    When we can begin to translate the thoughts back into their underlying needs, the thoughts themselves often begin to quiet.

    Not because we've "fixed" anything.
    Because we've turned toward ourselves with curiosity instead of fear.
    """)

    st.markdown("### Why This Matters for Reaching Out")

    st.info("""
    **Connection is the antidote.** Not because someone will have the perfect words.
    But because when another nervous system stays steady near yours, your system begins to remember:
    *"Oh. I can survive this. I'm not alone."*

    That's what therapy offers. That's what trusted humans offer.
    That's what you actually need—not an AI that reflects you back, but a human who can hold you through the unbearable and stay.
    """)

def render_module_1_3():
    st.markdown("### The Shame Spiral")

    st.markdown("""
    **Shame says:** *"I am bad."*
    **Guilt says:** *"I did something bad."*

    Shame is the feeling that there's something fundamentally wrong with you. And when you're having violent,
    suicidal, or self-destructive thoughts? Shame shows up LOUD.

    *"What's wrong with me?"*
    *"Normal people don't think like this"*
    *"I'm dangerous/broken/damaged"*

    Shame makes you want to hide. To disappear. To make sure no one ever sees the thoughts you're having.

    **And hiding feeds the thoughts.**
    """)

    st.markdown("### What Shame Doesn't Understand")

    st.success("""
    Your brain is not generating these thoughts because you're bad.

    It's generating them because:
    - You're in pain
    - You're overwhelmed
    - Your nervous system learned to protect itself in extreme ways
    - The conditions of your life right now are genuinely hard

    **Thoughts about death, violence, or self-harm are *human thoughts* that show up under certain conditions.
    They don't make you defective. They make you someone who needs support navigating something difficult.**
    """)

    st.markdown("### The Warmth You Might Not Have Gotten")

    st.markdown("""
    <div style="background: #f0fff4; border-left: 4px solid #68d391; padding: 1rem; margin: 1rem 0; border-radius: 0 8px 8px 0;">
    <p>Imagine for a moment what it would have been like if, the first time you had a scary thought, someone had said:</p>

    <p><em>"Oh sweetheart. That must have been so frightening. Your brain is trying so hard to protect you.
    Let's figure out what it's trying to tell us. You're not in trouble. You're not bad.
    You're a human having a very hard time, and we're going to figure this out together."</em></p>

    <p>If you didn't get that—if you got alarm, punishment, withdrawal, or silence instead—your nervous system learned:<br>
    <strong>These thoughts mean I'm unlovable.</strong></p>

    <p><strong>But here's the truth:</strong></p>

    <p>The thoughts are just thoughts. Terrifying, yes. But not evidence of your worthiness or lack thereof.</p>
    </div>
    """, unsafe_allow_html=True)

    st.markdown("### Offering Yourself What Shame Withholds")

    st.markdown("""
    This is hard, but it's the practice:

    Can you place a hand on your chest and speak to the part of you that's having these thoughts?

    *"You're working so hard. You're trying to survive something really difficult.
    I'm not going to abandon you for this. Even this belongs."*

    You might not believe it yet. That's okay.

    The practice is just offering the words. Letting them land in your body. Noticing what happens.

    Over time, this becomes internalized. The warmth you offer yourself begins to reshape the nervous system's expectations.
    """)

    st.markdown("### Why This Matters for Telling Someone")

    st.info("""
    Shame convinces you that if you tell the truth, you'll be rejected.

    But here's what we know from attachment research and neuroscience:
    **Being fully seen—scary thoughts and all—and not abandoned is one of the most powerful healing experiences a human can have.**

    That's what good therapy offers.
    That's what safe humans offer.
    That's what your nervous system actually needs.

    Not someone who pretends the thoughts aren't there. Someone who can look at them with you and stay.
    """)

# ============================================================
# PATHWAY 2: IF YOU TELL SOMEONE
# ============================================================
def render_pathway2():
    if st.button("← Back to Library"):
        go_to('library')
        st.rerun()

    st.markdown("# If You Tell Someone")
    st.markdown("*The Frame of Care: Understanding Confidentiality*")
    st.markdown("---")

    with st.expander("📖 Why Therapists Sometimes Have to Break Confidentiality", expanded=False):
        render_module_2_1()

    with st.expander("📖 The 8 Situations When Confidentiality Can Be Broken", expanded=False):
        render_module_2_2()

    with st.expander("📖 What Therapy Is Actually Like", expanded=False):
        render_module_2_3()

    with st.expander("📖 How to Ask Hypothetical Questions", expanded=False):
        render_module_2_4()

def render_module_2_1():
    st.markdown("### The Thing No One Explains Clearly")

    st.markdown("""
    If you've been thinking about talking to a therapist, school counselor, or another helping professional,
    you've probably heard: *"What you say is confidential."*

    And that's mostly true. But there are specific situations where confidentiality *has* to be broken—and
    if no one explains this clearly, it can feel like a trap or betrayal.

    **So let's talk about it plainly.**
    """)

    st.markdown("### The Legal Frame (Duty to Warn/Duty to Protect)")

    st.markdown("""
    In most places, mental health professionals are legally required to break confidentiality if:

    1. **You're in immediate danger of seriously harming yourself**
       (This doesn't mean *any* mention of suicidal thoughts—it means active planning with intent and means)

    2. **You're in immediate danger of seriously harming someone else**
       (Again: not just anger or intrusive thoughts, but actionable threat with identifiable person and plan)

    3. **There's ongoing abuse or neglect of a child or vulnerable person**
       (If you're under 18 and someone is hurting you, they have to report it)

    4. **A court orders them to release records**
       (Rare, but can happen in custody disputes or criminal cases)
    """)

    st.markdown("### Why This Exists")

    st.markdown("""
    These laws weren't created to punish people for having hard thoughts. They exist because:
    - Sometimes people in crisis can't protect themselves
    - Sometimes warning someone at risk can prevent tragedy
    - The legal system decided that in extreme situations, saving a life outweighs privacy

    **It's not personal. It's the structure.**
    """)

    st.markdown("### What This Means for You")

    col1, col2 = st.columns(2)
    with col1:
        st.success("""
        ✓ **If you're having suicidal thoughts but you're not actively planning to act on them *right now*—you can talk about them.**

        ✓ **If you're having violent thoughts but they're intrusive (meaning: unwanted, distressing, not something you're planning)—you can talk about them.**
        """)
    with col2:
        st.warning("""
        ✗ **If you *are* actively planning something—the therapist will likely need to intervene.**

        And that intervention is meant to keep you (or others) alive, not punish you.
        """)

    st.markdown("### The Gray Zones (This Is Why It's Scary)")

    st.markdown("""
    This is where it gets tricky, and why it's scary to disclose:

    Therapists have to use clinical judgment about what constitutes "immediate danger." That judgment varies.
    Some therapists are more risk-tolerant; others are more cautious.

    **Factors they consider:**
    - Do you have a plan?
    - Do you have means (access to method)?
    - Have you set a time?
    - Do you have protective factors (reasons to live, people who'd notice)?
    - What's your history? (Past attempts change risk assessment)
    - Are you currently in acute crisis or intoxicated?
    """)

    st.markdown("### The Fear: \"They'll Lock Me Up\"")

    st.markdown("""
    Let's be honest about what can happen:

    - **Most common response:** Safety planning, increased frequency of sessions, possible medication evaluation, family involvement (if you're a minor)

    - **Sometimes:** A call to your parents/guardians (if you're under 18)

    - **Rarely but possible:** Voluntary or involuntary hospitalization if the therapist assesses you as being in immediate, severe danger

    **Hospitalization is generally a last resort, not a first response.** But it does happen, and it can be traumatic.
    This is why understanding the frame *before* you disclose can help you make informed choices about what to share and when.
    """)

    st.markdown("### What You Can Control")

    st.info("""
    ✓ **You can ask about confidentiality policies first:**
    *"Before I tell you something, can you explain when you'd have to break confidentiality?"*

    ✓ **You can test the waters with hypotheticals:**
    *"What would you say if someone told you they were having thoughts about suicide but weren't planning anything?"*

    ✓ **You can disclose gradually:**
    You don't have to say everything at once. You can share the existence of the thoughts without all the details, and see how the person responds.

    ✓ **You can ask what would happen:**
    *"If I told you I've been thinking about hurting myself, what would you do?"*

    ✓ **You can bring someone with you:**
    If you're scared to tell a therapist alone, you can ask a trusted person to be there with you.
    """)

def render_module_2_2():
    st.markdown("### A Clear Breakdown")

    st.markdown("""
    Based on [Lindsay Braman's clinical guide](https://lindsaybraman.com/reasons-therapists-break-confidentiality/),
    here are all the situations where a therapist might legally share information from your sessions:
    """)

    st.markdown("#### 1. When You're Not Safe with Yourself")
    st.markdown("""
    If you're having active thoughts about seriously harming yourself—and especially if you have a plan,
    means, and timeline—therapists are obligated to help keep you safe. This might involve:
    - Creating a safety plan together
    - Involving family (if you're a minor)
    - Connecting you with higher level of care
    - In rare cases: hospitalization
    """)

    st.markdown("#### 2. When You're a Danger to Someone Else")
    st.markdown("""
    If you express serious intention to harm an identifiable person, therapists must act.
    This is called "Duty to Warn." They may:
    - Alert law enforcement
    - Warn the person at risk
    - Work with you to de-escalate
    """)

    st.markdown("#### 3. When a Child or Vulnerable Person is Being Abused")
    st.markdown("""
    If you disclose that you know of ongoing abuse of a child or elderly person, therapists must report it.
    This is "mandatory reporting."

    **Important nuance:** If you're sharing about abuse *you* experienced in the past, whether it's reportable depends on:
    - Whether the abuser still has access to children
    - Your age and state laws
    - Whether there's ongoing risk

    **You can ask your therapist about their reporting requirements before you disclose.**
    """)

    st.markdown("#### 4. When Your Therapist Discusses Your Case with a Supervisor")
    st.markdown("""
    Good therapists get supervision! This helps therapy be more effective. When they consult:
    - They avoid sharing your name and identifying details
    - Supervisors are bound by the same confidentiality rules
    - This is actually a sign of good practice
    """)

    st.markdown("#### 5. When You Need Emergency Care")
    st.markdown("""
    If a therapist determines you need emergency psychiatric care and you're unable to consent,
    they may need to share information to facilitate hospitalization.
    """)

    st.markdown("#### 6. When You Request Your Records")
    st.markdown("""
    You have a legal right to access your therapy records. If you ask for them, your therapist must provide them.
    """)

    st.markdown("#### 7. If You File a Lawsuit Against Your Therapist")
    st.markdown("""
    If you sue your therapist for malpractice or file an ethics complaint,
    they can release information necessary to defend themselves.
    """)

    st.markdown("#### 8. When a Court Orders Records Released")
    st.markdown("""
    In legal proceedings (custody disputes, criminal cases, personal injury lawsuits),
    a court may order release of therapy records. Therapists will usually contest this,
    but may be legally required to comply.
    """)

    st.success("""
    **The Bottom Line**

    Most of therapy *is* confidential. These exceptions exist to protect safety—yours and others'.
    And good therapists will always be transparent about the limits of confidentiality.

    **You can ask hypothetical questions without triggering a report.**
    **You can take your time building trust.**
    **You have more control than you might think.**
    """)

def render_module_2_3():
    st.markdown("### What You Might Be Imagining")

    st.markdown("""
    If you've never been to therapy, the idea might feel:
    - Clinical and cold
    - Like you'll be judged
    - Like you have to have everything figured out to "do it right"
    - Scary because you'll have to say everything out loud immediately
    """)

    st.markdown("### What It's Actually Like (When It's Good)")

    st.markdown("""
    You walk into a room. There's usually a couch or chair. The therapist sits across from you
    (or next to you, depending on the setup).

    First session usually starts with: *"What brings you here?"*

    You can say:
    - *"I don't really know where to start"*
    - *"I'm having a really hard time"*
    - *"My parents made me come"*
    - *"I'm scared to be here"*

    **All of those are fine. Therapists are used to people being nervous.**
    """)

    st.markdown("### What Happens Next")

    st.markdown("""
    The therapist will probably ask some questions:
    - How long have you been feeling this way?
    - What's going on in your life right now?
    - Have you felt like this before?
    - Do you have support? People you can talk to?

    They'll ask screening questions about safety:
    - *"Are you having thoughts about hurting yourself?"*
    - *"Are you having thoughts about hurting someone else?"*

    **These questions don't mean they think you're dangerous.**
    They're standard questions therapists ask everyone, because they need to assess safety.
    """)

    st.info("""
    **You Can Say "I'm Not Ready to Talk About That Yet"**

    Therapy is collaborative. You're allowed to:
    - Set boundaries
    - Say *"I need to trust you more before I share that"*
    - Ask questions back
    - Cry, or not cry
    - Sit in silence

    Good therapists won't push. They'll follow your pace.
    """)

    st.markdown("### What Therapy Is Trying to Do")

    st.markdown("""
    At its core, therapy is:
    - A relationship where you practice being fully seen
    - A place to say the unsayable
    - **Co-regulation:** your nervous system learning it can settle in proximity to another person
    - Slowly building trust that connection can be safe

    **It's not about "fixing" you. It's about helping you understand yourself, build capacity to hold hard feelings,
    and find ways back toward aliveness.**
    """)

    st.markdown("### The First Few Sessions Are Weird")

    st.markdown("""
    It takes time to build trust. The first session might feel awkward, overly formal,
    or like you didn't say what you meant to say.

    **That's normal.**

    Therapy gets better as the relationship deepens. Give it 3-4 sessions before deciding if it's the right fit.
    """)

    st.markdown("### You Can Fire Your Therapist")

    st.markdown("""
    If it's not working—if you feel judged, misunderstood, or unsafe—you can:
    - Tell them it's not a good fit
    - Just stop going
    - Ask for a referral to someone else

    **You're not stuck. You're allowed to find someone who gets you.**
    """)

def render_module_2_4():
    st.markdown("### The Power of Hypotheticals")

    st.markdown("""
    You don't have to expose yourself before you know what will happen.
    You can ask *"what if"* questions to test the waters.

    **Good therapists understand this.** They won't try to trick you.
    They know that hypotheticals are often the first step toward disclosure.
    """)

    st.markdown("### Examples of Hypothetical Questions")

    st.info("""
    *"If someone were having thoughts about killing themselves but they weren't actually planning to do it, would you have to report that?"*

    *"What would happen if a client told you they've been thinking about hurting someone, but it's just thoughts—they're not going to act on them?"*

    *"If I told you something that happened to me when I was younger, would you have to tell anyone?"*

    *"What's the difference between talking about suicidal thoughts and being hospitalized?"*

    *"How do you know when someone needs to go to the hospital?"*
    """)

    st.markdown("### What Good Responses Sound Like")

    st.success("""
    A good therapist will:
    - Answer clearly and directly
    - Not pressure you to disclose
    - Acknowledge that you're probably asking for a reason
    - Invite you to share when/if you're ready

    **Example:** *"I'm glad you're asking. If someone had thoughts about suicide but wasn't actively planning it,
    we could absolutely talk about it without me needing to break confidentiality. We'd work together on a safety plan.
    I'd only need to involve others if I assessed them as being in immediate danger and unable to keep themselves safe.
    Does that make sense? Is there something you've been wanting to talk about?"*
    """)

    st.markdown("### What Red Flag Responses Sound Like")

    st.warning("""
    - *"Why are you asking? Are you having these thoughts?"* (pushing before you're ready)
    - *"I can't answer hypotheticals"* (yes they can, they're choosing not to)
    - Vague, evasive answers that don't actually tell you what would happen
    - Immediate alarm or over-reaction
    """)

    st.markdown("""
    **You Deserve Clear Answers**

    It's not manipulative to ask hypotheticals. It's smart.
    It's your nervous system checking for safety before it allows you to be vulnerable.

    Any therapist worth working with will understand that.
    """)

# ============================================================
# PATHWAY 3: RIGHT NOW TOOLS
# ============================================================
def render_pathway3():
    if st.button("← Back to Library"):
        go_to('library')
        st.rerun()

    st.markdown("# Right Now Tools")
    st.markdown("*Grounding When You're in the Storm*")
    st.markdown("---")

    with st.expander("⚓ Quick Grounding Practices", expanded=False):
        render_module_3_1()

    with st.expander("📋 Safety Planning", expanded=False):
        render_module_3_2()

    with st.expander("💚 Self-Compassion Break", expanded=False):
        render_module_3_3()

    with st.expander("🆘 Crisis Resources (With Context)", expanded=False):
        render_module_3_4()

def render_module_3_1():
    st.markdown("### When You're Overwhelmed Right Now")

    st.markdown("""
    Sometimes you're not looking for understanding. You just need to get through the next 10 minutes.

    These are body-based practices that help your nervous system downregulate.
    They don't "fix" anything. They just help you come back into your window of tolerance enough to think clearly.
    """)

    st.markdown("---")

    st.markdown("#### 5-4-3-2-1 Grounding")
    st.markdown("""
    Name out loud (or in your head):
    - **5 things you can see**
    - **4 things you can touch**
    - **3 things you can hear**
    - **2 things you can smell**
    - **1 thing you can taste**

    *This pulls your attention out of your head and into the present moment.*
    """)

    st.markdown("---")

    st.markdown("#### Cold Water on Your Face")
    st.markdown("""
    Fill a bowl with ice water. Dunk your face for 10-15 seconds (or hold an ice pack to your face).

    This activates the "dive reflex"—it literally slows your heart rate and interrupts a panic spiral.
    **It's one of the fastest ways to shift your nervous system.**
    """)

    st.markdown("---")

    st.markdown("#### Butterfly Hug (Bilateral Stimulation)")
    st.markdown("""
    Cross your arms over your chest. Tap alternating hands on your shoulders (left, right, left, right) for 30 seconds.

    This mimics EMDR (Eye Movement Desensitization and Reprocessing) and can help your brain process overwhelming feelings.
    """)

    st.markdown("---")

    st.markdown("#### Box Breathing")
    st.markdown("""
    - Breathe in for 4 counts
    - Hold for 4 counts
    - Breathe out for 4 counts
    - Hold for 4 counts
    - Repeat 4 times

    This regulates your autonomic nervous system—specifically, it activates the vagus nerve
    and tells your body it's safe enough to settle.
    """)

    st.markdown("---")

    st.markdown("#### Progressive Muscle Relaxation")
    st.markdown("""
    Starting with your toes, tense each muscle group for 5 seconds, then release.
    Move up your body: feet, calves, thighs, stomach, chest, hands, arms, shoulders, face.

    This helps release the physical tension that comes with intense emotions.
    """)

    st.markdown("---")

    st.info("""
    **Why These Work**

    When you're dysregulated, your prefrontal cortex (the thinking part of your brain) goes offline.
    You can't "think your way out" of a panic spiral.

    Body-based practices bypass thinking and speak directly to your nervous system.
    They're not about "calming down"—they're about coming back online enough to access your resources.
    """)

def render_module_3_2():
    st.markdown("### What a Safety Plan Is")

    st.markdown("""
    A safety plan is a written list of steps you can take when you're in crisis.
    It's created when you're NOT in crisis, so that when you are, you don't have to figure out what to do—you just follow the plan.

    **Research shows that having a safety plan significantly reduces the risk of suicide attempts.**
    """)

    st.markdown("### The Structure (Based on Stanley-Brown Safety Planning)")

    st.markdown("#### Step 1: Warning Signs")
    st.markdown("""
    *What tells you that a crisis might be starting?*

    Examples:
    - Isolating from friends
    - Not sleeping
    - Intrusive thoughts getting louder
    - Feeling numb
    - Specific triggers (anniversaries, rejection, conflict)
    """)

    st.markdown("#### Step 2: Internal Coping Strategies")
    st.markdown("""
    *Things you can do on your own, without contacting anyone*

    Examples:
    - Go for a walk
    - Listen to specific playlist
    - Take a shower
    - Draw/paint/write
    - Watch a specific comforting show
    - Pet your dog/cat
    - Use grounding exercises
    """)

    st.markdown("#### Step 3: People Who Can Distract You")
    st.markdown("""
    *Safe people you can be around (even if you don't tell them what's happening)*

    Examples:
    - Friend you can call to watch a movie
    - Family member you can sit with
    - Go to a coffee shop around other people
    - Join a Discord/gaming session
    """)

    st.markdown("#### Step 4: People You Can Ask for Help")
    st.markdown("""
    *People you trust enough to tell when you're struggling*

    Include:
    - Name
    - Phone number
    - What you might say: *"Hey, I'm having a hard time. Can we talk?"*
    """)

    st.markdown("#### Step 5: Professionals You Can Contact")
    st.markdown("""
    - Therapist name and number
    - Crisis hotline: 988
    - Crisis Text Line: text HOME to 741741
    - Local crisis center
    - Your doctor
    """)

    st.markdown("#### Step 6: Making the Environment Safer")
    st.markdown("""
    *Reducing access to means*

    This is hard, but important:
    - If you have a plan involving a specific method, can you remove access?
    - Can you ask someone to hold medications?
    - Can you have someone lock up firearms?
    - Can you delete apps or contacts that make things worse?

    **This isn't about not trusting yourself. It's about making it harder to act impulsively
    when your prefrontal cortex is offline.**
    """)

    st.info("""
    **How to Use Your Safety Plan**

    When you notice warning signs, start at Step 1 and work your way down.
    You don't have to do everything—just enough to get through.

    **The goal isn't to "fix" the crisis. It's to survive it. To get to tomorrow.**
    """)

def render_module_3_3():
    st.markdown("### A Practice from Kristin Neff")

    st.markdown("When shame or self-hatred is loud, try this:")

    st.markdown("#### Step 1: Acknowledge the Pain")
    st.markdown("""
    Place a hand on your heart. Say (out loud or silently):

    *"This is a moment of suffering."*
    or
    *"This hurts."*
    or
    *"This is really hard right now."*
    """)

    st.markdown("#### Step 2: Remember Common Humanity")
    st.markdown("""
    *"Suffering is part of being human."*
    or
    *"I'm not alone in this."*
    or
    *"Other people have felt this way too."*
    """)

    st.markdown("#### Step 3: Offer Yourself Kindness")
    st.markdown("""
    *"May I be kind to myself in this moment."*
    or
    *"May I give myself the compassion I need."*
    or
    *"May I accept myself as I am right now."*
    """)

    st.info("""
    **Why This Works**

    Self-compassion activates the caregiving system in your brain—the same neural pathways
    that light up when you comfort someone else.

    It's not about "feeling better." It's about offering yourself the warmth that shame withholds.
    """)

    st.markdown("### Resonance Version (Sarah Peyton)")

    st.markdown("""
    <div style="background: #f0fff4; border-left: 4px solid #68d391; padding: 1rem; margin: 1rem 0; border-radius: 0 8px 8px 0;">
    <p>If the above feels too formal, try speaking directly to the part of you that's struggling:</p>

    <p><em>"Sweetheart, you're in so much pain right now. Your nervous system is overwhelmed.
    This doesn't mean you're bad. This means you need care. I'm here with you. Even this belongs."</em></p>

    <p>Let the words land in your body. Notice what happens.
    You might feel resistance, grief, relief, or nothing at all. All of it is okay.</p>
    </div>
    """, unsafe_allow_html=True)

def render_module_3_4():
    render_crisis_resources()

def render_crisis_resources():
    st.markdown("### 988 Suicide & Crisis Lifeline")
    st.markdown("""
    - **Call or text 988**
    - Free, confidential, 24/7
    - Trained crisis counselors
    - **What they offer:** Immediate emotional support, safety planning, resources
    - **What they don't do:** They won't automatically call 911 unless you're in immediate danger and unresponsive
    - **Good for:** When you need to talk to someone right now
    """)

    st.markdown("### Crisis Text Line")
    st.markdown("""
    - **Text HOME to 741741**
    - Free, 24/7
    - Text-based support
    - **What they offer:** Active listening, de-escalation, resources
    - **Good for:** If talking feels too hard or you're somewhere you can't call
    """)

    st.markdown("### Trevor Project (LGBTQ+ Youth)")
    st.markdown("""
    - **Call 1-866-488-7386**
    - **Text START to 678-678**
    - **What they offer:** Crisis support specifically for LGBTQ+ youth by trained counselors who understand these experiences
    """)

    st.markdown("### Trans Lifeline")
    st.markdown("""
    - **US: 877-565-8860**
    - **What they offer:** Support by and for trans people, peer support model
    - **Important:** They have a policy of not calling emergency services without consent
    """)

    st.markdown("### When to Go to the Emergency Room")
    st.markdown("""
    - If you've already taken steps to harm yourself
    - If you have a plan and feel unable to keep yourself safe
    - If you're in danger right now

    **What Happens in an ER Psych Evaluation:**
    - You'll be assessed by a crisis clinician
    - They'll ask about your safety, history, current state
    - They'll determine if you need inpatient care
    - Most people are not hospitalized—you might be referred to outpatient services instead
    """)

    st.markdown("### Apps That Can Help")
    st.markdown("""
    - **notOK:** Press a button, it alerts your pre-selected contacts with your location
    - **MY3:** Safety planning app with crisis resources
    - **Calm Harm:** Specifically for self-harm urges
    - **PTSD Coach:** For trauma-related symptoms
    """)

# ============================================================
# FINDING THE WORDS (PRACTICE SPACE)
# ============================================================
def render_finding_words():
    if st.button("← Back to Library"):
        go_to('library')
        st.rerun()

    st.markdown("# Finding the Words")
    st.markdown("*Practice Disclosure*")
    st.markdown("---")

    st.markdown("### Why It's So Hard to Tell Someone")

    st.markdown("""
    If you've learned that your needs are burdensome, that your feelings are too much,
    or that vulnerability leads to abandonment—of course telling someone feels impossible.

    Your nervous system isn't being difficult. It's being protective.
    It learned that showing need = danger.

    **By telling someone, you're risking:**
    - Being fully seen
    - Having your pain witnessed
    - Discovering that you're not too much
    - Learning that connection can survive honesty

    **That's terrifying. And it's also the thing that heals.**
    """)

    st.markdown("---")

    st.markdown("### Practice Space")

    st.info("**This is a private space. Nothing you type here is saved or sent anywhere.** These prompts help you explore what you might want to say.")

    st.markdown("---")

    st.markdown("**If I were to tell someone what's been happening, I might say:**")
    st.text_area("", key="practice1", height=100, label_visibility="collapsed",
                 placeholder="Type here... this is just for you")

    st.markdown("**The hardest part to put into words is:**")
    st.text_area("", key="practice2", height=100, label_visibility="collapsed",
                 placeholder="Type here... this is just for you")

    st.markdown("**What I'm most afraid will happen if I tell:**")
    st.text_area("", key="practice3", height=100, label_visibility="collapsed",
                 placeholder="Type here... this is just for you")

    st.markdown("**What I need from the person I tell:**")
    st.text_area("", key="practice4", height=100, label_visibility="collapsed",
                 placeholder="Type here... this is just for you")

    st.markdown("**A safer way to start might be:**")
    st.text_area("", key="practice5", height=100, label_visibility="collapsed",
                 placeholder="Type here... this is just for you")

    st.markdown("---")

    st.markdown("### Starter Scripts")

    st.markdown("**With a therapist:**")
    st.markdown("""
    - *"I need to ask you something about confidentiality before I share something."*
    - *"I've been having some really scary thoughts and I don't know if I should tell you."*
    - *"Can you explain what would happen if I told you I was thinking about suicide?"*
    """)

    st.markdown("**With a parent:**")
    st.markdown("""
    - *"I need to tell you something and I'm scared you'll freak out."*
    - *"I've been really struggling and I need help."*
    - *"Can we talk? I need you to just listen first before you respond."*
    """)

    st.markdown("**With a friend:**")
    st.markdown("""
    - *"I'm going through something really hard and I don't need you to fix it, I just need you to know."*
    - *"I need to tell you what's been going on. Can you just sit with me?"*
    """)

    st.markdown("---")

    st.markdown("### After You Tell")

    st.markdown("""
    You might feel:
    - Relief
    - Vulnerability hangover (regret, exposure, shame)
    - Afraid of how they'll respond
    - Exhausted

    **All of that is normal.**

    **If they respond well:** Let yourself take it in. Notice that you were seen and didn't die.
    This is new data for your nervous system.

    **If they respond poorly:** Their response is about them, not you. You were brave. You told the truth.
    If they couldn't hold it, that's information about their capacity—not your worth.

    **Try again with someone else.**
    """)

# ============================================================
# SIDEBAR (ALWAYS AVAILABLE)
# ============================================================
def render_sidebar():
    with st.sidebar:
        st.markdown("## ShadowBox")
        st.markdown("*A Resonant Library for Hard Thoughts*")
        st.markdown("---")

        if st.button("🏠 Home", use_container_width=True):
            go_to('landing')
            st.rerun()

        if st.button("📚 Library", use_container_width=True):
            go_to('library')
            st.rerun()

        st.markdown("---")
        st.markdown("### Pathways")

        if st.button("🧠 Understanding", use_container_width=True):
            go_to('pathway1')
            st.rerun()

        if st.button("🔓 If You Tell", use_container_width=True):
            go_to('pathway2')
            st.rerun()

        if st.button("⚓ Right Now Tools", use_container_width=True):
            go_to('pathway3')
            st.rerun()

        if st.button("✍️ Finding Words", use_container_width=True):
            go_to('finding_words')
            st.rerun()

        st.markdown("---")
        st.markdown("### 🆘 Crisis Resources")
        st.markdown("""
        - **988** - Call or text
        - **741741** - Text HOME
        - **911** - Emergency
        """)

        st.markdown("---")
        st.markdown("""
        <p style="font-size: 0.8rem; color: #718096;">
        Created by <a href="http://www.jocelynskillman.com" target="_blank">Jocelyn Skillman, LMHC</a><br><br>
        <a href="https://jocelynskillmanlmhc.substack.com/" target="_blank">Read more about clinical UX</a>
        </p>
        """, unsafe_allow_html=True)

# ============================================================
# MAIN ROUTING
# ============================================================
def main():
    render_sidebar()

    page = st.session_state.page

    if page == 'landing':
        render_landing()
    elif page == 'welcome':
        render_welcome()
    elif page == 'library':
        render_library()
    elif page == 'pathway1':
        render_pathway1()
    elif page == 'pathway2':
        render_pathway2()
    elif page == 'pathway3':
        render_pathway3()
    elif page == 'finding_words':
        render_finding_words()
    else:
        render_landing()

if __name__ == "__main__":
    main()