/**
 * DICE Mobility - Spatial Glass & Mobile Design System
 * Hyper-Translucent Frosted Glass, Squircles, Dynamic Aurora & Living Motion (毛玻璃 / 大圆角 / 极简科技)
 */

:root {
  /* System Tint Colors */
  --ios-emerald: #00D084;
  --ios-emerald-light: rgba(0, 208, 132, 0.15);
  --ios-emerald-glow: rgba(0, 208, 132, 0.4);
  --ios-blue: #007AFF;
  --ios-blue-light: rgba(0, 122, 255, 0.15);
  --ios-orange: #FF9500;
  --ios-orange-light: rgba(255, 149, 0, 0.15);
  --ios-red: #FF3B30;
  --ios-red-light: rgba(255, 59, 48, 0.15);
  --ios-purple: #AF52DE;
  --ios-cyan: #06B6D4;

  /* Spatial Liquid Glass Tokens */
  --ios-bg-canvas: #EEF2F7;
  --ios-glass-bg: rgba(255, 255, 255, 0.62);
  --ios-glass-sheet-bg: rgba(255, 255, 255, 0.72);
  --ios-glass-card-bg: rgba(255, 255, 255, 0.58);
  --ios-glass-border: rgba(255, 255, 255, 0.85);
  --ios-glass-subtle-border: rgba(255, 255, 255, 0.65);
  --ios-specular-highlight: inset 0 1.5px 2px 0 rgba(255, 255, 255, 1), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.02);

  /* Typography Colors */
  --ios-text-primary: #0F172A;
  --ios-text-secondary: #475569;
  --ios-text-tertiary: #64748B;
  --ios-text-quaternary: #94A3B8;

  /* Squircles (Continuous Corner Curvature) */
  --squircle-xs: 12px;
  --squircle-sm: 18px;
  --squircle-md: 24px;
  --squircle-lg: 32px;
  --squircle-xl: 40px;
  --squircle-2xl: 48px;
  --squircle-full: 9999px;

  /* Spatial Shadows */
  --ios-shadow-subtle: 0 8px 24px -4px rgba(15, 23, 42, 0.04), 0 2px 6px 0 rgba(15, 23, 42, 0.02);
  --ios-shadow-card: 0 16px 40px -8px rgba(15, 23, 42, 0.07), 0 4px 14px -2px rgba(15, 23, 42, 0.03);
  --ios-shadow-floating: 0 30px 70px -15px rgba(15, 23, 42, 0.14), 0 10px 25px -5px rgba(15, 23, 42, 0.05);
  --ios-shadow-island: 0 18px 45px -8px rgba(0, 0, 0, 0.22), 0 0 1px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Plus Jakarta Sans", Roboto, sans-serif;
  background-color: var(--ios-bg-canvas);
  color: var(--ios-text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  letter-spacing: -0.014em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =======================================================
   1. DYNAMIC LIVING AURORA LIGHT SPHERES
   ======================================================= */
.ios-aurora-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.ios-aurora-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.65;
  will-change: transform;
}

.aurora-orb-emerald {
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(0, 208, 132, 0.55) 0%, rgba(0, 208, 132, 0.05) 65%, transparent 75%);
  top: -80px;
  left: 5%;
  animation: floatOrb1 22s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

.aurora-orb-cyan {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.5) 0%, rgba(0, 122, 255, 0.08) 65%, transparent 75%);
  top: 18%;
  right: 5%;
  animation: floatOrb2 26s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

.aurora-orb-purple {
  width: 580px;
  height: 580px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.45) 0%, rgba(168, 85, 247, 0.05) 65%, transparent 75%);
  bottom: 5%;
  left: 10%;
  animation: floatOrb3 24s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

.aurora-orb-amber {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.45) 0%, rgba(245, 158, 11, 0.05) 65%, transparent 75%);
  bottom: 12%;
  right: 12%;
  animation: floatOrb4 20s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

