/* =========================================================
   Car Zone — styles just for this page.
   Three "hill scenes" you scroll down through (off-road vehicles bob up
   and down over the bumps), a transition, then a race track at the
   bottom. All vehicle movement is driven by js/cars.js.
   ========================================================= */

/* ---------- Car brand/model selector ---------- */

.car-selector-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
}

.car-selector-heading {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.car-selector-intro {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0 0 1.25rem;
}

.car-brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.car-brand-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.4rem;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.car-brand-btn:hover {
  transform: translateY(-2px);
}

.car-brand-btn.selected {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 212, 0.15);
}

.car-brand-btn .swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.car-brand-btn .brand-name {
  font-size: 0.65rem;
  text-align: center;
  line-height: 1.25;
}

.car-detail-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.car-detail-art {
  max-width: 320px;
  margin: 0 auto 0.75rem;
}

.car-detail-art svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.45));
}

.car-detail-name {
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 0.9rem;
}

.car-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin: 0 0 1rem;
  text-align: left;
}

.car-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}

.car-stat .stat-label {
  display: block;
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
}

.car-stat .stat-value {
  font-size: 0.78rem;
  color: var(--neon-cyan);
  font-weight: 700;
}

.car-detail-fact {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
}

.offroad-section {
  position: relative;
}

/* ---------- Dazzling sky layer: sun/moon arc, stars, drifting clouds ---------- */

.sky-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.sun-moon {
  position: absolute;
  top: 40px;
  left: 50%;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6cc, #ffd60a 60%, #ff9e2c 100%);
  box-shadow: 0 0 40px 12px rgba(255, 214, 10, 0.45);
  transition: background 0.6s ease, box-shadow 0.6s ease;
  will-change: transform;
}

