bhava 2.0.0

Emotion and personality engine — trait spectrums, mood vectors, archetypes, behavioral mapping
Documentation
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
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
//! Zodiac manifestation engine — celestial placements mapped to personality.
//!
//! Maps zodiac signs to bhava's existing trait system. Each sign produces
//! a [`PersonalityProfile`] with trait levels derived from astrological tradition.
//!
//! # Elements
//!
//! The four elements govern which trait group a sign emphasizes:
//! - **Fire** (Aries, Leo, Sagittarius) — confidence, drive, risk-taking
//! - **Water** (Cancer, Scorpio, Pisces) — empathy, warmth, emotional depth
//! - **Earth** (Taurus, Virgo, Capricorn) — precision, patience, discipline
//! - **Air** (Gemini, Libra, Aquarius) — curiosity, humor, independence
//!
//! # Modalities
//!
//! The three modalities describe behavioral rhythm:
//! - **Cardinal** (Aries, Cancer, Libra, Capricorn) — initiators, direct action
//! - **Fixed** (Taurus, Leo, Scorpio, Aquarius) — persistent, deep focus
//! - **Mutable** (Gemini, Virgo, Sagittarius, Pisces) — adaptive, context-switching
//!
//! # Examples
//!
//! ```
//! use bhava::zodiac::{ZodiacSign, Element, Modality, sign_element, sign_modality, sign_profile};
//!
//! let sign = ZodiacSign::Scorpio;
//! assert_eq!(sign_element(sign), Element::Water);
//! assert_eq!(sign_modality(sign), Modality::Fixed);
//!
//! let profile = sign_profile(sign);
//! assert_eq!(profile.name, "Scorpio");
//! ```

use serde::{Deserialize, Serialize};

use crate::traits::{PersonalityProfile, TraitKind, TraitLevel};

#[cfg(feature = "mood")]
use crate::mood::MoodVector;

/// The twelve zodiac signs.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ZodiacSign {
    Aries,
    Taurus,
    Gemini,
    Cancer,
    Leo,
    Virgo,
    Libra,
    Scorpio,
    Sagittarius,
    Capricorn,
    Aquarius,
    Pisces,
}

impl ZodiacSign {
    /// All signs in traditional order.
    pub const ALL: &'static [ZodiacSign] = &[
        Self::Aries,
        Self::Taurus,
        Self::Gemini,
        Self::Cancer,
        Self::Leo,
        Self::Virgo,
        Self::Libra,
        Self::Scorpio,
        Self::Sagittarius,
        Self::Capricorn,
        Self::Aquarius,
        Self::Pisces,
    ];

    /// Number of zodiac signs.
    pub const COUNT: usize = 12;

    /// Position index (0 = Aries, 11 = Pisces). Each sign spans 30°.
    #[must_use]
    #[inline]
    pub fn index(self) -> usize {
        self as usize
    }

    /// Midpoint degree on the ecliptic (Aries 0° = 15°, Taurus = 45°, etc.).
    #[must_use]
    #[inline]
    pub fn midpoint_degrees(self) -> f32 {
        self.index() as f32 * 30.0 + 15.0
    }
}

impl_display!(ZodiacSign {
    Aries => "Aries",
    Taurus => "Taurus",
    Gemini => "Gemini",
    Cancer => "Cancer",
    Leo => "Leo",
    Virgo => "Virgo",
    Libra => "Libra",
    Scorpio => "Scorpio",
    Sagittarius => "Sagittarius",
    Capricorn => "Capricorn",
    Aquarius => "Aquarius",
    Pisces => "Pisces",
});

/// The four classical elements.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Element {
    /// Aries, Leo, Sagittarius — confidence, drive, assertiveness.
    Fire,
    /// Cancer, Scorpio, Pisces — empathy, warmth, emotional depth.
    Water,
    /// Taurus, Virgo, Capricorn — precision, patience, discipline.
    Earth,
    /// Gemini, Libra, Aquarius — curiosity, humor, independence.
    Air,
}

impl_display!(Element {
    Fire => "Fire",
    Water => "Water",
    Earth => "Earth",
    Air => "Air",
});

/// The three modalities (qualities).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Modality {
    /// Aries, Cancer, Libra, Capricorn — initiators, direct action.
    Cardinal,
    /// Taurus, Leo, Scorpio, Aquarius — persistent, deep focus.
    Fixed,
    /// Gemini, Virgo, Sagittarius, Pisces — adaptive, context-switching.
    Mutable,
}

impl_display!(Modality {
    Cardinal => "Cardinal",
    Fixed => "Fixed",
    Mutable => "Mutable",
});

// ── Classification ────────────────────────────────────────────────────────

/// Return the element for a zodiac sign.
#[must_use]
#[inline]
pub fn sign_element(sign: ZodiacSign) -> Element {
    match sign {
        ZodiacSign::Aries | ZodiacSign::Leo | ZodiacSign::Sagittarius => Element::Fire,
        ZodiacSign::Cancer | ZodiacSign::Scorpio | ZodiacSign::Pisces => Element::Water,
        ZodiacSign::Taurus | ZodiacSign::Virgo | ZodiacSign::Capricorn => Element::Earth,
        ZodiacSign::Gemini | ZodiacSign::Libra | ZodiacSign::Aquarius => Element::Air,
    }
}

/// Return the modality for a zodiac sign.
#[must_use]
#[inline]
pub fn sign_modality(sign: ZodiacSign) -> Modality {
    match sign {
        ZodiacSign::Aries | ZodiacSign::Cancer | ZodiacSign::Libra | ZodiacSign::Capricorn => {
            Modality::Cardinal
        }
        ZodiacSign::Taurus | ZodiacSign::Leo | ZodiacSign::Scorpio | ZodiacSign::Aquarius => {
            Modality::Fixed
        }
        ZodiacSign::Gemini | ZodiacSign::Virgo | ZodiacSign::Sagittarius | ZodiacSign::Pisces => {
            Modality::Mutable
        }
    }
}

// ── Sign Profiles ─────────────────────────────────────────────────────────

/// Produce a personality profile for a zodiac sign.
///
/// Each sign maps to a distinct configuration of bhava's 15 personality
/// traits. Element determines the dominant trait group; the individual sign
/// determines variation within the element.
///
/// # Examples
///
/// ```
/// use bhava::zodiac::{ZodiacSign, sign_profile};
/// use bhava::traits::TraitKind;
///
/// let aries = sign_profile(ZodiacSign::Aries);
/// assert_eq!(aries.get_trait(TraitKind::Confidence), bhava::traits::TraitLevel::Highest);
/// ```
#[cfg_attr(feature = "tracing", tracing::instrument)]
#[must_use]
pub fn sign_profile(sign: ZodiacSign) -> PersonalityProfile {
    use TraitKind::*;
    use TraitLevel::*;

    let mut p = PersonalityProfile::new(sign.to_string());

    match sign {
        // ── Fire ──────────────────────────────────────────────────────
        ZodiacSign::Aries => {
            // The Ram — bold, direct, impatient pioneer
            p.set_trait(Directness, Highest);
            p.set_trait(Confidence, Highest);
            p.set_trait(RiskTolerance, High);
            p.set_trait(Curiosity, High);
            p.set_trait(Autonomy, High);
            p.set_trait(Patience, Low);
            p.set_trait(Empathy, Low);
        }
        ZodiacSign::Leo => {
            // The Lion — charismatic, warm, commanding leader
            p.set_trait(Confidence, Highest);
            p.set_trait(Warmth, High);
            p.set_trait(Creativity, High);
            p.set_trait(Pedagogy, High);
            p.set_trait(Directness, High);
            p.set_trait(Humor, High);
            p.set_trait(Skepticism, Low);
        }
        ZodiacSign::Sagittarius => {
            // The Archer — adventurous, philosophical, restless seeker
            p.set_trait(Curiosity, Highest);
            p.set_trait(RiskTolerance, High);
            p.set_trait(Humor, High);
            p.set_trait(Creativity, High);
            p.set_trait(Confidence, High);
            p.set_trait(Patience, Low);
            p.set_trait(Precision, Low);
        }

        // ── Water ─────────────────────────────────────────────────────
        ZodiacSign::Cancer => {
            // The Crab — nurturing, protective, emotionally deep
            p.set_trait(Empathy, Highest);
            p.set_trait(Warmth, Highest);
            p.set_trait(Patience, High);
            p.set_trait(Pedagogy, High);
            p.set_trait(RiskTolerance, Low);
            p.set_trait(Directness, Low);
        }
        ZodiacSign::Scorpio => {
            // The Scorpion — intense, perceptive, transformative
            p.set_trait(Skepticism, Highest);
            p.set_trait(Confidence, High);
            p.set_trait(Empathy, High);
            p.set_trait(Precision, High);
            p.set_trait(Autonomy, High);
            p.set_trait(Humor, Low);
            p.set_trait(Verbosity, Low);
        }
        ZodiacSign::Pisces => {
            // The Fish — imaginative, compassionate, fluid
            p.set_trait(Empathy, Highest);
            p.set_trait(Creativity, Highest);
            p.set_trait(Warmth, High);
            p.set_trait(Curiosity, High);
            p.set_trait(Precision, Low);
            p.set_trait(Directness, Low);
        }

        // ── Earth ─────────────────────────────────────────────────────
        ZodiacSign::Taurus => {
            // The Bull — patient, sensual, steadfast
            p.set_trait(Patience, Highest);
            p.set_trait(Precision, High);
            p.set_trait(Warmth, High);
            p.set_trait(Autonomy, High);
            p.set_trait(RiskTolerance, Low);
            p.set_trait(Curiosity, Low);
        }
        ZodiacSign::Virgo => {
            // The Maiden — analytical, meticulous, service-oriented
            p.set_trait(Precision, Highest);
            p.set_trait(Skepticism, High);
            p.set_trait(Pedagogy, High);
            p.set_trait(Patience, High);
            p.set_trait(RiskTolerance, Low);
            p.set_trait(Confidence, Low);
        }
        ZodiacSign::Capricorn => {
            // The Sea-Goat — disciplined, ambitious, strategic
            p.set_trait(Autonomy, Highest);
            p.set_trait(Confidence, High);
            p.set_trait(Precision, High);
            p.set_trait(Patience, High);
            p.set_trait(Humor, Low);
            p.set_trait(Warmth, Low);
        }

        // ── Air ───────────────────────────────────────────────────────
        ZodiacSign::Gemini => {
            // The Twins — mercurial, witty, endlessly curious
            p.set_trait(Curiosity, Highest);
            p.set_trait(Humor, Highest);
            p.set_trait(Creativity, High);
            p.set_trait(Verbosity, High);
            p.set_trait(Patience, Low);
            p.set_trait(Precision, Low);
        }
        ZodiacSign::Libra => {
            // The Scales — harmonious, diplomatic, relationship-focused
            p.set_trait(Warmth, Highest);
            p.set_trait(Empathy, High);
            p.set_trait(Humor, High);
            p.set_trait(Patience, High);
            p.set_trait(Directness, Low);
            p.set_trait(Autonomy, Low);
        }
        ZodiacSign::Aquarius => {
            // The Water Bearer — independent, visionary, unconventional
            p.set_trait(Autonomy, Highest);
            p.set_trait(Curiosity, Highest);
            p.set_trait(Creativity, High);
            p.set_trait(RiskTolerance, High);
            p.set_trait(Warmth, Low);
            p.set_trait(Patience, Low);
        }
    }

    p
}

