adryelmartinss commited on
Commit
ffcea9b
·
verified ·
1 Parent(s): 7f96749

Site estático do commit 0c28530

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/ldem_3_8bit.jpg filter=lfs diff=lfs merge=lfs -text
37
+ assets/lroc_color_2k.jpg filter=lfs diff=lfs merge=lfs -text
38
+ assets/polo_sul_normal.jpg filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,10 +1,22 @@
1
- ---
2
- title: Landerbnb
3
- emoji: 🌖
4
- colorFrom: indigo
5
- colorTo: gray
6
- sdk: static
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: LanderBnB
3
+ emoji: 🌙
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: static
7
+ app_file: index.html
8
+ pinned: false
9
+ short_description: Sun & Earth visibility at lunar south pole landing sites
10
+ ---
11
+
12
+ # LanderBnB: Lunar South Pole Landing Planner
13
+
14
+ Interactive planner for lunar south pole landings: will the **Sun** (power) and the **Earth**
15
+ (direct-to-Earth communication) be above the real terrain at the landing site, and what happens if
16
+ the landing slips? NASA Space Apps Challenge 2026.
17
+
18
+ This Space runs in **static mode**: every number is computed in your browser from precomputed data
19
+ (Sun/Earth ephemerides from JPL DE440 via Skyfield, terrain horizon from LRO LOLA). Source code,
20
+ pipeline, API and tests: https://github.com/adryeldeev/equipeOpera-oLua-unitaneu
21
+
22
+ Published from commit `0c28530`.
assets/ldem_3_8bit.jpg ADDED

Git LFS Details

  • SHA256: 6d93f887e7d8bedfe35ab89ba785e5e3ca12381bd092a5e6abe2c707dda8bb98
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
assets/lroc_color_2k.jpg ADDED

Git LFS Details

  • SHA256: f7130a1822681fa7512d7dcfd40db8c10b9ba4f06777910348698260ed7a2170
  • Pointer size: 131 Bytes
  • Size of remote file: 458 kB
assets/polo_sul_cor.png ADDED
assets/polo_sul_normal.jpg ADDED

Git LFS Details

  • SHA256: b74c634ff8ef7e4ac9c7ea58e9816952e3bc6118b1ddbc3fd6c054bd080541db
  • Pointer size: 131 Bytes
  • Size of remote file: 227 kB
data/horizon/apollo11.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mock":true,"site":"apollo11","az_step_deg":1,"horizon_deg":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]}
data/horizon/haworth.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"site":"haworth","az_step_deg":1.0,"horizon_deg":[0.484,0.42,0.274,0.165,-0.062,-0.278,-0.473,-0.608,-0.718,-0.768,-0.773,-0.791,-0.78,-0.719,-0.627,-0.536,-0.397,-0.272,-0.227,-0.115,0.009,0.079,0.184,0.349,0.409,0.51,0.638,0.733,0.805,0.877,0.897,1.01,1.12,1.186,1.234,1.271,1.327,1.471,1.662,1.705,1.875,2.103,2.353,2.636,2.802,2.915,2.915,2.927,3.065,3.281,3.487,3.639,3.749,3.847,3.906,3.886,3.84,3.815,3.763,3.687,3.585,3.439,3.295,3.278,3.246,3.288,3.37,3.363,3.312,3.265,3.184,3.047,2.797,2.518,2.219,1.878,1.554,1.214,0.977,0.884,0.83,0.778,0.759,0.735,0.593,0.447,0.263,0.429,0.547,0.51,0.586,0.732,0.798,0.737,0.726,0.58,0.45,0.467,0.229,0.217,0.316,0.23,0.093,-0.097,-0.262,-0.352,-0.408,-0.377,-0.407,-0.453,-0.545,-0.67,-0.793,-0.922,-1.088,-1.256,-1.396,-1.414,-1.479,-1.513,-1.504,-1.442,-1.525,-1.761,-1.944,-2.067,-2.148,-2.413,-2.516,-2.506,-2.562,-2.588,-2.427,-2.423,-2.418,-2.447,-2.513,-2.647,-2.755,-2.882,-2.957,-3.027,-2.979,-3.001,-3.006,-3.042,-2.985,-2.951,-2.917,-2.826,-2.846,-2.792,-2.879,-2.722,-2.722,-2.779,-2.586,-2.501,-2.498,-2.54,-2.527,-2.56,-2.576,-2.746,-2.758,-2.61,-2.682,-2.569,-2.384,-2.276,-2.09,-2.129,-2.025,-2.025,-1.854,-1.765,-1.707,-1.727,-1.77,-1.786,-1.795,-1.734,-1.668,-1.672,-1.826,-1.83,-1.701,-1.611,-1.561,-1.633,-1.762,-1.738,-1.636,-1.659,-1.762,-1.873,-1.965,-1.881,-1.652,-1.682,-1.783,-1.584,-1.413,-1.222,-1.147,-1.195,-1.166,-1.273,-1.351,-1.293,-1.372,-1.369,-1.53,-1.756,-1.934,-2.136,-2.171,-2.169,-2.283,-2.373,-2.228,-2.049,-1.838,-1.67,-1.544,-1.416,-1.324,-1.271,-1.214,-1.112,-0.926,-0.761,-0.624,-0.532,-0.419,-0.347,-0.279,-0.237,-0.197,-0.104,-0.013,0.064,0.148,0.211,0.288,0.343,0.395,0.435,0.466,0.562,0.683,0.758,0.846,0.922,1.01,1.07,1.091,1.122,1.173,1.227,1.264,1.274,1.296,1.31,1.334,1.326,1.306,1.286,1.276,1.277,1.254,1.211,1.21,1.185,1.205,1.245,1.285,1.343,1.384,1.435,1.491,1.551,1.61,1.688,1.783,1.88,1.976,2.057,2.118,2.175,2.257,2.3,2.345,2.392,2.432,2.481,2.525,2.563,2.604,2.643,2.629,2.601,2.572,2.547,2.532,2.489,2.409,2.328,2.245,2.169,2.177,2.215,2.255,2.324,2.381,2.428,2.475,2.527,2.576,2.616,2.654,2.685,2.714,2.707,2.724,2.724,2.711,2.866,3.09,3.225,3.326,3.401,3.476,3.565,3.568,3.461,3.293,3.097,2.913,2.753,2.596,2.417,2.211,1.989,1.795,1.591,1.387,1.247,1.166,1.067,0.979,0.89,0.786,0.671,0.542,0.427,0.282,0.242,0.226,0.395],"meta":{"fonte":"LOLA GDR polar (PDS Geosciences Node)","dems":["LDEM_80S_80M (80 m/pixel)","LDEM_75S_240M (240 m/pixel)"],"altura_local_m":1695.4,"altura_observador_m":2.0,"dist_max_m":299920.0,"alcance_min_m":299920.0,"lat":-86.8829,"lon":-19.0389,"gerado_em":"2026-11-15T19:00:02Z"},"mock":false}
data/horizon/malapert.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"site":"malapert","az_step_deg":1.0,"horizon_deg":[-1.899,-1.859,-1.819,-1.779,-1.74,-1.702,-1.663,-1.624,-1.605,-1.606,-1.606,-1.605,-1.602,-1.58,-1.557,-1.574,-1.556,-1.526,-1.496,-1.465,-1.434,-1.403,-1.37,-1.338,-1.305,-1.299,-1.307,-1.313,-1.292,-1.31,-1.328,-1.347,-1.335,-1.334,-1.366,-1.398,-1.431,-1.463,-1.483,-1.504,-1.528,-1.562,-1.596,-1.63,-1.645,-1.627,-1.608,-1.589,-1.569,-1.549,-1.529,-1.508,-1.509,-1.5,-1.478,-1.455,-1.432,-1.409,-1.378,-1.377,-1.381,-1.342,-1.308,-1.287,-1.21,-1.16,-1.045,-0.941,-0.898,-0.937,-1.019,-1.1,-1.128,-1.143,-1.09,-1.088,-1.102,-1.189,-1.159,-1.161,-1.091,-0.994,-0.833,-0.67,-0.524,-0.469,-0.379,-0.368,-0.276,-0.179,-0.094,-0.101,-0.164,-0.235,-0.349,-0.675,-0.713,-0.698,-0.644,-0.69,-0.803,-0.948,-1.127,-1.126,-1.113,-1.096,-1.076,-1.061,-1.063,-1.064,-1.02,-0.969,-0.948,-0.975,-1.033,-1.111,-1.195,-1.249,-1.232,-1.231,-1.216,-1.2,-1.185,-1.169,-1.152,-1.136,-1.12,-1.103,-1.086,-1.069,-1.052,-1.055,-1.069,-1.083,-1.096,-1.108,-1.119,-1.147,-1.179,-1.211,-1.242,-1.272,-1.302,-1.33,-1.359,-1.386,-1.413,-1.439,-1.464,-1.488,-1.512,-1.535,-1.557,-1.579,-1.6,-1.608,-1.615,-1.622,-1.628,-1.635,-1.642,-1.649,-1.656,-1.663,-1.67,-1.677,-1.684,-1.691,-1.698,-1.704,-1.711,-1.718,-1.725,-1.731,-1.738,-1.744,-1.751,-1.757,-1.764,-1.789,-1.813,-1.838,-1.862,-1.886,-1.91,-1.934,-1.958,-1.98,-1.982,-1.983,-1.984,-1.985,-1.986,-1.986,-1.986,-1.986,-1.986,-1.986,-1.986,-1.986,-1.985,-1.985,-1.985,-1.985,-1.985,-1.985,-1.985,-1.985,-1.988,-2.014,-2.04,-2.065,-2.088,-2.111,-2.133,-2.155,-2.175,-2.194,-2.199,-2.204,-2.212,-2.227,-2.241,-2.255,-2.267,-2.279,-2.293,-2.311,-2.328,-2.345,-2.358,-2.364,-2.368,-2.372,-2.375,-2.377,-2.378,-2.378,-2.386,-2.406,-2.426,-2.446,-2.465,-2.485,-2.504,-2.524,-2.543,-2.562,-2.581,-2.599,-2.618,-2.629,-2.623,-2.617,-2.61,-2.603,-2.595,-2.587,-2.578,-2.569,-2.56,-2.55,-2.54,-2.529,-2.518,-2.343,-2.171,-1.965,-1.747,-1.598,-1.464,-1.341,-1.271,-1.236,-1.326,-1.48,-1.638,-1.861,-2.145,-2.433,-2.668,-2.44,-2.281,-2.085,-1.83,-1.844,-1.837,-1.728,-1.826,-2.168,-2.615,-2.697,-2.654,-2.61,-2.565,-2.519,-2.471,-2.421,-2.369,-2.317,-2.295,-2.276,-2.261,-2.273,-2.308,-2.342,-2.373,-2.403,-2.417,-2.391,-2.393,-2.417,-2.437,-2.456,-2.472,-2.486,-2.497,-2.529,-2.564,-2.596,-2.615,-2.617,-2.618,-2.616,-2.603,-2.587,-2.571,-2.566,-2.533,-2.517,-2.489,-2.445,-2.4,-2.359,-2.337,-2.315,-2.291,-2.28,-2.291,-2.301,-2.309,-2.309,-2.306,-2.301,-2.295,-2.287,-2.277,-2.267,-2.254,-2.233,-2.206,-2.179,-2.15,-2.121,-2.094,-2.066,-2.037,-2.007,-1.975,-1.937],"meta":{"fonte":"LOLA GDR polar (PDS Geosciences Node)","dems":["LDEM_80S_80M (80 m/pixel)","LDEM_75S_240M (240 m/pixel)"],"altura_local_m":5172.0,"altura_observador_m":2.0,"dist_max_m":299920.0,"alcance_min_m":299920.0,"lat":-85.9876,"lon":2.0528,"gerado_em":"2026-11-15T18:56:15Z"},"mock":false}
data/horizon/mons_mouton.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"site":"mons_mouton","az_step_deg":1.0,"horizon_deg":[-0.497,-0.517,-0.584,-0.631,-0.631,-0.504,-0.351,-0.258,-0.169,-0.154,-0.164,-0.161,-0.015,0.173,0.317,0.429,0.492,0.53,0.556,0.569,0.596,0.64,0.688,0.726,0.719,0.678,0.619,0.539,0.558,0.62,0.663,0.707,0.753,0.826,0.827,0.795,0.766,0.733,0.683,0.611,0.56,0.509,0.47,0.432,0.432,0.491,0.512,0.49,0.498,0.55,0.514,0.457,0.474,0.44,0.374,0.295,0.322,0.313,0.38,0.413,0.361,0.349,0.437,0.525,0.672,0.792,0.84,0.829,0.932,1.072,1.225,1.381,1.493,1.669,1.728,1.915,2.148,2.279,2.4,2.493,2.462,2.332,2.255,2.318,2.514,2.703,2.795,2.87,2.938,2.921,2.905,2.886,2.916,3.012,3.048,3.056,3.075,3.239,3.289,3.199,3.12,3.284,3.419,3.504,3.578,3.676,3.825,3.913,3.945,3.982,4.001,3.992,3.91,3.861,3.875,3.905,3.953,4.052,4.039,4.002,3.941,3.837,3.761,3.737,3.724,3.678,3.588,3.506,3.374,3.244,3.103,2.896,2.717,2.538,2.471,2.386,2.341,2.276,2.174,2.056,1.933,1.969,2.023,2.078,2.132,2.185,2.237,2.288,2.339,2.43,2.663,2.856,3.016,3.088,3.14,3.114,2.974,2.888,2.827,2.792,2.862,2.927,2.982,2.925,2.79,2.815,2.837,2.858,2.878,2.895,2.911,2.924,2.94,2.957,2.971,2.98,2.981,2.982,2.982,2.982,2.983,2.996,3.009,3.01,3.007,3.001,2.994,2.968,2.937,2.923,2.895,2.857,2.817,2.782,2.751,2.719,2.684,2.637,2.604,2.573,2.544,2.509,2.462,2.403,2.348,2.3,2.255,2.213,2.175,2.135,2.092,2.05,2.011,1.973,1.932,1.877,1.827,1.771,1.714,1.656,1.597,1.536,1.474,1.413,1.357,1.31,1.263,1.215,1.16,1.104,1.049,0.992,0.936,0.879,0.822,0.765,0.711,0.668,0.625,0.582,0.538,0.495,0.451,0.407,0.362,0.318,0.273,0.229,0.183,0.137,0.091,0.045,0.001,-0.038,-0.077,-0.115,-0.153,-0.193,-0.224,-0.233,-0.271,-0.241,-0.202,-0.202,-0.232,-0.292,-0.372,-0.445,-0.509,-0.572,-0.627,-0.658,-0.657,-0.652,-0.663,-0.677,-0.699,-0.726,-0.649,-0.558,-0.383,-0.186,-0.006,0.158,0.31,0.459,0.582,0.662,0.756,0.821,0.848,0.827,0.799,0.755,0.832,0.901,0.938,0.922,0.858,0.767,0.631,0.47,0.315,0.154,0.011,-0.11,-0.236,-0.351,-0.461,-0.571,-0.669,-0.706,-0.757,-0.71,-0.684,-0.675,-0.692,-0.727,-0.797,-0.871,-0.993,-1.052,-1.097,-1.126,-1.164,-1.241,-1.351,-1.44,-1.468,-1.451,-1.417,-1.39,-1.376,-1.306,-1.239,-1.182,-1.11,-0.948,-0.881,-0.878,-0.877,-0.886,-0.88,-0.893,-0.937,-1.006,-1.048,-1.113,-1.228,-1.31,-1.234,-1.164,-1.079,-0.961,-0.863,-0.798,-0.758,-0.665,-0.584,-0.51],"meta":{"fonte":"LOLA GDR polar (PDS Geosciences Node)","dems":["LDEM_80S_80M (80 m/pixel)","LDEM_75S_240M (240 m/pixel)"],"altura_local_m":5321.1,"altura_observador_m":2.0,"dist_max_m":299920.0,"alcance_min_m":299920.0,"lat":-84.7906,"lon":29.1957,"gerado_em":"2026-11-15T18:56:16Z"},"mock":false}
data/horizon/nobile.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"site":"nobile","az_step_deg":1.0,"horizon_deg":[0.701,0.702,0.704,0.705,0.706,0.706,0.707,0.707,0.707,0.707,0.707,0.706,0.706,0.705,0.704,0.703,0.702,0.701,0.7,0.698,0.697,0.695,0.693,0.692,0.69,0.688,0.689,0.69,0.691,0.692,0.692,0.685,0.677,0.669,0.661,0.652,0.642,0.632,0.621,0.61,0.598,0.586,0.573,0.56,0.546,0.535,0.527,0.52,0.538,0.617,0.66,0.761,0.792,0.823,1.009,1.005,1.084,1.071,1.014,1.043,1.141,1.229,1.314,1.376,1.367,1.328,1.298,1.197,0.797,0.418,0.393,0.368,0.331,0.275,0.221,0.167,0.115,0.063,0.013,-0.036,-0.085,-0.132,-0.178,-0.223,-0.267,-0.309,-0.351,-0.391,-0.401,-0.351,-0.288,-0.266,-0.266,-0.279,-0.291,-0.256,-0.17,-0.084,-0.046,-0.006,0.035,0.083,0.129,0.163,0.213,0.284,0.333,0.354,0.376,0.398,0.422,0.414,0.389,0.366,0.343,0.276,0.171,0.064,-0.043,-0.146,-0.247,-0.315,-0.268,-0.256,-0.26,-0.337,-0.451,-0.607,-0.75,-0.808,-0.852,-0.951,-1.093,-1.251,-1.276,-1.281,-1.373,-1.474,-1.593,-1.669,-1.743,-1.816,-1.888,-1.835,-1.76,-1.668,-1.583,-1.581,-1.612,-1.582,-1.447,-1.385,-1.338,-1.281,-1.267,-1.296,-1.216,-1.284,-1.388,-1.436,-1.423,-1.406,-1.397,-1.548,-1.562,-1.679,-1.681,-1.703,-1.668,-1.696,-1.817,-1.583,-1.414,-1.377,-1.401,-1.416,-1.434,-1.507,-1.482,-1.521,-1.495,-1.454,-1.454,-1.442,-1.372,-1.199,-1.123,-0.985,-0.918,-0.794,-0.632,-0.449,-0.475,-0.418,-0.419,-0.422,-0.322,-0.212,-0.084,0.018,0.092,0.129,0.105,0.035,-0.1,0.111,0.358,0.641,0.917,1.099,1.208,1.291,1.353,1.401,1.429,1.425,1.418,1.458,1.512,1.585,1.715,1.884,2.084,2.274,2.419,2.556,2.65,2.65,2.591,2.551,2.764,3.101,3.245,3.243,3.254,3.244,3.3,3.404,3.511,3.443,3.601,3.674,3.792,3.831,3.968,4.064,4.203,4.239,4.154,4.063,4.14,4.333,4.539,4.692,4.768,4.85,5.001,5.044,5.171,5.346,5.501,5.474,5.454,5.211,4.885,4.541,4.302,4.261,4.167,4.055,3.906,3.653,3.295,2.897,3.078,3.336,3.595,3.855,4.097,4.305,4.532,4.733,4.948,5.161,5.361,5.557,5.706,5.865,6.052,6.24,6.336,6.439,6.533,6.628,6.713,6.792,6.864,6.947,7.0,7.02,7.038,7.042,7.043,7.047,7.05,7.025,7.023,7.056,7.033,7.015,6.974,6.908,6.854,6.802,6.752,6.694,6.636,6.54,6.419,6.326,6.274,6.225,6.168,6.057,5.939,5.823,5.711,5.568,5.39,5.212,5.023,4.815,4.585,4.375,4.193,4.029,3.878,3.715,3.531,3.371,3.178,2.941,2.755,2.507,2.306,2.09,1.916,1.727,1.559,1.393,1.234,1.062,0.886,0.726,0.717,0.707,0.697,0.695,0.697,0.699],"meta":{"fonte":"LOLA GDR polar (PDS Geosciences Node)","dems":["LDEM_80S_80M (80 m/pixel)","LDEM_75S_240M (240 m/pixel)"],"altura_local_m":1123.1,"altura_observador_m":2.0,"dist_max_m":299920.0,"alcance_min_m":299920.0,"lat":-84.20156,"lon":60.69989,"gerado_em":"2026-11-15T18:56:16Z"},"mock":false}
data/horizon/shackleton.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"site":"shackleton","az_step_deg":1.0,"horizon_deg":[-1.396,-1.494,-1.588,-1.679,-1.64,-1.51,-1.385,-1.25,-1.159,-1.0,-0.88,-0.796,-0.747,-0.741,-0.771,-0.816,-0.759,-0.707,-0.636,-0.547,-0.404,-0.258,-0.064,0.113,0.275,0.442,0.541,0.622,0.766,0.921,1.019,1.08,1.105,1.13,1.08,0.965,0.776,0.552,0.28,-0.014,-0.334,-0.646,-0.987,-1.328,-1.645,-1.737,-1.682,-1.76,-1.982,-1.835,-1.657,-1.489,-1.359,-1.255,-1.197,-1.068,-0.817,-0.631,-0.484,-0.418,-0.455,-0.547,-0.734,-0.957,-1.2,-1.354,-1.451,-1.347,-1.218,-1.093,-0.993,-0.932,-0.878,-0.82,-0.859,-0.829,-0.874,-0.88,-0.934,-1.061,-1.182,-1.34,-1.522,-1.576,-1.601,-1.741,-1.889,-2.023,-2.137,-2.134,-2.165,-2.217,-2.018,-1.765,-1.406,-1.144,-1.06,-0.74,-0.556,-0.633,-0.849,-1.096,-1.276,-1.429,-1.59,-1.729,-1.805,-1.93,-1.899,-1.885,-1.872,-1.858,-1.845,-1.832,-1.819,-1.805,-1.793,-1.78,-1.767,-1.754,-1.742,-1.688,-1.587,-1.485,-1.383,-1.28,-1.176,-1.072,-0.968,-0.863,-0.758,-0.653,-0.547,-0.441,-0.334,-0.3,-0.283,-0.191,-0.077,0.038,0.154,0.269,0.368,0.423,0.544,0.666,0.744,0.773,0.802,0.831,0.859,0.886,0.914,0.94,0.967,0.992,1.017,1.042,1.066,1.089,1.111,1.133,1.154,1.174,1.193,1.212,1.229,1.246,1.262,1.277,1.291,1.303,1.315,1.326,1.336,1.293,1.187,1.079,0.968,0.992,1.026,1.036,1.053,1.067,1.078,0.915,0.744,0.54,0.416,0.339,0.122,0.037,0.023,0.008,-0.008,-0.045,-0.21,-0.375,-0.537,-0.698,-0.858,-1.016,-1.172,-1.326,-1.418,-1.457,-1.486,-1.61,-1.669,-1.851,-1.929,-2.088,-2.152,-2.181,-2.189,-2.152,-2.222,-2.249,-2.235,-2.216,-2.252,-2.297,-2.292,-2.355,-2.422,-2.381,-2.365,-2.364,-2.385,-2.399,-2.376,-2.33,-2.217,-2.203,-2.109,-2.131,-2.19,-2.255,-2.156,-2.026,-1.891,-1.851,-1.822,-1.803,-1.837,-1.823,-1.855,-1.878,-1.907,-1.885,-1.878,-1.825,-1.886,-1.846,-1.794,-1.81,-1.761,-1.684,-1.674,-1.631,-1.582,-1.508,-1.629,-1.459,-1.33,-1.212,-0.999,-0.866,-0.789,-0.72,-0.763,-0.854,-0.966,-0.982,-1.024,-1.092,-1.121,-1.062,-1.137,-1.275,-1.441,-1.64,-1.696,-1.869,-2.028,-2.132,-2.24,-2.235,-2.279,-2.21,-2.134,-1.999,-1.973,-1.974,-1.96,-1.997,-1.964,-1.866,-1.773,-1.762,-1.79,-1.802,-1.837,-1.893,-1.982,-2.042,-2.138,-2.267,-2.323,-2.399,-2.401,-2.467,-2.52,-2.541,-2.518,-2.472,-2.425,-2.278,-2.111,-2.017,-1.96,-1.902,-1.843,-1.784,-1.724,-1.663,-1.61,-1.56,-1.509,-1.455,-1.4,-1.065,-0.732,-0.487,-0.282,-0.174,-0.117,-0.088,-0.176,-0.252,-0.403,-0.57,-0.644,-0.576,-0.508,-0.439,-0.371,-0.302,-0.335,-0.423,-0.512,-0.601,-0.689,-0.779,-0.868,-0.957,-1.047,-1.137,-1.227,-1.298],"meta":{"fonte":"LOLA GDR polar (PDS Geosciences Node)","dems":["LDEM_80S_80M (80 m/pixel)","LDEM_75S_240M (240 m/pixel)"],"altura_local_m":1728.3,"altura_observador_m":2.0,"dist_max_m":299920.0,"alcance_min_m":299920.0,"lat":-89.7682,"lon":-156.4384,"gerado_em":"2026-11-15T18:56:15Z"},"mock":false}
data/sites.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "id": "shackleton",
4
+ "name": "Shackleton Rim",
5
+ "lat": -89.7682,
6
+ "lon": -156.4384,
7
+ "category": "polo_sul",
8
+ "mission": "Artemis (Shackleton rim)",
9
+ "mock": false
10
+ },
11
+ {
12
+ "id": "malapert",
13
+ "name": "Malapert Massif Summit",
14
+ "lat": -85.9876,
15
+ "lon": 2.0528,
16
+ "category": "polo_sul",
17
+ "mission": "Artemis III (Malapert Massif region)",
18
+ "mock": false
19
+ },
20
+ {
21
+ "id": "nobile",
22
+ "name": "Nobile Rim 2",
23
+ "lat": -84.20156,
24
+ "lon": 60.69989,
25
+ "category": "polo_sul",
26
+ "mission": "Artemis III (Nobile Rim 2 region)",
27
+ "mock": false
28
+ },
29
+ {
30
+ "id": "haworth",
31
+ "name": "Haworth Rim",
32
+ "lat": -86.8829,
33
+ "lon": -19.0389,
34
+ "category": "polo_sul",
35
+ "mission": "Artemis III (Haworth region)",
36
+ "mock": false
37
+ },
38
+ {
39
+ "id": "mons_mouton",
40
+ "name": "Mons Mouton (IM-2 landing site)",
41
+ "lat": -84.7906,
42
+ "lon": 29.1957,
43
+ "category": "polo_sul",
44
+ "mission": "IM-2 (2025); Artemis III (Mons Mouton region)",
45
+ "mock": false
46
+ },
47
+ {
48
+ "id": "apollo11",
49
+ "name": "Apollo 11 (Sea of Tranquility)",
50
+ "lat": 0.674,
51
+ "lon": 23.473,
52
+ "category": "referencia",
53
+ "mission": "Apollo 11 (1969), non-polar reference",
54
+ "mock": false
55
+ }
56
+ ]
data/sky/_meta.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "fonte": "skyfield",
3
+ "skyfield_version": "1.55",
4
+ "kernels": [
5
+ "de440s.bsp",
6
+ "moon_pa_de440_200625.bpc",
7
+ "moon_de440_250416.tf"
8
+ ],
9
+ "frame": "MOON_ME",
10
+ "frame_spice": "MOON_ME_DE440_ME421",
11
+ "inicio": "2027-01-01T00:00:00Z",
12
+ "fim": "2027-12-31T23:00:00Z",
13
+ "step_min": 60,
14
+ "n_instantes": 8760,
15
+ "sites": [
16
+ "apollo11",
17
+ "haworth",
18
+ "malapert",
19
+ "mons_mouton",
20
+ "nobile",
21
+ "shackleton"
22
+ ],
23
+ "gerado_em": "2026-11-15T19:00:02Z"
24
+ }
data/sky/apollo11.json ADDED
The diff for this file is too large to render. See raw diff
 
