/* ==========================================================================
   apps/bmw-drive/style.css
   Кокпит-HUD тест-драйва BMW X3 по улицам центра Варны (aifaq.online)
   ========================================================================== */

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050814;
  position: relative;
}

/* Скрытый буфер предзагрузки тайлов Google Street View */
#streetview-preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 180px;
  opacity: 0.001;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Нижний слой: реальные панорамы Google Street View */
#streetview-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #050814;
  transition: opacity 0.18s ease, filter 0.18s ease;
}

#streetview-container.sv-loading-step {
  opacity: 0.92;
  filter: saturate(1.06) brightness(0.98);
}

#streetview-container.hidden-layer {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Прячем служебные подписи Google Street View, чтобы не перекрывать кокпит */
#streetview-container .gm-style-cc,
#streetview-container .gmnoprint,
#streetview-container a[href*="maps.google.com/maps"] {
  opacity: 0.25;
}

/* Верхний слой: 3D-кокпит BMW X3 (с прозрачным фоном в режиме Street View) */
#cockpit-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: grab;
  touch-action: none;
  background: transparent;
}

#cockpit-canvas:active {
  cursor: grabbing;
}

#cockpit-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: transparent;
}

/* Экран загрузки */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.94), rgba(5, 8, 20, 0.98));
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.05rem;
  transition: opacity 0.45s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-spinner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 4px solid rgba(56, 189, 248, 0.22);
  border-top-color: #38bdf8;
  border-right-color: #f59e0b;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.35);
  animation: bmwSpin 0.85s linear infinite;
}

@keyframes bmwSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   ВЕРХНИЕ ПАНЕЛИ HUD (чисто под .aifaq-navbar, pointer-events: none на слоях)
   ========================================================================== */
.hud-top-left,
.hud-top-right {
  position: fixed;
  top: 86px;
  z-index: 100;
  pointer-events: none;
}

.hud-top-left {
  left: 16px;
  width: 316px;
  max-width: calc(50vw - 24px);
}

.hud-top-right {
  right: 16px;
  width: 252px;
}

.hud-card {
  pointer-events: auto;
  background: rgba(10, 16, 33, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(56, 189, 248, 0.36);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 20px rgba(0, 212, 255, 0.14);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-card-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #7dd3fc;
}

.gps-live-badge {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #031525;
  background: linear-gradient(90deg, #00f5d4, #38bdf8);
  box-shadow: 0 0 10px rgba(0, 245, 212, 0.45);
}

.mode-toggle-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.6);
  background: rgba(14, 116, 144, 0.35);
  color: #e0f2fe;
  font-family: var(--font-family);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.mode-toggle-btn:hover {
  transform: translateY(-1px);
  border-color: #7dd3fc;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
}

.mode-toggle-btn.streetview-active {
  background: linear-gradient(90deg, #0284c7, #00f5d4);
  border-color: #a5f3fc;
  color: #031525;
  box-shadow: 0 0 14px rgba(0, 245, 212, 0.45);
}

.street-name-value {
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.25;
  color: #ffffff;
  text-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.hud-divider {
  height: 1px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.35), rgba(245, 158, 11, 0.15), transparent);
}

.destination-status-value {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
  color: #fde68a;
}

.engine-hint-toast {
  margin-top: 2px;
  padding: 8px 10px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fef3c7;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.14);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.engine-hint-toast.hidden {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.engine-hint-toast.success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(15, 23, 42, 0.9));
  border-color: rgba(74, 222, 128, 0.5);
  color: #dcfce7;
}

/* Мини-карта GPS */
.minimap-frame {
  align-self: center;
  padding: 4px;
  border-radius: 14px;
  background: rgba(4, 10, 24, 0.9);
  border: 1.5px solid rgba(56, 189, 248, 0.45);
  box-shadow: inset 0 0 16px rgba(0, 212, 255, 0.18);
  line-height: 0;
}

#minimap-canvas {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: 10px;
  background: #060d1f;
}

.gps-routes-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.gps-dest-btn {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(20, 31, 56, 0.85);
  color: #e2e8f0;
  font-family: var(--font-family);
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gps-dest-btn:hover {
  border-color: #38bdf8;
  background: rgba(14, 116, 144, 0.35);
  color: #ffffff;
  transform: translateY(-1px);
}

.gps-dest-btn.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.92), rgba(56, 189, 248, 0.88));
  border-color: #bae6fd;
  color: #031525;
  font-weight: 900;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.45);
}