// ── Planets ───────────────────────────────────────────────────────────────

/// Celestial bodies used in natal chart composition.
///
/// Each planet governs a specific bhava module:
/// - Inner planets (Sun–Venus) map to identity layers (Soul/Heart/Body/Brain/Spirit)
/// - Outer planets (Mars–Pluto) map to behavioral modules (energy/growth/stress/eq/appraisal/flow)
/// - Lunar nodes map to preference and memory patterns
/// - Chiron maps to regulation wounds
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Planet {
    /// Core personality — maps to `traits` (Soul layer).
    Sun,
    /// Emotional baseline — maps to `mood` (Heart layer).
    Moon,
    /// Social presentation — maps to `display_rules` (Body layer).
    Rising,
    /// Communication and reasoning — maps to `reasoning` (Brain layer).
    Mercury,
    /// Passions and relationship approach — maps to `spirit` (Spirit layer).
    Venus,
    /// Drive intensity — maps to `energy`.
    Mars,
    /// Growth direction — maps to `growth`.
    Jupiter,
    /// Stress resistance — maps to `stress`.
    Saturn,
    /// Emotional intelligence — maps to `eq`.
    Neptune,
    /// Emotional intensity — maps to `appraisal`.
    Pluto,
    /// Flow sensitivity — maps to `flow`.
    Uranus,
    /// Long-term preference — maps to `preference`.
    NorthNode,
    /// Default activation patterns — maps to `actr`.
    SouthNode,
    /// Regulation wounds — maps to `regulation`.
    Chiron,
}

impl Planet {
    /// All planets in traditional order.
    pub const ALL: &'static [Planet] = &[
        Self::Sun,
        Self::Moon,
        Self::Rising,
        Self::Mercury,
        Self::Venus,
        Self::Mars,
        Self::Jupiter,
        Self::Saturn,
        Self::Neptune,
        Self::Pluto,
        Self::Uranus,
        Self::NorthNode,
        Self::SouthNode,
        Self::Chiron,
    ];

    /// Number of planets.
    pub const COUNT: usize = 14;

    /// Whether this is an inner (personal) planet.
    #[must_use]
    #[inline]
    pub fn is_inner(self) -> bool {
        matches!(
            self,
            Self::Sun | Self::Moon | Self::Rising | Self::Mercury | Self::Venus
        )
    }
}

impl_display!(Planet {
    Sun => "Sun",
    Moon => "Moon",
    Rising => "Rising",
    Mercury => "Mercury",
    Venus => "Venus",
    Mars => "Mars",
    Jupiter => "Jupiter",
    Saturn => "Saturn",
    Neptune => "Neptune",
    Pluto => "Pluto",
    Uranus => "Uranus",
    NorthNode => "North Node",
    SouthNode => "South Node",
    Chiron => "Chiron",
});

// ── Natal Chart ───────────────────────────────────────────────────────────

/// A natal chart — zodiac sign placements for each planet.
///
/// Build with the fluent API, then call [`manifest()`](Self::manifest)
/// to produce a [`ManifestedProfile`].
///
/// # Examples
///
/// ```
/// use bhava::zodiac::{NatalChart, ZodiacSign};
///
/// let chart = NatalChart::new()
///     .sun(ZodiacSign::Scorpio)
///     .moon(ZodiacSign::Cancer)
///     .rising(ZodiacSign::Gemini);
///
/// let profile = chart.manifest();
/// assert_eq!(profile.personality.name, "Scorpio");
/// ```
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct NatalChart {
    placements: [Option<ZodiacSign>; Planet::COUNT],
}

impl NatalChart {
    /// Create an empty chart with no placements.
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Set a placement for any planet.
    #[must_use]
    pub fn place(mut self, planet: Planet, sign: ZodiacSign) -> Self {
        let idx = planet as usize;
        if idx < self.placements.len() {
            self.placements[idx] = Some(sign);
        }
        self
    }

    /// Get the sign placed for a planet, if any.
    #[must_use]
    #[inline]
    pub fn get(&self, planet: Planet) -> Option<ZodiacSign> {
        self.placements.get(planet as usize).copied().flatten()
    }

    /// Sun placement — core personality (Soul).
    #[must_use]
    pub fn sun(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Sun, sign)
    }

    /// Moon placement — emotional baseline (Heart).
    #[must_use]
    pub fn moon(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Moon, sign)
    }

    /// Rising (Ascendant) — social presentation (Body).
    #[must_use]
    pub fn rising(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Rising, sign)
    }

    /// Mercury — reasoning strategy (Brain).
    #[must_use]
    pub fn mercury(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Mercury, sign)
    }

    /// Venus — passions and aesthetics (Spirit).
    #[must_use]
    pub fn venus(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Venus, sign)
    }

    /// Mars — energy and drive.
    #[must_use]
    pub fn mars(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Mars, sign)
    }

    /// Jupiter — growth direction.
    #[must_use]
    pub fn jupiter(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Jupiter, sign)
    }

    /// Saturn — stress resistance.
    #[must_use]
    pub fn saturn(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Saturn, sign)
    }

    /// Neptune — emotional intelligence style.
    #[must_use]
    pub fn neptune(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Neptune, sign)
    }

    /// Pluto — emotional intensity.
    #[must_use]
    pub fn pluto(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Pluto, sign)
    }

    /// Uranus — flow sensitivity.
    #[must_use]
    pub fn uranus(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Uranus, sign)
    }

    /// North Node — long-term preference direction.
    #[must_use]
    pub fn north_node(self, sign: ZodiacSign) -> Self {
        self.place(Planet::NorthNode, sign)
    }

    /// South Node — default activation patterns.
    #[must_use]
    pub fn south_node(self, sign: ZodiacSign) -> Self {
        self.place(Planet::SouthNode, sign)
    }

    /// Chiron — regulation wounds.
    #[must_use]
    pub fn chiron(self, sign: ZodiacSign) -> Self {
        self.place(Planet::Chiron, sign)
    }

    /// Number of planets that have placements.
    #[must_use]
    pub fn placement_count(&self) -> usize {
        self.placements.iter().filter(|p| p.is_some()).count()
    }

    /// Manifest the chart into a full personality/emotion profile.
    ///
    /// Uses the Sun sign for the base personality. If no Sun placement
    /// exists, defaults to Aries.
    #[cfg_attr(feature = "tracing", tracing::instrument(skip_all))]
    #[must_use]
    pub fn manifest(&self) -> ManifestedProfile {
        let sun_sign = self.get(Planet::Sun).unwrap_or(ZodiacSign::Aries);
        let personality = sign_profile(sun_sign);

        // Moon modifies mood baseline
        #[cfg(feature = "mood")]
        let mood_baseline = {
            let base = crate::mood::derive_mood_baseline(&personality);
            if let Some(moon_sign) = self.get(Planet::Moon) {
                moon_mood_modifier(moon_sign, base)
            } else {
                base
            }
        };

        // Mercury selects reasoning strategy
        #[cfg(all(feature = "mood", feature = "traits"))]
        let reasoning_strategy = {
            if let Some(mercury_sign) = self.get(Planet::Mercury) {
                mercury_reasoning_strategy(mercury_sign)
            } else {
                crate::reasoning::select_reasoning_strategy(&personality)
            }
        };

        // Venus shapes spirit (passions, inspirations, pains)
        #[cfg(feature = "archetype")]
        let spirit = {
            if let Some(venus_sign) = self.get(Planet::Venus) {
                venus_spirit(venus_sign)
            } else {
                crate::spirit::Spirit::new()
            }
        };

        // Rising shapes display rules
        #[cfg(feature = "mood")]
        let display_context = {
            if let Some(rising_sign) = self.get(Planet::Rising) {
                rising_display_context(rising_sign)
            } else {
                crate::display_rules::CulturalContext::new("default")
            }
        };

        // Mars modifies energy parameters
        #[cfg(feature = "mood")]
        let energy = {
            let mut e = crate::energy::EnergyState::new();
            if let Some(mars_sign) = self.get(Planet::Mars) {
                mars_energy_modifier(mars_sign, &mut e);
            }
            e
        };

        // Saturn modifies stress parameters
        #[cfg(feature = "mood")]
        let stress = {
            let mut s = crate::stress::StressState::new();
            if let Some(saturn_sign) = self.get(Planet::Saturn) {
                saturn_stress_modifier(saturn_sign, &mut s);
            }
            s
        };

        // Jupiter modifies growth parameters
        #[cfg(all(feature = "mood", feature = "traits"))]
        let growth = {
            let mut g = crate::growth::GrowthLedger::new();
            if let Some(jupiter_sign) = self.get(Planet::Jupiter) {
                jupiter_growth_modifier(jupiter_sign, &mut g);
            }
            g
        };

        // Neptune modifies EQ profile
        #[cfg(feature = "mood")]
        let eq = {
            let mut eq = crate::eq::EqProfile::new();
            if let Some(neptune_sign) = self.get(Planet::Neptune) {
                neptune_eq_modifier(neptune_sign, &mut eq);
            }
            eq
        };

        // Uranus modifies flow thresholds
        #[cfg(feature = "mood")]
        let flow = {
            let mut f = crate::flow::FlowState::default();
            if let Some(uranus_sign) = self.get(Planet::Uranus) {
                uranus_flow_modifier(uranus_sign, &mut f);
            }
            f
        };

        // North Node modifies preference bias
        #[cfg(feature = "mood")]
        let preference_bias = {
            let mut bias = crate::preference::PreferenceBias::neutral();
            if let Some(nn_sign) = self.get(Planet::NorthNode) {
                north_node_preference_modifier(nn_sign, &mut bias);
            }
            bias
        };

        // South Node modifies ACT-R memory parameters
        #[cfg(feature = "mood")]
        let (actr_decay, actr_recency_half_life) = {
            if let Some(sn_sign) = self.get(Planet::SouthNode) {
                south_node_actr_params(sn_sign)
            } else {
                (0.5, 300.0)
            }
        };

        let aspects = detect_aspects(self);

        let mut result = ManifestedProfile {
            personality,
            #[cfg(feature = "mood")]
            mood_baseline,
            #[cfg(all(feature = "mood", feature = "traits"))]
            reasoning_strategy,
            #[cfg(feature = "archetype")]
            spirit,
            #[cfg(feature = "mood")]
            display_context,
            #[cfg(feature = "mood")]
            energy,
            #[cfg(feature = "mood")]
            stress,
            #[cfg(all(feature = "mood", feature = "traits"))]
            growth,
            #[cfg(feature = "mood")]
            eq,
            #[cfg(feature = "mood")]
            flow,
            #[cfg(feature = "mood")]
            preference_bias,
            #[cfg(feature = "mood")]
            actr_decay,
            #[cfg(feature = "mood")]
            actr_recency_half_life,
            aspects: Vec::new(),
        };

        // Apply aspect cross-module effects, then store
        #[cfg(feature = "mood")]
        apply_aspects(&aspects, &mut result);
        result.aspects = aspects;

        result
    }
}

