/* External Dependencies */

/* Google Fonts - BBH Bartle */
@import url('https://fonts.googleapis.com/css2?family=BBH+Bartle:wght@300;400;500;600;700&display=swap');

/* Bootstrap */
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css');

/* ============================================
   CSS Variables & Base Styles
   ============================================ */

:root {
  --bg: #05060a;
  --glass: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.14);
  --font: "BBH Bartle", system-ui, sans-serif;
  --neon-cyan: #00ffff;
  --neon-blue: #0080ff;
  --neon-purple: #8000ff;
  --glow: 0 0 20px rgba(0, 255, 255, 0.5);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: var(--font);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   Background Effects
   ============================================ */

/* Futuristic animated background particles */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(0, 255, 255, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(128, 0, 255, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 20%, rgba(0, 128, 255, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: pulseGlow 8s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Animated grid overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(0, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
  animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
  0% { transform: translate(0, 0); }
  100% { transform: translate(50px, 50px); }
}

/* ============================================
   Info Icon with Tooltip
   ============================================ */

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 10px;
  color: rgba(255, 255, 255, 0.6);
  cursor: help;
  position: relative;
  vertical-align: middle;
  transition: all 0.3s ease;
  flex-shrink: 0;
  overflow: visible;
  z-index: 99999; /* Ensure icon itself is on top layer */
}

.info-icon:hover {
  color: var(--neon-cyan);
  transform: scale(1.1);
}

.info-icon svg {
  width: 100%;
  height: 100%;
}

/* Tooltip */
.info-icon::before {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: rgba(5, 6, 10, 0.98);
  border: 2px solid rgba(0, 255, 255, 0.3);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 0.85rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.6;
  white-space: normal;
  width: 320px;
  max-width: calc(100vw - 40px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999999; /* Very high z-index to ensure it's always on top */
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(0, 255, 255, 0.2);
  text-align: left;
  backdrop-filter: blur(10px);
  /* Completely hide when not hovering - no space taken */
  display: none;
  /* Ensure it creates its own stacking context */
  isolation: isolate;
}

.info-icon::after {
  content: '';
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: rgba(0, 255, 255, 0.3);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000000; /* Even higher for the arrow */
  display: none;
}

.info-icon:hover::before,
.info-icon:hover::after {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.info-icon:hover::after {
  transform: translateX(-50%);
}

/* Adjust tooltip position for titles - position to the right side */
.tracker-title .info-icon::before,
.analysis-title .info-icon::before {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(-5px);
  top: calc(100% + 12px);
  display: none;
  z-index: 999999; /* Ensure it's on top */
}

.tracker-title .info-icon:hover::before,
.analysis-title .info-icon:hover::before {
  display: block;
  transform: translateX(0) translateY(0);
}

.tracker-title .info-icon::after,
.analysis-title .info-icon::after {
  left: auto;
  right: 12px;
  transform: translateX(0);
  top: calc(100% + 6px);
  display: none;
  z-index: 1000000; /* Ensure arrow is on top */
}

.tracker-title .info-icon:hover::after,
.analysis-title .info-icon:hover::after {
  display: block;
}

/* Control panel title - position below since it's in a sidebar */
.control-panel-title .info-icon::before {
  left: 0;
  right: auto;
  transform: translateX(0) translateY(-5px);
  top: calc(100% + 12px);
  width: 300px;
  display: none;
  z-index: 999999; /* Ensure it's on top */
}

.control-panel-title .info-icon:hover::before {
  display: block;
  transform: translateX(0) translateY(0);
}

.control-panel-title .info-icon::after {
  left: 12px;
  right: auto;
  transform: translateX(0);
  top: calc(100% + 6px);
  display: none;
  z-index: 1000000; /* Ensure arrow is on top */
}

.control-panel-title .info-icon:hover::after {
  display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .info-icon::before {
    width: calc(100vw - 40px);
    max-width: 280px;
    font-size: 0.8rem;
    padding: 12px 16px;
  }
  
  .tracker-title .info-icon::before,
  .analysis-title .info-icon::before {
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    top: calc(100% + 12px);
    display: none;
  }
  
  .tracker-title .info-icon:hover::before,
  .analysis-title .info-icon:hover::before {
    display: block;
    transform: translateX(-50%) translateY(0);
  }
  
  .tracker-title .info-icon::after,
  .analysis-title .info-icon::after {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    top: calc(100% + 6px);
    display: none;
  }
  
  .tracker-title .info-icon:hover::after,
  .analysis-title .info-icon:hover::after {
    display: block;
  }
  
  .control-panel-title .info-icon::before {
    left: 0;
    right: auto;
    width: calc(100vw - 40px);
    max-width: 280px;
    display: none;
  }
  
  .control-panel-title .info-icon:hover::before {
    display: block;
  }
  
  .control-panel-title .info-icon::after {
    left: 12px;
    right: auto;
    display: none;
  }
  
  .control-panel-title .info-icon:hover::after {
    display: block;
  }
}

/* ============================================
   Layout Components
   ============================================ */

#three-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.ui {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   Navigation Components
   ============================================ */

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
  background: rgba(5, 6, 10, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  z-index: 1000;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: absolute;
  right: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.actions.ready {
  opacity: 1 !important;
}

/* Hide actions on index.html until navigation check completes */
.index-page .actions,
body:has(main.hero) .actions {
  opacity: 0;
}

/* Show actions after navigation check completes */
.index-page .actions.ready,
body:has(main.hero) .actions.ready {
  opacity: 1;
}

/* Ensure actions are visible when navigation updates */
.actions .user-menu {
  opacity: 1 !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: white;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
  transition: all 0.3s ease;
  position: absolute;
  left: 20px;
}

.brand:hover {
  text-shadow: 0 0 20px var(--neon-cyan);
  transform: scale(1.05);
}

.dot {
  width: 10px;
  height: 10px;
  background: var(--neon-cyan);
  border-radius: 50%;
}

.nav {
  position: relative;
  z-index: 101;
}

.nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  margin: 0 16px;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: color 0.3s ease;
  position: relative;
  z-index: 102;
  pointer-events: auto;
  cursor: pointer;
}

.nav a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple));
  transition: width 0.3s ease;
}

.nav a:hover {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
}

.nav a:hover::after {
  width: 100%;
}

.nav a.active {
  color: white;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

.nav a.active::after {
  width: 100%;
  background: linear-gradient(90deg, white, rgba(255, 255, 255, 0.8));
}

/* ============================================
   Button & CTA Components
   ============================================ */

.cta {
  display: flex !important;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 48px 0 64px;
  width: 100%;
  max-width: 600px;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative;
  z-index: 10;
}

.cta button,
.cta .btn {
  padding: 24px 60px !important;
  font-weight: 600 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  font-size: 1.2rem !important;
  border-radius: 8px !important;
  transition: all 0.3s ease !important;
  border-width: 2px !important;
  min-width: 280px !important;
  visibility: visible !important;
  opacity: 1 !important;
  display: inline-block !important;
  position: relative !important;
  z-index: 10 !important;
  cursor: pointer !important;
}

.cta .btn-light,
.cta button.btn-light {
  background: white !important;
  color: var(--bg) !important;
  border-color: white !important;
  position: relative;
  overflow: hidden;
}

.cta .btn-light::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.cta .btn-light:hover::before {
  left: 100%;
}

.cta .btn-light:hover,
.cta button.btn-light:hover {
  background: rgba(255, 255, 255, 0.9) !important;
  border-color: var(--neon-cyan) !important;
  color: var(--bg) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.4) !important;
}

.cta .btn-outline-light,
.cta button.btn-outline-light {
  background: transparent !important;
  border-color: var(--neon-cyan) !important;
  color: var(--neon-cyan) !important;
  position: relative;
  overflow: hidden;
}

.cta .btn-outline-light::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.cta .btn-outline-light:hover::before {
  left: 100%;
}

.cta .btn-outline-light:hover,
.cta button.btn-outline-light:hover {
  background: rgba(0, 255, 255, 0.1) !important;
  border-color: var(--neon-cyan) !important;
  color: white !important;
  transform: translateY(-2px) !important;
  text-shadow: 0 0 10px var(--neon-cyan);
}

/* ============================================
   Utility Classes
   ============================================ */

.glass {
  background: rgba(255,255,255,0.08) !important;
  border-color: rgba(255,255,255,0.25) !important;
  color: white !important;
}

/* ============================================
   Stat Cards Component
   ============================================ */

.stats {
  display: flex !important;
  gap: 24px;
  margin-top: 40px;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
  visibility: visible !important;
  opacity: 1 !important;
}

.stats::before {
  content: '';
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.stat {
  padding: 24px 32px;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(0, 255, 255, 0.4);
  min-width: 200px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  visibility: visible !important;
  opacity: 1 !important;
  display: block !important;
}

.stat::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(0, 255, 255, 0.1) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat:hover::before {
  opacity: 1;
}

.stat:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(0, 255, 255, 0.6);
  transform: translateY(-4px);
}

.stat .num {
  position: relative;
  z-index: 1;
}

.stat:hover .num {
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.stat:hover .label {
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
}

.num {
  display: block;
  letter-spacing: 0.25em;
  opacity: 1;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.label {
  opacity: 0.7;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* ============================================
   Custom Scrollbar Styles
   ============================================ */

/* Custom Scrollbar for Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  border: 1px solid rgba(0, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(0, 255, 255, 0.4) 0%, rgba(0, 255, 255, 0.6) 100%);
  border-radius: 4px;
  border: 1px solid rgba(0, 255, 255, 0.3);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.3);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(0, 255, 255, 0.6) 0%, rgba(0, 255, 255, 0.8) 100%);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.5);
}

::-webkit-scrollbar-thumb:active {
  background: rgba(0, 255, 255, 0.8);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 255, 0.5) rgba(255, 255, 255, 0.05);
}