data/sky/haworth.json ADDED
The diff for this file is too large to render. See raw diff
 
data/sky/malapert.json ADDED
The diff for this file is too large to render. See raw diff
 
data/sky/mons_mouton.json ADDED
The diff for this file is too large to render. See raw diff
 
data/sky/nobile.json ADDED
The diff for this file is too large to render. See raw diff
 
data/sky/shackleton.json ADDED
The diff for this file is too large to render. See raw diff
 
index.html CHANGED
@@ -1,19 +1,234 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>LanderBnB</title>
7
+ <!-- Empty = auto-detect (same origin or http://localhost:8001). -->
8
+ <meta name="api-base" content="static">
9
+ <link rel="stylesheet" href="style.css">
10
+
11
+ <!-- BIBLIOTECA THREE.JS -->
12
+ <script type="importmap">
13
+ {
14
+ "imports": {
15
+ "three": "https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js",
16
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.180.0/examples/jsm/"
17
+ }
18
+ }
19
+ </script>
20
+ </head>
21
+
22
+ <body>
23
+
24
+ <!-- CABEÇALHO LANDERBNB -->
25
+ <header class="cabecalho">
26
+ <div class="identidade">
27
+ <div class="logo">🚀</div>
28
+ <div class="nome-projeto">
29
+ <h1>LanderBnB</h1>
30
+ <p>NASA Space Apps Challenge 2026: The Next Frontier</p>
31
+ </div>
32
+ </div>
33
+ <button class="botao-configuracoes" type="button" aria-label="Settings">⚙</button>
34
+ </header>
35
+
36
+ <p class="aviso-api" id="aviso-api" role="status" aria-live="polite" hidden></p>
37
+
38
+ <!-- ÁREA PRINCIPAL -->
39
+ <main class="layout-principal">
40
+
41
+ <!-- MENU LATERAL ESQUERDO -->
42
+ <aside class="menu-lateral">
43
+ <h2 class="titulo-menu">Mission Steps</h2>
44
+ <nav class="lista-passos" aria-label="Mission steps">
45
+ <button class="botao-passo ativo" type="button" data-etapa="localizacao" aria-current="step">
46
+ <span class="numero-passo">01</span>
47
+ <span class="texto-passo">Location</span>
48
+ <span class="seta-passo">›</span>
49
+ </button>
50
+ <button class="botao-passo" type="button" data-etapa="data-hora">
51
+ <span class="numero-passo">02</span>
52
+ <span class="texto-passo">Date/Time</span>
53
+ <span class="seta-passo">›</span>
54
+ </button>
55
+ <button class="botao-passo" type="button" data-etapa="sol-terra">
56
+ <span class="numero-passo">03</span>
57
+ <span class="texto-passo">View Sun/Earth</span>
58
+ <span class="seta-passo">›</span>
59
+ </button>
60
+ <button class="botao-passo" type="button" data-etapa="energia">
61
+ <span class="numero-passo">04</span>
62
+ <span class="texto-passo">Check Power</span>
63
+ <span class="seta-passo">›</span>
64
+ </button>
65
+ <button class="botao-passo" type="button" data-etapa="comunicacao">
66
+ <span class="numero-passo">05</span>
67
+ <span class="texto-passo">Communication</span>
68
+ <span class="seta-passo">›</span>
69
+ </button>
70
+ </nav>
71
+ </aside>
72
+
73
+ <!-- VISUALIZAÇÃO DA LUA 3D -->
74
+ <section class="area-mapa" aria-label="3D Moon">
75
+ <div class="visualizador-lua">
76
+ <h2 class="titulo-visualizador">3D Lunar Exploration</h2>
77
+ <div class="container-lua" id="lua-3d"></div>
78
+ <p class="instrucao-lua">Drag to rotate · scroll to zoom · click a site</p>
79
+ </div>
80
+ </section>
81
+
82
+ <!-- PAINEL DIREITO DA MISSÃO -->
83
+ <aside class="painel-direito">
84
+
85
+ <!-- GUIA DA MISSÃO -->
86
+ <section class="card-painel">
87
+ <h2>Mission Guide</h2>
88
+
89
+ <div class="etapas-missao">
90
+ <div class="etapa atual" data-indicador-etapa="localizacao"><span>1</span><small>Site</small></div>
91
+ <div class="etapa" data-indicador-etapa="data-hora"><span>2</span><small>Date</small></div>
92
+ <div class="etapa" data-indicador-etapa="sol-terra"><span>3</span><small>Sun/Earth</small></div>
93
+ <div class="etapa" data-indicador-etapa="energia"><span>4</span><small>Power</small></div>
94
+ <div class="etapa" data-indicador-etapa="comunicacao"><span>5</span><small>Comms</small></div>
95
+ </div>
96
+
97
+ <div class="conteudos-etapa" aria-live="polite">
98
+ <div class="resumo-data-missao" id="resumo-data-missao" hidden>
99
+ <span>Mission date/time (landing):</span>
100
+ <strong id="valor-resumo-data-missao"></strong>
101
+ </div>
102
+
103
+ <section class="conteudo-etapa" data-conteudo-etapa="localizacao">
104
+ <h3>Selected site</h3>
105
+ <strong class="valor-etapa" id="valor-etapa-localizacao">No site selected</strong>
106
+ <span class="detalhe-etapa" id="coordenadas-etapa-localizacao">
107
+ Select a landing site in the cards or on the Moon.
108
+ </span>
109
+ </section>
110
+
111
+ <section class="conteudo-etapa" data-conteudo-etapa="data-hora" hidden>
112
+ <h3>Mission date and time</h3>
113
+ <label class="campo-etapa" for="data-missao">
114
+ Date
115
+ <input type="date" id="data-missao">
116
+ </label>
117
+ <label class="campo-etapa" for="hora-missao">
118
+ Time (your browser time zone; converted to UTC)
119
+ <input type="time" id="hora-missao" step="3600">
120
+ </label>
121
+ <span class="detalhe-etapa">
122
+ Metrics use a 30-day window starting at this instant
123
+ (a bit more than one lunar solar day).
124
+ </span>
125
+ </section>
126
+
127
+ <section class="conteudo-etapa" data-conteudo-etapa="sol-terra" hidden>
128
+ <h3>Sun and Earth at landing time</h3>
129
+ <svg class="grafico-ceu" id="grafico-ceu" role="img"
130
+ aria-label="Terrain horizon with the Sun and Earth positions"></svg>
131
+ <p class="legenda-ceu">
132
+ <span class="chip relevo"></span>terrain (LOLA)
133
+ <span class="chip sol"></span>Sun
134
+ <span class="chip terra"></span>Earth
135
+ </p>
136
+ <p class="detalhe-etapa texto-sol-terra" id="texto-sol-terra">Select a site (step 1).</p>
137
+ <span class="aviso-simulacao-etapa">
138
+ Visible = any part of the disk above the terrain at that azimuth.
139
+ </span>
140
+ </section>
141
+
142
+ <section class="conteudo-etapa" data-conteudo-etapa="energia" hidden>
143
+ <h3>Solar power</h3>
144
+ <strong class="valor-etapa" id="valor-etapa-energia">Select a landing site.</strong>
145
+
146
+ <div class="parametros-energia">
147
+ <label class="campo-energia" for="potencia-paineis">
148
+ Rated panel power (W)
149
+ <input type="number" id="potencia-paineis" min="0.01" step="any">
150
+ </label>
151
+ <label class="campo-energia" for="consumo-missao">
152
+ Mission power draw (W)
153
+ <input type="number" id="consumo-missao" min="0" step="any">
154
+ </label>
155
+ <label class="campo-energia" for="capacidade-bateria">
156
+ Battery capacity (Wh)
157
+ <input type="number" id="capacidade-bateria" min="0.01" step="any">
158
+ </label>
159
+ <label class="campo-energia" for="carga-bateria">
160
+ Initial battery charge (%)
161
+ <input type="number" id="carga-bateria" min="0" max="100" step="any">
162
+ </label>
163
+ <label class="campo-energia" for="eficiencia-paineis">
164
+ System efficiency (%)
165
+ <input type="number" id="eficiencia-paineis" min="0.01" max="100" step="any">
166
+ </label>
167
+ </div>
168
+ <p class="detalhe-etapa">
169
+ The same parameters are used to compare every site, hour by hour,
170
+ with the real Sun visibility. Simple model: with Sun, output = power × efficiency;
171
+ without Sun, 0. An estimate, not a certified operational forecast.
172
+ </p>
173
+ <div class="resultados-simulacao-energia">
174
+ <h4>Power comparison</h4>
175
+ <p class="estado-simulacao-energia" id="estado-simulacao-energia" role="status" aria-live="polite"></p>
176
+ <p class="resumo-parametros-energia" id="resumo-parametros-energia"></p>
177
+ <ul class="lista-resultados-energia" id="lista-resultados-energia"></ul>
178
+ </div>
179
+ <div class="calculo-elevacao-solar">
180
+ <h4>Sun at landing time</h4>
181
+ <p class="estado-calculo-elevacao" id="estado-calculo-elevacao" role="status" aria-live="polite"></p>
182
+ <ul class="lista-elevacao-solar" id="lista-elevacao-solar"></ul>
183
+ <p class="aviso-topografia-solar">
184
+ LOLA terrain (80–240 m per pixel): boulders and smaller craters are not included.
185
+ The terrain error (~1–2°) is comparable to the Sun height at the pole, so
186
+ the cards show an uncertainty range.
187
+ </p>
188
+ </div>
189
+ </section>
190
+
191
+ <section class="conteudo-etapa" data-conteudo-etapa="comunicacao" hidden>
192
+ <h3>Direct-to-Earth communication</h3>
193
+ <strong class="valor-etapa" id="valor-etapa-comunicacao">Select a landing site.</strong>
194
+ <span class="aviso-simulacao-etapa">
195
+ Direct line of sight to Earth only. Out of scope: ground-station availability and relay satellites.
196
+ </span>
197
+ </section>
198
+ </div>
199
+ </section>
200
+
201
+ <!-- SIMULADOR DE ATRASO -->
202
+ <section class="card-painel">
203
+ <h2>Delay Simulator</h2>
204
+ <div class="valor-atraso"><span id="dias-atraso">+0 days</span></div>
205
+ <input type="range" id="simulador-atraso" min="0" max="14" value="0" aria-label="Delay in days">
206
+ <div class="limites-atraso"><span>0 days</span><span>+14 days</span></div>
207
+ <svg class="grafico-atraso" id="grafico-atraso" role="img" aria-label="Score per day of delay"></svg>
208
+ <p class="resultado-atraso" id="resultado-atraso" aria-live="polite">Select a site to simulate a delay.</p>
209
+ </section>
210
+
211
+ <!-- LOCAIS DE POUSO -->
212
+ <section class="card-painel">
213
+ <h2>Landing Sites</h2>
214
+ <div class="local-selecionado">
215
+ <span>Selected site:</span>
216
+ <strong id="nome-local-selecionado">No site selected</strong>
217
+ </div>
218
+ <div class="lista-locais" id="lista-locais"></div>
219
+ </section>
220
+
221
+ </aside>
222
+ </main>
223
+
224
+ <footer class="rodape">
225
+ Sky: Skyfield + JPL DE440 (NAIF) · Terrain: LRO LOLA (PDS Geosciences) ·
226
+ Moon texture: NASA's Scientific Visualization Studio (CGI Moon Kit) · Design: LanderBnB
227
+ </footer>
228
+
229
+ <!-- Order matters: the 3D Moon registers its listeners before the steps fire events. -->
230
+ <script type="module" src="js/lua.js"></script>
231
+ <script type="module" src="js/locais.js"></script>
232
+ <script type="module" src="js/etapas.js"></script>
233
+ </body>
234
+ </html>
js/api.js ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Cliente de dados do front. O front só LÊ: nada aqui escreve dados.
2
+ //
3
+ // Dois modos, com as MESMAS respostas (as telas não sabem qual está em uso):
4
+ // API chama api/main.py (céu calculado na hora, qualquer data 1849–2150);
5
+ // ESTÁTICO sem servidor: lê data/ (céu pré-calculado) e faz as contas no
6
+ // navegador com calculo.js, cópia fiel do pipeline/metrics.py.
7
+ //
8
+ // Escolha do modo (<meta name="api-base"> no index.html):
9
+ // "static" -> sempre estático (usado na hospedagem gratuita);
10
+ // "<url>" -> só essa API;
11
+ // vazio -> tenta a mesma origem e http://localhost:8001; se nenhuma
12
+ // responder, cai no modo estático.
13
+
14
+ import * as calc from "./calculo.js";
15
+
16
+ const CANDIDATOS_PADRAO = ["", "http://localhost:8001"];
17
+ const ATRASO_MAX_DIAS = 14;
18
+ let base = null; // URL da API, ou null no modo estático
19
+ let dados = null; // URL da pasta data/ (modo estático)
20
+
21
+ async function json(url) {
22
+ const r = await fetch(url);
23
+ if (!r.ok) {
24
+ let detalhe = `HTTP ${r.status}`;
25
+ try { detalhe = (await r.json()).detail || detalhe; } catch { /* sem corpo JSON */ }
26
+ throw new Error(detalhe);
27
+ }
28
+ return r.json();
29
+ }
30
+
31
+ // ---------------------------------------------------------------- modo estático
32
+
33
+ const cache = new Map();
34
+ function lerDados(rel) {
35
+ if (!cache.has(rel)) {
36
+ const p = json(new URL(rel, dados).href);
37
+ p.catch(() => cache.delete(rel));
38
+ cache.set(rel, p);
39
+ }
40
+ return cache.get(rel);
41
+ }
42
+
43
+ async function acharDados() {
44
+ for (const rel of ["data/", "../data/", "/data/"]) {
45
+ const url = new URL(rel, document.baseURI).href;
46
+ try {
47
+ await json(`${url}sites.json`);
48
+ return url;
49
+ } catch { /* tenta a próxima */ }
50
+ }
51
+ throw new Error("data/ not found (sites.json)");
52
+ }
53
+
54
+ async function saudeEstatica() {
55
+ const meta = await lerDados("sky/_meta.json");
56
+ // Última data de pouso útil: a janela padrão + o maior atraso cabem no céu gravado.
57
+ const fimMs = Date.parse(meta.fim) - (calc.JANELA_H_PADRAO + ATRASO_MAX_DIAS * 24) * 3600e3;
58
+ return {
59
+ status: "ok", modo: "estatico", efemerides: false, erro_efemerides: null,
60
+ intervalo_suportado: { inicio: meta.inicio, fim: new Date(fimMs).toISOString().replace(".000Z", "Z") },
61
+ padroes: { janela_h: calc.JANELA_H_PADRAO, ok: calc.OK_PADRAO, crit: calc.CRIT_PADRAO,
62
+ incerteza_graus: calc.INCERTEZA_PADRAO_GRAUS },
63
+ };
64
+ }
65
+
66
+ function fonte(hz) {
67
+ return { ceu: "data/sky (static mode, computed in the browser)",
68
+ horizonte: hz.mock ? "mock" : (hz.meta?.fonte || "real") };
69
+ }
70
+
71
+ async function par(id) {
72
+ return Promise.all([lerDados(`sky/${encodeURIComponent(id)}.json`), lerDados(`horizon/${encodeURIComponent(id)}.json`)]);
73
+ }
74
+
75
+ function limiares(ok = calc.OK_PADRAO, crit = calc.CRIT_PADRAO) {
76
+ ok = Number(ok); crit = Number(crit);
77
+ return ok > 1 || crit > 1 ? [ok / 100, crit / 100] : [ok, crit];
78
+ }
79
+
80
+ const estatico = {
81
+ sites: () => lerDados("sites.json"),
82
+ horizonte: (id) => lerDados(`horizon/${encodeURIComponent(id)}.json`),
83
+ async metricas(id, p) {
84
+ const [ceu, hz] = await par(id);
85
+ const [ok, crit] = limiares(p.ok, p.crit);
86
+ const m = calc.calcularMetricas(ceu, hz, calc.indiceDe(ceu, p.inicio), Number(p.janela_h ?? calc.JANELA_H_PADRAO), ok, crit);
87
+ return { ...m, fonte: fonte(hz) };
88
+ },
89
+ async atrasos(id, p) {
90
+ const [ceu, hz] = await par(id);
91
+ const [ok, crit] = limiares(p.ok, p.crit);
92
+ const janela = Number(p.janela_h ?? calc.JANELA_H_PADRAO);
93
+ const n = Number(p.atraso_max_dias ?? ATRASO_MAX_DIAS);
94
+ const serie = calc.seriePorAtraso(ceu, hz, calc.indiceDe(ceu, p.inicio), janela, [...Array(n + 1).keys()], ok, crit);
95
+ return { site: id, inicio: p.inicio, janela_h: janela, thresholds: { ok, crit },
96
+ mock: Boolean(ceu.mock) || Boolean(hz.mock), fonte: fonte(hz), serie };
97
+ },
98
+ async visibilidade(id, p) {
99
+ const [ceu, hz] = await par(id);
100
+ const i0 = calc.indiceDe(ceu, p.inicio);
101
+ const n = Math.ceil((Number(p.dias ?? 30) * 1440) / ceu.step_min);
102
+ if (i0 + n > ceu.sun.el.length) throw new Error("period out of the precomputed sky");
103
+ const g = calc.geometria(ceu, hz);
104
+ const v = calc.visivel(g);
105
+ const corta = (a) => a.slice(i0, i0 + n);
106
+ const corpo = (c, gc, vis) => ({ az: corta(c.az), el: corta(c.el), rad_deg: corta(c.rad_deg),
107
+ horizonte: corta(gc.hz).map((x) => Math.round(x * 1000) / 1000), visivel: corta(vis) });
108
+ return { site: id, start: p.inicio, step_min: ceu.step_min, mock: Boolean(ceu.mock) || Boolean(hz.mock),
109
+ fonte: fonte(hz), sol: corpo(ceu.sun, g.sun, v.sol), terra: corpo(ceu.earth, g.earth, v.terra) };
110
+ },
111
+ };
112
+
113
+ // ---------------------------------------------------------------- modo API
114
+
115
+ function q(params) {
116
+ return new URLSearchParams(Object.entries(params).filter(([, v]) => v !== undefined && v !== null));
117
+ }
118
+
119
+ const remoto = {
120
+ sites: () => json(`${base}/api/sites`),
121
+ horizonte: (id) => json(`${base}/api/sites/${encodeURIComponent(id)}/horizonte`),
122
+ metricas: (id, p) => json(`${base}/api/sites/${encodeURIComponent(id)}/metricas?${q(p)}`),
123
+ atrasos: (id, p) => json(`${base}/api/sites/${encodeURIComponent(id)}/atrasos?${q(p)}`),
124
+ visibilidade: (id, p) => json(`${base}/api/sites/${encodeURIComponent(id)}/visibilidade?${q(p)}`),
125
+ };
126
+
127
+ let impl = null;
128
+ export const api = {
129
+ sites: (...a) => impl.sites(...a),
130
+ horizonte: (...a) => impl.horizonte(...a),
131
+ metricas: (...a) => impl.metricas(...a),
132
+ atrasos: (...a) => impl.atrasos(...a),
133
+ visibilidade: (...a) => impl.visibilidade(...a),
134
+ };
135
+
136
+ /** Escolhe o modo; devolve {base, saude}. saude.modo === "estatico" no modo sem servidor. */
137
+ export async function conectar() {
138
+ const meta = document.querySelector('meta[name="api-base"]')?.content?.trim();
139
+ if (meta !== "static") {
140
+ for (const c of meta ? [meta] : CANDIDATOS_PADRAO) {
141
+ try {
142
+ const saude = await json(`${c}/api/saude`);
143
+ base = c;
144
+ impl = remoto;
145
+ return { base: c || location.origin, saude };
146
+ } catch { /* tenta a próxima */ }
147
+ }
148
+ }
149
+ dados = await acharDados();
150
+ impl = estatico;
151
+ return { base: dados, saude: await saudeEstatica() };
152
+ }
153
+
154
+ /** Sem API nem data/: ao menos tenta a lista de locais. */
155
+ export async function sitesSemApi() {
156
+ for (const url of ["/data/sites.json", new URL("../data/sites.json", document.baseURI).href]) {
157
+ try { return await json(url); } catch { /* tenta a próxima */ }
158
+ }
159
+ return [];
160
+ }
js/calculo.js ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Cópia em JavaScript de pipeline/metrics.py, para o MODO ESTÁTICO (site sem
2
+ // servidor: as contas rodam no navegador com os arquivos de data/).
3
+ //
4
+ // Deve dar EXATAMENTE os mesmos números do Python. Isso é conferido por
5
+ // web/tests/calculo.test.mjs contra web/tests/fixtures/metricas_ref.json,
6
+ // gerado pelo próprio pipeline (python pipeline/tools/gerar_referencia_js.py).
7
+ // Se mudar uma regra aqui, mude lá também (e vice-versa).
8
+
9
+ export const OK_PADRAO = 0.5;
10
+ export const CRIT_PADRAO = 0.2;
11
+ export const JANELA_H_PADRAO = 720;
12
+ export const INCERTEZA_PADRAO_GRAUS = 1.0;
13
+
14
+ /** Regra de visibilidade: alguma parte do disco acima do relevo + margem. */
15
+ export function regraVisivel(el, rad, hz, margem = 0) {
16
+ return el + rad > hz + margem;
17
+ }
18
+
19
+ /** Horizonte interpolado linearmente no azimute (com wrap em 360°). */
20
+ export function horizonteEm(h, az) {
21
+ const v = h.horizon_deg, passo = h.az_step_deg, n = v.length;
22
+ if (!n || passo <= 0 || Math.abs(n * passo - 360) > 1e-9) {
23
+ throw new Error(`invalid horizon: ${n} values with a ${passo}° step do not cover 360°`);
24
+ }
25
+ // Igual a np.mod(az, 360) / passo (resultado sempre em [0, 360)).
26
+ const x = (((az % 360) + 360) % 360) / passo;
27
+ const base = Math.floor(x);
28
+ const f = x - base;
29
+ const i0 = ((base % n) + n) % n;
30
+ const i1 = (i0 + 1) % n;
31
+ return v[i0] * (1 - f) + v[i1] * f;
32
+ }
33
+
34
+ function iso(ms) {
35
+ return new Date(ms).toISOString().replace(".000Z", "Z");
36
+ }
37
+
38
+ function instante(texto) {
39
+ return Date.parse(texto);
40
+ }
41
+
42
+ function maiorSequencia(b, ini, fim) {
43
+ let melhor = 0, atual = 0;
44
+ for (let i = ini; i < fim; i++) {
45
+ atual = b[i] ? atual + 1 : 0;
46
+ if (atual > melhor) melhor = atual;
47
+ }
48
+ return melhor;
49
+ }
50
+
51
+ function conferirLimiares(ok, crit) {
52
+ for (const [nome, v] of [["ok", ok], ["crit", crit]]) {
53
+ if (typeof v !== "number" || !Number.isFinite(v)) throw new Error(`threshold ${nome} must be a number (got: ${v})`);
54
+ if (v < 0 || v > 1) throw new Error(`threshold ${nome} must be a fraction between 0 and 1 (got: ${v})`);
55
+ }
56
+ if (!(crit < ok)) throw new Error(`the critical threshold (${crit}) must be lower than the ok threshold (${ok})`);
57
+ }
58
+
59
+ export function classificar(score, ok, crit) {
60
+ conferirLimiares(ok, crit);
61
+ if (score >= ok) return "ideal";
62
+ if (score < crit) return "critico";
63
+ return "moderado";
64
+ }
65
+
66
+ function passos(ceu, horas, nome) {
67
+ const n = (horas * 60) / ceu.step_min;
68
+ if (Math.abs(n - Math.round(n)) > 1e-9) {
69
+ throw new Error(`${nome} = ${horas} h is not a multiple of the sky time step (${ceu.step_min} min)`);
70
+ }
71
+ return Math.round(n);
72
+ }
73
+
74
+ function janela(ceu, inicioIdx, janelaH) {
75
+ const n = passos(ceu, janelaH, "janela_h");
76
+ if (n <= 0) throw new Error(`janela_h must be > 0 (got: ${janelaH})`);
77
+ const total = ceu.sun.el.length;
78
+ if (inicioIdx < 0 || inicioIdx + n > total) {
79
+ const ini = instante(ceu.start), passoMs = ceu.step_min * 60000;
80
+ throw new Error(
81
+ `window out of the sky range: requested ${iso(ini + passoMs * inicioIdx)} + ${janelaH} h, ` +
82
+ `but the sky for ${ceu.site} covers ${iso(ini)} to ${iso(ini + passoMs * total)} ` +
83
+ `(${total} samples of ${ceu.step_min} min)`);
84
+ }
85
+ return n;
86
+ }
87
+
88
+ /** Índice do instante (ms ou ISO) na grade do céu. */
89
+ export function indiceDe(ceu, quando) {
90
+ const ms = typeof quando === "number" ? quando : instante(quando);
91
+ const p = (ms - instante(ceu.start)) / (ceu.step_min * 60000);
92
+ if (Math.abs(p - Math.round(p)) > 1e-9) throw new Error(`${iso(ms)} is not on the ${ceu.step_min}-min grid of the sky`);
93
+ const i = Math.round(p);
94
+ if (i < 0 || i >= ceu.sun.el.length) throw new Error(`${iso(ms)} is out of the sky range for ${ceu.site}`);
95
+ return i;
96
+ }
97
+
98
+ /** Elevação, raio e horizonte por instante, para Sol e Terra (interpolação feita uma vez). */
99
+ export function geometria(ceu, hz) {
100
+ if (ceu.site !== hz.site) throw new Error(`sky and horizon are from different sites: '${ceu.site}' and '${hz.site}'`);
101
+ const g = {};
102
+ for (const corpo of ["sun", "earth"]) {
103
+ const c = ceu[corpo];
104
+ g[corpo] = { el: c.el, rad: c.rad_deg, hz: c.az.map((az) => horizonteEm(hz, az)) };
105
+ }
106
+ return g;
107
+ }
108
+
109
+ export function visivel(g, margem = 0) {
110
+ const f = (c) => c.el.map((el, i) => regraVisivel(el, c.rad[i], c.hz[i], margem));
111
+ return { sol: f(g.sun), terra: f(g.earth) };
112
+ }
113
+
114
+ function contar(b, ini, fim) {
115
+ let n = 0;
116
+ for (let i = ini; i < fim; i++) if (b[i]) n++;
117
+ return n;
118
+ }
119
+
120
+ function resumo(b, ini, fim, passoH) {
121
+ const n = fim - ini;
122
+ const sem = b.map((x) => !x);
123
+ return {
124
+ pct: contar(b, ini, fim) / n,
125
+ longest_with_h: maiorSequencia(b, ini, fim) * passoH,
126
+ longest_without_h: maiorSequencia(sem, ini, fim) * passoH,
127
+ };
128
+ }
129
+
130
+ function diario(b, ini, fim, inicioMs, stepMin) {
131
+ const vistos = [], totais = [];
132
+ for (let i = ini; i < fim; i++) {
133
+ const dia = Math.floor(((i - ini) * stepMin) / 1440);
134
+ vistos[dia] = (vistos[dia] || 0) + (b[i] ? 1 : 0);
135
+ totais[dia] = (totais[dia] || 0) + 1;
136
+ }
137
+ return totais.map((t, k) => ({ date: iso(inicioMs + k * 86400000), pct: vistos[k] / t }));
138
+ }
139
+
140
+ /** Mesma saída de pipeline.metrics.calcular_metricas. */
141
+ export function calcularMetricas(ceu, hz, inicioIdx, janelaH, ok = OK_PADRAO, crit = CRIT_PADRAO,
142
+ margem = 0, incerteza = INCERTEZA_PADRAO_GRAUS) {
143
+ conferirLimiares(ok, crit);
144
+ const n = janela(ceu, inicioIdx, janelaH);
145
+ if (incerteza < 0) throw new Error(`incerteza_graus must be >= 0 (got: ${incerteza})`);
146
+ const ini = inicioIdx, fim = inicioIdx + n;
147
+ const passoH = ceu.step_min / 60;
148
+ const inicioMs = instante(ceu.start) + ceu.step_min * 60000 * ini;
149
+ const g = geometria(ceu, hz);
150
+
151
+ const scoreCom = (m) => {
152
+ const v = visivel(g, m);
153
+ return Math.min(contar(v.sol, ini, fim), contar(v.terra, ini, fim)) / n;
154
+ };
155
+ const v = visivel(g, margem);
156
+ const ambos = v.sol.map((s, i) => s && v.terra[i]);
157
+ const energy = { ...resumo(v.sol, ini, fim, passoH), daily: diario(v.sol, ini, fim, inicioMs, ceu.step_min) };
158
+ const comms = { ...resumo(v.terra, ini, fim, passoH), daily: diario(v.terra, ini, fim, inicioMs, ceu.step_min) };
159
+ const score = Math.min(energy.pct, comms.pct);
160
+ return {
161
+ site: ceu.site,
162
+ window: { start: iso(inicioMs), hours: n * passoH },
163
+ mock: Boolean(ceu.mock) || Boolean(hz.mock),
164
+ energy, comms,
165
+ both: { pct: contar(ambos, ini, fim) / n, longest_h: maiorSequencia(ambos, ini, fim) * passoH },
166
+ score,
167
+ class: classificar(score, ok, crit),
168
+ thresholds: { ok, crit },
169
+ incerteza: { margem_graus: incerteza, score_min: scoreCom(margem + incerteza), score_max: scoreCom(margem - incerteza) },
170
+ };
171
+ }
172
+
173
+ /** Mesma saída de pipeline.metrics.serie_por_atraso. */
174
+ export function seriePorAtraso(ceu, hz, inicioIdx, janelaH, atrasos, ok = OK_PADRAO, crit = CRIT_PADRAO, margem = 0) {
175
+ conferirLimiares(ok, crit);
176
+ const n = janela(ceu, inicioIdx, janelaH);
177
+ const total = ceu.sun.el.length;
178
+ const desloc = atrasos.map((a) => {
179
+ const d = passos(ceu, a * 24, `delay of ${a} days`);
180
+ if (inicioIdx + d < 0 || inicioIdx + d + n > total) janela(ceu, inicioIdx + d, janelaH);
181
+ return d;
182
+ });
183
+ const v = visivel(geometria(ceu, hz), margem);
184
+ const acum = (b) => { const a = [0]; b.forEach((x, i) => a.push(a[i] + (x ? 1 : 0))); return a; };
185
+ const as = acum(v.sol), at = acum(v.terra);
186
+ return atrasos.map((a, k) => {
187
+ const i = inicioIdx + desloc[k];
188
+ const sc = Math.min(as[i + n] - as[i], at[i + n] - at[i]) / n;
189
+ return { atraso_dias: a, score: sc, class: classificar(sc, ok, crit) };
190
+ });
191
+ }
js/etapas.js ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Controle das 5 etapas (Local → Data/Hora → Sol/Terra → Energia → Comunicação),
2
+ // do simulador de atraso e da simulação de bateria. Toda a ciência vem da API;
3
+ // aqui só se busca, combina e mostra.
4
+
5
+ import { conectar, api, sitesSemApi } from "./api.js";
6
+ import { desenharCards } from "./locais.js";
7
+ import { direcaoDoCeu, paraUTC, pct, duracao, simularBateria, rotuloClasse } from "./geo.js";
8
+
9
+ const $ = (id) => document.getElementById(id);
10
+
11
+ const estado = {
12
+ padroes: { janela_h: 720, ok: 0.5, crit: 0.2 },
13
+ sites: [],
14
+ selecionado: null,
15
+ inicio: null, // ISO UTC
16
+ metricas: new Map(), // id -> /metricas
17
+ visibilidade: new Map(),// id -> /visibilidade (janela inteira)
18
+ horizontes: new Map(), // id -> /horizonte
19
+ atrasos: null, // /atrasos do selecionado
20
+ conectada: false,
21
+ pedido: 0, // descarta respostas de pedidos antigos
22
+ avisoBase: ["", "info"], // aviso permanente (modo estático / plano B)
23
+ };
24
+
25
+ // ---------------------------------------------------------------- utilidades
26
+
27
+ function el(tag, classe, texto) {
28
+ const e = document.createElement(tag);
29
+ if (classe) e.className = classe;
30
+ if (texto !== undefined) e.textContent = texto;
31
+ return e;
32
+ }
33
+
34
+ function local(id = estado.selecionado) {
35
+ return estado.sites.find((s) => s.id === id);
36
+ }
37
+
38
+ function aviso(texto, tipo = "info") {
39
+ const caixa = $("aviso-api");
40
+ caixa.textContent = texto;
41
+ caixa.dataset.tipo = tipo;
42
+ caixa.hidden = !texto;
43
+ }
44
+
45
+ function fmtDataLocal(iso) {
46
+ const d = new Date(iso);
47
+ return `${d.toLocaleString("en-US", { dateStyle: "medium", timeStyle: "short" })} (local time) · ` +
48
+ `${iso.replace("T", " ").replace(":00Z", " UTC")}`;
49
+ }
50
+
51
+ // ---------------------------------------------------------------- etapas (navegação)
52
+
53
+ const ETAPAS = ["localizacao", "data-hora", "sol-terra", "energia", "comunicacao"];
54
+
55
+ function mostrarEtapa(nome) {
56
+ document.querySelectorAll(".botao-passo").forEach((b) => {
57
+ const ativo = b.dataset.etapa === nome;
58
+ b.classList.toggle("ativo", ativo);
59
+ if (ativo) b.setAttribute("aria-current", "step"); else b.removeAttribute("aria-current");
60
+ });
61
+ const i = ETAPAS.indexOf(nome);
62
+ document.querySelectorAll("[data-indicador-etapa]").forEach((e) => {
63
+ const j = ETAPAS.indexOf(e.dataset.indicadorEtapa);
64
+ e.classList.toggle("atual", j === i);
65
+ e.classList.toggle("feita", j < i);
66
+ });
67
+ document.querySelectorAll("[data-conteudo-etapa]").forEach((s) => {
68
+ s.hidden = s.dataset.conteudoEtapa !== nome;
69
+ });
70
+ }
71
+
72
+ document.querySelectorAll(".botao-passo").forEach((b) => {
73
+ b.addEventListener("click", () => mostrarEtapa(b.dataset.etapa));
74
+ });
75
+ document.querySelectorAll("[data-indicador-etapa]").forEach((e) => {
76
+ e.addEventListener("click", () => mostrarEtapa(e.dataset.indicadorEtapa));
77
+ });
78
+
79
+ // ---------------------------------------------------------------- data e hora
80
+
81
+ function hojeAoMeioDia() {
82
+ const d = new Date();
83
+ const p = (n) => String(n).padStart(2, "0");
84
+ return [`${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`, "12:00"];
85
+ }
86
+
87
+ function lerDataHora() {
88
+ const iso = paraUTC($("data-missao").value, $("hora-missao").value);
89
+ if (!iso) return;
90
+ estado.inicio = iso;
91
+ $("resumo-data-missao").hidden = false;
92
+ $("valor-resumo-data-missao").textContent = fmtDataLocal(iso);
93
+ recarregarTudo();
94
+ }
95
+
96
+ $("data-missao").addEventListener("change", lerDataHora);
97
+ $("hora-missao").addEventListener("change", lerDataHora);
98
+
99
+ // ---------------------------------------------------------------- dados da API
100
+
101
+ async function recarregarTudo() {
102
+ if (!estado.conectada || !estado.inicio) return;
103
+ const pedido = ++estado.pedido;
104
+ const janela_h = estado.padroes.janela_h;
105
+ estado.metricas.clear();
106
+ estado.visibilidade.clear();
107
+ desenharCards(estado.sites, estado.metricas, estado.selecionado);
108
+
109
+ await Promise.all(estado.sites.map(async (s) => {
110
+ const params = { inicio: estado.inicio, janela_h };
111
+ const [m, v] = await Promise.allSettled([
112
+ api.metricas(s.id, params),
113
+ api.visibilidade(s.id, { inicio: estado.inicio, dias: janela_h / 24 }),
114
+ ]);
115
+ if (pedido !== estado.pedido) return;
116
+ estado.metricas.set(s.id, m.status === "fulfilled" ? m.value : { erro: m.reason.message });
117
+ if (v.status === "fulfilled") estado.visibilidade.set(s.id, v.value);
118
+ desenharCards(estado.sites, estado.metricas, estado.selecionado);
119
+ const mm = estado.metricas.get(s.id);
120
+ if (!mm.erro) {
121
+ document.dispatchEvent(new CustomEvent("metricas-local", {
122
+ detail: { id: s.id, energia: pct(mm.energy.pct), comunicacao: pct(mm.comms.pct), classe: mm.class },
123
+ }));
124
+ }
125
+ }));
126
+ if (pedido !== estado.pedido) return;
127
+ const erros = [...estado.metricas.values()].filter((m) => m.erro);
128
+ if (erros.length) aviso(`Some sites failed: ${erros[0].erro}`, "erro");
129
+ else aviso(...estado.avisoBase);
130
+ await carregarAtrasos();
131
+ atualizarPaineis();
132
+ }
133
+
134
+ async function carregarAtrasos() {
135
+ estado.atrasos = null;
136
+ if (!estado.selecionado || !estado.inicio) return;
137
+ const pedido = estado.pedido;
138
+ try {
139
+ const a = await api.atrasos(estado.selecionado, {
140
+ inicio: estado.inicio, janela_h: estado.padroes.janela_h, atraso_max_dias: 14,
141
+ });
142
+ if (pedido === estado.pedido) estado.atrasos = a;
143
+ } catch (e) {
144
+ $("resultado-atraso").textContent = `Delay simulation unavailable: ${e.message}`;
145
+ }
146
+ }
147
+
148
+ async function horizonte(id) {
149
+ if (!estado.horizontes.has(id)) estado.horizontes.set(id, await api.horizonte(id));
150
+ return estado.horizontes.get(id);
151
+ }
152
+
153
+ // ---------------------------------------------------------------- painéis
154
+
155
+ function atualizarPaineis() {
156
+ atualizarLocalizacao();
157
+ atualizarSolTerra();
158
+ atualizarEnergia();
159
+ atualizarComunicacao();
160
+ atualizarAtraso();
161
+ atualizarLuz();
162
+ }
163
+
164
+ function atualizarLocalizacao() {
165
+ const s = local();
166
+ $("valor-etapa-localizacao").textContent = s ? s.name : "No site selected";
167
+ $("coordenadas-etapa-localizacao").textContent = s
168
+ ? `${s.lat.toFixed(4)}°, ${s.lon.toFixed(4)}° (east-positive longitude) · ${s.mission}`
169
+ : "Select a landing site in the cards or on the Moon.";
170
+ }
171
+
172
+ function instante0(id) {
173
+ const v = estado.visibilidade.get(id);
174
+ if (!v) return null;
175
+ const pega = (c) => ({ az: c.az[0], el: c.el[0], rad: c.rad_deg[0], hz: c.horizonte[0], visivel: c.visivel[0] });
176
+ return { sol: pega(v.sol), terra: pega(v.terra) };
177
+ }
178
+
179
+ function textoAstro(nome, a) {
180
+ return `${nome}: azimuth ${a.az.toFixed(1)}°, elevation ${a.el.toFixed(2)}° · terrain at that azimuth ` +
181
+ `${a.hz.toFixed(2)}° → ${a.visivel ? "VISIBLE" : "behind the terrain"}`;
182
+ }
183
+
184
+ async function atualizarSolTerra() {
185
+ const caixa = $("texto-sol-terra");
186
+ const svg = $("grafico-ceu");
187
+ const s = local();
188
+ const i0 = s && instante0(s.id);
189
+ if (!s || !i0) {
190
+ caixa.textContent = s ? "Pick the date and time (step 2)." : "Select a site (step 1).";
191
+ svg.replaceChildren();
192
+ return;
193
+ }
194
+ caixa.replaceChildren(
195
+ el("span", `linha-astro ${i0.sol.visivel ? "ok" : "nao"}`, textoAstro("☀ Sun", i0.sol)),
196
+ el("span", `linha-astro ${i0.terra.visivel ? "ok" : "nao"}`, textoAstro("🌍 Earth", i0.terra)),
197
+ );
198
+ try {
199
+ desenharCeu(svg, await horizonte(s.id), i0);
200
+ } catch (e) {
201
+ svg.replaceChildren();
202
+ caixa.appendChild(el("span", "erro-card", `Horizon unavailable: ${e.message}`));
203
+ }
204
+ }
205
+
206
+ /** Panorama: horizonte do relevo (0–360°) com o Sol e a Terra no instante escolhido. */
207
+ function desenharCeu(svg, hz, i0) {
208
+ const NS = "http://www.w3.org/2000/svg";
209
+ const W = 300, H = 120, M = 14;
210
+ const h = hz.horizon_deg;
211
+ const passo = hz.az_step_deg;
212
+ const els = [...h, i0.sol.el + i0.sol.rad, i0.terra.el + i0.terra.rad];
213
+ const yMin = Math.floor(Math.min(...h, i0.sol.el, i0.terra.el, 0) - 1);
214
+ const yMax = Math.ceil(Math.max(...els, 1) + 1);
215
+ const X = (az) => M + (az / 360) * (W - 2 * M);
216
+ const Y = (e) => H - M - ((e - yMin) / (yMax - yMin)) * (H - 2 * M);
217
+ const mk = (tag, attrs, texto) => {
218
+ const n = document.createElementNS(NS, tag);
219
+ Object.entries(attrs).forEach(([k, v]) => n.setAttribute(k, v));
220
+ if (texto) n.textContent = texto;
221
+ return n;
222
+ };
223
+ const pontos = h.map((v, i) => `${X(i * passo).toFixed(1)},${Y(v).toFixed(1)}`);
224
+ pontos.push(`${X(360).toFixed(1)},${Y(h[0]).toFixed(1)}`);
225
+ const filhos = [
226
+ mk("rect", { x: 0, y: 0, width: W, height: H, class: "ceu-fundo" }),
227
+ mk("line", { x1: M, x2: W - M, y1: Y(0), y2: Y(0), class: "ceu-zero" }),
228
+ mk("polygon", { points: `${X(0)},${H - M} ${pontos.join(" ")} ${X(360)},${H - M}`, class: "ceu-relevo" }),
229
+ ];
230
+ [["N", 0], ["L", 90], ["S", 180], ["O", 270], ["N", 360]].forEach(([t, az]) => {
231
+ filhos.push(mk("text", { x: X(az), y: H - 2, class: "ceu-rotulo", "text-anchor": "middle" }, t));
232
+ });
233
+ filhos.push(mk("text", { x: 2, y: Y(0) - 2, class: "ceu-rotulo" }, "0°"));
234
+ const escalaY = (H - 2 * M) / (yMax - yMin);
235
+ [["sol", i0.sol, "ceu-sol"], ["terra", i0.terra, "ceu-terra"]].forEach(([, a, classe]) => {
236
+ filhos.push(mk("circle", { cx: X(a.az), cy: Y(a.el), r: Math.max(2.5, a.rad * escalaY), class: classe }));
237
+ });
238
+ svg.setAttribute("viewBox", `0 0 ${W} ${H}`);
239
+ svg.replaceChildren(...filhos);
240
+ }
241
+
242
+ function parametrosEnergia() {
243
+ const n = (id) => Number.parseFloat($(id).value);
244
+ const p = {
245
+ potenciaW: n("potencia-paineis"), consumoW: n("consumo-missao"), capacidadeWh: n("capacidade-bateria"),
246
+ cargaInicialPct: n("carga-bateria"), eficienciaPct: n("eficiencia-paineis"),
247
+ };
248
+ return Object.values(p).every(Number.isFinite) ? p : null;
249
+ }
250
+
251
+ function atualizarEnergia() {
252
+ const s = local();
253
+ const m = s && estado.metricas.get(s.id);
254
+ $("valor-etapa-energia").textContent = m && !m.erro
255
+ ? `Sun visible ${pct(m.energy.pct)} of the time · longest night: ${duracao(m.energy.longest_without_h)} · ` +
256
+ `longest sunlit period: ${duracao(m.energy.longest_with_h)} · site score ${pct(m.score)} ` +
257
+ `(range ${pct(m.incerteza.score_min)}–${pct(m.incerteza.score_max)})`
258
+ : "Select a landing site.";
259
+
260
+ // Comparação de todos os locais (mesmos parâmetros).
261
+ const p = parametrosEnergia();
262
+ $("resumo-parametros-energia").textContent = p
263
+ ? `Panels ${p.potenciaW} W × ${p.eficienciaPct}% · load ${p.consumoW} W · battery ${p.capacidadeWh} Wh ` +
264
+ `(start ${p.cargaInicialPct}%) · ${estado.padroes.janela_h} h window.`
265
+ : "Fill in the 5 parameters to simulate the battery at every site.";
266
+ const lista = $("lista-resultados-energia");
267
+ lista.replaceChildren(...estado.sites.map((st) => {
268
+ const mm = estado.metricas.get(st.id);
269
+ const v = estado.visibilidade.get(st.id);
270
+ const item = el("li", "resultado-local-energia");
271
+ item.appendChild(el("span", "nome-resultado-energia", st.name));
272
+ const linha = (rotulo, valor) => {
273
+ const l = el("span", "metrica-simulacao-energia");
274
+ l.append(el("span", "", rotulo), el("strong", "", valor));
275
+ item.appendChild(l);
276
+ };
277
+ if (!mm || mm.erro) { linha("Status", mm?.erro || "computing…"); return item; }
278
+ linha("Time in sunlight", pct(mm.energy.pct));
279
+ linha("Longest night", duracao(mm.energy.longest_without_h));
280
+ if (p && v) {
281
+ const r = simularBateria(v.sol.visivel, v.step_min / 60, p);
282
+ linha("Minimum battery", pct(r.cargaMinimaPct / 100));
283
+ linha("Hours without power", r.sobrevive ? "0 h (survives)" : `${Math.round(r.horasSemEnergia)} h`);
284
+ if (!r.sobrevive) linha("First outage after", duracao(r.primeiraFalhaH));
285
+ }
286
+ return item;
287
+ }));
288
+ const erroEnergia = $("estado-simulacao-energia");
289
+ erroEnergia.textContent = estado.metricas.size ? "" : "Waiting for the API…";
290
+ erroEnergia.hidden = !erroEnergia.textContent;
291
+
292
+ // Elevação do Sol no instante escolhido, por local.
293
+ const lst = $("lista-elevacao-solar");
294
+ lst.replaceChildren(...estado.sites.map((st) => {
295
+ const i0 = instante0(st.id);
296
+ const item = el("li", "resultado-elevacao-solar");
297
+ item.appendChild(el("span", "nome-local-elevacao", st.name));
298
+ item.appendChild(el("span", "valor-elevacao-solar", i0
299
+ ? `Sun at ${i0.sol.el.toFixed(2)}° · terrain ${i0.sol.hz.toFixed(2)}° at azimuth ${i0.sol.az.toFixed(0)}° → ` +
300
+ (i0.sol.visivel ? "sunlit" : "in shadow")
301
+ : "—"));
302
+ return item;
303
+ }));
304
+ $("estado-calculo-elevacao").textContent = estado.inicio
305
+ ? `Instant: ${fmtDataLocal(estado.inicio)}. Sky: Skyfield + DE440; terrain: LOLA.`
306
+ : "Pick the date and time (step 2).";
307
+ }
308
+
309
+ function atualizarComunicacao() {
310
+ const s = local();
311
+ const m = s && estado.metricas.get(s.id);
312
+ const i0 = s && instante0(s.id);
313
+ $("valor-etapa-comunicacao").textContent = m && !m.erro
314
+ ? `Earth visible ${pct(m.comms.pct)} of the time · longest blackout: ${duracao(m.comms.longest_without_h)} · ` +
315
+ `Sun and Earth together: ${pct(m.both.pct)}` +
316
+ (i0 ? ` · now: ${i0.terra.visivel ? "Earth visible" : "Earth behind the terrain"} (elevation ${i0.terra.el.toFixed(1)}°)` : "")
317
+ : "Select a landing site.";
318
+ }
319
+
320
+ function atualizarAtraso() {
321
+ const dias = Number($("simulador-atraso").value);
322
+ $("dias-atraso").textContent = `+${dias} ${dias === 1 ? "day" : "days"}`;
323
+ const resultado = $("resultado-atraso");
324
+ const svg = $("grafico-atraso");
325
+ const a = estado.atrasos;
326
+ if (!a) {
327
+ resultado.textContent = estado.selecionado ? "Computing…" : "Select a site to simulate a delay.";
328
+ svg.replaceChildren();
329
+ return;
330
+ }
331
+ const p = a.serie[dias];
332
+ const base = a.serie[0];
333
+ const dif = (p.score - base.score) * 100;
334
+ resultado.textContent = `With +${dias} ${dias === 1 ? "day" : "days"}: score ${pct(p.score)} (${rotuloClasse(p.class)})` +
335
+ (dias ? ` · ${dif >= 0 ? "+" : ""}${dif.toFixed(1)} pts vs. landing on schedule` : "");
336
+ resultado.dataset.classe = p.class;
337
+
338
+ const NS = "http://www.w3.org/2000/svg";
339
+ const W = 300, H = 70, n = a.serie.length, bw = W / n;
340
+ const barras = a.serie.map((q, i) => {
341
+ const r = document.createElementNS(NS, "rect");
342
+ const h = Math.max(1, q.score * (H - 12));
343
+ r.setAttribute("x", (i * bw + 1).toFixed(1));
344
+ r.setAttribute("width", (bw - 2).toFixed(1));
345
+ r.setAttribute("y", (H - h).toFixed(1));
346
+ r.setAttribute("height", h.toFixed(1));
347
+ r.setAttribute("class", `barra-atraso ${q.class}${i === dias ? " atual" : ""}`);
348
+ const t = document.createElementNS(NS, "title");
349
+ t.textContent = `+${i} d: ${pct(q.score)} (${rotuloClasse(q.class)})`;
350
+ r.appendChild(t);
351
+ return r;
352
+ });
353
+ const linha = (v, classe) => {
354
+ const l = document.createElementNS(NS, "line");
355
+ const y = H - v * (H - 12);
356
+ Object.entries({ x1: 0, x2: W, y1: y, y2: y, class: classe }).forEach(([k, val]) => l.setAttribute(k, val));
357
+ return l;
358
+ };
359
+ svg.setAttribute("viewBox", `0 0 ${W} ${H}`);
360
+ svg.replaceChildren(...barras, linha(a.thresholds.ok, "limiar-ok"), linha(a.thresholds.crit, "limiar-crit"));
361
+ }
362
+
363
+ $("simulador-atraso").addEventListener("input", atualizarAtraso);
364
+ document.querySelectorAll(".parametros-energia input").forEach((i) => i.addEventListener("input", atualizarEnergia));
365
+
366
+ function atualizarLuz() {
367
+ // A direção do Sol é a mesma para a Lua toda; usa o local selecionado
368
+ // (ou o primeiro com dados) só para converter az/el em vetor.
369
+ const s = local() || estado.sites.find((x) => estado.visibilidade.has(x.id));
370
+ const i0 = s && instante0(s.id);
371
+ document.dispatchEvent(new CustomEvent("direcao-sol", {
372
+ detail: i0
373
+ ? { direcao: direcaoDoCeu(s.lat, s.lon, i0.sol.az, i0.sol.el),
374
+ texto: `Light from the real Sun direction at ${fmtDataLocal(estado.inicio)} (Skyfield/DE440).` }
375
+ : { direcao: null, texto: "Pick a site, date and time: the light follows the real Sun direction." },
376
+ }));
377
+ }
378
+
379
+ // ---------------------------------------------------------------- seleção
380
+
381
+ document.addEventListener("destino-lunar-selecionado", async (e) => {
382
+ estado.selecionado = e.detail.id;
383
+ desenharCards(estado.sites, estado.metricas, estado.selecionado);
384
+ atualizarPaineis();
385
+ await carregarAtrasos();
386
+ atualizarAtraso();
387
+ });
388
+
389
+ // ---------------------------------------------------------------- início
390
+
391
+ async function iniciar() {
392
+ const [d, h] = hojeAoMeioDia();
393
+ $("data-missao").value = d;
394
+ $("hora-missao").value = h;
395
+ mostrarEtapa("localizacao");
396
+ try {
397
+ const { base, saude } = await conectar();
398
+ estado.conectada = true;
399
+ estado.padroes = { ...estado.padroes, ...saude.padroes };
400
+ if (saude.intervalo_suportado) {
401
+ const min = saude.intervalo_suportado.inicio.slice(0, 10);
402
+ const max = saude.intervalo_suportado.fim.slice(0, 10);
403
+ $("data-missao").min = min;
404
+ $("data-missao").max = max;
405
+ // Hoje fora dos dados disponíveis (ex.: modo estático só com 2027): começa no 1º dia.
406
+ if (d < min || d > max) $("data-missao").value = min;
407
+ }
408
+ if (saude.modo === "estatico") {
409
+ const ini = saude.intervalo_suportado.inicio.slice(0, 10), fim = saude.intervalo_suportado.fim.slice(0, 10);
410
+ estado.avisoBase = [`Static mode: results are computed in your browser from precomputed data ` +
411
+ `(JPL DE440 sky + LRO LOLA terrain). Landing dates from ${ini} to ${fim}.`, "info"];
412
+ } else {
413
+ estado.avisoBase = [saude.efemerides ? "" : `API in fallback mode (year 2027 only): ${saude.erro_efemerides}`, "alerta"];
414
+ }
415
+ aviso(...estado.avisoBase);
416
+ estado.sites = await api.sites();
417
+ console.info(`Dados: ${saude.modo === "estatico" ? "modo estático" : "API"} em ${base}`);
418
+ } catch (e) {
419
+ estado.sites = await sitesSemApi();
420
+ aviso(`${e.message}. From the project root run: uvicorn api.main:app --port 8001 ` +
421
+ "and open http://localhost:8001/ . Without the API only the site list is shown.", "erro");
422
+ }
423
+ desenharCards(estado.sites, estado.metricas, estado.selecionado);
424
+ document.dispatchEvent(new CustomEvent("locais-carregados", { detail: { sites: estado.sites } }));
425
+
426
+ // Cenário pela URL (link compartilhável): ?local=malapert&data=2027-03-01&hora=12:00&etapa=energia&atraso=5
427
+ const url = new URLSearchParams(location.search);
428
+ if (url.get("data")) $("data-missao").value = url.get("data");
429
+ if (url.get("hora")) $("hora-missao").value = url.get("hora");
430
+ if (url.get("atraso")) $("simulador-atraso").value = url.get("atraso");
431
+ if (ETAPAS.includes(url.get("etapa"))) mostrarEtapa(url.get("etapa"));
432
+ const id = url.get("local");
433
+ if (id && estado.sites.some((s) => s.id === id)) {
434
+ document.dispatchEvent(new CustomEvent("destino-lunar-selecionado", { detail: { id } }));
435
+ }
436
+ atualizarPaineis();
437
+ lerDataHora();
438
+ iniciado = true;
439
+ }
440
+
441
+ // Mantém a URL igual ao cenário na tela (para copiar e compartilhar).
442
+ let iniciado = false;
443
+ function sincronizarURL() {
444
+ if (!iniciado) return;
445
+ const p = new URLSearchParams();
446
+ if (estado.selecionado) p.set("local", estado.selecionado);
447
+ if ($("data-missao").value) p.set("data", $("data-missao").value);
448
+ if ($("hora-missao").value) p.set("hora", $("hora-missao").value);
449
+ const etapa = document.querySelector(".botao-passo.ativo")?.dataset.etapa;
450
+ if (etapa && etapa !== "localizacao") p.set("etapa", etapa);
451
+ if ($("simulador-atraso").value !== "0") p.set("atraso", $("simulador-atraso").value);
452
+ history.replaceState(null, "", `${location.pathname}?${p}`);
453
+ }
454
+ ["change", "input", "click"].forEach((ev) => document.addEventListener(ev, () => setTimeout(sincronizarURL)));
455
+ document.addEventListener("destino-lunar-selecionado", () => setTimeout(sincronizarURL));
456
+
457
+ iniciar();
js/geo.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Funções puras (sem DOM nem Three.js): geometria, datas e simulação de bateria.
2
+ // Testadas com: node --test web/tests/
3
+ //
4
+ // Eixos da cena (Three.js), a partir do referencial lunar MOON_ME:
5
+ // X = ME x (lat 0°, lon 0°: centro da face visível)
6
+ // Y = ME z (polo norte)
7
+ // Z = −ME y (lon 90° L fica em −Z)
8
+ // É a mesma convenção da textura equirretangular numa SphereGeometry padrão
9
+ // (lon −180° na borda esquerda, leste para a direita, norte em cima).
10
+
11
+ const RAD = Math.PI / 180;
12
+ export const R_LUA_M = 1_737_400;
13
+ // Calota sul (web/assets/polo_sul_*): grade estereográfica polar do LOLA.
14
+ export const CALOTA_MEIA_LARGURA_M = 304_000;
15
+ export const CALOTA_LAT_BORDA = -80;
16
+
17
+ /** Vetor unitário da cena para (lat, lon) em graus (lon leste positiva). */
18
+ export function direcaoCena(lat, lon) {
19
+ const f = lat * RAD, l = lon * RAD;
20
+ return [Math.cos(f) * Math.cos(l), Math.sin(f), -Math.cos(f) * Math.sin(l)];
21
+ }
22
+
23
+ /** (lat, lon) em graus a partir de um vetor da cena (qualquer módulo). */
24
+ export function latLonDaCena(x, y, z) {
25
+ const r = Math.hypot(x, y, z);
26
+ return [Math.asin(y / r) / RAD, Math.atan2(-z, x) / RAD];
27
+ }
28
+
29
+ /** UV da calota sul: projeção estereográfica polar, igual à do DEM. */
30
+ export function uvCalotaSul(lat, lon) {
31
+ const rho = 2 * R_LUA_M * Math.tan((45 + lat / 2) * RAD);
32
+ const x = rho * Math.sin(lon * RAD);
33
+ const y = rho * Math.cos(lon * RAD);
34
+ const L = CALOTA_MEIA_LARGURA_M;
35
+ return [(x + L) / (2 * L), (y + L) / (2 * L)];
36
+ }
37
+
38
+ /**
39
+ * Direção (vetor da cena) de um astro visto do local com azimute/elevação.
40
+ * Azimute a partir do Norte, horário. O Sol está tão longe que a mesma
41
+ * direção vale para a Lua inteira: serve para posicionar a luz.
42
+ */
43
+ export function direcaoDoCeu(lat, lon, azGraus, elGraus) {
44
+ const f = lat * RAD, l = lon * RAD, a = azGraus * RAD, e = elGraus * RAD;
45
+ const sf = Math.sin(f), cf = Math.cos(f), sl = Math.sin(l), cl = Math.cos(l);
46
+ const leste = [-sl, cl, 0];
47
+ const norte = [-sf * cl, -sf * sl, cf];
48
+ const cima = [cf * cl, cf * sl, sf];
49
+ const ce = Math.cos(e), se = Math.sin(e), sa = Math.sin(a), ca = Math.cos(a);
50
+ const me = [0, 1, 2].map((i) => ce * sa * leste[i] + ce * ca * norte[i] + se * cima[i]);
51
+ return [me[0], me[2], -me[1]];
52
+ }
53
+
54
+ /** "AAAA-MM-DD" + "HH:MM" no fuso do navegador -> ISO 8601 em UTC ("...Z"). */
55
+ export function paraUTC(data, hora) {
56
+ if (!data) return null;
57
+ const d = new Date(`${data}T${hora || "00:00"}:00`);
58
+ if (Number.isNaN(d.getTime())) return null;
59
+ d.setUTCMinutes(0, 0, 0); // a API trabalha em passos de 1 h
60
+ return d.toISOString().replace(".000Z", "Z");
61
+ }
62
+
63
+ /** Fraction (0–1) -> "66%" (or "66.4%" with decimals). */
64
+ export function pct(fracao, casas = 0) {
65
+ if (fracao === null || fracao === undefined || Number.isNaN(fracao)) return "—";
66
+ return `${(fracao * 100).toFixed(casas)}%`;
67
+ }
68
+
69
+ /** Hours -> "5 h" or "6.7 days". */
70
+ export function duracao(horas) {
71
+ if (horas === null || horas === undefined) return "—";
72
+ if (horas < 48) return `${Math.round(horas)} h`;
73
+ return `${(horas / 24).toFixed(1)} days`;
74
+ }
75
+
76
+ /**
77
+ * Simula a bateria hora a hora com a linha do tempo de Sol visível.
78
+ *
79
+ * Modelo simples e declarado: com Sol visível, o painel gera
80
+ * potência × eficiência (painel sempre apontado para o Sol, sem perda por
81
+ * ângulo); sem Sol, gera 0. Consumo constante. Carga limitada a [0, capacidade].
82
+ *
83
+ * @param {boolean[]} solVisivel um valor por passo
84
+ * @param {number} passoH duração do passo em horas
85
+ * @param {{potenciaW, consumoW, capacidadeWh, cargaInicialPct, eficienciaPct}} p
86
+ */
87
+ export function simularBateria(solVisivel, passoH, p) {
88
+ const geracao = p.potenciaW * (p.eficienciaPct / 100);
89
+ let carga = p.capacidadeWh * (p.cargaInicialPct / 100);
90
+ let minima = carga;
91
+ let horasSemEnergia = 0;
92
+ let deficitWh = 0;
93
+ let primeiraFalhaH = null;
94
+ solVisivel.forEach((visivel, i) => {
95
+ const saldo = ((visivel ? geracao : 0) - p.consumoW) * passoH;
96
+ let nova = carga + saldo;
97
+ if (nova < 0) {
98
+ deficitWh += -nova;
99
+ horasSemEnergia += passoH;
100
+ if (primeiraFalhaH === null) primeiraFalhaH = i * passoH;
101
+ nova = 0;
102
+ }
103
+ carga = Math.min(nova, p.capacidadeWh);
104
+ minima = Math.min(minima, carga);
105
+ });
106
+ return {
107
+ cargaFinalPct: (carga / p.capacidadeWh) * 100,
108
+ cargaMinimaPct: (minima / p.capacidadeWh) * 100,
109
+ horasSemEnergia,
110
+ deficitWh,
111
+ primeiraFalhaH,
112
+ sobrevive: horasSemEnergia === 0,
113
+ };
114
+ }
115
+
116
+ /** Classe da API -> classe CSS do card (o design usa "risco" para crítico). */
117
+ export function classeCss(classe) {
118
+ return { ideal: "ideal", moderado: "moderado", critico: "risco" }[classe] || "moderado";
119
+ }
120
+
121
+ export function rotuloClasse(classe) {
122
+ return { ideal: "Ideal", moderado: "Moderate", critico: "Critical" }[classe] || "—";
123
+ }
js/locais.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Cards dos locais de pouso (painel direito), gerados a partir de /api/sites.
2
+ // Ao clicar, dispara "destino-lunar-selecionado" {id} (a Lua 3D e as etapas escutam).
3
+
4
+ import { pct, classeCss, rotuloClasse } from "./geo.js";
5
+
6
+ const lista = document.getElementById("lista-locais");
7
+ const nomeSelecionado = document.getElementById("nome-local-selecionado");
8
+
9
+ function formatarCoord(lat, lon) {
10
+ return `${Math.abs(lat).toFixed(2)}° ${lat < 0 ? "S" : "N"} · ${Math.abs(lon).toFixed(2)}° ${lon < 0 ? "W" : "E"}`;
11
+ }
12
+
13
+ function el(tag, classe, texto) {
14
+ const e = document.createElement(tag);
15
+ if (classe) e.className = classe;
16
+ if (texto !== undefined) e.textContent = texto;
17
+ return e;
18
+ }
19
+
20
+ function indicador(rotulo, valor, classeBarra) {
21
+ const bloco = el("span", "indicador-local");
22
+ const linha = el("span", "linha-indicador");
23
+ linha.append(el("span", "", rotulo), el("span", "valor-indicador", valor === null ? "…" : pct(valor)));
24
+ const trilha = el("span", "trilha-indicador");
25
+ const barra = el("span", `preenchimento ${classeBarra}`);
26
+ barra.style.width = `${Math.round((valor ?? 0) * 100)}%`;
27
+ trilha.appendChild(barra);
28
+ bloco.append(linha, trilha);
29
+ return bloco;
30
+ }
31
+
32
+ /**
33
+ * Desenha os cards.
34
+ * @param {Array} sites [{id, name, lat, lon, mission, mock}]
35
+ * @param {Map} metricas id -> resposta de /metricas (ou {erro})
36
+ * @param {string|null} selecionado
37
+ */
38
+ export function desenharCards(sites, metricas, selecionado) {
39
+ lista.replaceChildren(...sites.map((s) => {
40
+ const m = metricas.get(s.id);
41
+ const classe = m && !m.erro ? m.class : null;
42
+ const card = el("button", `card-local ${classe ? classeCss(classe) : "carregando"}`);
43
+ card.type = "button";
44
+ card.dataset.id = s.id;
45
+ card.setAttribute("aria-pressed", String(s.id === selecionado));
46
+ card.classList.toggle("selecionado", s.id === selecionado);
47
+
48
+ const cab = el("span", "cabecalho-local");
49
+ const nome = el("strong", "", s.name);
50
+ const status = el("span", "status-local", m?.erro ? "Unavailable" : classe ? rotuloClasse(classe) : "Computing…");
51
+ cab.append(nome, status);
52
+ card.appendChild(cab);
53
+
54
+ const coord = el("span", "coordenadas-local", formatarCoord(s.lat, s.lon));
55
+ card.appendChild(coord);
56
+ if (s.mock || m?.mock) card.appendChild(el("span", "tag-mock", "mock data (synthetic horizon)"));
57
+
58
+ if (m && !m.erro) {
59
+ card.append(
60
+ indicador("Solar power", m.energy.pct, `energia-${classeCss(classe)}`),
61
+ indicador("Earth link", m.comms.pct, "comunicacao"),
62
+ );
63
+ const faixa = el("span", "faixa-incerteza",
64
+ `Score ${pct(m.score)} · range ${pct(m.incerteza.score_min)}–${pct(m.incerteza.score_max)} (terrain ±${m.incerteza.margem_graus}°)`);
65
+ card.appendChild(faixa);
66
+ } else if (m?.erro) {
67
+ card.appendChild(el("span", "erro-card", m.erro));
68
+ }
69
+ card.addEventListener("click", () => {
70
+ document.dispatchEvent(new CustomEvent("destino-lunar-selecionado", { detail: { id: s.id } }));
71
+ });
72
+ return card;
73
+ }));
74
+ const atual = sites.find((s) => s.id === selecionado);
75
+ nomeSelecionado.textContent = atual ? atual.name : "No site selected";
76
+ }
js/lua.js ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Lua 3D (Three.js). Baseado no visualizador do LanderBnB (feature/landerbnb).
2
+ //
3
+ // Esfera com as texturas do NASA SVS CGI Moon Kit (cor LROC + relevo LOLA)
4
+ // e, por cima, uma calota do polo sul (-80° a -90°) feita com o mesmo DEM do
5
+ // LOLA usado no horizonte (pipeline/tools/gerar_texturas_lua.py).
6
+ // Orientação: a de geo.js (lon 0 em +X, norte em +Y), conferida com
7
+ // Tycho, Copérnico e Mare Crisium na textura e com testes em web/tests/.
8
+ //
9
+ // Eventos que este módulo ESCUTA (disparados por etapas.js / locais.js):
10
+ // locais-carregados {sites: [{id, name, lat, lon, category}]}
11
+ // destino-lunar-selecionado {id}
12
+ // direcao-sol {direcao: [x, y, z] | null, texto}
13
+ // metricas-local {id, energia, comunicacao, classe}
14
+ // E DISPARA: destino-lunar-selecionado {id} ao clicar num marcador.
15
+
16
+ import * as THREE from "three";
17
+ import { OrbitControls } from "three/addons/controls/OrbitControls.js";
18
+
19
+ import { direcaoCena, latLonDaCena, uvCalotaSul, CALOTA_LAT_BORDA } from "./geo.js";
20
+
21
+ const RAIO = 1.5; // unidades da cena
22
+ const container = document.getElementById("lua-3d");
23
+
24
+ let locais = new Map(); // id -> {id, name, lat, lon, category}
25
+ let selecionado = null;
26
+ let transicaoCamera = null;
27
+ const marcadores = new Map(); // id -> {element, position}
28
+ const indicadores = new Map(); // id -> {energia, comunicacao}
29
+ const raycaster = new THREE.Raycaster();
30
+
31
+ // ---------------------------------------------------------------- camadas HTML
32
+
33
+ const camadaMarcadores = document.createElement("div");
34
+ camadaMarcadores.className = "camada-marcadores";
35
+ camadaMarcadores.setAttribute("aria-label", "Landing sites");
36
+ container.appendChild(camadaMarcadores);
37
+
38
+ const avisoOrientacao = document.createElement("div");
39
+ avisoOrientacao.className = "aviso-orientacao";
40
+ avisoOrientacao.textContent = "True positions (MOON_ME) · polar terrain: LOLA · texture: NASA SVS";
41
+ camadaMarcadores.appendChild(avisoOrientacao);
42
+
43
+ const painelLocal = document.createElement("section");
44
+ painelLocal.className = "painel-local-visualizador";
45
+ painelLocal.setAttribute("aria-label", "Selected site details");
46
+ painelLocal.setAttribute("aria-live", "polite");
47
+ painelLocal.hidden = true;
48
+
49
+ const cabecalhoPainel = document.createElement("div");
50
+ cabecalhoPainel.className = "cabecalho-painel-local";
51
+ const nomePainel = document.createElement("h3");
52
+ nomePainel.className = "nome-painel-local";
53
+ const fecharPainel = document.createElement("button");
54
+ fecharPainel.type = "button";
55
+ fecharPainel.className = "fechar-painel-local";
56
+ fecharPainel.setAttribute("aria-label", "Close site details");
57
+ fecharPainel.textContent = "×";
58
+ fecharPainel.addEventListener("click", () => { painelLocal.hidden = true; });
59
+ cabecalhoPainel.append(nomePainel, fecharPainel);
60
+ painelLocal.appendChild(cabecalhoPainel);
61
+
62
+ function linhaPainel(rotulo) {
63
+ const linha = document.createElement("p");
64
+ linha.className = "linha-painel-local";
65
+ const nome = document.createElement("span");
66
+ nome.className = "rotulo-painel-local";
67
+ nome.textContent = rotulo;
68
+ const valor = document.createElement("strong");
69
+ valor.className = "valor-painel-local";
70
+ linha.append(nome, valor);
71
+ painelLocal.appendChild(linha);
72
+ return valor;
73
+ }
74
+
75
+ const coordenadasPainel = linhaPainel("Lunar coordinates");
76
+ const energiaPainel = linhaPainel("Solar power");
77
+ const comunicacaoPainel = linhaPainel("Earth link");
78
+ const notaPainel = document.createElement("p");
79
+ notaPainel.className = "aviso-indicadores-simulados";
80
+ notaPainel.textContent = "% of time in the selected window · sky: Skyfield/DE440 · terrain: LOLA";
81
+ painelLocal.appendChild(notaPainel);
82
+ container.appendChild(painelLocal);
83
+
84
+ const destinoTexto = document.createElement("div");
85
+ destinoTexto.className = "destino-lua";
86
+ destinoTexto.setAttribute("aria-live", "polite");
87
+ container.appendChild(destinoTexto);
88
+
89
+ const estadoCarregamento = document.createElement("div");
90
+ estadoCarregamento.className = "estado-carregamento-lua";
91
+ estadoCarregamento.setAttribute("role", "status");
92
+ estadoCarregamento.textContent = "Loading 3D Moon...";
93
+ container.appendChild(estadoCarregamento);
94
+
95
+ const estadoIluminacao = document.createElement("div");
96
+ estadoIluminacao.className = "estado-iluminacao-solar";
97
+ estadoIluminacao.setAttribute("role", "status");
98
+ estadoIluminacao.setAttribute("aria-live", "polite");
99
+ estadoIluminacao.textContent = "Pick a site, date and time: the light follows the real Sun direction.";
100
+ container.appendChild(estadoIluminacao);
101
+
102
+ function formatarCoord(lat, lon) {
103
+ return `${Math.abs(lat).toFixed(2)}° ${lat < 0 ? "S" : "N"} · ${Math.abs(lon).toFixed(2)}° ${lon < 0 ? "W" : "E"}`;
104
+ }
105
+
106
+ function atualizarPainel() {
107
+ const local = locais.get(selecionado);
108
+ if (!local) { painelLocal.hidden = true; return; }
109
+ const ind = indicadores.get(selecionado) || {};
110
+ nomePainel.textContent = local.name;
111
+ coordenadasPainel.textContent = formatarCoord(local.lat, local.lon);
112
+ energiaPainel.textContent = ind.energia ?? "—";
113
+ comunicacaoPainel.textContent = ind.comunicacao ?? "—";
114
+ painelLocal.hidden = false;
115
+ }
116
+
117
+ // ---------------------------------------------------------------- cena
118
+
119
+ const scene = new THREE.Scene();
120
+ const camera = new THREE.PerspectiveCamera(45, 1, 0.01, 1000);
121
+ camera.up.set(1, 0, 0); // ver direcaoCamera(); precisa vir ANTES de criar o OrbitControls
122
+ camera.position.set(1, -3, 1);
123
+
124
+ const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
125
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
126
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
127
+ container.appendChild(renderer.domElement);
128
+
129
+ // Luz fraca de preenchimento + "Sol" direcional (posição definida pelo evento direcao-sol).
130
+ const luzAmbiente = new THREE.AmbientLight(0xffffff, 0.12);
131
+ scene.add(luzAmbiente);
132
+ const luzSolar = new THREE.DirectionalLight(0xffffff, 3.0);
133
+ luzSolar.position.set(5, 3, 5);
134
+ scene.add(luzSolar);
135
+
136
+ const controls = new OrbitControls(camera, renderer.domElement);
137
+ controls.enableDamping = false;
138
+ controls.enableZoom = true;
139
+ controls.enablePan = false;
140
+ // Sem minDistance/maxDistance: o OrbitControls mede até o ALVO (que fica na
141
+ // superfície depois de escolher um local) e empurraria a câmera para longe.
142
+ // O limite é aplicado em relação ao CENTRO da Lua, em limitarDistancia().
143
+ controls.addEventListener("start", () => { transicaoCamera = null; });
144
+
145
+ // ---------------------------------------------------------------- Lua
146
+
147
+ const lua = new THREE.Group();
148
+ scene.add(lua);
149
+
150
+ function carregarTextura(url, srgb = true) {
151
+ return new Promise((resolve, reject) => {
152
+ new THREE.TextureLoader().load(url, (t) => {
153
+ if (srgb) t.colorSpace = THREE.SRGBColorSpace;
154
+ t.anisotropy = renderer.capabilities.getMaxAnisotropy();
155
+ resolve(t);
156
+ }, undefined, reject);
157
+ });
158
+ }
159
+
160
+ function criarCalotaSul(cor, normal) {
161
+ // Faixa da esfera de -80° a -90°, um pouco acima da superfície global.
162
+ const largura = (90 + CALOTA_LAT_BORDA) * Math.PI / 180;
163
+ const geo = new THREE.SphereGeometry(RAIO * 1.0006, 256, 64, 0, Math.PI * 2, Math.PI - largura, largura);
164
+ // UV na grade estereográfica do DEM (em vez do UV equirretangular padrão).
165
+ const pos = geo.attributes.position;
166
+ const uv = geo.attributes.uv;
167
+ for (let i = 0; i < pos.count; i++) {
168
+ const [lat, lon] = latLonDaCena(pos.getX(i), pos.getY(i), pos.getZ(i));
169
+ const [u, v] = uvCalotaSul(lat, lon);
170
+ uv.setXY(i, u, v);
171
+ }
172
+ uv.needsUpdate = true;
173
+ const mat = new THREE.MeshStandardMaterial({
174
+ map: cor, normalMap: normal, normalMapType: THREE.ObjectSpaceNormalMap,
175
+ transparent: true, roughness: 1, metalness: 0, depthWrite: false,
176
+ });
177
+ return new THREE.Mesh(geo, mat);
178
+ }
179
+
180
+ async function montarLua() {
181
+ const [cor, relevo, calotaCor, calotaNormal] = await Promise.all([
182
+ carregarTextura("./assets/lroc_color_2k.jpg"),
183
+ carregarTextura("./assets/ldem_3_8bit.jpg", false),
184
+ carregarTextura("./assets/polo_sul_cor.png"),
185
+ carregarTextura("./assets/polo_sul_normal.jpg", false),
186
+ ]);
187
+ const esfera = new THREE.Mesh(
188
+ new THREE.SphereGeometry(RAIO, 192, 96),
189
+ new THREE.MeshStandardMaterial({ map: cor, bumpMap: relevo, bumpScale: 2, roughness: 1, metalness: 0 }),
190
+ );
191
+ lua.add(esfera, criarCalotaSul(calotaCor, calotaNormal));
192
+ }
193
+
194
+ // ---------------------------------------------------------------- marcadores
195
+
196
+ function posicaoDoLocal(local) {
197
+ const [x, y, z] = direcaoCena(local.lat, local.lon);
198
+ return new THREE.Vector3(x, y, z).multiplyScalar(RAIO * 1.003);
199
+ }
200
+
201
+ function criarMarcadores() {
202
+ marcadores.forEach((m) => m.element.remove());
203
+ marcadores.clear();
204
+ locais.forEach((local) => {
205
+ const botao = document.createElement("button");
206
+ botao.type = "button";
207
+ botao.className = "marcador-local";
208
+ botao.setAttribute("aria-label", `Select ${local.name}`);
209
+ botao.setAttribute("aria-pressed", String(local.id === selecionado));
210
+ botao.classList.toggle("selecionado", local.id === selecionado);
211
+ const ponto = document.createElement("span");
212
+ ponto.className = "ponto-marcador";
213
+ ponto.setAttribute("aria-hidden", "true");
214
+ const rotulo = document.createElement("span");
215
+ rotulo.className = "rotulo-marcador";
216
+ rotulo.textContent = local.name;
217
+ botao.append(ponto, rotulo);
218
+ botao.addEventListener("click", () => {
219
+ document.dispatchEvent(new CustomEvent("destino-lunar-selecionado", { detail: { id: local.id } }));
220
+ });
221
+ camadaMarcadores.appendChild(botao);
222
+ marcadores.set(local.id, { element: botao, position: posicaoDoLocal(local) });
223
+ });
224
+ }
225
+
226
+ function atualizarMarcadores() {
227
+ if (marcadores.size === 0) return;
228
+ const largura = container.clientWidth;
229
+ const altura = container.clientHeight;
230
+ const candidatos = [];
231
+
232
+ marcadores.forEach((m) => {
233
+ const p = m.position;
234
+ const normal = p.clone().normalize();
235
+ const paraCamera = camera.position.clone().sub(p).normalize();
236
+ const tela = p.clone().project(camera);
237
+ const dentro = tela.x >= -1 && tela.x <= 1 && tela.y >= -1 && tela.y <= 1 && tela.z >= -1 && tela.z <= 1;
238
+ if (!dentro || normal.dot(paraCamera) <= 0) { m.element.hidden = true; return; }
239
+
240
+ const dist = camera.position.distanceTo(p);
241
+ raycaster.set(camera.position, p.clone().sub(camera.position).normalize());
242
+ raycaster.far = Math.max(0, dist - 0.005);
243
+ const hits = raycaster.intersectObject(lua, true);
244
+ if (hits.length > 0 && hits[0].distance < dist - 0.005) { m.element.hidden = true; return; }
245
+
246
+ m.element.hidden = false;
247
+ candidatos.push({ element: m.element, x: (tela.x * 0.5 + 0.5) * largura, y: (-tela.y * 0.5 + 0.5) * altura });
248
+ });
249
+
250
+ // Rótulos sem sobreposição (mesma lógica do LanderBnB).
251
+ candidatos.sort((a, b) => a.y - b.y);
252
+ let ultimoY = 12;
253
+ candidatos.forEach((c) => { c.rotuloY = Math.max(c.y, ultimoY); ultimoY = c.rotuloY + 26; });
254
+ const excesso = ultimoY - 26 - (altura - 12);
255
+ if (excesso > 0) candidatos.forEach((c) => { c.rotuloY -= excesso; });
256
+ candidatos.forEach((c) => {
257
+ c.element.style.left = `${c.x}px`;
258
+ c.element.style.top = `${c.y}px`;
259
+ c.element.style.setProperty("--deslocamento-rotulo-y", `${c.rotuloY - c.y}px`);
260
+ });
261
+ }
262
+
263
+ // ---------------------------------------------------------------- câmera
264
+
265
+ // O "para cima" da câmera é +X (lon 0°, face voltada para a Terra), e não o
266
+ // polo norte: assim a câmera pode olhar o polo sul de frente sem a matriz de
267
+ // visão degenerar, e a tela fica como num mapa polar (lon 0° em cima).
268
+ // A singularidade passa para os pontos lat 0°/lon 0° e lon 180°, onde não há
269
+ // locais; mesmo assim a direção é desviada se chegar a menos de 5° deles.
270
+ function direcaoCamera(lat, lon) {
271
+ const v = new THREE.Vector3(...direcaoCena(lat, lon));
272
+ if (Math.abs(v.x) > Math.cos(5 * Math.PI / 180)) v.y -= 0.1;
273
+ return v.normalize();
274
+ }
275
+
276
+ function iniciarTransicao(id) {
277
+ const local = locais.get(id);
278
+ if (!local) return;
279
+ const [x, y, z] = direcaoCena(local.lat, local.lon);
280
+ const alvo = new THREE.Vector3(x, y, z);
281
+ const destino = direcaoCamera(local.lat, local.lon);
282
+ const polo = local.lat < -60;
283
+ transicaoCamera = {
284
+ inicio: performance.now(),
285
+ duracao: 1800,
286
+ direcaoInicial: camera.position.clone().normalize(),
287
+ rotacao: new THREE.Quaternion().setFromUnitVectors(camera.position.clone().normalize(), destino),
288
+ raioInicial: camera.position.length(),
289
+ // Locais polares ficam a poucos km uns dos outros: chega mais perto.
290
+ raioFinal: RAIO * (polo ? 1.25 : 1.8),
291
+ alvoInicial: controls.target.clone(),
292
+ alvoFinal: alvo.multiplyScalar(RAIO * 0.97),
293
+ };
294
+ }
295
+
296
+ function atualizarTransicao(agora) {
297
+ if (!transicaoCamera) return;
298
+ const t = transicaoCamera;
299
+ const prog = Math.min((agora - t.inicio) / t.duracao, 1);
300
+ const s = prog * prog * (3 - 2 * prog);
301
+ const rot = new THREE.Quaternion().slerp(t.rotacao, s);
302
+ const dir = t.direcaoInicial.clone().applyQuaternion(rot).normalize();
303
+ camera.position.copy(dir.multiplyScalar(THREE.MathUtils.lerp(t.raioInicial, t.raioFinal, s)));
304
+ controls.target.copy(t.alvoInicial).lerp(t.alvoFinal, s);
305
+ camera.lookAt(controls.target);
306
+ if (prog === 1) transicaoCamera = null;
307
+ }
308
+
309
+ /** Mantém a câmera fora da Lua e não longe demais (distância ao centro). */
310
+ function limitarDistancia() {
311
+ const d = camera.position.length();
312
+ const min = RAIO * 1.04, max = RAIO * 8;
313
+ if (d < min) camera.position.setLength(min);
314
+ else if (d > max) camera.position.setLength(max);
315
+ }
316
+
317
+ // ---------------------------------------------------------------- eventos
318
+
319
+ document.addEventListener("locais-carregados", (e) => {
320
+ locais = new Map(e.detail.sites.map((s) => [s.id, s]));
321
+ criarMarcadores();
322
+ // Câmera inicial: face voltada para a Terra, inclinada para o polo sul
323
+ // (onde estão os locais), sem ficar exatamente sobre o polo.
324
+ if (!selecionado) {
325
+ camera.position.copy(direcaoCamera(-70, 0).multiplyScalar(RAIO * 2.6));
326
+ controls.target.set(0, 0, 0);
327
+ controls.update();
328
+ }
329
+ });
330
+
331
+ document.addEventListener("destino-lunar-selecionado", (e) => {
332
+ selecionado = e.detail.id;
333
+ const local = locais.get(selecionado);
334
+ destinoTexto.textContent = local ? `Destination: ${local.name}` : "";
335
+ marcadores.forEach((m, id) => {
336
+ m.element.classList.toggle("selecionado", id === selecionado);
337
+ m.element.setAttribute("aria-pressed", String(id === selecionado));
338
+ });
339
+ atualizarPainel();
340
+ iniciarTransicao(selecionado);
341
+ });
342
+
343
+ document.addEventListener("direcao-sol", (e) => {
344
+ const { direcao, texto } = e.detail;
345
+ if (direcao) {
346
+ luzSolar.position.set(direcao[0], direcao[1], direcao[2]).multiplyScalar(10);
347
+ }
348
+ estadoIluminacao.textContent = texto;
349
+ });
350
+
351
+ document.addEventListener("metricas-local", (e) => {
352
+ indicadores.set(e.detail.id, { energia: e.detail.energia, comunicacao: e.detail.comunicacao });
353
+ if (e.detail.id === selecionado) atualizarPainel();
354
+ });
355
+
356
+ // ---------------------------------------------------------------- laço
357
+
358
+ function ajustarTela() {
359
+ const w = container.clientWidth, h = container.clientHeight;
360
+ if (!w || !h) return;
361
+ camera.aspect = w / h;
362
+ camera.updateProjectionMatrix();
363
+ renderer.setSize(w, h);
364
+ }
365
+
366
+ window.addEventListener("resize", ajustarTela);
367
+ ajustarTela();
368
+
369
+ function animar() {
370
+ requestAnimationFrame(animar);
371
+ controls.update();
372
+ atualizarTransicao(performance.now());
373
+ limitarDistancia();
374
+ atualizarMarcadores();
375
+ renderer.render(scene, camera);
376
+ }
377
+
378
+ montarLua()
379
+ .then(() => { estadoCarregamento.remove(); animar(); })
380
+ .catch((erro) => {
381
+ console.error("Erro ao carregar a Lua:", erro);
382
+ estadoCarregamento.textContent = "Could not load the Moon textures (web/assets/).";
383
+ estadoCarregamento.classList.add("erro");
384
+ animar();
385
+ });
style.css CHANGED
@@ -1,28 +1,1099 @@
 
 
 
 
 
 
 
 
 
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
 
 
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* CONFIGURAÇÕES GERAIS */
3
+ * {
4
+ margin: 0;
5
+ padding: 0;
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ /* FUNDO DA PÁGINA */
10
  body {
11
+ background-color: #030817;
12
+ font-family: Arial, sans-serif;
13
+ color: white;
14
+ }
15
+
16
+ /* CABEÇALHO */
17
+ .cabecalho {
18
+ width: 100%;
19
+ min-height: 110px;
20
+ padding: 20px 40px;
21
+
22
+ display: flex;
23
+ align-items: center;
24
+ justify-content: space-between;
25
+
26
+ background: linear-gradient(
27
+ 90deg,
28
+ #06152b,
29
+ #071c36,
30
+ #06152b
31
+ );
32
+
33
+ border-bottom: 1px solid #087eff;
34
+ box-shadow: 0 4px 18px rgba(0, 126, 255, 0.15);
35
+ }
36
+
37
+ /* IDENTIDADE DO PROJETO */
38
+ .identidade {
39
+ display: flex;
40
+ align-items: center;
41
+ gap: 15px;
42
+ }
43
+
44
+ /* FOGUETE */
45
+ .logo {
46
+ font-size: 38px;
47
+ }
48
+
49
+ /* NOME */
50
+ .nome-projeto h1 {
51
+ font-size: 32px;
52
+ font-weight: bold;
53
+ color: #20c8ff;
54
+ letter-spacing: 2px;
55
+ }
56
+
57
+ /* SUBTÍTULO */
58
+ .nome-projeto p {
59
+ margin-top: 5px;
60
+ font-size: 13px;
61
+ color: #b8cce3;
62
+ letter-spacing: 0.5px;
63
+ }
64
+
65
+ /* BOTÃO DE CONFIGURAÇÕES */
66
+ .botao-configuracoes {
67
+ width: 45px;
68
+ height: 45px;
69
+
70
+ border: 1px solid #087eff;
71
+ border-radius: 10px;
72
+
73
+ background-color: #0a2342;
74
+ color: #20c8ff;
75
+
76
+ font-size: 24px;
77
+ cursor: pointer;
78
+
79
+ transition: 0.3s;
80
+ }
81
+
82
+ /* EFEITO AO PASSAR O MOUSE */
83
+ .botao-configuracoes:hover {
84
+ background-color: #087eff;
85
+ color: white;
86
+ box-shadow: 0 0 15px #087eff;
87
+ }
88
+
89
+
90
+ /* ==================================
91
+ LAYOUT PRINCIPAL
92
+ ================================== */
93
+
94
+ .layout-principal {
95
+ display: grid;
96
+ grid-template-columns: 250px minmax(0, 1fr) 320px;
97
+ min-height: calc(100vh - 110px);
98
+ }
99
+
100
+ /* ==================================
101
+ MENU LATERAL ESQUERDO
102
+ ================================== */
103
+
104
+ .menu-lateral {
105
+ background: #061426;
106
+ border-right: 1px solid #16416a;
107
+ padding: 25px 15px;
108
+ }
109
+
110
+ .titulo-menu {
111
+ color: #20c8ff;
112
+ font-size: 18px;
113
+ font-weight: bold;
114
+ margin-bottom: 25px;
115
+ padding-left: 10px;
116
+ }
117
+
118
+ /* ORGANIZAÇÃO DOS BOTÕES */
119
+
120
+ .lista-passos {
121
+ display: flex;
122
+ flex-direction: column;
123
+ gap: 12px;
124
+ }
125
+
126
+ /* APARÊNCIA DOS BOTÕES */
127
+
128
+ .botao-passo {
129
+ width: 100%;
130
+ min-height: 60px;
131
+ padding: 12px;
132
+
133
+ display: flex;
134
+ align-items: center;
135
+ gap: 12px;
136
+
137
+ background: #0a1e35;
138
+ border: 1px solid #1c3650;
139
+ border-radius: 10px;
140
+
141
+ color: #e8f2ff;
142
+ font-size: 13px;
143
+ text-align: left;
144
+
145
+ cursor: pointer;
146
+ transition: 0.3s;
147
+ }
148
+
149
+ /* NÚMERO DA ETAPA */
150
+
151
+ .numero-passo {
152
+ color: #20c8ff;
153
+ font-size: 14px;
154
+ font-weight: bold;
155
+ }
156
+
157
+ /* TEXTO DO BOTÃO */
158
+
159
+ .texto-passo {
160
+ flex: 1;
161
+ }
162
+
163
+ /* SETA */
164
+
165
+ .seta-passo {
166
+ color: #20c8ff;
167
+ font-size: 22px;
168
+ }
169
+
170
+ /* BOTÃO SELECIONADO */
171
+
172
+ .botao-passo.ativo {
173
+ background: #10365b;
174
+ border-color: #168aff;
175
+ box-shadow: 0 0 12px rgba(0, 126, 255, 0.25);
176
+ }
177
+
178
+ /* EFEITO AO PASSAR O MOUSE */
179
+
180
+ .botao-passo:hover {
181
+ background: #12395e;
182
+ border-color: #20c8ff;
183
+ transform: translateX(3px);
184
+ }
185
+
186
+ /* ==================================
187
+ ESPAÇO DO MAPA LUNAR
188
+ ================================== */
189
+
190
+ .area-mapa {
191
+ min-height: 500px;
192
+ background: #030817;
193
+ }
194
+
195
+ /* ==================================
196
+ PAINEL DIREITO
197
+ ================================== */
198
+
199
+ .painel-direito {
200
+ background: #071629;
201
+ border-left: 1px solid #16416a;
202
+ }
203
+
204
+ /* ==================================
205
+ RESPONSIVIDADE
206
+ ================================== */
207
+
208
+ @media (max-width: 1000px) {
209
+ .layout-principal {
210
+ grid-template-columns: 220px minmax(0, 1fr);
211
+ }
212
+
213
+ .painel-direito {
214
+ grid-column: 1 / -1;
215
+ min-height: 150px;
216
+ }
217
+ }
218
+
219
+ @media (max-width: 600px) {
220
+ .layout-principal {
221
+ grid-template-columns: 1fr;
222
+ }
223
+
224
+ .menu-lateral {
225
+ border-right: none;
226
+ border-bottom: 1px solid #16416a;
227
+ }
228
+
229
+ .area-mapa {
230
+ min-height: 350px;
231
+ }
232
+
233
+ .painel-direito {
234
+ grid-column: auto;
235
+ }
236
+ }
237
+
238
+
239
+ /* ÁREA DA LUA 3D */
240
+
241
+ .visualizador-lua {
242
+ width: 100%;
243
+ min-height: 650px;
244
+
245
+ display: flex;
246
+ flex-direction: column;
247
+ align-items: center;
248
+ justify-content: center;
249
+
250
+ background: radial-gradient(
251
+ circle,
252
+ #102544 0%,
253
+ #030817 75%
254
+ );
255
+
256
+ position: relative;
257
+ overflow: hidden;
258
+ }
259
+
260
+ .titulo-visualizador {
261
+ color: #20c8ff;
262
+ font-size: 20px;
263
+ margin-bottom: 20px;
264
+ }
265
+
266
+ .container-lua {
267
+ width: 100%;
268
+ height: 450px;
269
+ position: relative;
270
+ }
271
+
272
+ .instrucao-lua {
273
+ color: #b8cce3;
274
+ font-size: 13px;
275
+ margin-top: 15px;
276
+ margin-bottom: 25px;
277
+ }
278
+
279
+ /* CELULAR */
280
+
281
+ @media (max-width: 600px) {
282
+ .visualizador-lua {
283
+ min-height: 480px;
284
+ }
285
+
286
+ .container-lua {
287
+ height: 320px;
288
+ }
289
+ }
290
+
291
+
292
+ /* VISUALIZADOR DA LUA */
293
+
294
+ #lua-3d {
295
+ width: 100%;
296
+ height: 450px;
297
+ min-height: 320px;
298
+ position: relative;
299
+ cursor: grab;
300
+ }
301
+
302
+ #lua-3d:active {
303
+ cursor: grabbing;
304
+ }
305
+
306
+ #lua-3d canvas {
307
+ display: block;
308
+ width: 100%;
309
+ height: 100%;
310
+ }
311
+
312
+ .camada-marcadores {
313
+ position: absolute;
314
+ inset: 0;
315
+ z-index: 2;
316
+ pointer-events: none;
317
+ }
318
+
319
+ .marcador-local {
320
+ position: absolute;
321
+ display: flex;
322
+ align-items: center;
323
+ gap: 0;
324
+ padding: 4px 8px 4px 4px;
325
+ transform: translate(-10px, calc(-50% + var(--deslocamento-rotulo-y, 0px)));
326
+ border: 1px solid rgba(32, 200, 255, 0.75);
327
+ border-radius: 20px;
328
+ background: rgba(3, 15, 31, 0.88);
329
+ color: #e8f7ff;
330
+ font: inherit;
331
+ white-space: nowrap;
332
+ cursor: pointer;
333
+ pointer-events: auto;
334
+ transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
335
+ }
336
+
337
+ .marcador-local:hover,
338
+ .marcador-local.selecionado {
339
+ border-color: #20c8ff;
340
+ background: #10365b;
341
+ box-shadow: 0 0 14px rgba(32, 200, 255, 0.7);
342
+ }
343
+
344
+ .ponto-marcador {
345
+ position: absolute;
346
+ top: calc(50% - var(--deslocamento-rotulo-y, 0px));
347
+ left: 4px;
348
+ width: 12px;
349
+ height: 12px;
350
+ border: 2px solid #ffffff;
351
+ border-radius: 50%;
352
+ background: #20c8ff;
353
+ box-shadow: 0 0 10px #20c8ff;
354
+ }
355
+
356
+ .marcador-local.selecionado .ponto-marcador {
357
+ background: #ffcf5a;
358
+ box-shadow: 0 0 12px #ffcf5a;
359
+ }
360
+
361
+ .rotulo-marcador {
362
+ margin-left: 20px;
363
+ font-size: 11px;
364
+ font-weight: 600;
365
+ }
366
+
367
+ .aviso-orientacao {
368
+ position: absolute;
369
+ right: 12px;
370
+ bottom: 12px;
371
+ max-width: calc(100% - 24px);
372
+ padding: 5px 8px;
373
+ border: 1px solid rgba(22, 65, 106, 0.8);
374
+ border-radius: 6px;
375
+ background: rgba(3, 15, 31, 0.78);
376
+ color: #b8cce3;
377
+ font-size: 10px;
378
+ text-align: right;
379
+ pointer-events: none;
380
+ }
381
+
382
+ .painel-local-visualizador {
383
+ position: absolute;
384
+ z-index: 3;
385
+ left: 12px;
386
+ bottom: 12px;
387
+ width: min(250px, calc(100% - 24px));
388
+ padding: 12px;
389
+ border: 1px solid rgba(32, 200, 255, 0.65);
390
+ border-radius: 10px;
391
+ background: rgba(5, 20, 39, 0.94);
392
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 12px rgba(32, 200, 255, 0.16);
393
+ color: #e8f2ff;
394
+ pointer-events: auto;
395
+ }
396
+
397
+ .painel-local-visualizador[hidden] {
398
+ display: none;
399
+ }
400
+
401
+ .cabecalho-painel-local {
402
+ display: flex;
403
+ align-items: flex-start;
404
+ justify-content: space-between;
405
+ gap: 8px;
406
+ margin-bottom: 8px;
407
+ }
408
+
409
+ .nome-painel-local {
410
+ color: #20c8ff;
411
+ font-size: 13px;
412
+ line-height: 1.35;
413
+ }
414
+
415
+ .fechar-painel-local {
416
+ flex: 0 0 24px;
417
+ width: 24px;
418
+ height: 24px;
419
+ border: 1px solid #24547b;
420
+ border-radius: 6px;
421
+ background: #0a2342;
422
+ color: #b8cce3;
423
+ font-size: 18px;
424
+ line-height: 1;
425
+ cursor: pointer;
426
+ }
427
+
428
+ .fechar-painel-local:hover {
429
+ border-color: #20c8ff;
430
+ color: #ffffff;
431
+ }
432
+
433
+ .linha-painel-local {
434
+ display: flex;
435
+ justify-content: space-between;
436
+ gap: 12px;
437
+ margin-top: 5px;
438
+ font-size: 11px;
439
+ }
440
+
441
+ .rotulo-painel-local {
442
+ color: #9fc5e4;
443
+ }
444
+
445
+ .valor-painel-local {
446
+ color: #ffffff;
447
+ text-align: right;
448
+ }
449
+
450
+ .aviso-indicadores-simulados {
451
+ margin-top: 9px;
452
+ padding-top: 7px;
453
+ border-top: 1px solid rgba(22, 65, 106, 0.8);
454
+ color: #b8cce3;
455
+ font-size: 9px;
456
+ line-height: 1.4;
457
+ }
458
+
459
+ .erro-lua {
460
+ position: absolute;
461
+ bottom: 20px;
462
+ left: 50%;
463
+ transform: translateX(-50%);
464
+ color: #ff454f;
465
+ font-size: 14px;
466
+ text-align: center;
467
+ }
468
+
469
+ .estado-iluminacao-solar {
470
+ position: absolute;
471
+ top: 12px;
472
+ left: 12px;
473
+ z-index: 3;
474
+ width: min(270px, calc(100% - 24px));
475
+ padding: 8px 10px;
476
+ border: 1px solid rgba(32, 200, 255, 0.55);
477
+ border-radius: 8px;
478
+ background: rgba(5, 20, 39, 0.9);
479
+ color: #c9deef;
480
+ font-size: 10px;
481
+ line-height: 1.4;
482
+ pointer-events: none;
483
+ }
484
+
485
+
486
+ /* ==================================
487
+ PAINEL DIREITO
488
+ ================================== */
489
+
490
+ .painel-direito {
491
+ background: #071629;
492
+ border-left: 1px solid #16416a;
493
+ padding: 16px;
494
+ display: flex;
495
+ flex-direction: column;
496
+ gap: 18px;
497
+ }
498
+
499
+ /* CARDS PRINCIPAIS */
500
+
501
+ .card-painel {
502
+ background: #091e35;
503
+ border: 1px solid #16416a;
504
+ border-radius: 12px;
505
+ padding: 16px;
506
+ }
507
+
508
+ .card-painel h2 {
509
+ color: #20c8ff;
510
+ font-size: 15px;
511
+ margin-bottom: 18px;
512
+ }
513
+
514
+ /* GUIA DE PASSOS */
515
+
516
+ .etapas-missao {
517
+ display: flex;
518
+ justify-content: space-between;
519
+ gap: 4px;
520
+ }
521
+
522
+ .etapa {
523
+ display: flex;
524
+ flex-direction: column;
525
+ align-items: center;
526
+ gap: 8px;
527
+ flex: 1;
528
+ }
529
+
530
+ .conteudos-etapa {
531
+ display: flex;
532
+ flex-direction: column;
533
+ gap: 10px;
534
+ margin-top: 16px;
535
+ padding-top: 12px;
536
+ border-top: 1px solid #16416a;
537
+ }
538
+
539
+ .conteudo-etapa[hidden],
540
+ .resumo-data-missao[hidden] {
541
+ display: none;
542
+ }
543
+
544
+ .conteudo-etapa {
545
+ display: flex;
546
+ flex-direction: column;
547
+ gap: 6px;
548
+ }
549
+
550
+ .conteudo-etapa h3 {
551
+ color: #20c8ff;
552
+ font-size: 13px;
553
+ }
554
+
555
+ .valor-etapa {
556
+ color: #ffffff;
557
+ font-size: 12px;
558
+ }
559
+
560
+ .detalhe-etapa {
561
+ color: #b8cce3;
562
+ font-size: 11px;
563
+ line-height: 1.45;
564
+ }
565
+
566
+ .aviso-simulacao-etapa {
567
+ color: #9fc5e4;
568
+ font-size: 10px;
569
+ line-height: 1.4;
570
+ }
571
+
572
+ .calculo-elevacao-solar {
573
+ display: flex;
574
+ flex-direction: column;
575
+ gap: 7px;
576
+ margin: 4px 0;
577
+ padding: 9px;
578
+ border: 1px solid #24547b;
579
+ border-radius: 8px;
580
+ background: #0a1e35;
581
+ }
582
+
583
+ .calculo-elevacao-solar h4 {
584
+ color: #20c8ff;
585
+ font-size: 11px;
586
+ }
587
+
588
+ .estado-calculo-elevacao {
589
+ color: #b8cce3;
590
+ font-size: 10px;
591
+ line-height: 1.4;
592
+ }
593
+
594
+ .lista-elevacao-solar {
595
+ display: flex;
596
+ flex-direction: column;
597
+ gap: 6px;
598
+ margin: 0;
599
+ padding: 0;
600
+ list-style: none;
601
+ }
602
+
603
+ .resultado-elevacao-solar {
604
+ display: flex;
605
+ flex-direction: column;
606
+ gap: 3px;
607
+ padding-top: 6px;
608
+ border-top: 1px solid rgba(36, 84, 123, 0.65);
609
+ }
610
+
611
+ .nome-local-elevacao {
612
+ color: #e8f2ff;
613
+ font-size: 10px;
614
+ }
615
+
616
+ .coordenadas-local-elevacao,
617
+ .valor-elevacao-solar,
618
+ .estado-horizonte-geometrico {
619
+ color: #b8cce3;
620
+ font-size: 9px;
621
+ line-height: 1.4;
622
+ overflow-wrap: anywhere;
623
+ }
624
+
625
+ .aviso-topografia-solar {
626
+ color: #9fc5e4;
627
+ font-size: 9px;
628
+ line-height: 1.4;
629
+ }
630
+
631
+ .parametros-energia {
632
+ display: grid;
633
+ grid-template-columns: repeat(2, minmax(0, 1fr));
634
+ gap: 8px;
635
+ margin: 4px 0;
636
+ }
637
+
638
+ .campo-energia {
639
+ display: flex;
640
+ flex-direction: column;
641
+ gap: 4px;
642
+ color: #b8cce3;
643
+ font-size: 9px;
644
+ line-height: 1.3;
645
+ }
646
+
647
+ .campo-energia input {
648
+ width: 100%;
649
+ min-width: 0;
650
+ min-height: 30px;
651
+ padding: 5px 7px;
652
+ border: 1px solid #24547b;
653
+ border-radius: 6px;
654
+ background: #0a1e35;
655
+ color: #ffffff;
656
+ color-scheme: dark;
657
+ font: inherit;
658
+ }
659
+
660
+ .campo-energia input:focus {
661
+ border-color: #20c8ff;
662
+ outline: 2px solid rgba(32, 200, 255, 0.25);
663
+ }
664
+
665
+ .resultados-simulacao-energia {
666
+ display: flex;
667
+ flex-direction: column;
668
+ gap: 7px;
669
+ margin: 4px 0;
670
+ padding: 9px;
671
+ border: 1px solid #24547b;
672
+ border-radius: 8px;
673
+ background: #0a1e35;
674
+ }
675
+
676
+ .resultados-simulacao-energia h4 {
677
+ color: #20c8ff;
678
+ font-size: 11px;
679
+ }
680
+
681
+ .estado-simulacao-energia,
682
+ .resumo-parametros-energia {
683
+ color: #b8cce3;
684
+ font-size: 9px;
685
+ line-height: 1.4;
686
+ overflow-wrap: anywhere;
687
  }
