/**
 * T&R Ihr Autohaus GmbH — Cockpit Telemetry HUD & Porsche Sound Control
 * ----------------------------------------------------------------------------
 * High-end motorsport instrumentation panel featuring:
 * - Floating glassmorphism chassis with T&R bronze-gold and carbon accents
 * - Analog circular tachometer with sweeping needle & digital readout
 * - Sequential LED shift lights (Racing Green -> Amber Gold -> Redline Strobe)
 * - Porsche Start/Stop button with pulsating status illumination
 * - Tactile drilled-aluminum rev pedal (click/touch/hold & spacebar support)
 * - Mute button and custom volume slider
 * - Mobile responsive bottom dock & collapsible launcher pill
 */

/* ==========================================================================
   1. Floating Cockpit HUD Panel Container
   ========================================================================== */
.cockpit-hud {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-hud, 200);
  width: 290px;
  background: rgba(18, 18, 18, 0.90);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(55, 170, 50, 0.25);
  border-radius: 20px;
  padding: 16px 18px 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75), 0 0 24px rgba(55, 170, 50, 0.10);
  color: var(--color-ink-light);
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.35s var(--ease-out), opacity 0.3s ease, visibility 0.35s ease;
  will-change: transform, opacity;
}

.cockpit-hud.is-collapsed {
  transform: translateY(30px) scale(0.92);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ==========================================================================
   2. HUD Header Bar
   ========================================================================== */
.hud-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 8px var(--color-accent);
  transition: background-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.cockpit-hud.is-running .hud-status-indicator {
  background: var(--color-brand-green);
  box-shadow: 0 0 10px var(--color-brand-green);
}

.hud-brand-text {
  display: flex;
  flex-direction: column;
}

.hud-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--color-ink-light);
  line-height: 1.1;
  text-transform: uppercase;
}

.hud-sub {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  line-height: 1.2;
}

.hud-top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hud-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ink-light-muted);
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}

.hud-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-ink-light);
  border-color: rgba(55, 170, 50, 0.4);
}

.hud-icon-btn.is-muted svg {
  opacity: 0.45;
}

.hud-icon-btn.is-muted::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 2px;
  background: var(--color-danger);
  transform: rotate(45deg);
}

/* ==========================================================================
   3. Sequential Shift Lights (5 LEDs)
   ========================================================================== */
.shift-lights-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.shift-led {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  transition: background-color 0.06s ease, box-shadow 0.06s ease;
}

/* LED Stages */
.shift-led[data-led="1"].is-lit,
.shift-led[data-led="2"].is-lit {
  background: var(--color-brand-green);
  box-shadow: 0 0 10px var(--color-brand-green), 0 0 4px #ffffff;
}

.shift-led[data-led="3"].is-lit,
.shift-led[data-led="4"].is-lit {
  background: #ffb300;
  box-shadow: 0 0 12px #ffb300, 0 0 4px #ffffff;
}

.shift-led[data-led="5"].is-lit {
  background: var(--color-danger);
  box-shadow: 0 0 14px var(--color-danger), 0 0 6px #ffffff;
}

/* Redline Limiter Strobe (All 5 LEDs flashing at 9,000 RPM) */
.shift-lights-bar.is-redlining .shift-led {
  animation: shift-strobe 0.08s infinite alternate !important;
}

@keyframes shift-strobe {
  0% {
    background: var(--color-danger);
    box-shadow: 0 0 16px var(--color-danger), 0 0 6px #ffffff;
  }
  100% {
    background: #4a0000;
    box-shadow: none;
  }
}

/* ==========================================================================
   4. Analog Circular Tachometer Dial
   ========================================================================== */