/* ==========================================================================
   НИЖНИЙ КОКПИТ УПРАВЛЕНИЯ (pointer-events: none на обёртке!)
   ========================================================================== */
.cockpit-dock {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 6px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}

.cockpit-clusters-row {
  width: 100%;
  max-width: 1380px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.cockpit-cluster {
  pointer-events: auto;
  background: rgba(10, 16, 33, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 10px;
  padding: 4px 7px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.cluster-caption {
  display: none;
}

/* Левый блок: узкий и компактный руль и поворотники */
.cluster-steering {
  width: 175px;
  max-width: 175px;
  min-width: 150px;
}

.steering-btn-row,
.turn-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.cockpit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 7px;
  min-height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: linear-gradient(155deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.94));
  color: #f8fafc;
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  touch-action: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.cockpit-btn:hover {
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.28);
}

.cockpit-btn:active,
.cockpit-btn.active,
.cockpit-btn.pressed {
  transform: translateY(2px) scale(0.97);
  border-color: #38bdf8;
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #041326;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.55);
}

/* Анимация мигания поворотников */
.turn-btn.active,
.turn-btn.blinking {
  color: #fffbeb;
  border-color: #fbbf24;
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.92), rgba(245, 158, 11, 0.92));
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.65);
  animation: turnBlink 0.65s steps(2, start) infinite;
}

@keyframes turnBlink {
  0%,
  49% {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    border-color: #fde68a;
    color: #081226;
    box-shadow: 0 0 22px rgba(251, 191, 36, 0.85);
  }
  50%,
  100% {
    background: linear-gradient(155deg, rgba(30, 41, 59, 0.94), rgba(15, 23, 42, 0.96));
    border-color: rgba(251, 191, 36, 0.35);
    color: #fde68a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

/* Центральный блок: одна тонкая горизонтальная строка у нижней кромки */
.cluster-center {
  flex: 0 1 auto;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 8px;
}

.center-top-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.telemetry-readout {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(5, 10, 22, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.32);
}

.speed-value {
  font-size: 0.88rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #38bdf8;
  min-width: 56px;
}

.gear-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 5px;
  border-radius: 6px;
  background: linear-gradient(135deg, #ea580c, #f59e0b);
  border: 1px solid #fed7aa;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
}

.engine-start-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 9px;
  min-height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(252, 165, 165, 0.72);
  background: linear-gradient(135deg, #991b1b, #dc2626);
  color: #ffffff;
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.3px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.35);
  transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.engine-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.6);
}

.engine-start-btn:active {
  transform: translateY(1px) scale(0.98);
}

.engine-start-btn.running,
.engine-start-btn.active {
  background: linear-gradient(135deg, #15803d, #22c55e);
  border-color: #86efac;
  box-shadow: 0 0 22px rgba(34, 197, 94, 0.55);
}

.engine-status-led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 35% 35%, #fecaca, #ef4444 65%, #7f1d1d);
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 10px #ef4444, 0 0 18px rgba(239, 68, 68, 0.85);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.engine-start-btn.running .engine-status-led,
.engine-start-btn.active .engine-status-led,
.engine-status-led.running,
.engine-status-led.active,
.engine-status-led.on {
  background: radial-gradient(circle at 35% 35%, #dcfce7, #22c55e 65%, #14532d);
  box-shadow: 0 0 10px #4ade80, 0 0 20px rgba(34, 197, 94, 0.95);
}

.center-actions-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.city-switch-btn {
  flex: 0 1 auto;
  font-size: 11px;
  padding: 4px 8px;
}

.city-switch-btn.active-city {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.34), rgba(56, 189, 248, 0.2));
  border-color: #38bdf8;
  color: #e0f2fe;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.horn-btn {
  border-color: rgba(251, 191, 36, 0.45);
  color: #fef3c7;
}

.horn-btn:active,
.horn-btn.active,
.horn-btn.pressed {
  background: linear-gradient(135deg, #d97706, #fbbf24);
  border-color: #fde68a;
  color: #041326;
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.65);
}