688
 
689
+ .estado-simulacao-energia {
690
+ color: #ffd98a;
 
691
  }
692
 
693
+ .lista-resultados-energia {
694
+ display: flex;
695
+ flex-direction: column;
696
+ gap: 7px;
697
+ margin: 0;
698
+ padding: 0;
699
+ list-style: none;
700
  }
701
 
702
+ .resultado-local-energia {
703
+ display: flex;
704
+ flex-direction: column;
705
+ gap: 3px;
706
+ padding-top: 7px;
707
+ border-top: 1px solid rgba(36, 84, 123, 0.65);
708
+ }
709
+
710
+ .nome-resultado-energia {
711
+ color: #e8f2ff;
712
+ font-size: 10px;
713
+ }
714
+
715
+ .coordenadas-resultado-energia {
716
+ color: #9fc5e4;
717
+ font-size: 9px;
718
+ }
719
+
720
+ .metrica-simulacao-energia {
721
+ display: flex;
722
+ justify-content: space-between;
723
+ gap: 8px;
724
+ color: #b8cce3;
725
+ font-size: 9px;
726
+ line-height: 1.35;
727
+ }
728
+
729
+ .metrica-simulacao-energia strong {
730
+ color: #20c8ff;
731
+ font-weight: normal;
732
+ text-align: right;
733
+ }
734
+
735
+ .campo-etapa {
736
+ display: flex;
737
+ flex-direction: column;
738
+ gap: 5px;
739
+ color: #b8cce3;
740
+ font-size: 11px;
741
+ }
742
+
743
+ .campo-etapa input {
744
+ width: 100%;
745
+ min-height: 34px;
746
+ padding: 6px 8px;
747
+ border: 1px solid #24547b;
748
+ border-radius: 6px;
749
+ background: #0a1e35;
750
+ color: #ffffff;
751
+ color-scheme: dark;
752
+ font: inherit;
753
+ }
754
+
755
+ .campo-etapa input:focus {
756
+ border-color: #20c8ff;
757
+ outline: 2px solid rgba(32, 200, 255, 0.25);
758
+ }
759
+
760
+ .resumo-data-missao {
761
+ display: flex;
762
+ flex-direction: column;
763
+ gap: 4px;
764
+ padding: 8px;
765
+ border: 1px solid #24547b;
766
+ border-radius: 7px;
767
+ background: #0a1e35;
768
+ color: #9fc5e4;
769
+ font-size: 10px;
770
+ }
771
+
772
+ .resumo-data-missao strong {
773
+ color: #ffffff;
774
+ font-size: 11px;
775
+ }
776
+
777
+ .etapa span {
778
+ width: 30px;
779
+ height: 30px;
780
+ display: flex;
781
+ align-items: center;
782
+ justify-content: center;
783
+ background: #123452;
784
+ border: 1px solid #24547b;
785
+ border-radius: 50%;
786
+ color: white;
787
+ font-size: 12px;
788
+ }
789
+
790
+ .etapa.atual span {
791
+ background: #087eff;
792
+ border-color: #20c8ff;
793
+ box-shadow: 0 0 12px #087eff;
794
+ }
795
+
796
+ .botao-passo:focus-visible {
797
+ outline: 2px solid #20c8ff;
798
+ outline-offset: 2px;
799
+ }
800
+
801
+ .etapa small {
802
+ font-size: 9px;
803
+ color: #b8cce3;
804
+ text-align: center;
805
+ }
806
+
807
+ /* SIMULADOR DE ATRASO */
808
+
809
+ .valor-atraso {
810
+ text-align: right;
811
+ color: white;
812
+ font-size: 14px;
813
+ margin-bottom: 12px;
814
+ }
815
+
816
+ #simulador-atraso {
817
+ width: 100%;
818
+ accent-color: #20c8ff;
819
+ cursor: pointer;
820
+ }
821
+
822
+ .limites-atraso {
823
+ display: flex;
824
+ justify-content: space-between;
825
+ margin-top: 10px;
826
+ color: #b8cce3;
827
+ font-size: 11px;
828
+ }
829
+
830
+ /* CARDS DOS LOCAIS */
831
+
832
+ .lista-locais {
833
+ display: flex;
834
+ flex-direction: column;
835
+ gap: 12px;
836
+ }
837
+
838
+ .card-local {
839
+ width: 100%;
840
+ display: flex;
841
+ flex-direction: column;
842
+ gap: 7px;
843
+ text-align: left;
844
+
845
+ padding: 14px;
846
+ border-radius: 9px;
847
+ background: #0a1e35;
848
+ color: white;
849
+ cursor: pointer;
850
+ transition: 0.3s;
851
  }