.sun-moon.is-night {
  background: radial-gradient(circle at 35% 30%, #f4f6ff, #c9d3f5 55%, #8f9bd6 100%);
  box-shadow: 0 0 30px 10px rgba(150, 165, 255, 0.35);
}

.stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 15%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 25% 40%, #fff, transparent),
    radial-gradient(1px 1px at 40% 12%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 60% 30%, #fff, transparent),
    radial-gradient(1px 1px at 75% 8%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 88% 22%, #fff, transparent),
    radial-gradient(1px 1px at 15% 60%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 50% 50%, #fff, transparent),
    radial-gradient(1px 1px at 92% 55%, #fff, transparent);
  background-size: 100% 800px;
  background-repeat: repeat-y;
  animation: twinkle 3s ease-in-out infinite;
}

.stars.is-visible {
  opacity: 1;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.cloud {
  position: absolute;
  font-size: 2.2rem;
  opacity: 0.55;
  filter: blur(0.3px) drop-shadow(0 4px 6px rgba(0,0,0,0.2));
  animation: drift 40s linear infinite;
}

.cloud-a { top: 90px; animation-duration: 46s; }
.cloud-b { top: 220px; font-size: 1.6rem; animation-duration: 34s; animation-delay: -12s; opacity: 0.4; }
.cloud-c { top: 380px; font-size: 2.6rem; animation-duration: 55s; animation-delay: -28s; opacity: 0.35; }

@keyframes drift {
  from { transform: translateX(-10vw); }
  to { transform: translateX(110vw); }
}

.hill-scene {
  position: relative;
  height: 640px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hill-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hill-scene-1 { background: linear-gradient(to bottom, #7ec8e3, #1f3a2c); }
.hill-scene-2 { background: linear-gradient(to bottom, #e39a5c, #2c5236); }
.hill-scene-3 { background: linear-gradient(to bottom, #5a4a8c, #3d6b3f); }
.hill-scene-4 { background: linear-gradient(to bottom, #0e1030, #26294f); }

.offroad-vehicle {
  position: relative;
  z-index: 2;
  width: 200px;
  cursor: pointer;
  will-change: transform;
  filter: drop-shadow(0 12px 10px rgba(0, 0, 0, 0.4));
}

.tap-combo {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', sans-serif;
  font-size: 0.7rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 214, 10, 0.8);
  pointer-events: none;
  opacity: 0;
  z-index: 4;
}

.tap-combo.show {
  animation: combo-pop 0.7s ease forwards;
}

@keyframes combo-pop {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); }
  75% { opacity: 1; transform: translate(-50%, -18px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(0.9); }
}

/* Headlights glow brighter once night falls */
.is-night-mode .headlight {
  filter: drop-shadow(0 0 6px #fff6cc) drop-shadow(0 0 12px #ffd60a);
}

.offroad-vehicle .vehicle-svg {
  width: 100%;
  height: auto;
  display: block;
}

.vehicle-label {
  text-align: center;
  margin: 0.4rem 0 0;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Wheels spin continuously to suggest motion, independent of scroll. */
.wheel {
  transform-origin: center;
  transform-box: fill-box;
  animation: wheel-spin 0.8s linear infinite;
}

@keyframes wheel-spin {
  to { transform: rotate(360deg); }
}

.scroll-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 0.75rem;
  z-index: 3;
  animation: bob 1.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.6; }
  50% { transform: translate(-50%, 8px); opacity: 1; }
}

/* ---------- Transition from hills to race track ---------- */

.terrain-transition {
  height: 220px;
  background: linear-gradient(to bottom, #3d6b3f, #4a4a4a 55%, #2b2b2b);
}

/* ---------- Race track ---------- */

.track-section {
  position: relative;
  padding: 3rem 1.5rem 4rem;
  background: #2b2b2b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.checkered-strip {
  width: 100%;
  max-width: 900px;
  height: 22px;
  background-image:
    conic-gradient(#eaf0ff 90deg, #0b0e14 90deg 180deg, #eaf0ff 180deg 270deg, #0b0e14 270deg);
  background-size: 22px 22px;
  border-radius: 4px;
}

.track {
  width: 100%;
  max-width: 900px;
  height: 260px;
  position: relative;
  background: repeating-linear-gradient(
    to bottom,
    #3a3a3a 0px,
    #3a3a3a 60px,
    #333 60px,
    #333 120px
  );
  border-radius: 12px;
  border: 4px solid #1a1a1a;
  overflow: hidden;
}

.track::before {
  /* dashed center line down the middle of the track */
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 6px;
  transform: translateY(-50%);
  background-image: repeating-linear-gradient(to right, #ffd60a 0 30px, transparent 30px 55px);
}

.race-car {
  position: absolute;
  top: 12px;
  left: 40px;
  width: 150px;
  cursor: pointer;
  will-change: transform;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5));
}

.race-car .vehicle-svg {
  width: 100%;
  height: auto;
  display: block;
  position: relative;
  z-index: 1;
}

.race-car-2 {
  top: 86px;
}

.race-car-3 {
  top: 160px;
}

.speed-trail {
  position: absolute;
  top: 38%;
  right: 100%;
  height: 10px;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(to left, var(--car-color, #fff), transparent);
  opacity: 0;
  filter: blur(1px);
}

.race-car.racing .speed-trail {
  opacity: 0.85;
  width: 90px;
  transition: width 0.15s ease, opacity 0.15s ease;
}

.race-button {
  padding: 0.9rem 1.8rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(90deg, var(--neon-yellow), #ff9e2c);
  color: #2b1a00;
  font-family: 'Press Start 2P', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  box-shadow: 0 8px 0 0 #a35f00, 0 12px 20px -4px rgba(255, 158, 44, 0.5);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.race-button:active,
.race-button.pressed {
  transform: translateY(6px);
  box-shadow: 0 2px 0 0 #a35f00, 0 4px 10px -2px rgba(255, 158, 44, 0.5);
}

.track-hint {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
}

/* Little exhaust/dust puffs spawned during the race and on vehicle taps */
.puff {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(234, 240, 255, 0.55);
  pointer-events: none;
  animation: puff-fade 0.6s ease-out forwards;
  z-index: 1;
}

@keyframes puff-fade {
  0% { opacity: 0.7; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(1.8) translateY(-10px); }
}

/* Confetti burst when the race finishes */
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  top: 0;
  left: 50%;
  pointer-events: none;
  z-index: 5;
  animation: confetti-fall 1.1s ease-out forwards;
}

@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx, 0), 160px) rotate(var(--rot, 360deg)); opacity: 0; }
}