.tachometer-wrap {
  position: relative;
  width: 100%;
  max-width: 220px;
  height: 190px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tachometer-dial {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

.tacho-needle-group {
  transition: transform 0.04s linear;
  will-change: transform;
}

/* Central Digital Readout */
.tachometer-center-display {
  position: absolute;
  top: 58%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.digital-gear {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 0.05em;
  background: rgba(55, 170, 50, 0.12);
  border: 1px solid rgba(55, 170, 50, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
}

.digital-rpm-val {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  letter-spacing: -0.04em;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.25);
}

.digital-rpm-unit {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--color-ink-light-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 1px;
}

/* ==========================================================================
   5. Interactive Controls Row: Start/Stop Button & Rev Pedal
   ========================================================================== */
.hud-controls-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

/* Porsche Start / Stop Button with Pulsing Halo */
.engine-start-btn {
  position: relative;
  width: 86px;
  height: 64px;
  border-radius: 12px;
  background: linear-gradient(145deg, #2a2a2a, #161616);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  transition: transform var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.engine-start-btn:active {
  transform: scale(0.96);
}

/* Pulsing Outer Halo */
.engine-halo-ring {
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  pointer-events: none;
  transition: all var(--dur-base) ease;
}

/* OFF state: Amber gold gentle breath pulse */
.cockpit-hud.is-stopped .engine-halo-ring {
  border: 1.5px solid var(--color-accent);
  box-shadow: 0 0 10px rgba(55, 170, 50, 0.4);
  animation: pulse-amber 2.2s infinite ease-in-out;
}

/* RUNNING state: Racing Green steady/energetic glow */
.cockpit-hud.is-running .engine-halo-ring {
  border: 1.5px solid var(--color-brand-green);
  box-shadow: 0 0 14px rgba(55, 170, 50, 0.65);
  animation: pulse-green 1.8s infinite ease-in-out;
}

@keyframes pulse-amber {
  0%, 100% {
    box-shadow: 0 0 6px rgba(55, 170, 50, 0.35);
  }
  50% {
    box-shadow: 0 0 16px rgba(55, 170, 50, 0.7);
  }
}

@keyframes pulse-green {
  0%, 100% {
    box-shadow: 0 0 10px rgba(55, 170, 50, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(55, 170, 50, 0.85);
  }
}

.engine-btn-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  pointer-events: none;
}

.engine-btn-text {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--color-ink-light);
}

.engine-btn-sub {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  margin-top: 2px;
}

.cockpit-hud.is-running .engine-btn-sub {
  color: var(--color-brand-green);
}

/* Tactile Drilled-Aluminum Motorsport Gas Pedal */
.gas-pedal-btn {
  position: relative;
  height: 64px;
  background: linear-gradient(160deg, #2e2e2e 0%, #1e1e1e 60%, #141414 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.06s ease, box-shadow 0.06s ease, border-color 0.1s ease;
}

.gas-pedal-btn:hover {
  border-color: rgba(55, 170, 50, 0.4);
}

.gas-pedal-btn.is-pressed,
.gas-pedal-btn:active {
  transform: translateY(3px) scale(0.98);
  border-color: var(--color-brand-green);
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.8), 0 0 16px rgba(55, 170, 50, 0.45);
  background: linear-gradient(160deg, #222222 0%, #171717 100%);
}

.pedal-face {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
}

.pedal-grooves {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pedal-grooves span {
  display: block;
  width: 14px;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.gas-pedal-btn.is-pressed .pedal-grooves span {
  background: var(--color-brand-green);
  box-shadow: 0 0 6px var(--color-brand-green);
}

.pedal-copy {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.pedal-action {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #ffffff;
  line-height: 1.15;
}

.pedal-sub {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  margin-top: 2px;
}

/* ==========================================================================
   6. Sound Volume Control Strip
   ========================================================================= */
.hud-sound-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sound-label {
  font-family: var(--font-mono);
  font-size: 0.60rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-ink-light-muted);
}

.hud-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: background var(--dur-fast) ease;
}

.hud-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 6px rgba(55, 170, 50, 0.6);
  cursor: pointer;
  transition: transform var(--dur-fast) ease, background var(--dur-fast) ease;
}

.hud-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
  box-shadow: 0 0 6px rgba(55, 170, 50, 0.6);
  cursor: pointer;
}

.hud-slider:hover::-webkit-slider-thumb {
  transform: scale(1.2);
  background: var(--color-brand-green);
  box-shadow: 0 0 8px rgba(55, 170, 50, 0.8);
}

.sound-pct {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--color-ink-light-muted);
  width: 28px;
  text-align: right;
}

/* ==========================================================================
   7. Minimized Floating Launcher Pill
   ========================================================================== */
.hud-launcher-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-hud, 200);
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(55, 170, 50, 0.35);
  border-radius: 30px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 16px rgba(55, 170, 50, 0.15);
  cursor: pointer;
  outline: none;
  transition: transform 0.3s var(--ease-out), opacity 0.3s ease, border-color var(--dur-fast) ease;
}

.hud-launcher-pill:hover {
  border-color: var(--color-brand-green);
  transform: translateY(-2px);
}

.hud-launcher-pill.is-hidden {
  transform: translateY(30px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.launcher-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 8px var(--color-accent);
  animation: pulse-amber 2s infinite ease-in-out;
}

.hud-launcher-pill.is-running .launcher-dot {
  background: var(--color-brand-green);
  box-shadow: 0 0 8px var(--color-brand-green);
  animation: pulse-green 1.8s infinite ease-in-out;
}

.launcher-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffffff;
}

.launcher-rpm {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-accent);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   8. Mobile Viewport Docking (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .cockpit-hud {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    left: 14px;
    width: auto;
    max-width: 380px;
    margin: 0 auto;
    padding: 12px 14px 10px;
  }

  .tachometer-wrap {
    max-width: 190px;
    height: 165px;
    margin-bottom: 8px;
  }

  .hud-launcher-pill {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    right: 14px;
  }

  .gas-pedal-btn {
    height: 56px;
  }

  .engine-start-btn {
    height: 56px;
    width: 78px;
  }
}
