/* ==========================================================================
   SAKURA CRIMSON SPEEDOMETER HUD — STYLESHEET
   Transparent HUD for OBS / FiveM NUI / RageMP / JGVRP Webview
   ========================================================================== */

:root {
  /* Cluster default dimensions (optimally balanced for 1920x1080 resolution) */
  --hud-width: 560px;
  --hud-right: 32px;
  --hud-bottom: 28px;

  /* Theme Palette */
  --sakura-accent: #f47292;
  --sakura-bright: #ff5c7c;
  --sakura-glow: rgba(244, 114, 146, 0.55);
  --hud-bg-dark: #12070a;
  --hud-border-wine: #4a1523;
  --hud-text-white: #ffffff;
  --hud-text-muted: #d9d2d6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  background: transparent !important;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Optional preview background modes (for standalone browser testing) */
body.bg-checkerboard {
  background-color: #18181b !important;
  background-image: 
    linear-gradient(45deg, #27272a 25%, transparent 25%), 
    linear-gradient(-45deg, #27272a 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #27272a 75%), 
    linear-gradient(-45deg, transparent 75%, #27272a 75%) !important;
  background-size: 24px 24px !important;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0 !important;
}

body.bg-asphalt {
  background: 
    radial-gradient(ellipse at 50% 60%, rgba(45, 28, 32, 0.35) 0%, rgba(15, 12, 14, 0.88) 100%),
    repeating-linear-gradient(98deg, rgba(255,255,255,0.015) 0px, rgba(255,255,255,0.015) 2px, transparent 2px, transparent 9px),
    repeating-linear-gradient(8deg, rgba(0,0,0,0.22) 0px, rgba(0,0,0,0.22) 3px, rgba(42,38,40,0.25) 3px, rgba(42,38,40,0.25) 7px),
    linear-gradient(180deg, #231f21 0%, #312c2e 45%, #262123 100%) !important;
}

/* Lane lines for optional asphalt preview */
.asphalt-lane-lines {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
body.bg-asphalt .asphalt-lane-lines {
  display: block;
}

/* ==========================================================================
   SPEEDOMETER HUD CONTAINER & DRAGGING
   ========================================================================== */
#speedometer-hud {
  position: fixed;
  right: var(--hud-right);
  bottom: var(--hud-bottom);
  width: var(--hud-width);
  max-width: 96vw;
  z-index: 999;
  cursor: grab;
  touch-action: none;
  transform-origin: bottom right;
  pointer-events: auto;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.75));
  transition: filter 0.2s ease;
}

#speedometer-hud.is-dragging {
  cursor: grabbing !important;
}

#speedometer-hud.is-dragging * {
  cursor: grabbing !important;
}

#speedometerSvg {
  width: 100%;
  height: auto;
  overflow: visible;
  display: block;
}

/* ==========================================================================
   TYPOGRAPHY & DIAL LABELS
   ========================================================================== */
.dial-num {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  fill: #f5f5f7;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: -0.02em;
}

.dial-num-red {
  fill: #ff3b4e;
}

.dial-label {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  fill: #d6d1d4;
  text-anchor: middle;
  letter-spacing: 0.06em;
}

.digital-speed {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  fill: #ffffff;
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   INDICATOR LIGHTS & BLINKING
   ========================================================================== */
.indicator-lamp {
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.indicator-off {
  opacity: 0.12 !important;
  filter: none !important;
}

@keyframes blinkIndicator {
  0%, 48% {
    opacity: 1;
    filter: drop-shadow(0 0 6px #00ff44);
  }
  50%, 100% {
    opacity: 0.12;
    filter: none !important;
  }
}

.blinking-indicator {
  animation: blinkIndicator 0.72s infinite !important;
}

/* Clickable indicator zones */
.hud-clickable {
  cursor: pointer;
}

/* ==========================================================================
   MEDIA PLAYER TRANSPORT BUTTONS & MUSIC PULSE
   ========================================================================== */
.media-btn {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.media-btn:hover {
  transform: scale(1.14);
  filter: drop-shadow(0 0 6px rgba(255, 160, 185, 0.95));
}

.media-btn:active {
  transform: scale(0.95);
}

@keyframes musicPulse {
  0%, 100% {
    transform: scale(1) rotate(-3deg);
  }
  50% {
    transform: scale(1.08) rotate(2deg);
  }
}

.music-playing {
  transform-box: fill-box;
  transform-origin: center;
  animation: musicPulse 1.8s ease-in-out infinite;
}

/* ==========================================================================
   SIZE SLIDER POPUP & RESIZE CONTROLS
   Initially only the button is visible, clicking opens the slider
   ========================================================================== */
.hud-size-widget {
  position: absolute;
  top: -36px;
  right: 14px;
  display: flex;
  align-items: center;
  z-index: 1010;
}

.hud-gear-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(18, 7, 11, 0.88);
  border: 1px solid rgba(244, 114, 146, 0.45);
  color: #ffd4de;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 8px rgba(244, 114, 146, 0.25);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  padding: 0;
}

.hud-gear-btn:hover {
  background: rgba(38, 12, 22, 0.95);
  border-color: #ff5c7c;
  color: #ffffff;
  transform: rotate(45deg) scale(1.1);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 12px rgba(244, 114, 146, 0.5);
}

.hud-gear-btn:active {
  transform: rotate(45deg) scale(0.95);
}

.hud-gear-btn .gear-icon {
  width: 17px;
  height: 17px;
  stroke: currentColor;
}

/* Expandable Size Popover */
.size-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 285px;
  background: #14070c;
  border: 1.5px solid #4a1523;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75), 0 0 16px rgba(244, 114, 146, 0.3);
  color: #ffffff;
  z-index: 1020;
  font-family: 'Inter', sans-serif;
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.size-popover.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92) translateY(8px);
  display: none;
}

.size-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(244, 114, 146, 0.22);
}

.size-popover-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #ffd4de;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.size-popover-close {
  background: transparent;
  border: none;
  color: #cfa3b0;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.size-popover-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.size-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.size-slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  height: 5px;
  border-radius: 999px;
  outline: none;
}

.size-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #f47292;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(244, 114, 146, 0.85);
  transition: transform 0.15s;
}

.size-slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}

.size-val-badge {
  font-size: 11px;
  font-weight: 700;
  color: #f47292;
  background: rgba(244, 114, 146, 0.12);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(244, 114, 146, 0.3);
  min-width: 48px;
  text-align: center;
}

.size-popover-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.size-reset-btn {
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffd4de;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.size-reset-btn:hover {
  background: rgba(244, 114, 146, 0.22);
  border-color: rgba(244, 114, 146, 0.5);
  color: #ffffff;
}