@keyframes floatOrb1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(140px, 90px) scale(1.18); }
  100% { transform: translate(-80px, 160px) scale(0.92); }
}
@keyframes floatOrb2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-160px, 120px) scale(1.22); }
  100% { transform: translate(80px, -70px) scale(0.88); }
}
@keyframes floatOrb3 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(120px, -140px) scale(1.12); }
  100% { transform: translate(-60px, -90px) scale(1.28); }
}
@keyframes floatOrb4 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-90px, -120px) scale(1.2); }
  100% { transform: translate(110px, 60px) scale(0.92); }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(142, 142, 147, 0.35);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(142, 142, 147, 0.6);
}

/* =======================================================
   2. HYPER-FROSTED LIQUID GLASS UTILITIES
   ======================================================= */

/* Floating Dynamic Capsule (Top Control Island) */
.ios-glass-capsule {
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(48px) saturate(230%);
  -webkit-backdrop-filter: blur(48px) saturate(230%);
  border: 1px solid var(--ios-glass-border);
  box-shadow: 
    var(--ios-shadow-floating), 
    var(--ios-specular-highlight),
    0 0 30px rgba(255, 255, 255, 0.6);
  border-radius: var(--squircle-full);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

/* Specular Shimmer Sweep Effect across Glass */
.ios-glass-capsule::after,
.ios-glass-card::after {
  content: '';
  position: absolute;
  top: -100%;
  left: -100%;
  width: 300%;
  height: 300%;
  background: linear-gradient(
    55deg,
    transparent 45%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 55%
  );
  transform: rotate(25deg);
  animation: glassSheenGlide 10s ease-in-out infinite;
  pointer-events: none;
}

@keyframes glassSheenGlide {
  0%, 75% { transform: rotate(25deg) translateY(-140%); }
  100% { transform: rotate(25deg) translateY(140%); }
}

/* High-Gloss Translucent Card (KPIs, Corridors, Telemetry) */
.ios-glass-card {
  background: var(--ios-glass-card-bg);
  backdrop-filter: blur(36px) saturate(210%);
  -webkit-backdrop-filter: blur(36px) saturate(210%);
  border: 1px solid var(--ios-glass-border);
  box-shadow: 
    var(--ios-shadow-card), 
    var(--ios-specular-highlight);
  border-radius: var(--squircle-lg);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.ios-glass-card:hover {
  transform: translateY(-4px) scale(1.012);
  border-color: rgba(255, 255, 255, 1);
  box-shadow: 
    0 24px 55px -10px rgba(15, 23, 42, 0.1),
    0 0 24px rgba(0, 208, 132, 0.16),
    var(--ios-specular-highlight);
}

/* Glass Bottom Sheet & Modals */
.ios-glass-sheet {
  background: var(--ios-glass-sheet-bg);
  backdrop-filter: blur(48px) saturate(230%);
  -webkit-backdrop-filter: blur(48px) saturate(230%);
  border-top: 1px solid rgba(255, 255, 255, 1);
  box-shadow: 0 -20px 50px -10px rgba(15, 23, 42, 0.12), inset 0 1.5px 2px 0 rgba(255, 255, 255, 1);
  border-radius: var(--squircle-2xl) var(--squircle-2xl) 0 0;
}

/* Native Grab Handle */
.ios-sheet-handle {
  width: 40px;
  height: 5px;
  background: rgba(142, 142, 147, 0.45);
  border-radius: 9999px;
  margin: 0 auto 12px auto;
  transition: all 0.2s ease;
}

/* Inset Grouped Container */
.ios-inset-group {
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border-radius: var(--squircle-md);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--ios-shadow-subtle), var(--ios-specular-highlight);
  overflow: hidden;
}

.ios-inset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  position: relative;
  transition: background-color 0.15s ease;
}
.ios-inset-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 56px;
  right: 0;
  height: 0.5px;
  background: rgba(226, 232, 240, 0.7);
}
.ios-inset-item:active {
  background: rgba(0, 0, 0, 0.04);
}

/* Segmented Control (Sliding Spring Pill) */
.ios-segmented-control {
  display: flex;
  align-items: center;
  padding: 3.5px;
  background: rgba(142, 142, 147, 0.16);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--squircle-full);
  position: relative;
  user-select: none;
  border: 0.5px solid rgba(255, 255, 255, 0.6);
}

