/* TrackMySpeed - Mobile-First Responsive CSS */

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: rgba(0, 212, 255, 0.3);
}

html {
  font-size: 16px; /* Base font size */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography - Mobile First with Relative Units */
h1 {
  font-size: 2rem; /* 32px on mobile - More balanced */
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1rem 0;
  word-wrap: break-word;
  text-align: center;
}

h2 {
  font-size: 1.25rem; /* 20px on mobile */
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.75rem 0;
}

h3 {
  font-size: 1.125rem; /* 18px on mobile */
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.5rem 0;
}

/* Metric Numbers - Large and Readable with Better Contrast */
.metric-number {
  font-size: 1.875rem !important; /* 30px on mobile - slightly larger */
  font-weight: 700;
  line-height: 1.1;
  word-break: break-all;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Labels and Small Text - Better Readability */
.metric-label {
  font-size: 0.9375rem !important; /* 15px on mobile - larger for readability */
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9) !important;
}

.network-info-text {
  font-size: 0.875rem !important; /* 14px on mobile - larger */
  line-height: 1.5;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.9) !important;
}



/* Container and Layout */
.container {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem; /* 12px on mobile */
  margin: 0 auto;
}

.main-content {
  max-width: 100%;
  padding: 1rem; /* 16px on mobile */
}

/* Grid System - Mobile First */
.metrics-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.metric-card {
  flex: 1;
  min-height: 4rem;
  padding: 0.75rem;
  text-align: center;
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Enhanced Touch-Friendly Buttons */
.btn {
  min-height: 3rem; /* 48px minimum */
  min-width: 3rem;
  padding: 1rem 2rem;
  border-radius: 1rem;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  word-wrap: break-word;
  user-select: none;
}

.btn-primary {
  width: 100%; /* Full width on mobile */
  max-width: 22rem;
  margin: 1rem auto;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
  font-size: 1.125rem;
  font-weight: 600;
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}

.btn-primary:active {
  transform: translateY(0);
}



/* Tab Navigation - Mobile Optimized */
.tab-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem;
  border-radius: 1rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  min-height: 3rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: none;
  font-size: 0.9375rem; /* 15px */
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tab-btn.active {
  background: linear-gradient(135deg, #00D4FF 0%, #39FF14 100%);
  color: white;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* Vehicle Mode and Unit Buttons */
.mode-selector, .unit-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: 1rem;
}

.vehicle-mode, .unit-btn {
  min-height: 3rem;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  min-width: calc(50% - 0.25rem);
  justify-content: center;
}

.vehicle-mode.active, .unit-btn.active {
  background: linear-gradient(135deg, #00D4FF 0%, #39FF14 100%);
  color: white;
  border-color: currentColor;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

/* Speed Gauge Container - Perfect Centering */
.gauge-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.5rem auto;
  position: relative;
  width: 100%;
  padding: 1rem 0;
}

.speed-gauge {
  width: 10rem; /* 160px on mobile */
  height: 10rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.1) 0%, rgba(0, 0, 0, 0.3) 70%);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
}

/* Canvas Element Centering */
.speed-gauge canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100% !important;
  height: 100% !important;
  border-radius: 50%;
}

/* Speed Display Overlay - Perfect Center */
.speed-display-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  text-align: center;
}

/* Network Information Grid */
.network-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.network-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.network-info-item:last-child {
  border-bottom: none;
}

.network-info-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.network-info-value {
  font-size: 0.875rem;
  color: #00D4FF;
  font-weight: 600;
  word-break: break-all;
}

/* Speed Statistics */
.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

.stat-item {
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #39FF14;
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}



/* Glassmorphism Effects */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.glass-dark {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Neon Effects - Subtle for Mobile */
.neon-border {
  box-shadow: 0 0 5px currentColor, 0 0 10px currentColor, inset 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Subtle Neon Effects - Better Accessibility */
.neon-text {
  text-shadow: 
    0 0 3px currentColor, 
    0 0 6px rgba(0, 212, 255, 0.5),
    0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Enhanced title styling - More Refined */
.main-title {
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
  text-shadow: 
    0 0 8px rgba(0, 212, 255, 0.6),
    0 2px 4px rgba(0, 0, 0, 0.4);
}



/* Loading Overlay - Mobile Optimized */
#loadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

#loadingOverlay .loading-content {
  text-align: center;
  padding: 2rem;
}

#loadingOverlay i {
  font-size: 3rem;
  margin-bottom: 1rem;
}

#loadingOverlay p {
  font-size: 1.125rem;
  margin: 0;
}

