/* dp-3d Core Layout — Base styles, CSS custom properties, HUD positioning */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Orbitron:wght@400;500;600;700;800;900&display=swap');

/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  /* Backgrounds */
  --bg: #050510;
  --surface: #0c0c1a;
  --surface-2: #14142a;
  --border: rgba(255, 255, 255, 0.06);

  /* Text */
  --text: #e0e0e8;
  --text-dim: rgba(255, 255, 255, 0.45);

  /* Accent */
  --accent: #E8820C;
  --accent-glow: rgba(232, 130, 12, 0.25);

  /* Palette */
  --green: #22c55e;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --pink: #f472b6;
  --cyan: #22d3ee;
  --red: #ef4444;
  --amber: #f59e0b;

  /* Spacing */
  --hud-offset: 16px;
  --hud-radius: 12px;
  --hud-blur: 16px;

  /* Typography */
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 600ms ease;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(96,165,250,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(167,139,250,0.025) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(232,130,12,0.02) 0%, transparent 40%),
    #050510;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Canvas — Full Viewport
   ============================================================ */
canvas#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ============================================================
   HUD Panel — Glass-Morphism Base
   ============================================================ */
.hud-panel {
  background: rgba(5, 5, 16, 0.75);
  backdrop-filter: blur(var(--hud-blur));
  -webkit-backdrop-filter: blur(var(--hud-blur));
  border: 1px solid var(--border);
  border-radius: var(--hud-radius);
  padding: 16px;
  color: var(--text);
  font-family: var(--font-body);
  z-index: 10;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.hud-panel:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

/* ============================================================
   HUD Positioning — Fixed Corners
   ============================================================ */
.hud-top-left {
  position: fixed;
  top: var(--hud-offset);
  left: var(--hud-offset);
}

.hud-top-right {
  position: fixed;
  top: var(--hud-offset);
  right: var(--hud-offset);
}

.hud-bottom-left {
  position: fixed;
  bottom: var(--hud-offset);
  left: var(--hud-offset);
}

.hud-bottom-right {
  position: fixed;
  bottom: var(--hud-offset);
  right: var(--hud-offset);
}

.hud-center {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ============================================================
   Loading Overlay
   ============================================================ */
.loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  transition: opacity 0.5s ease;
}

.loading.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text);
}

.loading-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.loading-bar-track {
  width: 240px;
  height: 2px;
  background: var(--surface-2);
  border-radius: 1px;
  overflow: hidden;
}

.loading-bar {
  height: 2px;
  width: 0%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ============================================================
   Fallback Hero — CSS-Only Background (GPU Tier 0 / No WebGL)
   ============================================================ */
.fallback-hero {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse at 50% 50%, rgba(232, 130, 12, 0.15) 0%, var(--bg) 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Legacy .ring support (pulse variant) */
.fallback-hero .ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 1px solid rgba(232, 130, 12, 0.1);
  transform: translate(-50%, -50%);
  animation: ring-pulse 8s ease-in-out infinite;
}

.fallback-hero .ring:nth-child(1) { width: 200px; height: 200px; animation-delay: 0s; }
.fallback-hero .ring:nth-child(2) { width: 350px; height: 350px; animation-delay: 1.5s; }
.fallback-hero .ring:nth-child(3) { width: 500px; height: 500px; animation-delay: 3s; }
.fallback-hero .ring:nth-child(4) { width: 650px; height: 650px; animation-delay: 4.5s; }

@keyframes ring-pulse {
  0%, 100% { opacity: 0.15; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.4; transform: translate(-50%, -50%) scale(1.05); }
}

/* Animated orbital rings — mimics the 3D orbital system */
.fallback-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: ring-orbit linear infinite;
}
.fallback-ring:nth-child(1) { width: 200px; height: 200px; animation-duration: 20s; border-color: rgba(245, 158, 11, 0.15); }
.fallback-ring:nth-child(2) { width: 320px; height: 320px; animation-duration: 28s; border-color: rgba(96, 165, 250, 0.12); animation-direction: reverse; }
.fallback-ring:nth-child(3) { width: 440px; height: 440px; animation-duration: 35s; border-color: rgba(167, 139, 250, 0.1); }
.fallback-ring:nth-child(4) { width: 560px; height: 560px; animation-duration: 42s; border-color: rgba(34, 211, 238, 0.08); animation-direction: reverse; }
.fallback-ring:nth-child(5) { width: 680px; height: 680px; animation-duration: 50s; border-color: rgba(34, 197, 94, 0.06); }

@keyframes ring-orbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Central glow dot */
.fallback-core {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-glow);
  animation: core-pulse 3s ease-in-out infinite;
  z-index: 2;
}

@keyframes core-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

/* Fallback stat cards */
.fallback-stats {
  display: flex;
  gap: 32px;
  margin-top: 48px;
  z-index: 2;
}

.fallback-stat {
  text-align: center;
}

.fallback-stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.fallback-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ============================================================
   Typography Utilities
   ============================================================ */
.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-blue { color: var(--blue); }
.text-purple { color: var(--purple); }
.text-pink { color: var(--pink); }
.text-cyan { color: var(--cyan); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

/* Tablet: <= 1024px */
@media (max-width: 1024px) {
  :root {
    --hud-offset: 12px;
  }

  .hud-panel {
    padding: 12px;
    border-radius: 10px;
  }

  .hud-top-left,
  .hud-top-right {
    font-size: 11px;
    padding: 10px;
  }

  .hud-bottom-left {
    max-width: 280px;
  }

  .hud-bottom-right {
    transform: scale(0.9);
    transform-origin: bottom right;
  }

  .loading-title {
    font-size: 20px;
    letter-spacing: 3px;
  }
}

/* Mobile: <= 768px */
@media (max-width: 768px) {
  :root {
    --hud-offset: 8px;
    --hud-blur: 12px;
  }

  html, body {
    font-size: 13px;
  }

  .hud-panel {
    padding: 10px;
    border-radius: 8px;
  }

  /* Hide all corner HUD panels on mobile — use FAB + sheet instead */
  .hud-top-left,
  .hud-top-right,
  .hud-bottom-left,
  .hud-bottom-right {
    display: none;
  }

  .loading-title {
    font-size: 16px;
    letter-spacing: 2px;
  }

  .loading-bar-track {
    width: 180px;
  }

  /* Fallback: hide outer rings on mobile */
  .fallback-hero .ring:nth-child(3),
  .fallback-hero .ring:nth-child(4) {
    display: none;
  }

  .fallback-ring:nth-child(4),
  .fallback-ring:nth-child(5) {
    display: none;
  }

  .fallback-stats {
    flex-direction: column;
    gap: 16px;
  }

  /* Mobile FAB — show on mobile only */
  .mobile-fab {
    display: flex;
  }
}

/* ============================================================
   Mobile FAB + Bottom Sheet
   ============================================================ */
.mobile-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #000;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 4px 16px var(--accent-glow);
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.mobile-fab:active {
  transform: scale(0.95);
}

.mobile-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 49;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-sheet.open {
  transform: translateY(0);
}

.mobile-sheet-handle {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 16px;
}

/* ============================================================
   Universe Canvas — Full Viewport (alternative ID)
   ============================================================ */
#universe-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ============================================================
   Touch Target Safety — 44px minimum for all interactive elements
   ============================================================ */
.hud-panel button,
.hud-panel a,
.view-mode-btn {
  min-height: 44px;
  min-width: 44px;
}