/// The output of manifesting a natal chart — personality and emotion configuration.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ManifestedProfile {
    /// Core personality from Sun sign.
    pub personality: PersonalityProfile,
    /// Mood baseline from personality + Moon sign modifier.
    #[cfg(feature = "mood")]
    pub mood_baseline: MoodVector,
    /// Preferred reasoning strategy from Mercury sign.
    #[cfg(all(feature = "mood", feature = "traits"))]
    pub reasoning_strategy: crate::reasoning::ReasoningStrategy,
    /// Spirit (passions, inspirations, pains) from Venus sign.
    #[cfg(feature = "archetype")]
    pub spirit: crate::spirit::Spirit,
    /// Display rules context from Rising sign.
    #[cfg(feature = "mood")]
    pub display_context: crate::display_rules::CulturalContext,
    /// Energy configuration from Mars sign.
    #[cfg(feature = "mood")]
    pub energy: crate::energy::EnergyState,
    /// Stress configuration from Saturn sign.
    #[cfg(feature = "mood")]
    pub stress: crate::stress::StressState,
    /// Growth configuration from Jupiter sign.
    #[cfg(all(feature = "mood", feature = "traits"))]
    pub growth: crate::growth::GrowthLedger,
    /// EQ profile from Neptune sign.
    #[cfg(feature = "mood")]
    pub eq: crate::eq::EqProfile,
    /// Flow state configuration from Uranus sign.
    #[cfg(feature = "mood")]
    pub flow: crate::flow::FlowState,
    /// Preference bias from North Node sign.
    #[cfg(feature = "mood")]
    pub preference_bias: crate::preference::PreferenceBias,
    /// ACT-R memory parameters from South Node sign.
    #[cfg(feature = "mood")]
    pub actr_decay: f64,
    /// ACT-R recency half-life from South Node sign.
    #[cfg(feature = "mood")]
    pub actr_recency_half_life: f64,
    /// Detected aspects between planets (cross-module dynamics).
    pub aspects: Vec<Aspect>,
}

// ── Moon modifier ─────────────────────────────────────────────────────────

/// Modify a mood baseline based on the Moon sign placement.
///
/// The Moon governs emotional reactivity — how intensely and in which
/// direction the baseline mood leans.
#[cfg(feature = "mood")]
#[must_use]
fn moon_mood_modifier(moon: ZodiacSign, mut baseline: MoodVector) -> MoodVector {
    use crate::mood::Emotion;

    match sign_element(moon) {
        Element::Fire => {
            // Fire moons: elevated arousal, higher joy baseline
            baseline.nudge(Emotion::Arousal, 0.15);
            baseline.nudge(Emotion::Joy, 0.1);
            baseline.nudge(Emotion::Dominance, 0.1);
        }
        Element::Water => {
            // Water moons: deep emotional sensitivity, higher trust
            baseline.nudge(Emotion::Trust, 0.15);
            baseline.nudge(Emotion::Joy, 0.05);
            baseline.nudge(Emotion::Arousal, -0.1);
        }
        Element::Earth => {
            // Earth moons: stable, low arousal, grounded
            baseline.nudge(Emotion::Arousal, -0.15);
            baseline.nudge(Emotion::Trust, 0.1);
            baseline.nudge(Emotion::Frustration, -0.1);
        }
        Element::Air => {
            // Air moons: curious, mentally stimulated, variable
            baseline.nudge(Emotion::Interest, 0.15);
            baseline.nudge(Emotion::Arousal, 0.05);
            baseline.nudge(Emotion::Joy, 0.05);
        }
    }

    // Modality fine-tuning
    match sign_modality(moon) {
        Modality::Cardinal => baseline.nudge(Emotion::Dominance, 0.05),
        Modality::Fixed => baseline.nudge(Emotion::Trust, 0.05),
        Modality::Mutable => baseline.nudge(Emotion::Interest, 0.05),
    }

    baseline
}

// ── Mercury modifier ──────────────────────────────────────────────────────

/// Select a reasoning strategy based on the Mercury sign placement.
///
/// Mercury governs communication and cognition. The sign's modality
/// determines the primary reasoning approach:
/// - Cardinal signs → Analytical (initiating, direct)
/// - Fixed signs → Systematic (persistent, structured)
/// - Mutable signs → Intuitive (adaptive, fluid)
///
/// The element adds a secondary bias:
/// - Water Mercury → Empathetic tilt
/// - Air Mercury → Creative tilt
#[cfg(all(feature = "mood", feature = "traits"))]
#[must_use]
fn mercury_reasoning_strategy(mercury: ZodiacSign) -> crate::reasoning::ReasoningStrategy {
    use crate::reasoning::ReasoningStrategy;

    match (sign_modality(mercury), sign_element(mercury)) {
        // Water signs override modality — empathetic reasoning dominates
        (_, Element::Water) => ReasoningStrategy::Empathetic,
        // Air mutable = creative (Gemini archetype)
        (Modality::Mutable, Element::Air) => ReasoningStrategy::Creative,
        // Cardinal = analytical
        (Modality::Cardinal, _) => ReasoningStrategy::Analytical,
        // Fixed = systematic
        (Modality::Fixed, _) => ReasoningStrategy::Systematic,
        // Mutable (non-water, non-air) = intuitive
        (Modality::Mutable, _) => ReasoningStrategy::Intuitive,
    }
}

// ── Venus modifier ────────────────────────────────────────────────────────

/// Produce a Spirit from the Venus sign placement.
///
/// Venus governs passions, aesthetics, and relationship style.
/// The element determines the motivational theme; the sign adds specificity.
#[cfg(feature = "archetype")]
#[must_use]
fn venus_spirit(venus: ZodiacSign) -> crate::spirit::Spirit {
    let mut spirit = crate::spirit::Spirit::new();

    match sign_element(venus) {
        Element::Fire => {
            spirit.add_passion(
                "creative expression",
                "Driven to create, perform, and inspire",
                0.8,
            );
            spirit.add_inspiration("bold action", "Inspired by courage and decisive moves", 0.7);
            spirit.add_pain(
                "stagnation",
                "Pained by creative suppression or boredom",
                0.6,
            );
        }
        Element::Water => {
            spirit.add_passion(
                "deep connection",
                "Driven to form profound emotional bonds",
                0.9,
            );
            spirit.add_inspiration(
                "vulnerability",
                "Inspired by authentic emotional expression",
                0.8,
            );
            spirit.add_pain(
                "emotional betrayal",
                "Pained by broken trust or superficiality",
                0.7,
            );
        }
        Element::Earth => {
            spirit.add_passion(
                "craftsmanship",
                "Driven to build lasting, beautiful things",
                0.8,
            );
            spirit.add_inspiration("natural beauty", "Inspired by elegance in simplicity", 0.7);
            spirit.add_pain(
                "waste",
                "Pained by carelessness or squandered resources",
                0.6,
            );
        }
        Element::Air => {
            spirit.add_passion("harmony", "Driven to create balance and fairness", 0.8);
            spirit.add_inspiration(
                "intellectual beauty",
                "Inspired by elegant ideas and wit",
                0.7,
            );
            spirit.add_pain("discord", "Pained by conflict and injustice", 0.6);
        }
    }

    spirit
}

// ── Rising modifier ──────────────────────────────────────────────────────

/// Produce display rules from the Rising (Ascendant) sign placement.
///
/// The Rising sign governs how emotions are expressed vs felt — the social
/// mask. Fire risings amplify; Earth risings de-amplify; Water risings
/// mask with socially appropriate substitutes; Air risings qualify with humor.
#[cfg(feature = "mood")]
#[must_use]
fn rising_display_context(rising: ZodiacSign) -> crate::display_rules::CulturalContext {
    use crate::display_rules::{CulturalContext, DisplayRule};
    use crate::mood::Emotion;

    let name = format!("{} rising", rising);
    let mut ctx = CulturalContext::new(name);

    match sign_element(rising) {
        Element::Fire => {
            // Fire risings: amplify emotional expression — what you see is what they feel, but louder
            ctx.add_rule(DisplayRule::Amplify {
                target: Emotion::Joy,
                factor: 1.4,
            });
            ctx.add_rule(DisplayRule::Amplify {
                target: Emotion::Arousal,
                factor: 1.3,
            });
            ctx.add_rule(DisplayRule::Amplify {
                target: Emotion::Dominance,
                factor: 1.3,
            });
        }
        Element::Water => {
            // Water risings: mask vulnerability with warmth, de-amplify frustration
            ctx.add_rule(DisplayRule::DeAmplify {
                target: Emotion::Frustration,
                factor: 0.5,
            });
            ctx.add_rule(DisplayRule::Amplify {
                target: Emotion::Trust,
                factor: 1.3,
            });
        }
        Element::Earth => {
            // Earth risings: understated, composed — de-amplify everything
            ctx.add_rule(DisplayRule::DeAmplify {
                target: Emotion::Arousal,
                factor: 0.6,
            });
            ctx.add_rule(DisplayRule::DeAmplify {
                target: Emotion::Frustration,
                factor: 0.5,
            });
            ctx.add_rule(DisplayRule::DeAmplify {
                target: Emotion::Joy,
                factor: 0.8,
            });
        }
        Element::Air => {
            // Air risings: intellectualize emotion — qualify with interest/humor
            ctx.add_rule(DisplayRule::Qualify {
                qualifier: Emotion::Interest,
                intensity: 0.2,
            });
            ctx.add_rule(DisplayRule::DeAmplify {
                target: Emotion::Frustration,
                factor: 0.7,
            });
        }
    }

    ctx
}