/* Правый блок: компактные педали Тормоз и Газ */
.cluster-pedals {
  flex-direction: row;
  align-items: center;
  gap: 5px;
  min-width: auto;
}

.pedal-btn {
  flex: 0 0 62px;
  width: 62px;
  height: 54px;
  min-height: 54px;
  padding: 4px 5px;
  border-radius: 10px;
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.2px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  touch-action: none;
  transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.pedal-brake {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.06) 0px,
      rgba(255, 255, 255, 0.06) 4px,
      transparent 4px,
      transparent 10px
    ),
    linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  border: 2px solid #fca5a5;
  box-shadow: 0 6px 0 #450a0a, 0 10px 22px rgba(220, 38, 38, 0.35);
}

.pedal-brake:hover {
  filter: brightness(1.08);
}

.pedal-brake:active,
.pedal-brake.pressed,
.pedal-brake.active {
  transform: translateY(4px) scale(0.97);
  box-shadow: 0 2px 0 #450a0a, 0 0 22px rgba(239, 68, 68, 0.78);
  filter: brightness(1.16);
}

.pedal-gas {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.08) 0px,
      rgba(255, 255, 255, 0.08) 4px,
      transparent 4px,
      transparent 10px
    ),
    linear-gradient(180deg, #0ea5e9 0%, #0369a1 100%);
  border: 2px solid #7dd3fc;
  box-shadow: 0 6px 0 #082f49, 0 10px 22px rgba(14, 165, 233, 0.38);
}

.pedal-gas:hover {
  filter: brightness(1.08);
}

.pedal-gas:active,
.pedal-gas.pressed,
.pedal-gas.active {
  transform: translateY(4px) scale(0.97);
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.1) 0px,
      rgba(255, 255, 255, 0.1) 4px,
      transparent 4px,
      transparent 10px
    ),
    linear-gradient(180deg, #22c55e 0%, #15803d 100%);
  border-color: #86efac;
  box-shadow: 0 2px 0 #052e16, 0 0 24px rgba(34, 197, 94, 0.8);
}

/* Легенда клавиатуры */
.keyboard-legend {
  pointer-events: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(8, 13, 28, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.15px;
}

/* ==========================================================================
   АДАПТИВНОСТЬ (<= 900px: планшеты, узкие окна и смартфоны)
   ========================================================================== */
@media (max-width: 900px) {
  .hud-top-left,
  .hud-top-right {
    top: 124px;
  }

  .hud-top-left {
    left: 8px;
    width: calc(54vw - 12px);
    max-width: 260px;
  }

  .hud-top-right {
    right: 8px;
    width: 176px;
  }

  .hud-card {
    padding: 9px 10px;
    border-radius: 14px;
    gap: 6px;
  }

  .street-name-value {
    font-size: 0.92rem;
  }

  .destination-status-value,
  .engine-hint-toast {
    font-size: 0.74rem;
    padding: 6px 8px;
  }

  #minimap-canvas {
    width: 144px;
    height: 144px;
  }

  .gps-dest-btn {
    padding: 5px 7px;
    font-size: 0.7rem;
  }

  .cockpit-dock {
    left: 8px;
    right: 8px;
    bottom: 8px;
    gap: 4px;
  }

  .cockpit-clusters-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .cockpit-cluster {
    padding: 8px 9px;
    border-radius: 14px;
    gap: 5px;
  }

  .cluster-steering {
    flex: 1 1 220px;
    min-width: 0;
  }

  .cluster-center {
    flex: 1 1 280px;
    min-width: 0;
  }

  .cluster-pedals {
    flex: 1 1 200px;
    min-width: 0;
  }

  .cockpit-btn {
    min-height: 36px;
    padding: 7px 8px;
    font-size: 0.78rem;
  }

  .engine-start-btn {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .speed-value {
    font-size: 1.02rem;
    min-width: 68px;
  }

  .pedal-btn {
    min-height: 56px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .keyboard-legend {
    font-size: 0.66rem;
    padding: 4px 10px;
    line-height: 1.3;
  }
}

@media (max-width: 600px) {
  .hud-top-left,
  .hud-top-right {
    top: 136px;
  }

  .hud-top-right {
    width: 152px;
  }

  #minimap-canvas {
    width: 124px;
    height: 124px;
  }

  .keyboard-legend {
    display: none;
  }
}
