/*  racetrack.css */

.racetrack {
  position: relative;
  width: 100%;
  font-family: 'Oxanium', system-ui, sans-serif;
  color: #e8eefc;
  line-height: 1.4;
}
.racetrack *,
.racetrack *::before,
.racetrack *::after {
  box-sizing: border-box;
  margin: 0;
}

/* SVG */
.racetrack svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* Track */
.racetrack .track         { fill: none; stroke: rgba(0,0,0,0.25); stroke-width: 18; stroke-linecap: round; stroke-linejoin: round }
.racetrack .track-center  { fill: none; stroke: rgba(255,255,255,0.18); stroke-width: 2;  stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 12 8 }

/* Dot */
.racetrack .dot      { fill: #7cf7ff; filter: url(#rt-dotGlow) }
.racetrack .dot-core { fill: #ffffff }

/* Trail layers */
.racetrack .tail-outer { fill: none; stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; opacity: 0.15 }
.racetrack .tail-mid   { fill: none; stroke-width: 7;  stroke-linecap: round; stroke-linejoin: round; opacity: 0.55 }
.racetrack .tail-inner { fill: none; stroke-width: 3;  stroke-linecap: round; stroke-linejoin: round; opacity: 0.9 }

/* Markers */
.racetrack .split-marker-ring { fill: none; stroke: rgba(255,255,255,0.5); stroke-width: 2 }
.racetrack .split-marker-dot  { fill: rgba(255,255,255,0.85) }

/* Speed lines */
.racetrack .speed-line { fill: none; stroke: rgba(124,247,255,0.12); stroke-width: 1; stroke-linecap: round; opacity: 0 }

/* ── Popup overlay layer ── */
.racetrack .rt-popup-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ── Individual popup wrapper ── */
.racetrack .rt-popup {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  perspective: 600px;
}

/* ── 3D card ── */
.racetrack .rt-popup-card {
  width: 200px;
  padding: 13px 16px 12px 20px;
  border-radius: 14px;
  background: rgba(8, 12, 24, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(255,255,255,0.08);
  transform: rotateX(12deg) rotateY(-4deg);
  transform-style: preserve-3d;
  transform-origin: left bottom;
  box-shadow:
    0 10px 40px rgba(0,0,0,0.55),
    0 2px 8px rgba(0,0,0,0.3),
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.07);
  position: relative;
  overflow: hidden;
}
.racetrack .rt-popup-card::after {
  content: '';
  position: absolute;
  top: 0; left: 4px; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}

/* Accent bar */
.racetrack .rt-popup-accent {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}

/* Reflection */
.racetrack .rt-popup-reflection {
  width: 200px;
  height: 14px;
  margin-top: -1px;
  border-radius: 0 0 14px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  transform: rotateX(-20deg) scaleY(0.5);
  transform-origin: top center;
  opacity: 0.4;
}

/* ── Popup content ── */
.racetrack .rt-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}
.racetrack .rt-sector {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.racetrack .rt-delta {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255,255,255,0.06);
}

.racetrack .rt-time-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}
.racetrack .rt-time {
  font-size: 28px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -1px;
  color: #fff;
  line-height: 1;
}
.racetrack .rt-time-unit {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  font-weight: 400;
}

.racetrack .rt-speed-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.racetrack .rt-speed-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: rt-speed-pulse 0.8s ease-in-out infinite alternate;
}
.racetrack .rt-speed-label {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
}
.racetrack .rt-speed-val {
  font-size: 15px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: rgba(255,255,255,0.88);
  margin-left: auto;
}
.racetrack .rt-speed-unit {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  margin-left: 2px;
}

@keyframes rt-speed-pulse {
  0%   { opacity: 0.4; transform: scale(0.8) }
  100% { opacity: 1;   transform: scale(1.1) }
}

/* ── Lap timer ── */
.racetrack .rt-lap-timer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  gap: 4px;
}
.racetrack .rt-lap-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(36px, 8vw, 155px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: -2px;
  line-height: 1;
  user-select: none;
}
.racetrack .rt-lap-ms {
  font-size: 0.55em;
  opacity: 0.7;
}
.racetrack .rt-lap-delta {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(14px, 3vw, 30px);
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1;
  user-select: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.racetrack .rt-lap-delta.rt-delta-pos { color: rgba(255, 107, 107, 0.5); }
.racetrack .rt-lap-delta.rt-delta-neg { color: rgba(107, 255, 124, 0.5); }
.racetrack .rt-lap-delta.rt-delta-even { color: rgba(255, 255, 255, 0.25); }

/* ── Mobile responsiveness ── */
@media (max-width: 640px) {
  .racetrack .rt-popup-card {
    width: 100px;
    padding: 6px 8px 6px 10px;
    border-radius: 8px;
  }
  .racetrack .rt-popup-reflection {
    width: 100px;
    height: 8px;
  }
  .racetrack .rt-popup-accent {
    width: 3px;
  }
  .racetrack .rt-time {
    font-size: 15px;
  }
  .racetrack .rt-time-unit {
    font-size: 8px;
  }
  .racetrack .rt-sector {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .racetrack .rt-delta {
    font-size: 8px;
    padding: 1px 4px;
    border-radius: 3px;
  }
  .racetrack .rt-speed-row {
    display: none;
  }
  .racetrack .rt-header {
    gap: 4px;
    margin-bottom: 3px;
  }
  .racetrack .rt-time-row {
    margin-bottom: 0;
    gap: 3px;
  }
}