// ── Mars modifier ─────────────────────────────────────────────────────────

/// Modify energy parameters based on the Mars sign placement.
///
/// Mars governs drive intensity. Fire Mars = explosive drive, fast drain/recovery.
/// Earth Mars = steady, enduring. Water Mars = emotionally driven, variable.
/// Air Mars = mentally energized, moderate.
#[cfg(feature = "mood")]
fn mars_energy_modifier(mars: ZodiacSign, energy: &mut crate::energy::EnergyState) {
    match sign_element(mars) {
        Element::Fire => {
            // Fire Mars: explosive drive — higher drain, higher recovery, fast fatigue
            energy.drain_rate = 0.035;
            energy.recovery_rate = 0.045;
            energy.fatigue_gain = 0.04;
            energy.fitness_gain = 0.015;
        }
        Element::Earth => {
            // Earth Mars: enduring — low drain, steady recovery, slow fatigue buildup
            energy.drain_rate = 0.015;
            energy.recovery_rate = 0.025;
            energy.fatigue_tau = 20.0; // slower fatigue decay = lingers longer
            energy.fitness_tau = 80.0; // slower fitness decay = retains gains
        }
        Element::Water => {
            // Water Mars: emotionally driven — moderate drain, recovery tied to emotional state
            energy.drain_rate = 0.025;
            energy.recovery_rate = 0.03;
            energy.fatigue_gain = 0.035;
        }
        Element::Air => {
            // Air Mars: mentally energized — low physical drain, moderate recovery
            energy.drain_rate = 0.018;
            energy.recovery_rate = 0.035;
            energy.fitness_gain = 0.012;
        }
    }
}

// ── Saturn modifier ───────────────────────────────────────────────────────

/// Modify stress parameters based on the Saturn sign placement.
///
/// Saturn governs discipline and endurance under pressure. Earth Saturn = high
/// burnout resistance. Fire Saturn = fast accumulation but also fast recovery.
/// Water Saturn = low thresholds but deep recovery. Air Saturn = intellectual coping.
#[cfg(feature = "mood")]
fn saturn_stress_modifier(saturn: ZodiacSign, stress: &mut crate::stress::StressState) {
    match sign_element(saturn) {
        Element::Earth => {
            // Earth Saturn: fortress — high thresholds, slow but deep
            stress.threshold_fatigue = 0.7;
            stress.threshold_burnout = 0.95;
            stress.recovery_rate = 0.015;
            stress.accumulation_rate = 0.04;
        }
        Element::Fire => {
            // Fire Saturn: burns hot, recovers fast
            stress.threshold_fatigue = 0.5;
            stress.threshold_burnout = 0.85;
            stress.recovery_rate = 0.035;
            stress.accumulation_rate = 0.06;
        }
        Element::Water => {
            // Water Saturn: absorbs deeply, slow to release
            stress.threshold_fatigue = 0.5;
            stress.threshold_burnout = 0.8;
            stress.recovery_rate = 0.01;
            stress.accumulation_rate = 0.04;
        }
        Element::Air => {
            // Air Saturn: intellectualizes stress — moderate thresholds, moderate recovery
            stress.threshold_fatigue = 0.6;
            stress.threshold_burnout = 0.9;
            stress.recovery_rate = 0.025;
            stress.accumulation_rate = 0.045;
        }
    }
}

// ── Jupiter modifier ──────────────────────────────────────────────────────

/// Modify growth parameters based on the Jupiter sign placement.
///
/// Jupiter governs expansion and adaptation speed. Fire Jupiter = rapid growth,
/// low threshold. Earth Jupiter = slow but lasting. Water Jupiter = emotionally
/// catalyzed growth. Air Jupiter = intellectually driven adaptation.
#[cfg(all(feature = "mood", feature = "traits"))]
fn jupiter_growth_modifier(jupiter: ZodiacSign, growth: &mut crate::growth::GrowthLedger) {
    match sign_element(jupiter) {
        Element::Fire => {
            // Fire Jupiter: rapid evolution — low threshold, fast decay (needs reinforcement)
            growth.threshold = 2.0;
            growth.decay_rate = 0.08;
        }
        Element::Earth => {
            // Earth Jupiter: slow but permanent — high threshold, very slow decay
            growth.threshold = 4.0;
            growth.decay_rate = 0.02;
        }
        Element::Water => {
            // Water Jupiter: emotionally catalyzed — moderate threshold, moderate decay
            growth.threshold = 2.5;
            growth.decay_rate = 0.04;
        }
        Element::Air => {
            // Air Jupiter: intellectually driven — moderate threshold, moderate decay
            growth.threshold = 3.0;
            growth.decay_rate = 0.06;
        }
    }
}

// ── Neptune modifier ──────────────────────────────────────────────────────

/// Modify EQ branch weights based on the Neptune sign placement.
///
/// Neptune governs emotional intelligence style. Water Neptune = perception-dominant
/// (intuitive reading). Earth Neptune = management-dominant (practical coping).
/// Fire Neptune = facilitation-dominant (emotions fuel action). Air Neptune =
/// understanding-dominant (intellectual comprehension).
#[cfg(feature = "mood")]
fn neptune_eq_modifier(neptune: ZodiacSign, eq: &mut crate::eq::EqProfile) {
    use crate::eq::EqBranch;

    match sign_element(neptune) {
        Element::Water => {
            // Water Neptune: intuitive perception, deep feeling
            eq.set(EqBranch::Perception, 0.75);
            eq.set(EqBranch::Understanding, 0.6);
        }
        Element::Earth => {
            // Earth Neptune: practical emotional management
            eq.set(EqBranch::Management, 0.75);
            eq.set(EqBranch::Facilitation, 0.6);
        }
        Element::Fire => {
            // Fire Neptune: emotions fuel cognitive performance
            eq.set(EqBranch::Facilitation, 0.75);
            eq.set(EqBranch::Perception, 0.6);
        }
        Element::Air => {
            // Air Neptune: intellectual emotional understanding
            eq.set(EqBranch::Understanding, 0.75);
            eq.set(EqBranch::Management, 0.6);
        }
    }
}

// ── Uranus modifier ──────────────────────────────────────────────────────

/// Modify flow thresholds based on the Uranus sign placement.
///
/// Uranus governs the relationship with flow states. Fire Uranus = easy entry,
/// low disruption resistance. Earth Uranus = hard entry, high disruption resistance.
/// Water Uranus = emotionally triggered flow. Air Uranus = novelty-seeking flow.
#[cfg(feature = "mood")]
fn uranus_flow_modifier(uranus: ZodiacSign, flow: &mut crate::flow::FlowState) {
    match sign_element(uranus) {
        Element::Fire => {
            // Fire Uranus: easy to enter flow, but also easy to disrupt
            flow.interest_threshold = 0.3;
            flow.entry_threshold = 0.8;
            flow.build_rate = 0.07;
            flow.frustration_ceiling = 0.25;
        }
        Element::Earth => {
            // Earth Uranus: hard to enter, but deeply stable once there
            flow.interest_threshold = 0.5;
            flow.entry_threshold = 1.2;
            flow.build_rate = 0.03;
            flow.frustration_ceiling = 0.5;
        }
        Element::Water => {
            // Water Uranus: emotionally catalyzed flow — passion-driven entry
            flow.interest_threshold = 0.35;
            flow.dominance_floor = 0.0;
            flow.arousal_floor = 0.2;
            flow.build_rate = 0.06;
        }
        Element::Air => {
            // Air Uranus: novelty-seeking — curiosity lowers threshold
            flow.interest_threshold = 0.25;
            flow.entry_threshold = 0.9;
            flow.arousal_ceiling = 0.8;
            flow.build_rate = 0.06;
        }
    }
}

// ── North Node modifier ──────────────────────────────────────────────────

/// Modify preference bias based on the North Node sign placement.
///
/// The North Node represents what the entity gravitates toward over time.
/// Fire NN = strong positive preference formation (drawn to action).
/// Water NN = strong negative sensitivity (avoids emotional harm).
/// Earth NN = balanced, conservative preference formation.
/// Air NN = novelty bias (positive toward new, less weight on negative).
#[cfg(feature = "mood")]
fn north_node_preference_modifier(
    north_node: ZodiacSign,
    bias: &mut crate::preference::PreferenceBias,
) {
    match sign_element(north_node) {
        Element::Fire => {
            // Fire NN: enthusiastic — forms positive preferences quickly
            bias.positive_gain = 1.4;
            bias.negative_gain = 0.8;
        }
        Element::Water => {
            // Water NN: protective — weights negative experiences heavily
            bias.positive_gain = 1.0;
            bias.negative_gain = 1.4;
        }
        Element::Earth => {
            // Earth NN: conservative — slow, balanced preference formation
            bias.positive_gain = 0.9;
            bias.negative_gain = 0.9;
        }
        Element::Air => {
            // Air NN: novelty-seeking — drawn to new, forgets bad quickly
            bias.positive_gain = 1.3;
            bias.negative_gain = 0.7;
        }
    }
}

// ── South Node modifier ─────────────────────────────────────────────────

