/*
  =====================================================================
  HAND RACING GAME — style.css
  =====================================================================
  Visual styling for the HUD overlay that sits on top of the 3D canvas.

  Key ideas:
    - The <canvas> is fullscreen (position: fixed, covers the viewport).
    - The #hud div is also fullscreen but has pointer-events: none so
      clicks pass through to the canvas.  Individual HUD children
      re-enable pointer-events where needed.
    - We use a dark, semi-transparent aesthetic with a neon-red accent
      (#ff3838) for a dramatic night-racing feel.
  =====================================================================
*/

/* -------------------- Reset & base -------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;                 /* no scrollbars */
  background: #000;                /* fallback while canvas loads */
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: #eee;
}

/* -------------------- 3D Canvas -------------------- */
#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* -------------------- HUD Layer -------------------- */
#hud {
  position: fixed;
  top: 0;  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;            /* let clicks pass through */
  z-index: 10;
  /* We use this as a flex/grid parent for layout */
}

/* Re-enable pointer events on interactive HUD elements */
#hud > * {
  pointer-events: auto;
}

/* ---- Accent colour variable ---- */
:root {
  --accent: #ff3838;
  --accent-dim: #ff383855;
  --hud-bg: rgba(10, 10, 15, 0.70);
  --hud-border: rgba(255, 56, 56, 0.25);
}

/* -------------------- Webcam Feed (top-left) -------------------- */
#webcamContainer {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 320px;
  height: 180px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 14px;
  overflow: hidden;
  backdrop-filter: blur(6px);
}

#webcamFeed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  opacity: 0.9;
}

#webcamLabel {
  position: absolute;
  bottom: 8px;
  left: 12px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
}

/* -------------------- Connection Status (top-left) -------------------- */
#connectionStatus {
  position: absolute;
  top: 210px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  letter-spacing: 0.5px;
  backdrop-filter: blur(6px);
}

#statusDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff3838;             /* red = disconnected by default */
  box-shadow: 0 0 6px #ff3838;
  transition: background 0.3s, box-shadow 0.3s;
}

#statusDot.connected {
  background: #00e676;
  box-shadow: 0 0 8px #00e676;
}

/* -------------------- Minimap (top-right) -------------------- */
#minimapContainer {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 200px;
  height: 200px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 14px;
  overflow: hidden;
  backdrop-filter: blur(6px);
}

#minimapCanvas {
  width: 100%;
  height: 100%;
}

/* -------------------- Lap Info (below minimap) -------------------- */
#lapInfo {
  position: absolute;
  top: 228px;
  right: 18px;
  width: 200px;
  text-align: center;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 14px;
  padding: 10px;
  font-size: 15px;
  letter-spacing: 1px;
  backdrop-filter: blur(6px);
}

#lapTime {
  font-size: 22px;
  font-weight: bold;
  color: var(--accent);
  margin-top: 2px;
}

/* -------------------- Dashboard (bottom center) -------------------- */
#dashboard {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 28px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 18px;
  padding: 16px 32px;
  backdrop-filter: blur(8px);
}

/* ---- Speedometer ---- */
#speedometer {
  text-align: center;
  min-width: 100px;
}

#speedValue {
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 20px var(--accent-dim);
}

#speedUnit {
  font-size: 13px;
  color: #999;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#revBadge {
  display: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  background: #4466ff;
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 4px;
}

/* ---- Throttle / Brake bars ---- */
#pedalBars {
  display: flex;
  gap: 12px;
}

.barGroup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.barLabel {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #888;
}

.barTrack {
  width: 22px;
  height: 80px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.barFill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: 6px;
  transition: height 0.08s ease;
}

.throttleFill {
  background: linear-gradient(to top, #00e676, #00c853);
  box-shadow: 0 0 8px #00e67644;
}

.brakeFill {
  background: linear-gradient(to top, #ff3838, #ff1744);
  box-shadow: 0 0 8px #ff383844;
}

/* ---- Steering indicator ---- */
#steeringIndicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#steeringLabel {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #888;
}

#steeringTrack {
  width: 120px;
  height: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  position: relative;
}

#steeringThumb {
  position: absolute;
  top: -2px;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  /* Centered by default (left: calc(50% - 8px)) — updated by JS */
  left: calc(50% - 8px);
  transition: left 0.06s ease;
}

/* ---- Gesture readout ---- */
#gestures {
  font-size: 12px;
  line-height: 1.7;
  color: #aaa;
  min-width: 90px;
}

.gesture span {
  color: var(--accent);
  font-weight: 600;
}

/* -------------------- Responsive tweaks -------------------- */
@media (max-width: 700px) {
  #dashboard {
    flex-wrap: wrap;
    gap: 14px;
    padding: 12px 18px;
  }
  #minimapContainer {
    width: 140px;
    height: 140px;
  }
  #minimapCanvas {
    width: 140px;
    height: 140px;
  }
}

/* -------------------- Menu / Pause / Pause Button -------------------- */
/* All menu and pause styles are injected by game.js via a <style> tag. */
/* Do NOT add menu styles here to avoid conflicts. */

/* -------------------- Hide HUD in menu -------------------- */
#hud.hidden { display: none; }
