Elffuss BraidHub

kikocis/osiris public

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