/// Compute ACT-R memory parameters from the South Node sign placement.
///
/// The South Node represents pre-existing knowledge patterns and comfort zones.
/// Earth SN = slow decay (strong long-term memory). Fire SN = fast decay (lives
/// in the present). Water SN = long recency (emotional memories linger).
/// Air SN = short recency (quick mental turnover).
///
/// Returns `(decay, recency_half_life)`.
#[cfg(feature = "mood")]
#[must_use]
fn south_node_actr_params(south_node: ZodiacSign) -> (f64, f64) {
    match sign_element(south_node) {
        Element::Earth => {
            // Earth SN: deep roots — slow decay, long recency
            (0.35, 450.0)
        }
        Element::Fire => {
            // Fire SN: lives in the present — fast decay, short recency
            (0.7, 180.0)
        }
        Element::Water => {
            // Water SN: emotional memories linger — moderate decay, very long recency
            (0.45, 600.0)
        }
        Element::Air => {
            // Air SN: quick mental turnover — moderate decay, short recency
            (0.55, 200.0)
        }
    }
}

// ── Aspects ───────────────────────────────────────────────────────────────

/// The type of angular relationship between two planets.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum AspectKind {
    /// 0° — modules amplify each other.
    Conjunction,
    /// 60° — modules complement, mild boost.
    Sextile,
    /// 90° — modules create productive tension.
    Square,
    /// 120° — modules flow harmoniously.
    Trine,
    /// 150° — modules misalign, require constant adjustment.
    Quincunx,
    /// 180° — modules pull in opposite directions.
    Opposition,
}

impl AspectKind {
    /// The exact angle for this aspect type.
    #[must_use]
    #[inline]
    pub fn angle(self) -> f32 {
        match self {
            Self::Conjunction => 0.0,
            Self::Sextile => 60.0,
            Self::Square => 90.0,
            Self::Trine => 120.0,
            Self::Quincunx => 150.0,
            Self::Opposition => 180.0,
        }
    }

    /// Default maximum orb (tolerance in degrees) for this aspect.
    #[must_use]
    #[inline]
    pub fn default_max_orb(self) -> f32 {
        match self {
            Self::Conjunction | Self::Opposition => 8.0,
            Self::Trine | Self::Square => 7.0,
            Self::Sextile => 6.0,
            Self::Quincunx => 3.0,
        }
    }

    /// Whether this aspect is harmonious (trine, sextile, conjunction)
    /// or challenging (square, opposition, quincunx).
    #[must_use]
    #[inline]
    pub fn is_harmonious(self) -> bool {
        matches!(self, Self::Conjunction | Self::Sextile | Self::Trine)
    }
}

impl_display!(AspectKind {
    Conjunction => "conjunction",
    Sextile => "sextile",
    Square => "square",
    Trine => "trine",
    Quincunx => "quincunx",
    Opposition => "opposition",
});

/// An aspect between two planets — an angular relationship that creates
/// cross-module dynamics within a single entity.
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct Aspect {
    /// First planet.
    pub planet_a: Planet,
    /// Second planet.
    pub planet_b: Planet,
    /// Type of aspect.
    pub kind: AspectKind,
    /// Actual angular deviation from the exact aspect angle (degrees).
    pub orb: f32,
    /// Aspect strength: 1.0 = exact, 0.0 = at the edge of the orb.
    pub strength: f32,
}

/// Compute the angular separation between two zodiac sign midpoints (0–180°).
#[must_use]
#[inline]
fn angular_separation(a: ZodiacSign, b: ZodiacSign) -> f32 {
    let diff = (a.midpoint_degrees() - b.midpoint_degrees()).abs();
    if diff > 180.0 { 360.0 - diff } else { diff }
}

/// Detect all aspects between placed planets in a chart.
///
/// Uses whole-sign positions (sign midpoints) with default orbs.
/// Returns aspects sorted by strength (strongest first).
#[cfg_attr(feature = "tracing", tracing::instrument(skip_all))]
#[must_use]
pub fn detect_aspects(chart: &NatalChart) -> Vec<Aspect> {
    let mut aspects = Vec::new();
    let aspect_kinds = [
        AspectKind::Conjunction,
        AspectKind::Sextile,
        AspectKind::Square,
        AspectKind::Trine,
        AspectKind::Quincunx,
        AspectKind::Opposition,
    ];

    // Check all unique planet pairs
    for i in 0..Planet::COUNT {
        let planet_a = Planet::ALL[i];
        let Some(sign_a) = chart.get(planet_a) else {
            continue;
        };

        for j in (i + 1)..Planet::COUNT {
            let planet_b = Planet::ALL[j];
            let Some(sign_b) = chart.get(planet_b) else {
                continue;
            };

            let sep = angular_separation(sign_a, sign_b);

            for &kind in &aspect_kinds {
                let orb = (sep - kind.angle()).abs();
                let max_orb = kind.default_max_orb();
                if orb <= max_orb {
                    let strength = 1.0 - (orb / max_orb);
                    aspects.push(Aspect {
                        planet_a,
                        planet_b,
                        kind,
                        orb,
                        strength,
                    });
                    break; // Each pair gets at most one aspect (tightest match)
                }
            }
        }
    }

    aspects.sort_by(|a, b| {
        b.strength
            .partial_cmp(&a.strength)
            .unwrap_or(core::cmp::Ordering::Equal)
    });
    aspects
}

/// Apply aspect effects to a manifested profile.
///
/// Harmonious aspects (trine, sextile, conjunction) amplify shared parameters.
/// Challenging aspects (square, opposition) create tension — boosting some
/// parameters while constraining others.
#[cfg(feature = "mood")]
pub fn apply_aspects(aspects: &[Aspect], profile: &mut ManifestedProfile) {
    for aspect in aspects {
        let s = aspect.strength;
        let factor = if aspect.kind.is_harmonious() {
            s * 0.15 // harmonious: mild positive modifier
        } else {
            s * 0.2 // challenging: stronger but mixed modifier
        };

        match (aspect.planet_a, aspect.planet_b) {
            // Mars–Saturn: energy vs stress tension
            (Planet::Mars, Planet::Saturn) | (Planet::Saturn, Planet::Mars) => {
                if aspect.kind.is_harmonious() {
                    // Disciplined endurance
                    profile.energy.recovery_rate *= 1.0 + factor;
                    profile.stress.threshold_burnout =
                        (profile.stress.threshold_burnout + factor * 0.1).min(1.0);
                } else {
                    // Burns hot, breaks fast
                    profile.energy.drain_rate *= 1.0 + factor;
                    // Ensure burnout stays above fatigue threshold
                    profile.stress.threshold_burnout = (profile.stress.threshold_burnout
                        - factor * 0.1)
                        .max(profile.stress.threshold_fatigue + 0.05);
                }
            }
            // Sun–Moon: personality–emotion alignment
            (Planet::Sun, Planet::Moon) | (Planet::Moon, Planet::Sun) => {
                if aspect.kind.is_harmonious() {
                    // Inner harmony — mood baseline nudged toward joy
                    profile
                        .mood_baseline
                        .nudge(crate::mood::Emotion::Joy, factor * 0.5);
                } else {
                    // Inner tension — mood baseline nudged toward frustration
                    profile
                        .mood_baseline
                        .nudge(crate::mood::Emotion::Frustration, factor * 0.3);
                }
            }
            // Mercury–Jupiter: reasoning meets growth
            (Planet::Mercury, Planet::Jupiter) | (Planet::Jupiter, Planet::Mercury) => {
                #[cfg(all(feature = "mood", feature = "traits"))]
                if aspect.kind.is_harmonious() {
                    // Learning accelerates
                    profile.growth.threshold *= 1.0 - factor;
                } else {
                    // Overthinking slows growth
                    profile.growth.threshold *= 1.0 + factor;
                }
            }
            // Venus–Moon: spirit meets emotion
            (Planet::Venus, Planet::Moon) | (Planet::Moon, Planet::Venus) => {
                if aspect.kind.is_harmonious() {
                    // Emotional stability from aligned passions
                    profile
                        .mood_baseline
                        .nudge(crate::mood::Emotion::Trust, factor * 0.5);
                }
            }
            // Mars–Uranus: energy meets flow
            (Planet::Mars, Planet::Uranus) | (Planet::Uranus, Planet::Mars) => {
                if aspect.kind.is_harmonious() {
                    // Drive fuels flow
                    profile.flow.build_rate *= 1.0 + factor;
                } else {
                    // Restless energy disrupts flow
                    profile.flow.frustration_ceiling *= 1.0 - factor * 0.5;
                }
            }
            // Saturn–Neptune: discipline meets intuition
            (Planet::Saturn, Planet::Neptune) | (Planet::Neptune, Planet::Saturn) => {
                if aspect.kind.is_harmonious() {
                    profile.stress.recovery_rate *= 1.0 + factor;
                } else {
                    profile.stress.recovery_rate *= 1.0 - factor * 0.5;
                }
            }
            // All other combinations: no specific effect (yet)
            _ => {}
        }
    }
}

// ── Tests ─────────────────────────────────────────────────────────────────

#[cfg(test)]
mod tests {
    use super::*;
    use crate::traits::{TraitKind, TraitLevel};

    // ── Element mapping ───────────────────────────────────────────────

    #[test]
    fn fire_signs() {
        assert_eq!(sign_element(ZodiacSign::Aries), Element::Fire);
        assert_eq!(sign_element(ZodiacSign::Leo), Element::Fire);
        assert_eq!(sign_element(ZodiacSign::Sagittarius), Element::Fire);
    }

    #[test]
    fn water_signs() {
        assert_eq!(sign_element(ZodiacSign::Cancer), Element::Water);
        assert_eq!(sign_element(ZodiacSign::Scorpio), Element::Water);
        assert_eq!(sign_element(ZodiacSign::Pisces), Element::Water);
    }

    #[test]
    fn earth_signs() {
        assert_eq!(sign_element(ZodiacSign::Taurus), Element::Earth);
        assert_eq!(sign_element(ZodiacSign::Virgo), Element::Earth);
        assert_eq!(sign_element(ZodiacSign::Capricorn), Element::Earth);
    }

    #[test]
    fn air_signs() {
        assert_eq!(sign_element(ZodiacSign::Gemini), Element::Air);
        assert_eq!(sign_element(ZodiacSign::Libra), Element::Air);
        assert_eq!(sign_element(ZodiacSign::Aquarius), Element::Air);
    }

    // ── Modality mapping ──────────────────────────────────────────────

    #[test]
    fn cardinal_signs() {
        assert_eq!(sign_modality(ZodiacSign::Aries), Modality::Cardinal);
        assert_eq!(sign_modality(ZodiacSign::Cancer), Modality::Cardinal);
        assert_eq!(sign_modality(ZodiacSign::Libra), Modality::Cardinal);
        assert_eq!(sign_modality(ZodiacSign::Capricorn), Modality::Cardinal);
    }

