Elffuss BraidHub

kikocis/osiris public

09d1cb3093e4 · 59.1 KiBRawPermalink
1'use client';
2
3import { useEffect, useState, useRef, useCallback, useMemo } from 'react';
4import dynamic from 'next/dynamic';
5import { motion, AnimatePresence } from 'framer-motion';
6import { Layers, BarChart3, Newspaper, Search, Share2, Map as MapIcon, X, Globe, MapPinned, Radar, Satellite, Moon, ExternalLink, AlertTriangle, Building2, RadioTower, Activity, Shield, Database, Wifi } from 'lucide-react';
7import IntelFeed from '@/components/IntelFeed';
8import MarketsPanel from '@/components/MarketsPanel';
9import SearchBar from '@/components/SearchBar';
10import ScaleBar from '@/components/ScaleBar';
11import ErrorBoundary from '@/components/ErrorBoundary';
12import SharePanel from '@/components/SharePanel';
13import ViewPresets from '@/components/ViewPresets';
14import KeyboardShortcuts from '@/components/KeyboardShortcuts';
15import GlobalStatusBar from '@/components/GlobalStatusBar';
16import LiveAlerts from '@/components/LiveAlerts';
17
18const OsirisMap = dynamic(() => import('@/components/OsirisMap'), { ssr: false });
19const LayerPanel = dynamic(() => import('@/components/LayerPanel'));
20const CameraViewer = dynamic(() => import('@/components/CameraViewer'));
21const OsintPanel = dynamic(() => import('@/components/OsintPanel'));
22
23function useIsMobile() {
24 const [isMobile, setIsMobile] = useState(false);
25 useEffect(() => {
26 const check = () => {
27 const w = window.innerWidth;
28 const h = window.innerHeight;
29 // Mobile if narrow, OR landscape phone (short height + moderate width)
30 setIsMobile(w < 768 || (h < 500 && w < 1024));
31 };
32 check();
33 window.addEventListener('resize', check);
34 window.addEventListener('orientationchange', check);
35 return () => {
36 window.removeEventListener('resize', check);
37 window.removeEventListener('orientationchange', check);
38 };
39 }, []);
40 return isMobile;
41}
42const UptimeClock = () => {
43 const [uptime, setUptime] = useState('00:00:00');
44 const startTime = useRef(Date.now());
45 useEffect(() => {
46 const iv = setInterval(() => {
47 const e = Math.floor((Date.now() - startTime.current) / 1000);
48 setUptime(`${String(Math.floor(e/3600)).padStart(2,'0')}:${String(Math.floor((e%3600)/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`);
49 }, 1000);
50 return () => clearInterval(iv);
51 }, []);
52 return <span className="hidden lg:inline">UPTIME: <span className="text-[var(--gold-primary)]">{uptime}</span></span>;
53};
54
55const ZuluClock = () => {
56 const [time, setTime] = useState('');
57 useEffect(() => {
58 const iv = setInterval(() => {
59 const now = new Date();
60 setTime(`ZULU ${String(now.getUTCHours()).padStart(2,'0')}:${String(now.getUTCMinutes()).padStart(2,'0')}:${String(now.getUTCSeconds()).padStart(2,'0')}Z`);
61 }, 1000);
62 return () => clearInterval(iv);
63 }, []);
64 return <span className="text-[var(--cyan-primary)] font-bold tabular-nums">{time || 'ZULU --:--:--Z'}</span>;
65};
66
67const DataThroughput = ({ data }: { data: any }) => {
68 const [throughput, setThroughput] = useState('0.00');
69 const [pingTime, setPingTime] = useState<number | null>(null);
70
71 useEffect(() => {
72 const iv = setInterval(() => {
73 let estimatedBytes = 0;
74 if (data) {
75 if (data.satellites) estimatedBytes += data.satellites.length * 150;
76 if (data.commercial_flights) estimatedBytes += data.commercial_flights.length * 120;
77 if (data.cameras) estimatedBytes += data.cameras.length * 80;
78 if (data.gdelt) estimatedBytes += data.gdelt.length * 300;
79 if (data.live_feeds) estimatedBytes += data.live_feeds.length * 500;
80 }
81
82 const megabytes = estimatedBytes / 1024 / 1024;
83 setThroughput(megabytes > 0 ? (megabytes * 1.5).toFixed(2) : "0.00");
84
85 setPingTime(Math.floor(30 + estimatedBytes / 100000));
86 }, 2500);
87 return () => clearInterval(iv);
88 }, [data]);
89
90 return <span className="text-[var(--alert-green)] font-bold tabular-nums">{throughput} MB/s</span>;
91};
92
93export default function Dashboard() {
94 const dataRef = useRef<any>({});
95 const [dataVersion, setDataVersion] = useState(0);
96 const data = dataRef.current;
97
98 const [backendStatus, setBackendStatus] = useState<'connecting' | 'connected' | 'error'>('connecting');
99 const [mapView, setMapView] = useState({ zoom: 2.5, latitude: 20 });
100 const [flyToLocation, setFlyToLocation] = useState<{ lat: number; lng: number; ts: number } | null>(null);
101 const [globalStats, setGlobalStats] = useState<any>(null);
102 const mouseCoordsRef = useRef<{ lat: number; lng: number } | null>(null);
103 const coordsDisplayRef = useRef<HTMLDivElement>(null);
104 const [locationLabel, setLocationLabel] = useState('');
105 const [regionDossier, setRegionDossier] = useState<any>(null);
106 const [dossierLoading, setDossierLoading] = useState(false);
107 const [showSplash, setShowSplash] = useState(true);
108 const [activeCamera, setActiveCamera] = useState<any>(null);
109 const [spaceWeather, setSpaceWeather] = useState<any>(null);
110 const [showLayers, setShowLayers] = useState(true);
111 const [showMarkets, setShowMarkets] = useState(true);
112 const [showIntel, setShowIntel] = useState(true);
113 const [isFullscreen, setIsFullscreen] = useState(false);
114 const [mobilePanel, setMobilePanel] = useState<'layers'|'markets'|'intel'|'search'|'recon'|null>(null);
115 const [mapProjection, setMapProjection] = useState<'globe'|'mercator'>('globe');
116 const [mapStyle, setMapStyle] = useState<'dark'|'satellite'>('dark');
117 const [sweepData, setSweepData] = useState<any>(null);
118 const [scanTargets, setScanTargets] = useState<any[]>([]);
119
120 const isMobile = useIsMobile();
121 const startTime = useRef(Date.now());
122 const geocodeCache = useRef<Map<string, string>>(new Map());
123 const geocodeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
124 const lastGeocodedPos = useRef<{ lat: number; lng: number } | null>(null);
125
126 // ── DEFAULT: Most layers OFF — fast initial load ──
127 const [activeLayers, setActiveLayers] = useState({
128 flights: false,
129 private: false,
130 jets: false,
131 military: false,
132 maritime: true,
133 satellites: false,
134 balloons: false,
135 cctv: true,
136 live_news: true,
137 news_intel: true,
138 earthquakes: true,
139 fires: false,
140 weather: false,
141 radiation: false,
142 infrastructure: false,
143 global_incidents: true,
144 war_alerts: false,
145 gps_jamming: false,
146 day_night: true,
147 });
148 const [liveFeedUrl, setLiveFeedUrl] = useState<string | null>(null);
149 const [liveFeedName, setLiveFeedName] = useState('');
150 const [liveFeedEmbedAllowed, setLiveFeedEmbedAllowed] = useState(true);
151
152 // Splash screen
153 useEffect(() => {
154 const splashTimer = setTimeout(() => setShowSplash(false), 2500);
155 return () => clearTimeout(splashTimer);
156 }, []);
157
158 // URL state: parse on mount
159 useEffect(() => {
160 if (typeof window === 'undefined') return;
161 const p = new URLSearchParams(window.location.search);
162 const lat = parseFloat(p.get('lat') || '');
163 const lon = parseFloat(p.get('lon') || '');
164 const zoom = parseFloat(p.get('zoom') || '');
165 if (!isNaN(lat) && !isNaN(lon)) {
166 setFlyToLocation({ lat, lng: lon, ts: Date.now() });
167 if (!isNaN(zoom)) setMapView(v => ({ ...v, zoom }));
168 }
169 const layers = p.get('layers');
170 if (layers) {
171 const active = layers.split(',');
172 setActiveLayers(prev => {
173 const next = { ...prev };
174 Object.keys(next).forEach(k => { (next as any)[k] = active.includes(k); });
175 return next;
176 });
177 }
178 }, []);
179
180 // URL state: update URL on view change (debounced)
181 const urlTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
182 useEffect(() => {
183 if (typeof window === 'undefined') return;
184 if (urlTimer.current) clearTimeout(urlTimer.current);
185 urlTimer.current = setTimeout(() => {
186 const p = new URLSearchParams();
187 p.set('lat', (mouseCoordsRef.current?.lat ?? mapView.latitude ?? 20).toFixed(4));
188 p.set('lon', (mouseCoordsRef.current?.lng ?? 0).toFixed(4));
189 p.set('zoom', mapView.zoom.toFixed(2));
190 const active = Object.entries(activeLayers).filter(([,v]) => v).map(([k]) => k).join(',');
191 p.set('layers', active);
192 const url = `${window.location.pathname}?${p.toString()}`;
193 window.history.replaceState(null, '', url);
194 }, 1500);
195 }, [mapView, activeLayers]);
196
197 // Global Stats Fetch
198 useEffect(() => {
199 fetch('/api/stats')
200 .then(res => res.json())
201 .then(d => {
202 if (d.stats) setGlobalStats(d.stats);
203 })
204 .catch(console.error);
205 }, []);
206
207 // Keyboard shortcuts
208 useEffect(() => {
209 const handler = (e: KeyboardEvent) => {
210 if (['INPUT', 'TEXTAREA'].includes((e.target as Element)?.tagName)) return;
211 if (e.key === 'f' && !e.ctrlKey) {
212 if (document.fullscreenElement) document.exitFullscreen();
213 else document.documentElement.requestFullscreen();
214 setIsFullscreen(!!document.fullscreenElement);
215 }
216 if (e.key === 'l') setShowLayers(p => !p);
217 if (e.key === 'm') setShowMarkets(p => !p);
218 if (e.key === 'i') setShowIntel(p => !p);
219 if (e.key === 'r') setFlyToLocation({ lat: 20, lng: 0, ts: Date.now() });
220 if (e.key === 'g') setMapProjection(p => p === 'globe' ? 'mercator' : 'globe');
221 };
222 window.addEventListener('keydown', handler);
223 return () => window.removeEventListener('keydown', handler);
224 }, []);
225
226 // Mouse coords + reverse geocode (Zero-Render)
227 const handleMouseCoords = useCallback((coords: { lat: number; lng: number }) => {
228 mouseCoordsRef.current = coords;
229 if (coordsDisplayRef.current) {
230 coordsDisplayRef.current.innerText = `${coords.lat.toFixed(4)}, ${coords.lng.toFixed(4)}`;
231 }
232 if (geocodeTimer.current) clearTimeout(geocodeTimer.current);
233 geocodeTimer.current = setTimeout(async () => {
234 if (lastGeocodedPos.current) {
235 const d = Math.abs(coords.lat - lastGeocodedPos.current.lat) + Math.abs(coords.lng - lastGeocodedPos.current.lng);
236 if (d < 0.5) return; // increased threshold — fewer geocode calls
237 }
238 const gk = `${coords.lat.toFixed(1)},${coords.lng.toFixed(1)}`; // coarser grid = more cache hits
239 if (geocodeCache.current.has(gk)) { setLocationLabel(geocodeCache.current.get(gk)!); lastGeocodedPos.current = coords; return; }
240 try {
241 const res = await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${coords.lat}&lon=${coords.lng}&format=json&zoom=10&addressdetails=1`, { headers: { 'Accept-Language': 'en' } });
242 if (res.ok) {
243 const d = await res.json();
244 const a = d.address || {};
245 const label = [a.city||a.town||a.village||a.county, a.state||a.region, a.country].filter(Boolean).join(', ') || 'Unknown';
246 if (geocodeCache.current.size > 500) { const it = geocodeCache.current.keys(); for (let i=0;i<100;i++) { const k = it.next().value; if(k) geocodeCache.current.delete(k); }}
247 geocodeCache.current.set(gk, label);
248 setLocationLabel(label);
249 lastGeocodedPos.current = coords;
250 }
251 } catch (e) { console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e); }
252 }, 3000); // 3s debounce (was 1.5s)
253 }, []);
254
255 // Region dossier (right-click)
256 const handleRightClick = useCallback(async (coords: { lat: number; lng: number }) => {
257 setDossierLoading(true); setRegionDossier(null);
258 try {
259 const res = await fetch(`/api/region-dossier?lat=${coords.lat}&lng=${coords.lng}`);
260 if (res.ok) setRegionDossier(await res.json());
261 } catch (e) { console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e); } finally { setDossierLoading(false); }
262 }, []);
263
264 // Entity click handler (hoisted from JSX to comply with Rules of Hooks — Fixes #113)
265 const handleEntityClick = useCallback((entity: any) => {
266 if (entity?.type === 'cctv') setActiveCamera(entity);
267 if (entity?.type === 'live_news' && entity.url) {
268 setLiveFeedUrl(entity.url);
269 setLiveFeedName(entity.name);
270 setLiveFeedEmbedAllowed(entity.embed_allowed !== false);
271 }
272 }, []);
273
274 // ── SHARED FETCH UTILITY (Fixes #107 — single definition, not 3 copies) ──
275 const fetchEndpoint = useCallback(async (url: string, transform?: (d: any) => any, options?: RequestInit) => {
276 if (typeof document !== 'undefined' && document.hidden) return;
277 try {
278 const res = await fetch(url, options);
279 if (res.ok) {
280 const json = await res.json();
281 const d = transform ? transform(json) : json;
282 dataRef.current = { ...dataRef.current, ...d };
283 setDataVersion(v => v + 1);
284 setBackendStatus('connected');
285 }
286 } catch (e) {
287 console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e);
288 setBackendStatus('error');
289 }
290 }, []);
291
292 // ── PROGRESSIVE DATA LOADING (request-optimized) ──
293 useEffect(() => {
294 // Priority 1: Core feeds (always needed for panels)
295 fetchEndpoint('/api/earthquakes');
296 fetchEndpoint('/api/news');
297 const marketTimer = setTimeout(() => fetchEndpoint('/api/markets', d => ({ markets: d })), 800);
298
299 // Priority 2: Space Weather (needed for MarketsPanel)
300 const spaceTimer = setTimeout(async () => {
301 try {
302 const r = await fetch('/api/space-weather');
303 if (r.ok) setSpaceWeather(await r.json());
304 } catch (e) { console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e); }
305 }, 5000);
306
307 // Polling — OPTIMIZED intervals to minimize edge requests
308 const intervals = [
309 setInterval(() => fetchEndpoint('/api/earthquakes'), 900000), // 15 min (was 5)
310 setInterval(() => fetchEndpoint('/api/news'), 1800000), // 30 min (was 10)
311 setInterval(() => fetchEndpoint('/api/markets', d => ({ markets: d })), 900000), // 15 min (was 5)
312 ];
313 return () => {
314 clearTimeout(marketTimer);
315 clearTimeout(spaceTimer);
316 intervals.forEach(clearInterval);
317 };
318 }, [fetchEndpoint]);
319
320 // ── LAYER-AWARE DATA LOADING — only fetch when layer is toggled ON ──
321 const layerFetchedRef = useRef<Set<string>>(new Set());
322 useEffect(() => {
323
324 // Flights
325 if (activeLayers.flights || activeLayers.military || activeLayers.jets || activeLayers.private) {
326 if (!layerFetchedRef.current.has('flights')) {
327 fetchEndpoint('/api/flights');
328 layerFetchedRef.current.add('flights');
329 }
330 }
331 // Satellites
332 if (activeLayers.satellites && !layerFetchedRef.current.has('satellites')) {
333 fetchEndpoint('/api/satellites');
334 layerFetchedRef.current.add('satellites');
335 }
336 // Fires
337 if (activeLayers.fires && !layerFetchedRef.current.has('fires')) {
338 fetchEndpoint('/api/fires');
339 layerFetchedRef.current.add('fires');
340 }
341 // CCTV
342 if (activeLayers.cctv && !layerFetchedRef.current.has('cctv')) {
343 fetchEndpoint('/api/cctv?region=all');
344 layerFetchedRef.current.add('cctv');
345 }
346 // Maritime
347 if (activeLayers.maritime && !layerFetchedRef.current.has('maritime')) {
348 fetchEndpoint('/api/maritime', d => ({ maritime_ports: d.ports, maritime_chokepoints: d.chokepoints, maritime_ships: d.ships }));
349 layerFetchedRef.current.add('maritime');
350 }
351 // Balloons
352 if (activeLayers.balloons && !layerFetchedRef.current.has('balloons')) {
353 fetchEndpoint('/api/balloons', d => ({ balloons: d.balloons }));
354 layerFetchedRef.current.add('balloons');
355 }
356 // Radiation
357 if (activeLayers.radiation && !layerFetchedRef.current.has('radiation')) {
358 fetchEndpoint('/api/radiation', d => ({ radiation: d.stations }));
359 layerFetchedRef.current.add('radiation');
360 }
361 // Live News
362 if (activeLayers.live_news && !layerFetchedRef.current.has('live_news')) {
363 fetchEndpoint('/api/live-news', d => ({ live_feeds: d.feeds }));
364 layerFetchedRef.current.add('live_news');
365 }
366 // Weather
367 if (activeLayers.weather && !layerFetchedRef.current.has('weather')) {
368 fetchEndpoint('/api/weather', d => ({ weather_events: d.events }));
369 layerFetchedRef.current.add('weather');
370 }
371 // Infrastructure
372 if (activeLayers.infrastructure && !layerFetchedRef.current.has('infrastructure')) {
373 fetchEndpoint('/api/infrastructure', d => ({ infrastructure: d.infrastructure }));
374 layerFetchedRef.current.add('infrastructure');
375 }
376 // Global Incidents (GDELT)
377 if (activeLayers.global_incidents && !layerFetchedRef.current.has('gdelt')) {
378 fetchEndpoint('/api/gdelt', d => ({ gdelt: d.events }));
379 layerFetchedRef.current.add('gdelt');
380 }
381
382 }, [activeLayers]);
383
384 // ── LAYER-AWARE POLLING — only poll data for active layers ──
385 useEffect(() => {
386 const intervals: ReturnType<typeof setInterval>[] = [];
387 if (activeLayers.flights || activeLayers.military || activeLayers.jets || activeLayers.private) {
388 intervals.push(setInterval(() => fetchEndpoint('/api/flights'), 300000)); // 5 min (was 2 min)
389 }
390
391 if (activeLayers.balloons) {
392 intervals.push(setInterval(() => fetchEndpoint('/api/balloons', d => ({ balloons: d.balloons })), 300000)); // 5m
393 }
394 if (activeLayers.radiation) {
395 intervals.push(setInterval(() => fetchEndpoint('/api/radiation', d => ({ radiation: d.stations })), 300000)); // 5m
396 }
397 if (activeLayers.maritime) {
398 intervals.push(setInterval(() => fetchEndpoint('/api/maritime', d => ({ maritime_ports: d.ports, maritime_chokepoints: d.chokepoints, maritime_ships: d.ships })), 60000)); // 1m
399 }
400 // Fires: no polling needed (data changes very slowly, initial fetch is enough)
401 return () => intervals.forEach(clearInterval);
402 }, [activeLayers, fetchEndpoint]);
403
404 // CCTV: loaded once on layer toggle via layerFetchedRef (no viewport polling)
405
406 // Reactive layer fetch: handled by layerFetchedRef above (no duplicate)
407
408 const totalFlights = useMemo(() => (
409 (data.commercial_flights?.length||0)+(data.private_flights?.length||0)+(data.private_jets?.length||0)+(data.military_flights?.length||0)
410 ), [data.commercial_flights, data.private_flights, data.private_jets, data.military_flights]);
411
412
413 return (
414 <main className="fixed inset-0 w-full h-full bg-[var(--bg-void)] overflow-hidden">
415
416 {/* ── SPLASH ── */}
417 <AnimatePresence>
418 {showSplash && (
419 <motion.div
420 initial={{ opacity: 1 }}
421 exit={{ opacity: 0 }}
422 transition={{ duration: 0.8, ease: 'easeInOut' }}
423 className="absolute inset-0 z-[999] flex flex-col items-center justify-center overflow-hidden"
424 style={{ background: 'radial-gradient(ellipse at center, #0a0a14 0%, var(--bg-void) 70%)' }}
425 >
426 {/* ── Scanline CRT overlay ── */}
427 <div className="absolute inset-0 pointer-events-none z-[1]" style={{
428 backgroundImage: 'repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(212,175,55,0.015) 2px, rgba(212,175,55,0.015) 4px)',
429 animation: 'splashScanDrift 8s linear infinite',
430 }} />
431
432 {/* ── V4.2 badge — top-left ── */}
433 <motion.div
434 initial={{ opacity: 0 }}
435 animate={{ opacity: 0.6 }}
436 transition={{ delay: 0.8, duration: 0.5 }}
437 className="absolute top-6 left-6 z-[2] font-mono text-[10px] tracking-[0.3em] text-[var(--gold-primary)]"
438 >
439 V4.2
440 </motion.div>
441
442
443
444 {/* ── Geometric tactical logo ── */}
445 <div className="relative w-40 h-40 mb-8 flex items-center justify-center z-[2]">
446 {/* Outer ring — slow clockwise */}
447 <motion.div
448 initial={{ opacity: 0, scale: 0.6, rotate: 0 }}
449 animate={{ opacity: 1, scale: 1, rotate: 360 }}
450 transition={{ opacity: { duration: 0.6 }, scale: { duration: 0.8, ease: 'easeOut' }, rotate: { duration: 20, repeat: Infinity, ease: 'linear' } }}
451 className="absolute inset-0 rounded-full"
452 style={{ border: '1px solid rgba(212,175,55,0.2)' }}
453 >
454 <div className="absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 w-2 h-2 rounded-full" style={{ background: 'var(--gold-primary)', boxShadow: '0 0 12px var(--gold-primary), 0 0 24px rgba(212,175,55,0.3)' }} />
455 <div className="absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 w-1 h-1 rounded-full" style={{ background: 'rgba(212,175,55,0.5)', boxShadow: '0 0 6px rgba(212,175,55,0.3)' }} />
456 </motion.div>
457
458 {/* Middle ring — faster counter-clockwise */}
459 <motion.div
460 initial={{ opacity: 0, scale: 0.4, rotate: 0 }}
461 animate={{ opacity: 1, scale: 1, rotate: -360 }}
462 transition={{ opacity: { duration: 0.6, delay: 0.15 }, scale: { duration: 0.8, delay: 0.15, ease: 'easeOut' }, rotate: { duration: 12, repeat: Infinity, ease: 'linear' } }}
463 className="absolute rounded-full"
464 style={{ inset: '18px', border: '1px solid rgba(0,229,255,0.15)' }}
465 >
466 <div className="absolute top-1/2 right-0 translate-x-1/2 -translate-y-1/2 w-1.5 h-1.5 rounded-full" style={{ background: 'var(--cyan-primary)', boxShadow: '0 0 10px var(--cyan-primary), 0 0 20px rgba(0,229,255,0.2)' }} />
467 <div className="absolute bottom-0 left-1/4 translate-y-1/2 w-1 h-1 rounded-full" style={{ background: 'rgba(0,229,255,0.4)' }} />
468 </motion.div>
469
470 {/* Inner ring — fastest clockwise */}
471 <motion.div
472 initial={{ opacity: 0, scale: 0.2, rotate: 0 }}
473 animate={{ opacity: 1, scale: 1, rotate: 360 }}
474 transition={{ opacity: { duration: 0.6, delay: 0.3 }, scale: { duration: 0.8, delay: 0.3, ease: 'easeOut' }, rotate: { duration: 7, repeat: Infinity, ease: 'linear' } }}
475 className="absolute rounded-full"
476 style={{ inset: '40px', border: '1px solid rgba(212,175,55,0.25)' }}
477 >
478 <div className="absolute top-0 left-1/4 -translate-y-1/2 w-1.5 h-1.5 rounded-full" style={{ background: 'var(--gold-primary)', boxShadow: '0 0 8px var(--gold-primary)' }} />
479 </motion.div>
480
481 {/* Core circle + crosshair */}
482 <motion.div
483 initial={{ opacity: 0, scale: 0 }}
484 animate={{ opacity: 1, scale: 1 }}
485 transition={{ delay: 0.4, duration: 0.6, ease: [0.34, 1.56, 0.64, 1] }}
486 className="relative w-12 h-12 rounded-full flex items-center justify-center"
487 style={{ border: '2px solid var(--gold-primary)', boxShadow: '0 0 20px rgba(212,175,55,0.15), inset 0 0 20px rgba(212,175,55,0.05)' }}
488 >
489 <motion.div
490 animate={{ opacity: [0.3, 0.8, 0.3] }}
491 transition={{ duration: 2, repeat: Infinity, ease: 'easeInOut' }}
492 className="w-5 h-5 rounded-full"
493 style={{ background: 'radial-gradient(circle, rgba(212,175,55,0.4) 0%, rgba(212,175,55,0.05) 70%)' }}
494 />
495 {/* Crosshair lines */}
496 <div className="absolute w-[1px] h-full" style={{ background: 'linear-gradient(to bottom, transparent, rgba(212,175,55,0.3), transparent)' }} />
497 <div className="absolute w-full h-[1px]" style={{ background: 'linear-gradient(to right, transparent, rgba(212,175,55,0.3), transparent)' }} />
498 </motion.div>
499
500 {/* Faint pulsing radar sweep */}
501 <motion.div
502 initial={{ opacity: 0 }}
503 animate={{ opacity: [0, 0.15, 0], rotate: [0, 360] }}
504 transition={{ opacity: { duration: 3, repeat: Infinity }, rotate: { duration: 3, repeat: Infinity, ease: 'linear' }, delay: 0.6 }}
505 className="absolute inset-[10px] rounded-full"
506 style={{ background: 'conic-gradient(from 0deg, transparent 0deg, rgba(212,175,55,0.15) 40deg, transparent 80deg)' }}
507 />
508 </div>
509
510 {/* ── OSIRIS title — letter-by-letter stagger ── */}
511 <div className="flex items-center gap-[2px] mb-3 z-[2]">
512 {'OSIRIS'.split('').map((letter, i) => (
513 <motion.span
514 key={i}
515 initial={{ opacity: 0, y: 20, filter: 'blur(8px)' }}
516 animate={{ opacity: 1, y: 0, filter: 'blur(0px)' }}
517 transition={{ delay: 0.5 + i * 0.08, duration: 0.5, ease: 'easeOut' }}
518 className="text-4xl md:text-5xl font-bold tracking-[0.5em] font-mono"
519 style={{ color: 'var(--text-heading)', textShadow: '0 0 30px rgba(212,175,55,0.2)' }}
520 >
521 {letter}
522 </motion.span>
523 ))}
524 </div>
525
526 {/* ── Subtitle — typewriter reveal ── */}
527 <div className="overflow-hidden mb-8 z-[2]">
528 <motion.div
529 initial={{ width: 0 }}
530 animate={{ width: '100%' }}
531 transition={{ delay: 1.2, duration: 0.8, ease: 'easeInOut' }}
532 className="overflow-hidden whitespace-nowrap"
533 >
534 <p className="text-[10px] md:text-[11px] font-mono tracking-[0.5em] text-[var(--gold-primary)]" style={{ opacity: 0.8 }}>
535 GLOBAL INTELLIGENCE PLATFORM
536 </p>
537 </motion.div>
538 </div>
539
540 {/* ── Multi-stage progress bar ── */}
541 <div className="w-64 md:w-80 z-[2]">
542 {/* Thin progress track */}
543 <div className="relative w-full h-[2px] rounded-full overflow-hidden" style={{ background: 'rgba(212,175,55,0.1)' }}>
544 <motion.div
545 initial={{ width: '0%' }}
546 animate={{ width: ['0%', '25%', '50%', '78%', '100%'] }}
547 transition={{ duration: 2.2, delay: 0.5, times: [0, 0.25, 0.5, 0.75, 1], ease: 'easeInOut' }}
548 className="absolute inset-y-0 left-0 rounded-full"
549 style={{ background: 'linear-gradient(90deg, var(--gold-primary), var(--cyan-primary), var(--gold-primary))', boxShadow: '0 0 12px rgba(212,175,55,0.4)' }}
550 />
551 </div>
552
553 {/* Status messages — cycling */}
554 <div className="mt-3 h-4 flex items-center justify-center">
555 {[
556 { text: 'ESTABLISHING SECURE CONNECTION...', delay: 0.5 },
557 { text: 'INITIALIZING FEEDS...', delay: 1.1 },
558 { text: 'CALIBRATING SENSORS...', delay: 1.7 },
559 { text: 'SYSTEM READY', delay: 2.2 },
560 ].map((stage, i) => (
561 <motion.span
562 key={i}
563 initial={{ opacity: 0 }}
564 animate={{ opacity: [0, 1, 1, 0] }}
565 transition={{ delay: stage.delay, duration: 0.6, times: [0, 0.1, 0.7, 1] }}
566 className="absolute text-[9px] font-mono tracking-[0.25em]"
567 style={{ color: i === 3 ? 'var(--cyan-primary)' : 'var(--text-muted)' }}
568 >
569 {stage.text}
570 </motion.span>
571 ))}
572 </div>
573 </div>
574
575 {/* ── Decorative grid lines ── */}
576 <div className="absolute inset-0 pointer-events-none z-[0]" style={{ opacity: 0.03 }}>
577 <div className="absolute inset-0" style={{
578 backgroundImage: 'linear-gradient(rgba(212,175,55,0.5) 1px, transparent 1px), linear-gradient(90deg, rgba(212,175,55,0.5) 1px, transparent 1px)',
579 backgroundSize: '60px 60px',
580 }} />
581 </div>
582
583 {/* ── Corner frame accents ── */}
584 {[
585 { t: '10px', l: '10px', bw: '2px 0 0 2px' },
586 { t: '10px', r: '10px', bw: '2px 2px 0 0' },
587 { b: '10px', l: '10px', bw: '0 0 2px 2px' },
588 { b: '10px', r: '10px', bw: '0 2px 2px 0' },
589 ].map((pos, i) => (
590 <motion.div
591 key={i}
592 initial={{ opacity: 0 }}
593 animate={{ opacity: 0.3 }}
594 transition={{ delay: 0.8 + i * 0.1, duration: 0.5 }}
595 className="absolute w-8 h-8 z-[2]"
596 style={{ top: pos.t, bottom: pos.b, left: pos.l, right: pos.r, borderWidth: pos.bw, borderStyle: 'solid', borderColor: 'var(--gold-primary)' }}
597 />
598 ))}
599
600
601
602 {/* ── Inline keyframe for scanline drift ── */}
603 <style>{`
604 @keyframes splashScanDrift {
605 0% { background-position: 0 0; }
606 100% { background-position: 0 100vh; }
607 }
608 `}</style>
609 </motion.div>
610 )}
611 </AnimatePresence>
612
613
614
615 {/* ── MAP ── */}
616 <ErrorBoundary name="Map">
617 <OsirisMap
618 data={data}
619 activeLayers={activeLayers}
620 projection={mapProjection}
621 mapStyle={mapStyle === 'satellite' ? 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}' : 'dark'}
622 onEntityClick={handleEntityClick}
623 onMouseCoords={handleMouseCoords}
624 onRightClick={handleRightClick}
625 onViewStateChange={setMapView}
626 flyToLocation={flyToLocation}
627 sweepData={sweepData}
628 scanTargets={scanTargets}
629 />
630 </ErrorBoundary>
631
632
633 {/* ── MAP VIEW CONTROLS (3D/2D + SATELLITE TOGGLE) ── */}
634 <motion.div
635 initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ delay: 3.5 }}
636 className="absolute bottom-[75px] md:bottom-6 left-3 md:left-[315px] z-[200] flex items-center gap-2 pointer-events-none"
637 >
638 {/* 3D/2D Toggle */}
639 <button
640 onClick={() => setMapProjection(p => p === 'globe' ? 'mercator' : 'globe')}
641 className="glass-panel p-2.5 pointer-events-auto hover:border-[var(--gold-primary)]/40 transition-colors group relative"
642 title={mapProjection === 'globe' ? 'Switch to 2D Map' : 'Switch to 3D Globe'}
643 >
644 {mapProjection === 'globe' ? (
645 <MapPinned className="w-4 h-4 text-[var(--gold-primary)] group-hover:scale-110 transition-transform" />
646 ) : (
647 <Globe className="w-4 h-4 text-[var(--cyan-primary)] group-hover:scale-110 transition-transform" />
648 )}
649 <span className="absolute bottom-full mb-2 left-1/2 -translate-x-1/2 text-[9px] font-mono text-[var(--text-muted)] whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity glass-panel px-2 py-1 z-[300]">
650 {mapProjection === 'globe' ? '2D MAP' : '3D GLOBE'}
651 </span>
652 </button>
653
654 {/* Map Style Toggle */}
655 <button
656 onClick={() => setMapStyle(s => s === 'dark' ? 'satellite' : 'dark')}
657 className="glass-panel p-2.5 pointer-events-auto hover:border-[var(--gold-primary)]/40 transition-colors group relative"
658 title={mapStyle === 'dark' ? 'Satellite View' : 'Night View'}
659 >
660 {mapStyle === 'dark' ? (
661 <Satellite className="w-4 h-4 text-[var(--alert-green)] group-hover:scale-110 transition-transform" />
662 ) : (
663 <Moon className="w-4 h-4 text-[var(--cyan-primary)] group-hover:scale-110 transition-transform" />
664 )}
665 <span className="absolute bottom-full mb-2 left-1/2 -translate-x-1/2 text-[9px] font-mono text-[var(--text-muted)] whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity glass-panel px-2 py-1 z-[300]">
666 {mapStyle === 'dark' ? 'SATELLITE' : 'NIGHT MODE'}
667 </span>
668 </button>
669 </motion.div>
670
671 {/* ── HEADER ── */}
672 <motion.div initial={{ opacity: 0, y: -20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 1, delay: 2.5 }} className={`absolute top-3 left-3 md:top-5 md:left-5 z-[200] pointer-events-none flex items-center gap-2 md:gap-3`}>
673 <div className="w-7 h-7 md:w-9 md:h-9 flex items-center justify-center relative">
674 {/* Ambient glow ring — slow rotating */}
675 <div className="absolute inset-[-4px] md:inset-[-5px] rounded-full border border-[var(--gold-primary)]/20" style={{ animation: 'osiris-rotate 12s linear infinite' }}>
676 <div className="absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-1 rounded-full bg-[var(--gold-primary)] shadow-[0_0_6px_var(--gold-primary)]" />
677 </div>
678 <div className="absolute inset-[-8px] md:inset-[-10px] rounded-full border border-[var(--gold-primary)]/10" style={{ animation: 'osiris-rotate 20s linear infinite reverse' }}>
679 <div className="absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 w-0.5 h-0.5 rounded-full bg-[var(--gold-primary)]/60" />
680 </div>
681 <div className="w-5 h-5 md:w-7 md:h-7 rounded-full border-2 border-[var(--gold-primary)] flex items-center justify-center animate-glow-pulse">
682 <div className="w-2.5 h-2.5 md:w-3.5 md:h-3.5 rounded-full bg-[var(--gold-primary)]/30 border border-[var(--gold-primary)]/60" />
683 </div>
684 <div className="absolute w-[1px] h-full bg-[var(--gold-primary)]/30" />
685 <div className="absolute w-full h-[1px] bg-[var(--gold-primary)]/30" />
686 </div>
687 {/* Horizontal rule extending from logo */}
688 <div className="hidden md:block absolute top-1/2 left-[52px] w-[200px] h-[1px] bg-gradient-to-r from-[var(--gold-primary)]/40 via-[var(--gold-primary)]/15 to-transparent" />
689 <div className="flex flex-col">
690 <div className="flex items-center gap-2">
691 <h1 className="text-base md:text-xl font-bold tracking-[0.4em] md:tracking-[0.5em] text-[var(--text-heading)] font-mono">OSIRIS</h1>
692 <span className="hidden md:inline-flex items-center gap-1 px-1.5 py-[1px] rounded-sm border border-[var(--cyan-primary)]/40 bg-[var(--cyan-primary)]/10 text-[7px] font-mono font-bold tracking-[0.15em] text-[var(--cyan-primary)] uppercase" style={{ lineHeight: '1.4' }}>
693 <Globe className="w-2.5 h-2.5" />
694 OPEN SOURCE
695 </span>
696 </div>
697 <span className="text-[8px] md:text-[9px] text-[var(--gold-primary)] font-mono tracking-[0.2em] md:tracking-[0.3em] opacity-80">GLOBAL INTELLIGENCE COMMAND</span>
698 </div>
699 </motion.div>
700
701 {/* ── TOP-RIGHT STATUS (desktop) — C2 DISPLAY ── */}
702 <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 3 }} className="status-bar-desktop absolute top-3 right-3 md:top-4 md:right-5 z-[200] pointer-events-none flex items-center gap-1.5 md:gap-3 text-[9px] md:text-[10px] font-mono tracking-widest text-[var(--text-muted)]">
703
704 {/* Zulu Clock */}
705 <span className="hidden lg:inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm border border-[var(--border-primary)] bg-black/30">
706 <ZuluClock />
707 </span>
708
709 <span className="hidden lg:inline text-[var(--border-primary)]">│</span>
710
711 <span className="flex items-center gap-1">SYS: <span className={backendStatus === 'connected' ? 'text-[var(--alert-green)]' : 'text-[var(--alert-red)]'}>{backendStatus.toUpperCase()}</span></span>
712
713 {spaceWeather && <span className="hidden lg:inline">SOLAR: <span style={{ color: spaceWeather.storm_color, fontWeight: 700 }}>Kp{spaceWeather.kp_index}</span></span>}
714
715 {/* Active Data Feeds */}
716 <span className="hidden lg:inline-flex items-center gap-1">
717 <Wifi className="w-3 h-3 text-[var(--cyan-primary)]" />
718 <span className="text-[var(--cyan-primary)] font-bold">{Object.values(activeLayers).filter(Boolean).length}</span>
719 <span className="text-[var(--text-muted)]/60">FEEDS</span>
720 </span>
721
722 <UptimeClock />
723
724 <a href='https://ko-fi.com/M8D41ZYW4Z' target='_blank' className="pointer-events-auto hover:opacity-80 transition-opacity ml-1 flex items-center">
725 <span className="px-3 py-1 rounded-sm border border-[var(--gold-primary)]/40 bg-[var(--gold-primary)]/10 text-[var(--gold-primary)] text-[11px] font-bold tracking-[0.2em]">SUPPORT PROJECT</span>
726 </a>
727 </motion.div>
728
729 {/* ── MOBILE: Compact top status ── */}
730 {isMobile && (
731 <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 2.5 }} className="absolute top-3 right-3 z-[200] pointer-events-auto flex items-center gap-2">
732 <a href='https://ko-fi.com/M8D41ZYW4Z' target='_blank' className="glass-panel px-2 py-1 flex items-center gap-1.5 text-[7px] font-mono tracking-widest hover:opacity-80 transition-opacity border-[var(--gold-primary)]/40 bg-[var(--gold-primary)]/10">
733 <div className="w-1 h-1 rounded-full bg-[var(--gold-primary)] animate-osiris-pulse" />
734 <span className="text-[var(--gold-primary)] font-bold">SUPPORT PROJECT</span>
735 </a>
736 </motion.div>
737 )}
738
739
740
741 {/* ── LEFT HUD (desktop): Layers + Stats + Markets + Intel ── */}
742 <div className="desktop-panel absolute left-5 top-20 bottom-24 w-72 flex flex-col gap-3 z-[200] pointer-events-none overflow-y-auto styled-scrollbar pr-1">
743 {showLayers && (
744 <>
745 <LayerPanel data={data} activeLayers={activeLayers} setActiveLayers={setActiveLayers} />
746 <motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.5 }} className="glass-panel px-3 py-2.5 pointer-events-auto">
747 <div className="grid grid-cols-5 gap-2 text-center">
748 <div><div className="hud-label">AIRCRAFT</div><div className="hud-value text-[10px] animate-data-pulse">{globalStats ? globalStats.flights.toLocaleString() : '0'}</div></div>
749 <div><div className="hud-label">SATS</div><div className="hud-value text-[10px]">{globalStats ? globalStats.sats.toLocaleString() : '0'}</div></div>
750 <div><div className="hud-label">CCTV</div><div className="hud-value text-[10px]">{globalStats ? globalStats.cctv.toLocaleString() : '0'}</div></div>
751 <div><div className="hud-label">WEATHER</div><div className="hud-value text-[10px]" style={{ color: '#E040FB' }}>{globalStats ? globalStats.weather.toLocaleString() : '0'}</div></div>
752 <div><div className="hud-label">NUCLEAR</div><div className="hud-value text-[10px]" style={{ color: '#76FF03' }}>{globalStats ? globalStats.nuclear.toLocaleString() : '0'}</div></div>
753 </div>
754 </motion.div>
755 <ViewPresets onNavigate={(lat, lng, zoom) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMapView(v => ({ ...v, zoom })); }} />
756 </>
757 )}
758 {showMarkets && <MarketsPanel data={data} spaceWeather={spaceWeather} />}
759 {showIntel && <IntelFeed data={data} onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })} />}
760 </div>
761
762 {/* ── RIGHT HUD (desktop): Search + RECON + Live Alerts ── */}
763 <div className="desktop-panel absolute right-5 top-20 bottom-24 w-80 flex flex-col gap-3 z-[200] pointer-events-auto overflow-y-auto styled-scrollbar pr-1">
764 <div className="flex gap-2 items-start">
765 <div className="flex-1"><SearchBar onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })} /></div>
766 <div className="relative"><SharePanel mapView={mapView} activeLayers={activeLayers} mouseCoords={null} /></div>
767 </div>
768 <OsintPanel onSweepVisualize={setSweepData} onScanGeolocate={(target, data) => {
769 setScanTargets(prev => {
770 const existing = prev.filter(t => t.id !== target);
771 return [{ id: target, timestamp: Date.now(), ...data }, ...existing].slice(0, 10);
772 });
773 setFlyToLocation({ lat: data.lat, lng: data.lng, ts: Date.now() });
774 }} />
775 <LiveAlerts data={data} onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })} onWatchFeed={(url, name) => { setLiveFeedUrl(url); setLiveFeedName(name); }} />
776 </div>
777
778 {/* ── LIVE FEED VIEWER OVERLAY ── */}
779 <AnimatePresence>
780 {liveFeedUrl && (
781 <motion.div
782 initial={{ opacity: 0, scale: 0.9 }}
783 animate={{ opacity: 1, scale: 1 }}
784 exit={{ opacity: 0, scale: 0.9 }}
785 className="fixed inset-0 z-[500] flex items-center justify-center bg-black/70 backdrop-blur-sm"
786 onClick={() => setLiveFeedUrl(null)}
787 >
788 <motion.div
789 initial={{ y: 20 }}
790 animate={{ y: 0 }}
791 className="w-[90vw] max-w-[900px] flex flex-col relative rounded-xl overflow-hidden border border-[var(--border-primary)] shadow-2xl bg-black"
792 onClick={e => e.stopPropagation()}
793 >
794 {/* Header */}
795 <div className="flex items-center justify-between px-4 py-2.5 bg-[#111] border-b border-[var(--border-primary)]">
796 <div className="flex items-center gap-2">
797 <div className="w-2 h-2 rounded-full bg-[#FF4081] animate-osiris-pulse" />
798 <span className="text-[12px] font-mono font-bold text-white tracking-wider">{liveFeedName}</span>
799 <span className="px-1.5 py-0.5 rounded bg-red-500/20 text-red-400 font-mono text-[9px] font-bold">LIVE STREAM</span>
800 {!liveFeedEmbedAllowed && (
801 <span className="px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 font-mono text-[9px]">EXTERNAL ONLY</span>
802 )}
803 </div>
804 <div className="flex items-center gap-3">
805 <a
806 href={
807 liveFeedUrl.includes('channel=')
808 ? `https://www.youtube.com/channel/${liveFeedUrl.split('channel=')[1].split('&')[0]}/live`
809 : liveFeedUrl.includes('/embed/')
810 ? `https://www.youtube.com/watch?v=${liveFeedUrl.split('/embed/')[1].split('?')[0]}`
811 : liveFeedUrl
812 }
813 target="_blank"
814 rel="noopener noreferrer"
815 className="flex items-center gap-1.5 px-2.5 py-1 rounded bg-[var(--border-primary)] hover:bg-[var(--gold-primary)] hover:text-black text-white transition-colors text-[11px] font-mono"
816 >
817 <span>Open in YouTube</span>
818 <ExternalLink className="w-3 h-3" />
819 </a>
820 <button onClick={() => setLiveFeedUrl(null)} className="text-white/70 hover:text-white transition-colors p-1">
821 <X className="w-5 h-5" />
822 </button>
823 </div>
824 </div>
825
826 {/* Body — iframe or external card */}
827 {liveFeedEmbedAllowed ? (
828 <div className="w-full aspect-video relative bg-black">
829 <iframe
830 src={liveFeedUrl}
831 className="w-full h-full absolute inset-0"
832 allow="autoplay; encrypted-media"
833 allowFullScreen
834 />
835 </div>
836 ) : (
837 <div className="w-full aspect-video flex items-center justify-center bg-black/95">
838 <div className="text-center px-8">
839 <div className="w-14 h-14 rounded-full bg-[#39FF14]/10 border border-[#39FF14]/20 flex items-center justify-center mx-auto mb-4">
840 <ExternalLink className="w-6 h-6 text-[#39FF14]" />
841 </div>
842 <p className="text-[13px] font-mono font-bold text-white tracking-widest mb-2">EMBED RESTRICTED</p>
843 <p className="text-[11px] font-mono text-white/50 mb-6 max-w-xs">
844 {liveFeedName} does not allow third-party embedding. Click below to open the live stream directly.
845 </p>
846 <a
847 href={
848 liveFeedUrl.includes('channel=')
849 ? `https://www.youtube.com/channel/${liveFeedUrl.split('channel=')[1].split('&')[0]}/live`
850 : liveFeedUrl.includes('/embed/')
851 ? `https://www.youtube.com/watch?v=${liveFeedUrl.split('/embed/')[1].split('?')[0]}`
852 : liveFeedUrl
853 }
854 target="_blank"
855 rel="noopener noreferrer"
856 className="inline-flex items-center gap-2 px-6 py-2.5 rounded border border-[#39FF14]/40 text-[#39FF14] font-mono text-[12px] hover:bg-[#39FF14]/10 transition-colors tracking-wider"
857 >
858 <ExternalLink className="w-4 h-4" />
859 OPEN LIVE STREAM
860 </a>
861 </div>
862 </div>
863 )}
864
865 {/* Footer — only show for embeddable feeds */}
866 {liveFeedEmbedAllowed && (
867 <div className="bg-[#111]/90 px-4 py-2.5 border-t border-[var(--border-primary)] flex items-center gap-2.5">
868 <AlertTriangle className="w-4 h-4 text-[var(--gold-primary)] shrink-0" />
869 <span className="text-[11px] font-mono text-white/70 leading-relaxed">
870 If you see &ldquo;Video unavailable&rdquo;, use <strong className="text-[var(--gold-primary)]">Open in YouTube</strong> above.
871 </span>
872 </div>
873 )}
874 </motion.div>
875 </motion.div>
876 )}
877 </AnimatePresence>
878
879 {/* ═══ MOBILE UI ═══ */}
880 {isMobile && (
881 <>
882 {/* Mobile Bottom Navigation */}
883 <div className="mobile-nav">
884 <div className="glass-panel mobile-nav-inner">
885 {[
886 { id: 'layers' as const, icon: Layers, label: 'LAYERS' },
887 { id: 'markets' as const, icon: BarChart3, label: 'MARKETS' },
888 { id: 'intel' as const, icon: Newspaper, label: 'INTEL' },
889 { id: 'recon' as const, icon: Radar, label: 'RECON' },
890 { id: 'search' as const, icon: Search, label: 'SEARCH' },
891 ].map(tab => (
892 <button key={tab.id} onClick={() => setMobilePanel(mobilePanel === tab.id ? null : tab.id)}
893 className={`mobile-nav-btn ${mobilePanel === tab.id ? 'active' : ''}`}>
894 <tab.icon className={`w-4 h-4 ${tab.id === 'recon' ? 'text-[var(--cyan-primary)]' : ''}`} />
895 <span className={tab.id === 'recon' ? 'text-[var(--cyan-primary)]' : ''}>{tab.label}</span>
896 </button>
897 ))}
898 </div>
899 </div>
900
901 {/* Mobile Drawer */}
902 <AnimatePresence>
903 {mobilePanel && (
904 <motion.div
905 initial={{ y: '100%' }} animate={{ y: 0 }} exit={{ y: '100%' }}
906 transition={{ type: 'spring', damping: 30, stiffness: 300 }}
907 className="fixed bottom-[52px] left-0 right-0 z-[400] glass-panel rounded-b-none overflow-y-auto styled-scrollbar"
908 style={{ maxHeight: 'min(55vh, calc(100dvh - 100px))', paddingBottom: 'env(safe-area-inset-bottom, 4px)' }}
909 >
910 <div className="mobile-drawer-handle" />
911 <div className="px-3 pb-3">
912 <div className="flex items-center justify-between mb-2">
913 <span className="hud-text text-[9px] text-[var(--text-primary)]">
914 {mobilePanel === 'layers' ? 'LAYERS & STATS' : mobilePanel === 'markets' ? 'MARKETS & INTEL' : mobilePanel === 'intel' ? 'INTEL FEED' : mobilePanel === 'recon' ? 'OSIRIS RECON' : 'SEARCH'}
915 </span>
916 <button onClick={() => setMobilePanel(null)} className="text-[var(--text-muted)] p-1"><X className="w-4 h-4" /></button>
917 </div>
918 {mobilePanel === 'layers' && (
919 <>
920 <div className="glass-panel-sm p-2 mb-2">
921 <div className="grid grid-cols-5 gap-1 text-center">
922 <div><div className="hud-label" style={{fontSize:'6px'}}>AIR</div><div className="hud-value text-[9px]">{totalFlights.toLocaleString()}</div></div>
923 <div><div className="hud-label" style={{fontSize:'6px'}}>SAT</div><div className="hud-value text-[9px]">{(data.satellites?.length||0)}</div></div>
924 <div><div className="hud-label" style={{fontSize:'6px'}}>CAM</div><div className="hud-value text-[9px]">{(data.cameras?.length||0)}</div></div>
925 <div><div className="hud-label" style={{fontSize:'6px'}}>WX</div><div className="hud-value text-[9px]" style={{color:'#E040FB'}}>{(data.weather_events?.length||0)}</div></div>
926 <div><div className="hud-label" style={{fontSize:'6px'}}>NUC</div><div className="hud-value text-[9px]" style={{color:'#76FF03'}}>{(data.infrastructure?.length||0)}</div></div>
927 </div>
928 </div>
929 <LayerPanel data={data} activeLayers={activeLayers} setActiveLayers={setActiveLayers} />
930 <div className="mt-2">
931 <ViewPresets onNavigate={(lat, lng, zoom) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMapView(v => ({ ...v, zoom })); setMobilePanel(null); }} />
932 </div>
933 </>
934 )}
935 {mobilePanel === 'markets' && <MarketsPanel data={data} spaceWeather={spaceWeather} />}
936 {mobilePanel === 'intel' && <IntelFeed data={data} onLocate={(lat, lng) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMobilePanel(null); }} />}
937 {mobilePanel === 'search' && (
938 <div className="space-y-2">
939 <SearchBar onLocate={(lat, lng) => { setFlyToLocation({ lat, lng, ts: Date.now() }); setMobilePanel(null); }} />
940 <SharePanel mapView={mapView} activeLayers={activeLayers} mouseCoords={null} />
941 </div>
942 )}
943 {mobilePanel === 'recon' && (
944 <div className="space-y-2">
945 <OsintPanel isOpen={true} onClose={() => setMobilePanel(null)} isMobile={true} onSweepVisualize={setSweepData} />
946 </div>
947 )}
948 </div>
949 </motion.div>
950 )}
951 </AnimatePresence>
952 </>
953 )}
954
955 {/* ── BOTTOM CENTER (desktop) ── */}
956 {!isMobile && (
957 <motion.div initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ delay: 3, duration: 0.8 }} className="desktop-only absolute bottom-5 left-1/2 -translate-x-1/2 z-[200] pointer-events-auto">
958 <div className="glass-panel px-5 py-2.5 flex items-center gap-0 osiris-glow relative overflow-hidden" style={{ borderImage: 'linear-gradient(90deg, rgba(212,175,55,0.05), rgba(212,175,55,0.2), rgba(212,175,55,0.05)) 1', borderImageSlice: 1, borderWidth: '1px', borderStyle: 'solid' }}>
959
960 {/* Animated scan line sweeping across the bar */}
961 <div className="absolute inset-0 pointer-events-none overflow-hidden" aria-hidden="true">
962 <div className="absolute top-0 bottom-0 w-[60px] bg-gradient-to-r from-transparent via-[var(--gold-primary)]/[0.07] to-transparent" style={{ animation: 'hud-scanline 4s ease-in-out infinite' }} />
963 </div>
964
965 {/* COORDINATES */}
966 <div className="flex flex-col items-center min-w-[110px] px-3">
967 <div className="hud-label">COORDINATES</div>
968 <div ref={coordsDisplayRef} className="text-[10px] font-mono font-bold text-[var(--gold-primary)] tracking-wide tabular-nums">—</div>
969 </div>
970
971 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
972
973 {/* LOCATION */}
974 <div className="flex flex-col items-center min-w-[160px] max-w-[280px] px-3">
975 <div className="hud-label">LOCATION</div>
976 <div className="text-[9px] text-[var(--text-secondary)] font-mono truncate max-w-[280px]">{locationLabel || 'Hover over map...'}</div>
977 </div>
978
979 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
980
981 {/* ZOOM */}
982 <div className="flex flex-col items-center px-3">
983 <div className="hud-label">ZOOM</div>
984 <div className="text-[10px] font-mono font-bold text-[var(--gold-primary)] tabular-nums">{mapView.zoom.toFixed(1)}</div>
985 </div>
986
987 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
988
989 {/* ACTIVE LAYERS */}
990 <div className="flex flex-col items-center px-3 min-w-[60px]">
991 <div className="hud-label">ACTIVE LAYERS</div>
992 <div className="flex items-center gap-1">
993 <Layers className="w-3 h-3 text-[var(--gold-primary)]" />
994 <span className="text-[10px] font-mono font-bold text-[var(--gold-primary)] tabular-nums">{Object.values(activeLayers).filter(Boolean).length}</span>
995 </div>
996 </div>
997
998 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
999
1000 {/* DATA FEEDS */}
1001 <div className="flex flex-col items-center px-3 min-w-[60px]">
1002 <div className="hud-label">FEEDS</div>
1003 <div className="flex items-center gap-1">
1004 <Activity className="w-3 h-3 text-[var(--cyan-primary)]" />
1005 <span className="text-[10px] font-mono font-bold text-[var(--cyan-primary)] tabular-nums">{Object.values(activeLayers).filter(Boolean).length}</span>
1006 </div>
1007 </div>
1008
1009 <div className="w-px h-8 bg-gradient-to-b from-transparent via-[var(--border-primary)] to-transparent flex-shrink-0" />
1010
1011 {/* THROUGHPUT */}
1012 <div className="flex flex-col items-center px-3 min-w-[70px]">
1013 <div className="hud-label">THROUGHPUT</div>
1014 <div className="flex items-center gap-1">
1015 <Database className="w-3 h-3 text-[var(--alert-green)]" />
1016 <DataThroughput data={data} />
1017 </div>
1018 </div>
1019
1020 </div>
1021 </motion.div>
1022 )}
1023
1024 {/* ── Scale Bar (desktop) ── */}
1025 <div className="desktop-only absolute bottom-[4.5rem] left-[20rem] z-[201] pointer-events-none">
1026 <ScaleBar zoom={mapView.zoom} latitude={mapView.latitude} />
1027 </div>
1028
1029 {/* ── Region Dossier ── */}
1030 {(regionDossier || dossierLoading) && (
1031 <motion.div initial={{ opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }} className="absolute top-16 md:top-20 left-2 right-2 md:left-1/2 md:right-auto md:-translate-x-1/2 z-[300] md:w-[480px] max-h-[65vh] overflow-y-auto styled-scrollbar">
1032 <div className="glass-panel p-5 osiris-glow">
1033 <div className="flex items-center justify-between mb-3">
1034 <h2 className="text-sm font-mono font-bold text-[var(--gold-primary)] tracking-wider">REGION DOSSIER</h2>
1035 <button onClick={() => { setRegionDossier(null); setDossierLoading(false); }} className="text-[var(--text-muted)] hover:text-[var(--text-primary)] text-xs">✕</button>
1036 </div>
1037 {dossierLoading ? (
1038 <div className="text-center py-8">
1039 <div className="w-5 h-5 border-2 border-[var(--gold-primary)] border-t-transparent rounded-full animate-spin mx-auto mb-2" />
1040 <span className="text-[8px] font-mono text-[var(--text-muted)] tracking-widest">COMPILING INTEL...</span>
1041 </div>
1042 ) : regionDossier && (
1043 <div className="space-y-3">
1044 <div><div className="hud-label mb-0.5">LOCATION</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.location?.display_name}</div></div>
1045 {regionDossier.country && (
1046 <div className="grid grid-cols-2 gap-2">
1047 <div><div className="hud-label mb-0.5">COUNTRY</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.flag} {regionDossier.country.name}</div></div>
1048 <div><div className="hud-label mb-0.5">CAPITAL</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.capital}</div></div>
1049 <div><div className="hud-label mb-0.5">POPULATION</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.population?.toLocaleString()}</div></div>
1050 <div><div className="hud-label mb-0.5">REGION</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.subregion || regionDossier.country.region}</div></div>
1051 <div><div className="hud-label mb-0.5">LANGUAGES</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.languages?.join(', ')}</div></div>
1052 <div><div className="hud-label mb-0.5">AREA</div><div className="text-xs text-[var(--text-primary)]">{regionDossier.country.area?.toLocaleString()} km²</div></div>
1053 </div>
1054 )}
1055 {regionDossier.head_of_state && (<div><div className="hud-label mb-0.5">HEAD OF STATE</div><div className="text-xs text-[var(--gold-primary)]">{regionDossier.head_of_state.name}</div><div className="text-[8px] text-[var(--text-muted)]">{regionDossier.head_of_state.position}</div></div>)}
1056 {regionDossier.wikipedia && (<div><div className="hud-label mb-1">INTELLIGENCE BRIEF</div><div className="flex gap-3">{regionDossier.wikipedia.thumbnail && <img src={regionDossier.wikipedia.thumbnail} alt="" className="w-14 h-14 rounded object-cover flex-shrink-0" />}<p className="text-[8px] text-[var(--text-secondary)] leading-relaxed">{regionDossier.wikipedia.extract}</p></div></div>)}
1057 </div>
1058 )}
1059 </div>
1060 </motion.div>
1061 )}
1062
1063 {/* ── Camera Viewer ── */}
1064 <CameraViewer
1065 camera={activeCamera}
1066 onClose={() => setActiveCamera(null)}
1067 onLocate={(lat, lng) => setFlyToLocation({ lat, lng, ts: Date.now() })}
1068 />
1069
1070 {/* ── OVERLAYS ── */}
1071 <div className="vignette absolute inset-0 pointer-events-none z-[2]" />
1072 <div className="crt-scanlines absolute inset-0 pointer-events-none z-[3] opacity-[0.02]" />
1073 {/* Corner frames */}
1074 {['top-0 left-0','top-0 right-0','bottom-0 left-0','bottom-0 right-0'].map((pos, i) => (
1075 <div key={i} className={`absolute ${pos} w-16 h-16 pointer-events-none z-[1]`}>
1076 <div className={`absolute ${pos.includes('top') ? 'top-0' : 'bottom-0'} ${pos.includes('left') ? 'left-0' : 'right-0'} w-full h-[1px] bg-gradient-to-${pos.includes('left') ? 'r' : 'l'} from-[var(--gold-primary)]/30 to-transparent`} />
1077 <div className={`absolute ${pos.includes('top') ? 'top-0' : 'bottom-0'} ${pos.includes('left') ? 'left-0' : 'right-0'} w-[1px] h-full bg-gradient-to-${pos.includes('top') ? 'b' : 't'} from-[var(--gold-primary)]/30 to-transparent`} />
1078 </div>
1079 ))}
1080
1081 {/* Keyboard Shortcuts Overlay */}
1082 <KeyboardShortcuts />
1083
1084 {/* ── GLOBAL STATUS TICKER (bottom) ── */}
1085 <GlobalStatusBar />
1086
1087 {/* Shortcut hint */}
1088 <div className="desktop-only absolute bottom-[26px] right-5 z-[200] pointer-events-none text-[6px] font-mono text-[var(--text-muted)]/40 tracking-widest">
1089 [?] SHORTCUTS · [F] FULLSCREEN · [S] SHARE · [R] RESET VIEW
1090 </div>
1091
1092
1093 </main>
1094 );
1095}