852
 
853
+ .card-local strong {
854
+ font-size: 13px;
855
  }
856
+
857
+ .card-local span {
858
+ font-size: 11px;
859
+ }
860
+
861
+ .card-local.risco {
862
+ border: 1px solid #ff454f;
863
+ }
864
+
865
+ .card-local.risco span {
866
+ color: #ff454f;
867
+ }
868
+
869
+ .card-local.ideal {
870
+ border: 1px solid #16c784;
871
+ }
872
+
873
+ .card-local.ideal span {
874
+ color: #16c784;
875
+ }
876
+
877
+ .card-local.moderado {
878
+ border: 1px solid #f0b94b;
879
+ }
880
+
881
+ .card-local.moderado span {
882
+ color: #f0b94b;
883
+ }
884
+
885
+ .card-local:hover {
886
+ transform: translateY(-2px);
887
+ background: #123452;
888
+ }
889
+
890
+ /* ==================================
891
+ DETALHES DOS LOCAIS DE POUSO
892
+ ================================== */
893
+
894
+ .cabecalho-local {
895
+ display: flex;
896
+ justify-content: space-between;
897
+ align-items: flex-start;
898
+ gap: 8px;
899
+ width: 100%;
900
+ }
901
+
902
+ .cabecalho-local strong {
903
+ font-size: 12px;
904
+ line-height: 1.4;
905
+ }
906
+
907
+ .card-local .status-local {
908
+ font-size: 10px;
909
+ white-space: nowrap;
910
+ }
911
+
912
+ .card-local .coordenadas-local {
913
+ color: #a8bed6;
914
+ font-size: 11px;
915
+ }
916
+
917
+ .indicador-local {
918
+ display: flex;
919
+ flex-direction: column;
920
+ gap: 6px;
921
+ width: 100%;
922
+ }
923
+
924
+ .linha-indicador {
925
+ display: flex;
926
+ justify-content: space-between;
927
+ gap: 8px;
928
+ width: 100%;
929
+ }
930
+
931
+ .card-local .linha-indicador span {
932
+ color: #dce9f8;
933
+ font-size: 11px;
934
+ }
935
+
936
+ .trilha-indicador {
937
+ display: block;
938
+ width: 100%;
939
+ height: 7px;
940
+ overflow: hidden;
941
+ background: #18334d;
942
+ border-radius: 10px;
943
+ }
944
+
945
+ .preenchimento {
946
+ display: block;
947
+ height: 100%;
948
+ border-radius: 10px;
949
+ }
950
+
951
+ /* ENERGIA */
952
+
953
+ .energia-risco {
954
+ width: 45%;
955
+ background: #ff454f;
956
+ }
957
+
958
+ .energia-ideal {
959
+ width: 80%;
960
+ background: #16c784;
961
+ }
962
+
963
+ .energia-moderada {
964
+ width: 65%;
965
+ background: #f0b94b;
966
+ }
967
+
968
+ /* COMUNICAÇÃO */
969
+
970
+ .comunicacao-shackleton {
971
+ width: 85%;
972
+ background: #20c8ff;
973
+ }
974
+
975
+ .comunicacao-malapert {
976
+ width: 90%;
977
+ background: #20c8ff;
978
+ }
979
+
980
+ .comunicacao-nobile {
981
+ width: 70%;
982
+ background: #20c8ff;
983
+ }
984
+
985
+ /* LOCAL SELECIONADO */
986
+
987
+ .local-selecionado {
988
+ display: flex;
989
+ flex-direction: column;
990
+ gap: 5px;
991
+
992
+ background: #102b47;
993
+ border: 1px solid #16416a;
994
+ border-radius: 8px;
995
+
996
+ padding: 12px;
997
+ margin-bottom: 15px;
998
+ }
999
+
1000
+ .local-selecionado span {
1001
+ color: #9fc5e4;
1002
+ font-size: 11px;
1003
+ }
1004
+
1005
+ .local-selecionado strong {
1006
+ color: white;
1007
+ font-size: 13px;
1008
+ }
1009
+
1010
+ /* CARD ATIVO */
1011
+
1012
+ .card-local.selecionado {
1013
+ background: #143451;
1014
+ border: 2px solid #20c8ff;
1015
+ box-shadow: 0 0 15px rgba(32, 200, 255, 0.25);
1016
+ }
1017
+
1018
+
1019
+
1020
+ /* ==================================
1021
+ INTEGRAÇÃO COM A API (acréscimos)
1022
+ ================================== */
1023
+
1024
+ .aviso-api {
1025
+ margin: 0;
1026
+ padding: 10px 40px;
1027
+ font-size: 13px;
1028
+ background: #0a2342;
1029
+ border-bottom: 1px solid #16416a;
1030
+ color: #c9deef;
1031
+ }
1032
+ .aviso-api[data-tipo="alerta"] { background: #3a2c07; color: #ffd98a; border-color: #6b5313; }
1033
+ .aviso-api[data-tipo="erro"] { background: #3a0d12; color: #ffb3b8; border-color: #7a1f27; }
1034
+ .aviso-api[hidden] { display: none; }
1035
+
1036
+ .destino-lua {
1037
+ position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1;
1038
+ color: #ffffff; font-size: 16px; font-weight: 600; text-align: center; pointer-events: none;
1039
+ }
1040
+ .estado-carregamento-lua {
1041
+ position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 1;
1042
+ color: #ffffff; font-size: 14px; text-align: center; pointer-events: none;
1043
+ }
1044
+ .estado-carregamento-lua.erro { color: #ff454f; }
1045
+
1046
+ .etapa { cursor: pointer; }
1047
+ .etapa.feita span { background: #0d4d3a; border-color: #16c784; }
1048
+
1049
+ /* Barras dos cards (largura vem do JS). */
1050
+ .energia-moderado { background: #f0b94b; }
1051
+ .comunicacao { background: #20c8ff; }
1052
+ .card-local.carregando { border: 1px solid #24547b; }
1053
+ .card-local .tag-mock {
1054
+ align-self: flex-start; padding: 1px 6px; border-radius: 4px;
1055
+ background: #3a2c07; color: #ffd98a !important; font-size: 9px !important;
1056
+ }
1057
+ .card-local .faixa-incerteza { color: #9fc5e4 !important; font-size: 10px !important; }
1058
+ .card-local .erro-card, .erro-card { color: #ff8a91 !important; font-size: 10px; }
1059
+
1060
+ /* Panorama do céu (etapa 3). */
1061
+ .grafico-ceu { width: 100%; height: auto; display: block; border-radius: 6px; border: 1px solid #24547b; }
1062
+ .ceu-fundo { fill: #0a1e35; }
1063
+ .ceu-zero { stroke: #3f6c93; stroke-dasharray: 3 3; stroke-width: 0.6; }
1064
+ .ceu-relevo { fill: #5d6b78; stroke: #b8cce3; stroke-width: 0.6; }
1065
+ .ceu-sol { fill: #ffcf5a; stroke: #fff2c7; stroke-width: 0.6; }
1066
+ .ceu-terra { fill: #20c8ff; stroke: #d5f5ff; stroke-width: 0.6; }
1067
+ .ceu-rotulo { fill: #9fc5e4; font-size: 8px; }
1068
+ .legenda-ceu { display: flex; gap: 10px; align-items: center; color: #b8cce3; font-size: 10px; }
1069
+ .legenda-ceu .chip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: -6px; }
1070
+ .chip.relevo { background: #5d6b78; border-radius: 2px; }
1071
+ .chip.sol { background: #ffcf5a; }
1072
+ .chip.terra { background: #20c8ff; }
1073
+ .texto-sol-terra { display: flex; flex-direction: column; gap: 4px; }
1074
+ .linha-astro.ok { color: #7fe3b9; }
1075
+ .linha-astro.nao { color: #ffb3b8; }
1076
+
1077
+ /* Simulador de atraso. */
1078
+ .grafico-atraso { width: 100%; height: 70px; display: block; margin-top: 12px; }
1079
+ .barra-atraso { fill: #24547b; }
1080
+ .barra-atraso.ideal { fill: #16c784; }
1081
+ .barra-atraso.moderado { fill: #f0b94b; }
1082
+ .barra-atraso.critico { fill: #ff454f; }
1083
+ .barra-atraso.atual { stroke: #ffffff; stroke-width: 1.5; }
1084
+ .limiar-ok, .limiar-crit { stroke-width: 0.7; stroke-dasharray: 4 3; }
1085
+ .limiar-ok { stroke: #16c784; }
1086
+ .limiar-crit { stroke: #ff454f; }
1087
+ .resultado-atraso { margin-top: 8px; color: #dce9f8; font-size: 12px; line-height: 1.4; }
1088
+ .resultado-atraso[data-classe="ideal"] { color: #16c784; }
1089
+ .resultado-atraso[data-classe="moderado"] { color: #f0b94b; }
1090
+ .resultado-atraso[data-classe="critico"] { color: #ff454f; }
1091
+
1092
+ .rodape {
1093
+ padding: 12px 40px; border-top: 1px solid #16416a; background: #061426;
1094
+ color: #7f9bb8; font-size: 11px; text-align: center;
1095
+ }
1096
+
1097
+ /* O display:flex do .marcador-local anulava o atributo hidden
1098
+ (marcadores do outro lado da Lua apareciam no canto). */
1099
+ .marcador-local[hidden] { display: none; }