/* Particle Background - Reduced for Mobile Performance */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 1px;
  height: 1px;
  background: #00D4FF;
  border-radius: 50%;
  opacity: 0.6;
  animation: float 8s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10%, 90% { opacity: 0.6; }
  50% { transform: translateY(-10px) rotate(180deg); opacity: 1; }
}

/* Tablet Breakpoint (481px - 768px) */
@media (min-width: 30.0625rem) {
  h1 {
    font-size: 2.5rem; /* 40px on tablets - Progressive scaling */
  }
  .container {
    padding: 1rem;
  }
  
  .main-content {
    padding: 1.5rem;
  }
  
  .tab-nav {
    flex-direction: row;
    justify-content: center;
  }
  
  .tab-btn {
    flex: 1;
    max-width: 12rem;
  }
  
  .metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  
  .network-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  
  .network-info-item {
    flex-direction: row;
    justify-content: space-between;
    border-bottom: none;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem;
    border-radius: 0.5rem;
  }
  
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
  
  /* Tablet Gauge Sizes */
  .speed-gauge {
    width: 12rem;
    height: 12rem;
  }
  
  .speed-gauge canvas {
    width: 12rem !important;
    height: 12rem !important;
  }
  
  .btn-primary {
    width: auto;
    min-width: 12rem;
  }
}

/* Desktop Breakpoint (769px+) */
@media (min-width: 48.0625rem) {
  html {
    font-size: 18px; /* Larger base font for desktop */
  }
  
  h1 {
    font-size: 3rem; /* 48px+ on desktop - More balanced */
  }
  
  .metric-number {
    font-size: 3rem !important; /* 48px+ on desktop */
  }
  
  .metric-label {
    font-size: 1rem !important; /* 16px+ on desktop */
  }
  
  .network-info-text {
    font-size: 0.9375rem !important; /* 15px+ on desktop */
  }
  
  .container {
    max-width: 75rem;
    padding: 2rem;
  }
  
  .main-content {
    padding: 2rem;
  }
  
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }
  
  /* Desktop Gauge Sizes */
  .speed-gauge {
    width: 15rem;
    height: 15rem;
  }
  
  .speed-gauge canvas {
    width: 15rem !important;
    height: 15rem !important;
  }
  
  .particle {
    width: 2px;
    height: 2px;
  }
}

/* Large Desktop (1024px+) */
@media (min-width: 64rem) {
  .container {
    max-width: 80rem;
  }
  
  /* Large Desktop Gauge Sizes */
  .speed-gauge {
    width: 18rem;
    height: 18rem;
  }
  
  .speed-gauge canvas {
    width: 18rem !important;
    height: 18rem !important;
  }
}

/* Ultra-wide Desktop (1440px+) */
@media (min-width: 90rem) {
  .container {
    max-width: 90rem;
  }
  
  h1 {
    font-size: 3.5rem; /* 56px on ultra-wide - More reasonable */
  }
}

/* Small Mobile Portrait (max 375px) */
@media (max-width: 23.4375rem) {
  html {
    font-size: 14px;
  }
  
  .container {
    padding: 0.5rem;
  }
  
  .main-content {
    padding: 0.75rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  /* Small Mobile Gauge Sizes */
  .speed-gauge {
    width: 8rem;
    height: 8rem;
  }
  
  .speed-gauge canvas {
    width: 8rem !important;
    height: 8rem !important;
  }
  
  .vehicle-mode, .unit-btn {
    min-width: 100%;
    margin-bottom: 0.25rem;
  }
  
  .mode-selector, .unit-selector {
    flex-direction: column;
  }
}

/* Performance and Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .particle {
    display: none;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .neon-border, .neon-text {
    text-rendering: optimizeLegibility;
  }
}

/* Focus States for Accessibility */
button:focus-visible {
  outline: 2px solid #00D4FF;
  outline-offset: 2px;
}



/* Enhanced Tooltips */
[title] {
  position: relative;
  cursor: help;
}

/* Better Loading States */
.loading-state {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.loading-state::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border: 2px solid transparent;
  border-top: 2px solid #00D4FF;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Improved Focus States */
button:focus-visible,
.tab-btn:focus-visible,
.vehicle-mode:focus-visible,
.unit-btn:focus-visible {
  outline: 3px solid #00D4FF;
  outline-offset: 2px;
}

/* Prevent horizontal scrolling */
body, html {
  max-width: 100%;
  overflow-x: hidden;
}

/* Ensure all interactive elements are touch-friendly */
button, .tab-btn, .vehicle-mode, .unit-btn {
  touch-action: manipulation;
  user-select: none;
}