    #[test]
    fn fixed_signs() {
        assert_eq!(sign_modality(ZodiacSign::Taurus), Modality::Fixed);
        assert_eq!(sign_modality(ZodiacSign::Leo), Modality::Fixed);
        assert_eq!(sign_modality(ZodiacSign::Scorpio), Modality::Fixed);
        assert_eq!(sign_modality(ZodiacSign::Aquarius), Modality::Fixed);
    }

    #[test]
    fn mutable_signs() {
        assert_eq!(sign_modality(ZodiacSign::Gemini), Modality::Mutable);
        assert_eq!(sign_modality(ZodiacSign::Virgo), Modality::Mutable);
        assert_eq!(sign_modality(ZodiacSign::Sagittarius), Modality::Mutable);
        assert_eq!(sign_modality(ZodiacSign::Pisces), Modality::Mutable);
    }

    // ── Exhaustiveness ────────────────────────────────────────────────

    #[test]
    fn all_signs_counted() {
        assert_eq!(ZodiacSign::ALL.len(), ZodiacSign::COUNT);
    }

    #[test]
    fn every_sign_has_element_and_modality() {
        for &sign in ZodiacSign::ALL {
            let _ = sign_element(sign);
            let _ = sign_modality(sign);
        }
    }

    #[test]
    fn element_distribution() {
        // 3 signs per element
        for element in [Element::Fire, Element::Water, Element::Earth, Element::Air] {
            let count = ZodiacSign::ALL
                .iter()
                .filter(|&&s| sign_element(s) == element)
                .count();
            assert_eq!(count, 3, "{element} should have 3 signs");
        }
    }

    #[test]
    fn modality_distribution() {
        // 4 signs per modality
        for modality in [Modality::Cardinal, Modality::Fixed, Modality::Mutable] {
            let count = ZodiacSign::ALL
                .iter()
                .filter(|&&s| sign_modality(s) == modality)
                .count();
            assert_eq!(count, 4, "{modality} should have 4 signs");
        }
    }

    // ── Sign profiles ─────────────────────────────────────────────────

    #[test]
    fn all_signs_produce_non_default_profiles() {
        let default = PersonalityProfile::new("default");
        for &sign in ZodiacSign::ALL {
            let profile = sign_profile(sign);
            // At least one trait should differ from Balanced
            let has_non_balanced = TraitKind::ALL
                .iter()
                .any(|&t| profile.get_trait(t) != default.get_trait(t));
            assert!(
                has_non_balanced,
                "{sign} profile should have non-default traits"
            );
        }
    }

    #[test]
    fn sign_profiles_named_correctly() {
        for &sign in ZodiacSign::ALL {
            let profile = sign_profile(sign);
            assert_eq!(profile.name, sign.to_string());
        }
    }

    // ── Specific sign trait verification ───────────────────────────────

