/* VelocityGlasses — Design Tokens & Core Styling */

:root {
  /* Common System Colors */
  --bg-pure-black: #000000;
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1b1b26;
  --bg-card: rgba(27, 27, 38, 0.8);
  
  --text-primary: #ffffff;
  --text-secondary: #a0a5b5;
  --text-muted: #626575;
  
  --danger: #ff455b;
  --danger-glow: rgba(255, 69, 91, 0.35);
  --success: #00ff88;
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  /* Fonts */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Transition timings */
  --transition-fast: 0.1s ease;
  --transition-normal: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Theme Selection Custom Properties --- */
body.theme-cyan {
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.45);
  --accent-secondary: #00b4d8;
  --accent-dim: rgba(0, 212, 255, 0.15);
}

body.theme-green {
  --accent: #39ff14;
  --accent-glow: rgba(57, 255, 20, 0.45);
  --accent-secondary: #00cc6a;
  --accent-dim: rgba(57, 255, 20, 0.15);
}

body.theme-pink {
  --accent: #ff007f;
  --accent-glow: rgba(255, 0, 127, 0.45);
  --accent-secondary: #cc0066;
  --accent-dim: rgba(255, 0, 127, 0.15);
}

body.theme-amber {
  --accent: #ffaa00;
  --accent-glow: rgba(255, 170, 0, 0.45);
  --accent-secondary: #e69900;
  --accent-dim: rgba(255, 170, 0, 0.15);
}

/* --- Resets & Base Configuration --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--bg-pure-black); /* Crucial for glasses additive transparent rendering */
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* --- Screens Structure --- */
.screen {
  width: 600px;
  height: 600px;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  background: var(--bg-pure-black);
  animation: fadeIn 0.15s ease-out forwards;
}

.screen.hidden {
  display: none !important;
}

/* --- Header Layout --- */
.header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
  gap: 12px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex: 1;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.header-meta {
  font-size: 13px;
  font-weight: 600;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  transition: all var(--transition-normal);
}

.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 600;
  padding: 4px 12px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Content Panels --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scrollable-list-container {
  overflow-y: auto;
  padding-bottom: 24px;
}

.flex-center {
  align-items: center;
  justify-content: center;
  gap: 20px;
}

/* --- Accent Utilities --- */
.text-accent {
  color: var(--accent) !important;
}

/* --- D-Pad Differentiate Focus Rules --- */
.focusable {
  outline: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  border: 2px solid transparent;
  transform: scale(1);
  opacity: 0.85;
}

.focusable:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: scale(0.96); /* Scale-down design specification for pressed feedback preview */
  opacity: 1;
  background-color: var(--bg-tertiary);
}

/* --- Navigation Bars --- */
.nav-bar {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
  height: 88px; /* Button height target standard */
  align-items: center;
}

.nav-bar.scale-narrow {
  padding: 8px 12px;
  gap: 6px;
}

.nav-item {
  flex: 1;
  height: 60px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item.primary {
  background: var(--accent);
  color: var(--bg-pure-black);
}

.nav-item.primary:focus {
  background: var(--accent);
  color: var(--bg-pure-black);
}

.nav-item.danger {
  background: var(--danger);
  color: var(--text-primary);
}

.nav-item.danger:focus {
  box-shadow: 0 0 16px var(--danger-glow);
  border-color: var(--danger);
}

.hidden-btn {
  display: none !important;
}

/* --- HUD Home Visual Elements --- */
.hud-dashboard-preview {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 4px dashed var(--accent);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 30px var(--accent-dim);
  animation: pulseOuter 3s infinite ease-in-out;
}

.dashboard-preview-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.preview-metric {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.preview-value {
  font-size: 46px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
}

.preview-unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.gps-location-card {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gps-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.detail-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.detail-value {
  font-family: monospace;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Speedometer Gauge & Readout --- */
.speedometer-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  justify-content: center;
  padding-top: 10px;
}

.speedometer-container {
  width: 250px;
  height: 220px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.speed-gauge {
  width: 250px;
  height: 250px;
  transform: rotate(0deg);
}

.gauge-track {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  /* Arc circumference calculation: radius is 75, angle is 270 deg (3/4 of circle).
     Full circ = 2 * PI * 75 = 471.24.
     3/4 circ = 471.24 * 0.75 = 353.4. */
  stroke-dasharray: 353.4;
  stroke-dashoffset: 353.4; /* Dynamic based on speed */
  transition: stroke-dashoffset 0.15s cubic-bezier(0.35, 1, 0.4, 1), stroke var(--transition-normal);
  filter: drop-shadow(0 0 6px var(--accent));
}

.speed-readout {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.speed-num {
  font-size: 82px;
  font-weight: 900;
  color: #ffffff;
  line-height: 0.9;
  letter-spacing: -2px;
}

.speed-unit-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.simulation-tag {
  position: absolute;
  bottom: 0px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
  box-shadow: 0 0 8px var(--danger-glow);
}

/* --- Live Stats Grid --- */
.stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stat-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
}

.stat-unit {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* --- List Styling (Trip History) --- */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
}

.list-item {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  gap: 12px;
}

.list-item:focus {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.list-item-rank {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.list-item-title {
  font-weight: 600;
  color: #ffffff;
}

.list-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

.list-item-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
  border: 1px solid rgba(0, 212, 255, 0.2);
}

/* --- Settings Groups --- */
.settings-container {
  gap: 16px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-row {
  min-height: 72px;
}

.setting-icon {
  font-size: 20px;
  color: var(--accent);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.setting-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.setting-title {
  font-weight: 600;
  color: #ffffff;
  font-size: 15px;
}

.setting-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--bg-tertiary);
}

.badge-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.text-danger-row {
  border-color: rgba(255, 69, 91, 0.2);
}

.text-danger-row:focus {
  border-color: var(--danger) !important;
  box-shadow: 0 0 16px var(--danger-glow) !important;
}

.text-danger-row .setting-icon {
  color: var(--danger);
}

/* --- Toast Messaging --- */
.toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  border: 1.5px solid var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 30px;
  z-index: 100;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 12px var(--accent-glow);
  animation: slideDownIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.hidden {
  display: none !important;
}

/* --- Empty States --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideDownIn {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes pulseOuter {
  0% { box-shadow: inset 0 0 30px var(--accent-dim), 0 0 0px var(--accent-glow); }
  50% { box-shadow: inset 0 0 40px var(--accent-dim), 0 0 10px var(--accent-glow); }
  100% { box-shadow: inset 0 0 30px var(--accent-dim), 0 0 0px var(--accent-glow); }
}
