/* ==========================================================================
   RUNQIX Runner Mode - Mobile-First Cockpit UI
   "Nie gesehen" (Never seen before) running experience
   ========================================================================== */

/* ==========================================================================
   CSS Variables for Runner Mode
   ========================================================================== */
:root {
  /* Pace colors */
  --pace-good: #00FF88;
  --pace-slow: #FFD700;
  --pace-fast: #FF0066;
  --pace-idle: #888888;

  /* Hero button */
  --touch-target-hero: 72px;
  --orbital-gap: 8px;

  /* Glass effects */
  --glass-blur-intense: blur(40px);
  --glass-bg-runner: rgba(10, 10, 15, 0.85);

  /* Runner cockpit */
  --cockpit-bg: rgba(10, 10, 15, 0.95);
  --cockpit-height: 200px;
}

/* ==========================================================================
   Orbital Bottom Navigation - Revolutionary Layout
   ========================================================================== */
.bottom-nav--orbital {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: 1fr;
  align-items: end;
  height: calc(var(--bottom-nav-height) + 24px); /* Extra space for floating button */
  padding-bottom: env(safe-area-inset-bottom);
}

/* The hero RUN button - floats above the nav */
.bottom-nav__run--hero {
  position: relative;
  width: var(--touch-target-hero);
  height: var(--touch-target-hero);
  margin-top: calc(-1 * var(--touch-target-hero) / 2 + 8px);
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 0 30px rgba(0, 255, 136, 0.4),
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  justify-self: center;
}

.bottom-nav__run--hero svg {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.bottom-nav__run--hero:active {
  transform: scale(0.95);
}

.bottom-nav__run--hero:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 0 50px rgba(0, 255, 136, 0.5),
    0 12px 40px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

/* Orbital pulse animation for active state */
.bottom-nav__run--hero::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--gradient-primary);
  opacity: 0;
  z-index: -1;
  animation: orbitalPulse 2s ease-in-out infinite;
}

.bottom-nav__run--hero:hover::before,
.bottom-nav__run--hero:focus::before {
  opacity: 1;
}

/* Stop state for hero button */
.bottom-nav__run--hero.bottom-nav__run--stop {
  background: var(--gradient-secondary);
  box-shadow:
    0 0 30px rgba(255, 0, 102, 0.4),
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

.bottom-nav__run--hero.bottom-nav__run--stop::before {
  background: var(--gradient-secondary);
}

/* ==========================================================================
   Runner Cockpit Mode - Glanceable During-Run UI
   ========================================================================== */
.runner-cockpit {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-bottom-sheet);
  background: var(--cockpit-bg);
  backdrop-filter: var(--glass-blur-intense);
  -webkit-backdrop-filter: var(--glass-blur-intense);
  border-top: 1px solid rgba(0, 255, 136, 0.3);
  padding: var(--spacing-lg) var(--spacing-md);
  padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.runner-cockpit--active {
  transform: translateY(0);
}

/* Time display - secondary */
.cockpit-time {
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: var(--spacing-sm);
  font-variant-numeric: tabular-nums;
}

/* Distance - HERO metric */
.cockpit-distance {
  text-align: center;
  font-size: 48px;
  font-weight: 900;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.3));
  line-height: 1;
  margin-bottom: var(--spacing-xs);
  font-variant-numeric: tabular-nums;
}

.cockpit-distance-unit {
  font-size: 24px;
  font-weight: 600;
  margin-left: 4px;
}

/* Pace indicator bar */
.cockpit-pace-bar {
  position: relative;
  width: 100%;
  max-width: 280px;
  height: 8px;
  margin: var(--spacing-md) auto;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-full);
  overflow: hidden;
}

.cockpit-pace-bar__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  background: var(--pace-good);
  border-radius: var(--border-radius-full);
  transition: width 0.5s ease-out, background-color 0.3s ease;
  box-shadow: 0 0 10px currentColor;
}

.cockpit-pace-bar__fill--slow {
  background: var(--pace-slow);
}

.cockpit-pace-bar__fill--fast {
  background: var(--pace-fast);
}

.cockpit-pace-bar__fill--idle {
  background: var(--pace-idle);
}

/* Status text */
.cockpit-status {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--pace-good);
  margin-bottom: var(--spacing-lg);
  transition: color 0.3s ease;
}

.cockpit-status--slow {
  color: var(--pace-slow);
}

.cockpit-status--fast {
  color: var(--pace-fast);
}

.cockpit-status--idle {
  color: var(--pace-idle);
}

/* Single big STOP button */
.cockpit-stop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
  padding: var(--spacing-md) var(--spacing-xl);
  background: rgba(255, 0, 102, 0.2);
  border: 2px solid var(--secondary);
  border-radius: var(--border-radius-lg);
  color: var(--secondary);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cockpit-stop-btn:active {
  transform: scale(0.98);
  background: var(--secondary);
  color: var(--dark);
}