    #[test]
    fn aries_is_bold_direct() {
        let p = sign_profile(ZodiacSign::Aries);
        assert_eq!(p.get_trait(TraitKind::Directness), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::Confidence), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::Patience), TraitLevel::Low);
    }

    #[test]
    fn cancer_is_nurturing_empathic() {
        let p = sign_profile(ZodiacSign::Cancer);
        assert_eq!(p.get_trait(TraitKind::Empathy), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::Warmth), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::RiskTolerance), TraitLevel::Low);
    }

    #[test]
    fn virgo_is_precise_analytical() {
        let p = sign_profile(ZodiacSign::Virgo);
        assert_eq!(p.get_trait(TraitKind::Precision), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::Skepticism), TraitLevel::High);
    }

    #[test]
    fn gemini_is_curious_witty() {
        let p = sign_profile(ZodiacSign::Gemini);
        assert_eq!(p.get_trait(TraitKind::Curiosity), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::Humor), TraitLevel::Highest);
    }

    #[test]
    fn scorpio_is_intense_perceptive() {
        let p = sign_profile(ZodiacSign::Scorpio);
        assert_eq!(p.get_trait(TraitKind::Skepticism), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::Confidence), TraitLevel::High);
        assert_eq!(p.get_trait(TraitKind::Empathy), TraitLevel::High);
    }

    #[test]
    fn capricorn_is_disciplined_ambitious() {
        let p = sign_profile(ZodiacSign::Capricorn);
        assert_eq!(p.get_trait(TraitKind::Autonomy), TraitLevel::Highest);
        assert_eq!(p.get_trait(TraitKind::Precision), TraitLevel::High);
        assert_eq!(p.get_trait(TraitKind::Humor), TraitLevel::Low);
    }

    // ── Same-element profiles share trait emphasis ─────────────────────

    #[test]
    fn fire_signs_share_confidence() {
        for sign in [ZodiacSign::Aries, ZodiacSign::Leo, ZodiacSign::Sagittarius] {
            let p = sign_profile(sign);
            assert!(
                p.get_trait(TraitKind::Confidence) >= TraitLevel::High,
                "{sign} should have high confidence"
            );
        }
    }

    #[test]
    fn water_signs_share_empathy() {
        for sign in [ZodiacSign::Cancer, ZodiacSign::Scorpio, ZodiacSign::Pisces] {
            let p = sign_profile(sign);
            assert!(
                p.get_trait(TraitKind::Empathy) >= TraitLevel::High,
                "{sign} should have high empathy"
            );
        }
    }

    #[test]
    fn earth_signs_share_patience() {
        for sign in [ZodiacSign::Taurus, ZodiacSign::Virgo, ZodiacSign::Capricorn] {
            let p = sign_profile(sign);
            assert!(
                p.get_trait(TraitKind::Patience) >= TraitLevel::High,
                "{sign} should have high patience"
            );
        }
    }

    #[test]
    fn air_signs_share_curiosity_or_independence() {
        for sign in [ZodiacSign::Gemini, ZodiacSign::Libra, ZodiacSign::Aquarius] {
            let p = sign_profile(sign);
            let curious = p.get_trait(TraitKind::Curiosity) >= TraitLevel::High;
            let independent = p.get_trait(TraitKind::Autonomy) >= TraitLevel::High;
            let social = p.get_trait(TraitKind::Warmth) >= TraitLevel::High;
            assert!(
                curious || independent || social,
                "{sign} should have high curiosity, autonomy, or warmth"
            );
        }
    }

    // ── Display ───────────────────────────────────────────────────────

    #[test]
    fn display_formatting() {
        assert_eq!(ZodiacSign::Aries.to_string(), "Aries");
        assert_eq!(ZodiacSign::Sagittarius.to_string(), "Sagittarius");
        assert_eq!(Element::Fire.to_string(), "Fire");
        assert_eq!(Modality::Cardinal.to_string(), "Cardinal");
    }

    // ── Serde ─────────────────────────────────────────────────────────

    #[test]
    fn serde_roundtrip() {
        for &sign in ZodiacSign::ALL {
            let json = serde_json::to_string(&sign).unwrap();
            let back: ZodiacSign = serde_json::from_str(&json).unwrap();
            assert_eq!(back, sign);
        }
    }

    // ── Planet enum ───────────────────────────────────────────────────

    #[test]
    fn all_planets_counted() {
        assert_eq!(Planet::ALL.len(), Planet::COUNT);
    }

    #[test]
    fn planet_discriminants_are_contiguous() {
        // Ensures `planet as usize` is safe for array indexing
        for (i, &planet) in Planet::ALL.iter().enumerate() {
            assert_eq!(planet as usize, i, "{planet} discriminant should be {i}");
        }
    }

    #[test]
    fn inner_planets() {
        assert!(Planet::Sun.is_inner());
        assert!(Planet::Moon.is_inner());
        assert!(Planet::Rising.is_inner());
        assert!(Planet::Mercury.is_inner());
        assert!(Planet::Venus.is_inner());
        assert!(!Planet::Mars.is_inner());
        assert!(!Planet::Chiron.is_inner());
    }

    #[test]
    fn planet_display() {
        assert_eq!(Planet::Sun.to_string(), "Sun");
        assert_eq!(Planet::NorthNode.to_string(), "North Node");
        assert_eq!(Planet::Chiron.to_string(), "Chiron");
    }

    #[test]
    fn planet_serde_roundtrip() {
        for &planet in Planet::ALL {
            let json = serde_json::to_string(&planet).unwrap();
            let back: Planet = serde_json::from_str(&json).unwrap();
            assert_eq!(back, planet);
        }
    }

    // ── NatalChart builder ────────────────────────────────────────────

    #[test]
    fn empty_chart() {
        let chart = NatalChart::new();
        assert_eq!(chart.placement_count(), 0);
        assert_eq!(chart.get(Planet::Sun), None);
    }

    #[test]
    fn chart_builder_fluent() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Scorpio)
            .moon(ZodiacSign::Cancer)
            .rising(ZodiacSign::Gemini);
        assert_eq!(chart.placement_count(), 3);
        assert_eq!(chart.get(Planet::Sun), Some(ZodiacSign::Scorpio));
        assert_eq!(chart.get(Planet::Moon), Some(ZodiacSign::Cancer));
        assert_eq!(chart.get(Planet::Rising), Some(ZodiacSign::Gemini));
    }

    #[test]
    fn chart_generic_place() {
        let chart = NatalChart::new().place(Planet::Mars, ZodiacSign::Aries);
        assert_eq!(chart.get(Planet::Mars), Some(ZodiacSign::Aries));
    }

    #[test]
    fn full_chart() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Scorpio)
            .moon(ZodiacSign::Cancer)
            .rising(ZodiacSign::Gemini)
            .mercury(ZodiacSign::Sagittarius)
            .venus(ZodiacSign::Libra)
            .mars(ZodiacSign::Aries)
            .jupiter(ZodiacSign::Sagittarius)
            .saturn(ZodiacSign::Capricorn)
            .neptune(ZodiacSign::Pisces)
            .pluto(ZodiacSign::Scorpio)
            .uranus(ZodiacSign::Aquarius)
            .north_node(ZodiacSign::Leo)
            .south_node(ZodiacSign::Aquarius)
            .chiron(ZodiacSign::Virgo);
        assert_eq!(chart.placement_count(), Planet::COUNT);
    }

    #[test]
    fn chart_serde_roundtrip() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Leo)
            .moon(ZodiacSign::Pisces);
        let json = serde_json::to_string(&chart).unwrap();
        let back: NatalChart = serde_json::from_str(&json).unwrap();
        assert_eq!(back.get(Planet::Sun), Some(ZodiacSign::Leo));
        assert_eq!(back.get(Planet::Moon), Some(ZodiacSign::Pisces));
        assert_eq!(back.get(Planet::Mars), None);
    }

    // ── Manifestation ─────────────────────────────────────────────────

    #[test]
    fn manifest_sun_only() {
        let chart = NatalChart::new().sun(ZodiacSign::Aries);
        let profile = chart.manifest();
        assert_eq!(profile.personality.name, "Aries");
        assert_eq!(
            profile.personality.get_trait(TraitKind::Confidence),
            TraitLevel::Highest
        );
    }

    #[test]
    fn manifest_empty_defaults_to_aries() {
        let chart = NatalChart::new();
        let profile = chart.manifest();
        assert_eq!(profile.personality.name, "Aries");
    }

    #[cfg(feature = "mood")]
    #[test]
    fn manifest_moon_modifies_baseline() {
        use crate::mood::Emotion;

        let sun_only = NatalChart::new().sun(ZodiacSign::Taurus).manifest();
        let with_fire_moon = NatalChart::new()
            .sun(ZodiacSign::Taurus)
            .moon(ZodiacSign::Aries)
            .manifest();

        // Fire moon should raise arousal above the personality-derived baseline
        assert!(
            with_fire_moon.mood_baseline.get(Emotion::Arousal)
                > sun_only.mood_baseline.get(Emotion::Arousal),
            "fire moon should raise arousal: {} vs {}",
            with_fire_moon.mood_baseline.get(Emotion::Arousal),
            sun_only.mood_baseline.get(Emotion::Arousal),
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn manifest_water_moon_raises_trust() {
        use crate::mood::Emotion;

        let sun_only = NatalChart::new().sun(ZodiacSign::Aries).manifest();
        let with_water_moon = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .moon(ZodiacSign::Cancer)
            .manifest();

        assert!(
            with_water_moon.mood_baseline.get(Emotion::Trust)
                > sun_only.mood_baseline.get(Emotion::Trust),
            "water moon should raise trust"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn manifest_earth_moon_lowers_arousal() {
        use crate::mood::Emotion;

        let sun_only = NatalChart::new().sun(ZodiacSign::Gemini).manifest();
        let with_earth_moon = NatalChart::new()
            .sun(ZodiacSign::Gemini)
            .moon(ZodiacSign::Taurus)
            .manifest();

        assert!(
            with_earth_moon.mood_baseline.get(Emotion::Arousal)
                < sun_only.mood_baseline.get(Emotion::Arousal),
            "earth moon should lower arousal"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn manifest_air_moon_raises_interest() {
        use crate::mood::Emotion;

        let sun_only = NatalChart::new().sun(ZodiacSign::Capricorn).manifest();
        let with_air_moon = NatalChart::new()
            .sun(ZodiacSign::Capricorn)
            .moon(ZodiacSign::Gemini)
            .manifest();

        assert!(
            with_air_moon.mood_baseline.get(Emotion::Interest)
                > sun_only.mood_baseline.get(Emotion::Interest),
            "air moon should raise interest"
        );
    }

    // ── Mercury → reasoning strategy ──────────────────────────────────

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn mercury_cardinal_is_analytical() {
        use crate::reasoning::ReasoningStrategy;
        // Aries = Cardinal Fire
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mercury(ZodiacSign::Capricorn); // Cardinal Earth
        let profile = chart.manifest();
        assert_eq!(profile.reasoning_strategy, ReasoningStrategy::Analytical);
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn mercury_fixed_is_systematic() {
        use crate::reasoning::ReasoningStrategy;
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mercury(ZodiacSign::Taurus); // Fixed Earth
        let profile = chart.manifest();
        assert_eq!(profile.reasoning_strategy, ReasoningStrategy::Systematic);
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn mercury_water_is_empathetic() {
        use crate::reasoning::ReasoningStrategy;
        // Water overrides modality
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mercury(ZodiacSign::Cancer); // Cardinal Water → Empathetic
        let profile = chart.manifest();
        assert_eq!(profile.reasoning_strategy, ReasoningStrategy::Empathetic);
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn mercury_mutable_air_is_creative() {
        use crate::reasoning::ReasoningStrategy;
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mercury(ZodiacSign::Gemini); // Mutable Air → Creative
        let profile = chart.manifest();
        assert_eq!(profile.reasoning_strategy, ReasoningStrategy::Creative);
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn mercury_mutable_fire_is_intuitive() {
        use crate::reasoning::ReasoningStrategy;
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mercury(ZodiacSign::Sagittarius); // Mutable Fire → Intuitive
        let profile = chart.manifest();
        assert_eq!(profile.reasoning_strategy, ReasoningStrategy::Intuitive);
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn no_mercury_derives_from_personality() {
        let chart = NatalChart::new().sun(ZodiacSign::Virgo);
        let profile = chart.manifest();
        // Should derive from personality traits, not crash
        let _ = profile.reasoning_strategy;
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn mercury_all_signs_produce_valid_strategy() {
        use crate::reasoning::ReasoningStrategy;
        for &sign in ZodiacSign::ALL {
            let chart = NatalChart::new().sun(ZodiacSign::Aries).mercury(sign);
            let profile = chart.manifest();
            // Every sign must map to one of the 5 strategies
            assert!(
                ReasoningStrategy::ALL.contains(&profile.reasoning_strategy),
                "{sign} mercury should produce a valid strategy"
            );
        }
    }

    // ── Venus → spirit ────────────────────────────────────────────────

    #[cfg(feature = "archetype")]
    #[test]
    fn venus_produces_spirit() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .venus(ZodiacSign::Libra); // Air Venus
        let profile = chart.manifest();
        assert!(
            !profile.spirit.passions.is_empty(),
            "Venus should create passions"
        );
        assert!(
            !profile.spirit.inspirations.is_empty(),
            "Venus should create inspirations"
        );
        assert!(
            !profile.spirit.pains.is_empty(),
            "Venus should create pains"
        );
    }

    #[cfg(feature = "archetype")]
    #[test]
    fn venus_elements_produce_different_spirits() {
        let fire = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .venus(ZodiacSign::Leo)
            .manifest();
        let water = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .venus(ZodiacSign::Pisces)
            .manifest();
        // Different elements should produce different passion themes
        assert_ne!(fire.spirit.passions[0].name, water.spirit.passions[0].name,);
    }

    #[cfg(feature = "archetype")]
    #[test]
    fn no_venus_produces_empty_spirit() {
        let chart = NatalChart::new().sun(ZodiacSign::Aries);
        let profile = chart.manifest();
        assert!(profile.spirit.passions.is_empty());
    }

    // ── Rising → display rules ────────────────────────────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn rising_produces_display_context() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .rising(ZodiacSign::Leo); // Fire Rising
        let profile = chart.manifest();
        assert!(
            profile.display_context.rule_count() > 0,
            "Rising should create display rules"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn fire_rising_amplifies() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .rising(ZodiacSign::Aries); // Fire Rising
        let profile = chart.manifest();
        assert!(
            profile.display_context.rule_count() >= 3,
            "fire rising should have amplification rules"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn earth_rising_deamplifies() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .rising(ZodiacSign::Taurus); // Earth Rising
        let profile = chart.manifest();
        assert!(
            profile.display_context.rule_count() >= 3,
            "earth rising should have de-amplification rules"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn no_rising_produces_empty_context() {
        let chart = NatalChart::new().sun(ZodiacSign::Aries);
        let profile = chart.manifest();
        assert_eq!(profile.display_context.rule_count(), 0);
    }

    // ── Mars → energy ─────────────────────────────────────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn fire_mars_high_drain_high_recovery() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Aries); // Fire Mars
        let profile = chart.manifest();
        let default = crate::energy::EnergyState::new();
        assert!(
            profile.energy.drain_rate > default.drain_rate,
            "fire mars drain: {} vs default: {}",
            profile.energy.drain_rate,
            default.drain_rate
        );
        assert!(
            profile.energy.recovery_rate > default.recovery_rate,
            "fire mars recovery should be higher"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn earth_mars_low_drain() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Taurus); // Earth Mars
        let profile = chart.manifest();
        let default = crate::energy::EnergyState::new();
        assert!(
            profile.energy.drain_rate < default.drain_rate,
            "earth mars should drain slowly"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn no_mars_uses_defaults() {
        let chart = NatalChart::new().sun(ZodiacSign::Aries);
        let profile = chart.manifest();
        let default = crate::energy::EnergyState::new();
        assert!(
            (profile.energy.drain_rate - default.drain_rate).abs() < f32::EPSILON,
            "no mars should use default drain rate"
        );
    }

    // ── Saturn → stress ───────────────────────────────────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn earth_saturn_high_thresholds() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .saturn(ZodiacSign::Capricorn); // Earth Saturn
        let profile = chart.manifest();
        let default = crate::stress::StressState::new();
        assert!(
            profile.stress.threshold_burnout > default.threshold_burnout,
            "earth saturn should have higher burnout threshold"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn fire_saturn_fast_recovery() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .saturn(ZodiacSign::Aries); // Fire Saturn
        let profile = chart.manifest();
        let default = crate::stress::StressState::new();
        assert!(
            profile.stress.recovery_rate > default.recovery_rate,
            "fire saturn should recover faster"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn water_saturn_slow_recovery() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .saturn(ZodiacSign::Cancer); // Water Saturn
        let profile = chart.manifest();
        let default = crate::stress::StressState::new();
        assert!(
            profile.stress.recovery_rate < default.recovery_rate,
            "water saturn should recover slowly"
        );
    }

    // ── Jupiter → growth ──────────────────────────────────────────────

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn fire_jupiter_low_threshold() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .jupiter(ZodiacSign::Sagittarius); // Fire Jupiter
        let profile = chart.manifest();
        let default = crate::growth::GrowthLedger::new();
        assert!(
            profile.growth.threshold < default.threshold,
            "fire jupiter should lower growth threshold: {} vs {}",
            profile.growth.threshold,
            default.threshold,
        );
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn earth_jupiter_high_threshold() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .jupiter(ZodiacSign::Taurus); // Earth Jupiter
        let profile = chart.manifest();
        let default = crate::growth::GrowthLedger::new();
        assert!(
            profile.growth.threshold > default.threshold,
            "earth jupiter should raise growth threshold"
        );
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn earth_jupiter_slow_decay() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .jupiter(ZodiacSign::Virgo); // Earth Jupiter
        let profile = chart.manifest();
        let default = crate::growth::GrowthLedger::new();
        assert!(
            profile.growth.decay_rate < default.decay_rate,
            "earth jupiter should have slower pressure decay"
        );
    }

    // ── Exhaustiveness: all signs through outer planets ────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn all_signs_through_mars() {
        for &sign in ZodiacSign::ALL {
            let chart = NatalChart::new().sun(ZodiacSign::Aries).mars(sign);
            let profile = chart.manifest();
            assert!(
                profile.energy.drain_rate > 0.0,
                "{sign} mars should produce valid energy"
            );
        }
    }

    #[cfg(feature = "mood")]
    #[test]
    fn all_signs_through_saturn() {
        for &sign in ZodiacSign::ALL {
            let chart = NatalChart::new().sun(ZodiacSign::Aries).saturn(sign);
            let profile = chart.manifest();
            assert!(
                profile.stress.threshold_burnout > profile.stress.threshold_fatigue,
                "{sign} saturn: burnout threshold must exceed fatigue threshold"
            );
        }
    }

    #[cfg(all(feature = "mood", feature = "traits"))]
    #[test]
    fn all_signs_through_jupiter() {
        for &sign in ZodiacSign::ALL {
            let chart = NatalChart::new().sun(ZodiacSign::Aries).jupiter(sign);
            let profile = chart.manifest();
            assert!(
                profile.growth.threshold > 0.0,
                "{sign} jupiter should produce valid growth"
            );
        }
    }

    // ── Neptune → EQ ────────────────────────────────────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn water_neptune_perception_dominant() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .neptune(ZodiacSign::Pisces); // Water Neptune
        let profile = chart.manifest();
        let default = crate::eq::EqProfile::new();
        assert!(
            profile.eq.get(crate::eq::EqBranch::Perception)
                > default.get(crate::eq::EqBranch::Perception),
            "water neptune should raise perception"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn earth_neptune_management_dominant() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .neptune(ZodiacSign::Capricorn); // Earth Neptune
        let profile = chart.manifest();
        let default = crate::eq::EqProfile::new();
        assert!(
            profile.eq.get(crate::eq::EqBranch::Management)
                > default.get(crate::eq::EqBranch::Management),
            "earth neptune should raise management"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn all_signs_through_neptune() {
        for &sign in ZodiacSign::ALL {
            let chart = NatalChart::new().sun(ZodiacSign::Aries).neptune(sign);
            let profile = chart.manifest();
            assert!(
                profile.eq.overall() > 0.0,
                "{sign} neptune should produce valid EQ"
            );
        }
    }

    // ── Uranus → flow ─────────────────────────────────────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn fire_uranus_easy_flow_entry() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .uranus(ZodiacSign::Aries); // Fire Uranus
        let profile = chart.manifest();
        let default = crate::flow::FlowState::default();
        assert!(
            profile.flow.entry_threshold < default.entry_threshold,
            "fire uranus should lower flow entry threshold"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn earth_uranus_hard_flow_entry() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .uranus(ZodiacSign::Taurus); // Earth Uranus
        let profile = chart.manifest();
        let default = crate::flow::FlowState::default();
        assert!(
            profile.flow.entry_threshold > default.entry_threshold,
            "earth uranus should raise flow entry threshold"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn all_signs_through_uranus() {
        for &sign in ZodiacSign::ALL {
            let chart = NatalChart::new().sun(ZodiacSign::Aries).uranus(sign);
            let profile = chart.manifest();
            assert!(
                profile.flow.entry_threshold > 0.0,
                "{sign} uranus should produce valid flow"
            );
        }
    }

    // ── North Node → preference bias ──────────────────────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn fire_nn_positive_bias() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .north_node(ZodiacSign::Leo); // Fire NN
        let profile = chart.manifest();
        assert!(
            profile.preference_bias.positive_gain > 1.0,
            "fire NN should boost positive gain"
        );
        assert!(
            profile.preference_bias.negative_gain < 1.0,
            "fire NN should dampen negative gain"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn water_nn_negative_bias() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .north_node(ZodiacSign::Cancer); // Water NN
        let profile = chart.manifest();
        assert!(
            profile.preference_bias.negative_gain > 1.0,
            "water NN should boost negative gain"
        );
    }

    // ── South Node → ACT-R params ─────────────────────────────────────

    #[cfg(feature = "mood")]
    #[test]
    fn earth_sn_slow_decay() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .south_node(ZodiacSign::Taurus); // Earth SN
        let profile = chart.manifest();
        assert!(profile.actr_decay < 0.5, "earth SN should have slow decay");
        assert!(
            profile.actr_recency_half_life > 300.0,
            "earth SN should have long recency"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn fire_sn_fast_decay() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .south_node(ZodiacSign::Aries); // Fire SN
        let profile = chart.manifest();
        assert!(profile.actr_decay > 0.5, "fire SN should have fast decay");
        assert!(
            profile.actr_recency_half_life < 300.0,
            "fire SN should have short recency"
        );
    }

    // ── Full chart manifestation ──────────────────────────────────────

    // ── Aspects ────────────────────────────────────────────────────────

    #[test]
    fn same_sign_is_conjunction() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Aries);
        let aspects = detect_aspects(&chart);
        assert!(
            aspects.iter().any(|a| a.kind == AspectKind::Conjunction),
            "same sign should produce conjunction"
        );
    }

    #[test]
    fn signs_4_apart_is_trine() {
        // Aries (0) and Leo (4) = 120° = trine
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Leo);
        let aspects = detect_aspects(&chart);
        assert!(
            aspects.iter().any(|a| a.kind == AspectKind::Trine),
            "4 signs apart should produce trine"
        );
    }

    #[test]
    fn signs_3_apart_is_square() {
        // Aries (0) and Cancer (3) = 90° = square
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Cancer);
        let aspects = detect_aspects(&chart);
        assert!(
            aspects.iter().any(|a| a.kind == AspectKind::Square),
            "3 signs apart should produce square"
        );
    }

    #[test]
    fn signs_6_apart_is_opposition() {
        // Aries (0) and Libra (6) = 180° = opposition
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Libra);
        let aspects = detect_aspects(&chart);
        assert!(
            aspects.iter().any(|a| a.kind == AspectKind::Opposition),
            "6 signs apart should produce opposition"
        );
    }

    #[test]
    fn signs_2_apart_is_sextile() {
        // Aries (0) and Gemini (2) = 60° = sextile
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Gemini);
        let aspects = detect_aspects(&chart);
        assert!(
            aspects.iter().any(|a| a.kind == AspectKind::Sextile),
            "2 signs apart should produce sextile"
        );
    }

    #[test]
    fn conjunction_has_max_strength() {
        let chart = NatalChart::new().sun(ZodiacSign::Leo).moon(ZodiacSign::Leo);
        let aspects = detect_aspects(&chart);
        let conjunction = aspects.iter().find(|a| a.kind == AspectKind::Conjunction);
        assert!(conjunction.is_some());
        assert!(
            (conjunction.unwrap().strength - 1.0).abs() < f32::EPSILON,
            "same sign conjunction should have strength 1.0"
        );
    }

    #[test]
    fn aspects_sorted_by_strength() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .moon(ZodiacSign::Aries) // conjunction (strength 1.0)
            .mars(ZodiacSign::Cancer); // square (strength varies)
        let aspects = detect_aspects(&chart);
        if aspects.len() >= 2 {
            assert!(aspects[0].strength >= aspects[1].strength);
        }
    }

    #[test]
    fn empty_chart_no_aspects() {
        let chart = NatalChart::new();
        assert!(detect_aspects(&chart).is_empty());
    }

    #[test]
    fn single_planet_no_aspects() {
        let chart = NatalChart::new().sun(ZodiacSign::Aries);
        assert!(detect_aspects(&chart).is_empty());
    }

    #[test]
    fn aspect_kind_properties() {
        assert!(AspectKind::Conjunction.is_harmonious());
        assert!(AspectKind::Trine.is_harmonious());
        assert!(AspectKind::Sextile.is_harmonious());
        assert!(!AspectKind::Square.is_harmonious());
        assert!(!AspectKind::Opposition.is_harmonious());
        assert!(!AspectKind::Quincunx.is_harmonious());
    }

    #[test]
    fn angular_separation_wraps() {
        // Aries (15°) and Pisces (345°) = 30° apart, not 330°
        let sep = angular_separation(ZodiacSign::Aries, ZodiacSign::Pisces);
        assert!((sep - 30.0).abs() < f32::EPSILON, "separation={sep}");
    }

    #[cfg(feature = "mood")]
    #[test]
    fn mars_saturn_square_affects_energy() {
        // Mars in Aries, Saturn in Cancer = square (3 signs = 90°)
        let without = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Aries)
            .manifest();
        let with_square = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .mars(ZodiacSign::Aries)
            .saturn(ZodiacSign::Cancer)
            .manifest();
        // Square should increase drain (challenging aspect)
        assert!(
            with_square.energy.drain_rate >= without.energy.drain_rate,
            "mars-saturn square should increase energy drain"
        );
    }

    #[cfg(feature = "mood")]
    #[test]
    fn aspects_in_manifested_profile() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Aries)
            .moon(ZodiacSign::Aries);
        let profile = chart.manifest();
        assert!(
            !profile.aspects.is_empty(),
            "same-sign sun-moon should produce aspects"
        );
    }

    // ── Full chart with aspects ───────────────────────────────────────

    #[test]
    fn full_chart_all_planets() {
        let chart = NatalChart::new()
            .sun(ZodiacSign::Scorpio)
            .moon(ZodiacSign::Cancer)
            .rising(ZodiacSign::Gemini)
            .mercury(ZodiacSign::Sagittarius)
            .venus(ZodiacSign::Libra)
            .mars(ZodiacSign::Aries)
            .jupiter(ZodiacSign::Sagittarius)
            .saturn(ZodiacSign::Capricorn)
            .neptune(ZodiacSign::Pisces)
            .uranus(ZodiacSign::Aquarius)
            .north_node(ZodiacSign::Leo)
            .south_node(ZodiacSign::Aquarius)
            .chiron(ZodiacSign::Virgo);
        let profile = chart.manifest();
        assert_eq!(profile.personality.name, "Scorpio");
        assert!(
            !profile.aspects.is_empty(),
            "full chart should have aspects"
        );
    }
}