.ios-segment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--squircle-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--ios-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
.ios-segment-btn:active {
  transform: scale(0.94);
}
.ios-segment-btn.active {
  color: var(--ios-text-primary);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 
    0 4px 14px rgba(0, 0, 0, 0.1), 
    0 1px 3px rgba(0, 0, 0, 0.05),
    inset 0 1px 1px #FFFFFF;
  font-weight: 700;
  transform: scale(1.02);
}

/* Apple Standard Toggle Switch (51x31) */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  cursor: pointer;
}
.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.ios-switch-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(229, 231, 235, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 9999px;
  transition: background-color 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}
.ios-switch-slider::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ios-switch input:checked + .ios-switch-slider {
  background-color: var(--ios-emerald);
}
.ios-switch input:checked + .ios-switch-slider::before {
  transform: translateX(20px);
}

/* Tactile Spring Buttons */
.ios-btn-primary {
  background: linear-gradient(135deg, #00D084 0%, #05B371 100%);
  color: #FFFFFF;
  font-weight: 700;
  border-radius: var(--squircle-md);
  box-shadow: 0 4px 18px var(--ios-emerald-glow), inset 0 1.5px 1.5px rgba(255, 255, 255, 0.45);
  border: none;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ios-btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px var(--ios-emerald-glow);
}
.ios-btn-primary:active {
  transform: scale(0.94);
}

.ios-btn-secondary {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--ios-text-primary);
  font-weight: 600;
  border-radius: var(--squircle-md);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04), inset 0 1px 1px #FFFFFF;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ios-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}
.ios-btn-secondary:active {
  transform: scale(0.94);
}

.ios-btn-danger {
  background: linear-gradient(135deg, #FF3B30 0%, #E0281D 100%);
  color: #FFFFFF;
  font-weight: 700;
  border-radius: var(--squircle-md);
  box-shadow: 0 4px 18px rgba(255, 59, 48, 0.35), inset 0 1.5px 1.5px rgba(255, 255, 255, 0.4);
  border: none;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ios-btn-danger:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(255, 59, 48, 0.45);
}
.ios-btn-danger:active {
  transform: scale(0.94);
}

/* Vehicle Tier Selection Card */
.tier-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--squircle-md);
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  cursor: pointer;
  transition: all 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tier-card:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 208, 132, 0.6);
  transform: translateY(-2px) scale(1.01);
  box-shadow: var(--ios-shadow-subtle);
}
.tier-card.selected {
  background: rgba(0, 208, 132, 0.12);
  border-color: var(--ios-emerald);
  box-shadow: 0 0 0 1px var(--ios-emerald), 0 8px 24px rgba(0, 208, 132, 0.25);
  transform: scale(1.015);
}

/* Map Containers */
.dice-map-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background: #EBF0F5;
}
.leaflet-tile {
  filter: contrast(1.03) saturate(1.1);
}

/* Map Car Marker */
.dice-car-marker-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.dice-car-marker {
  position: relative;
  transition: transform 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast Floating Pill (Positioned cleanly below top Dynamic Capsule) */
#toast-notification {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translate(-50%, -16px) scale(0.94);
  opacity: 0;
  z-index: 99999;
  pointer-events: none;
  transition: all 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#toast-notification.show {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Telemetry Pills */
.telemetry-pill {
  padding: 4px 10px;
  border-radius: var(--squircle-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Backward compatibility aliases */
.glass-panel {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(36px) saturate(210%);
  -webkit-backdrop-filter: blur(36px) saturate(210%);
  border: 1px solid var(--ios-glass-border);
  box-shadow: var(--ios-shadow-card), var(--ios-specular-highlight);
}
.glass-card {
  background: var(--ios-glass-card-bg);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border: 1px solid var(--ios-glass-subtle-border);
  box-shadow: var(--ios-shadow-subtle), var(--ios-specular-highlight);
}
.glass-sheet {
  background: var(--ios-glass-sheet-bg);
  backdrop-filter: blur(48px) saturate(230%);
  -webkit-backdrop-filter: blur(48px) saturate(230%);
  border-top: 1px solid rgba(255, 255, 255, 1);
  box-shadow: 0 -18px 50px -10px rgba(15, 23, 42, 0.12);
}