.cockpit-stop-btn svg {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   Ready Panel - Swipe Up to Start
   ========================================================================== */
.ready-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-bottom-sheet);
  background: var(--cockpit-bg);
  backdrop-filter: var(--glass-blur-intense);
  -webkit-backdrop-filter: var(--glass-blur-intense);
  border-top-left-radius: var(--border-radius-xl);
  border-top-right-radius: var(--border-radius-xl);
  padding: var(--spacing-lg);
  padding-bottom: calc(var(--spacing-xl) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: pan-y;
}

.ready-panel--visible {
  transform: translateY(0);
}

.ready-panel__handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: var(--border-radius-full);
  margin: 0 auto var(--spacing-lg);
}

/* GPS accuracy indicator */
.ready-panel__gps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.gps-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--spacing-xs) var(--spacing-md);
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: var(--border-radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.gps-indicator__dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: gpsPulse 1.5s ease-in-out infinite;
}

.gps-indicator--weak {
  background: rgba(255, 215, 0, 0.1);
  border-color: rgba(255, 215, 0, 0.3);
  color: var(--gold);
}

.gps-indicator--weak .gps-indicator__dot {
  background: var(--gold);
}

.gps-indicator--poor {
  background: rgba(255, 0, 102, 0.1);
  border-color: rgba(255, 0, 102, 0.3);
  color: var(--secondary);
}

.gps-indicator--poor .gps-indicator__dot {
  background: var(--secondary);
}

/* Last run quick stats */
.ready-panel__last-run {
  display: flex;
  justify-content: space-around;
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-lg);
  margin-bottom: var(--spacing-lg);
}

.last-run-stat {
  text-align: center;
}

.last-run-stat__value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.last-run-stat__label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Swipe instruction */
.ready-panel__swipe {
  text-align: center;
}

.swipe-instruction {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.swipe-instruction__arrow {
  width: 24px;
  height: 24px;
  animation: swipeUp 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Post-Run Victory Screen
   ========================================================================== */
.victory-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-celebration);
  background: rgba(10, 10, 15, 0.98);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.victory-screen--visible {
  opacity: 1;
  visibility: visible;
}

.victory-title {
  font-size: 28px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-sm);
  animation: victoryPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.victory-xp {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: var(--spacing-xl);
  animation: xpCountUp 1s ease-out 0.3s both;
}

/* Victory stats row */
.victory-stats {
  display: flex;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.victory-stat {
  text-align: center;
  padding: var(--spacing-md) var(--spacing-lg);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-lg);
  animation: fadeInUp 0.5s ease-out both;
}

.victory-stat:nth-child(1) { animation-delay: 0.4s; }
.victory-stat:nth-child(2) { animation-delay: 0.5s; }
.victory-stat:nth-child(3) { animation-delay: 0.6s; }

.victory-stat__value {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 4px;
}

.victory-stat__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Victory actions */
.victory-actions {
  display: flex;
  gap: var(--spacing-md);
  animation: fadeInUp 0.5s ease-out 0.7s both;
}

.victory-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-xl);
  border-radius: var(--border-radius-lg);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.victory-btn--share {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.victory-btn--share:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.victory-btn--again {
  background: var(--gradient-primary);
  border: none;
  color: var(--dark);
}

.victory-btn--again:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 255, 136, 0.3);
}

/* ==========================================================================
   Hide Chrome During Runs
   ========================================================================== */
body.running-mode .app-header {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

body.running-mode .bottom-nav {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

body.running-mode .app-main {
  margin-top: 0;
  margin-bottom: 0;
}

body.running-mode #map-container {
  position: fixed;
  inset: 0;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes orbitalPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.15);
    opacity: 0;
  }
}

@keyframes gpsPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

@keyframes swipeUp {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

@keyframes victoryPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes xpCountUp {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes paceBarSlide {
  0% {
    width: 0;
  }
  100% {
    width: var(--pace-width, 50%);
  }
}

@keyframes conquestFlash {
  0% {
    background: rgba(0, 255, 136, 0);
  }
  50% {
    background: rgba(0, 255, 136, 0.3);
  }
  100% {
    background: rgba(0, 255, 136, 0);
  }
}

/* ==========================================================================
   Milestone Notifications
   ========================================================================== */
.milestone-toast {
  position: fixed;
  top: env(safe-area-inset-top, 20px);
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  z-index: var(--z-toast);
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--gradient-primary);
  border-radius: var(--border-radius-full);
  color: var(--dark);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 8px 32px rgba(0, 255, 136, 0.4);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.milestone-toast--visible {
  transform: translateX(-50%) translateY(20px);
}

.milestone-toast--distance {
  background: var(--gradient-primary);
}

.milestone-toast--time {
  background: linear-gradient(135deg, #00D4FF 0%, #7C3AED 100%);
}

.milestone-toast--territory {
  background: linear-gradient(135deg, #FFD700 0%, #FF6B35 100%);
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .cockpit-pace-bar__fill,
  .ready-panel,
  .runner-cockpit,
  .victory-screen,
  .milestone-toast {
    transition: none;
  }

  .bottom-nav__run--hero::before,
  .gps-indicator__dot,
  .swipe-instruction__arrow {
    animation: none;
  }
}
