/* HNTB Second Kiosk - Horse Race Styles */

/* Base styles */
#hntb-kiosk-second {
  font-family: "Interstate", Roboto, Helvetica, Arial, sans-serif;
  position: absolute;
  top: 0;
  left: 0;
  width: 1080px;
  height: 1920px;
  background: #000;
  overflow: hidden !important;
}

/* Ensure body and html never show scrollbars */
body, html {
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

#hntb-kiosk-second * {
  box-sizing: border-box;
}

/* Track Container */
.track-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  contain: layout style paint;
  overflow: hidden !important;
}

/* Track Sections */
.track-section {
  position: relative;
  overflow: hidden;
  width: 100%;
  contain: layout style paint;
}

.track-top {
  height: 111px;
  transform: translate3d(0, 0, 0); /* Force GPU acceleration */
  animation: scrollTrack 40s linear infinite;
  background-repeat: repeat-x;
  background-size: auto 100%;
  will-change: background-position;
  backface-visibility: hidden; /* Prevent flickering */
  -webkit-backface-visibility: hidden;
  perspective: 1000px; /* Create stacking context */
}

.track-middle {
  position: relative;
  height: 868px;
}

.track-bottom {
  height: 101px;
  transform: translate3d(0, 0, 0); /* Force GPU acceleration */
  animation: scrollTrack 40s linear infinite;
  background-repeat: repeat-x;
  background-size: auto 100%;
  will-change: background-position;
  backface-visibility: hidden; /* Prevent flickering */
  -webkit-backface-visibility: hidden;
  perspective: 1000px; /* Create stacking context */
}

/* Track background animation */
@keyframes scrollTrack {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -2000px; /* Double the distance for smoother looping */
  }
}

.track-bg {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translate3d(0, 0, 0); /* Force GPU acceleration */
  animation: scrollTrack 40s linear infinite;
  background-repeat: repeat-x;
  background-size: auto 100%;
  will-change: background-position;
  backface-visibility: hidden; /* Prevent flickering */
  -webkit-backface-visibility: hidden;
  perspective: 1000px; /* Create stacking context */
}

/* Tracks Container */
.tracks {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Individual Track Lane */
.track-lane {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  transform: translateZ(0); /* Create layer for each lane */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.track-lane:last-child {
  border-bottom: none;
}

/* State Label */
.state-label {
  font-size: 17px; /* 28px * 0.6 */
  font-weight: bold;
  position: absolute;
  z-index: 3;
  left: 10px;
  justify-content: center;
  width: 40px;
  min-width: 40px; /* 60px * 0.6 */
  padding: 4px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  color: #b3bc2e;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
}

/* Pulse animation for state label when horse moves */
.track-lane.state-active .state-label {
  animation: labelPulse 0.6s ease-out;
}

@keyframes labelPulse {
  0% {
    transform: scale(1);
    background: rgba(0, 0, 0, 0.7);
  }
  50% {
    transform: scale(1.2);
    background: rgba(0, 102, 0, 0.9);
    color: #00ff00;
  }
  100% {
    transform: scale(1);
    background: rgba(0, 0, 0, 0.7);
    color: white;
  }
}

/* Horse */
.horse {
  position: absolute;
  /* Maintain aspect ratio: 293:205 = 1.43:1 */
  z-index: 2;
  top: 50%;
  left: 0;
  width: 83px; /* 58px * 1.43 */
  height: 58px;
  transition: transform var(--horse-movement-duration, 0.5s) cubic-bezier(0.4, 0, 0.2, 1);
  transform: translate3d(var(--horse-x-position, 0), -50%, 0);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.horse.moving {
  /* Movement transition is handled by the main .horse class */
}

/* Speed up animation when horse is moving */
.horse.moving .horse-sprite {
  animation-duration: var(--horse-moving-animation-duration, 0.3s) !important;
}

.horse-sprite {
  width: 100%;
  height: 100%;
  transform: translateZ(0); /* Force GPU acceleration for sprite */
  /* Scale the original sprite (293x2460) to fit our container (83x58) */
  animation: horseRun 1s infinite step-end;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 83px 696px; /* 83px width, 696px height (58px * 12 frames) */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

@keyframes horseRun {
  0% {
    background-position: 0 0;
  }
  8.33% {
    background-position: 0 -58px;
  }
  16.67% {
    background-position: 0 -116px;
  }
  25% {
    background-position: 0 -174px;
  }
  33.33% {
    background-position: 0 -232px;
  }
  41.67% {
    background-position: 0 -290px;
  }
  50% {
    background-position: 0 -348px;
  }
  58.33% {
    background-position: 0 -406px;
  }
  66.67% {
    background-position: 0 -464px;
  }
  75% {
    background-position: 0 -522px;
  }
  83.33% {
    background-position: 0 -580px;
  }
  91.67% {
    background-position: 0 -638px;
  }
  100% {
    background-position: 0 0;
  }
}

/* State Info */
.state-info {
  position: absolute;
  z-index: 3;
  right: 10px;
  display: flex;
  align-items: center;
  padding: 6px 12px; /* 10px * 0.6, 20px * 0.6 */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  overflow: visible;
}

/* Animation when horse moves */
.state-info.pulse {
  animation: statePulse 0.6s ease-out;
}

@keyframes statePulse {
  0% {
    transform: scale(1) translateZ(0);
    background: rgba(0, 0, 0, 0.7);
    box-shadow: 0 0 0 0 rgba(0, 255, 0, 0);
  }
  50% {
    transform: scale(1.1) translateZ(0);
    background: rgba(0, 102, 0, 0.9);
    box-shadow: 0 0 20px 5px rgba(0, 255, 0, 0.4);
  }
  100% {
    transform: scale(1) translateZ(0);
    background: rgba(0, 0, 0, 0.7);
    box-shadow: 0 0 0 0 rgba(0, 255, 0, 0);
  }
}

.state-name {
  font-size: 14px; /* 20px * 0.6 */
  width: 100px;
  color: white;
}

.state-score {
  font-size: 19px; /* 32px * 0.6 */
  font-weight: bold;
  position: relative;
  min-width: 36px; /* 60px * 0.6 */
  text-align: right;
  color: #00ff00;
  overflow: visible;
}

/* Score increment animation */
.score-increment {
  font-size: 24px;
  font-weight: bold;
  position: absolute;
  top: -20px;
  right: 0;
  animation: scoreIncrement 1.5s ease-out forwards;
  pointer-events: none;
  opacity: 0;
  color: #00ff00;
  text-shadow: 0 0 20px rgba(0, 255, 0, 1),
               0 0 40px rgba(0, 255, 0, 0.8),
               0 0 60px rgba(0, 255, 0, 0.6);
  z-index: 10;
  white-space: nowrap;
}

@keyframes scoreIncrement {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.3) rotate(-15deg);
  }
  20% {
    opacity: 1;
    transform: translateY(-10px) scale(1.5) rotate(5deg);
  }
  40% {
    opacity: 1;
    transform: translateY(-20px) scale(1.8) rotate(-5deg);
  }
  60% {
    opacity: 1;
    transform: translateY(-30px) scale(1.6) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-50px) scale(0.8) rotate(0deg);
  }
}

/* Debug Controls */
.debug-controls {
  position: fixed;
  z-index: 1000;
  right: 20px;
  bottom: 20px;
  padding: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.debug-controls button {
  font-size: 16px;
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.2s ease;
  color: white;
  border: none;
  border-radius: 5px;
  background: #0066cc;
}

.debug-controls button:last-child {
  margin-bottom: 0;
}

.debug-controls button:hover {
  background: #0052a3;
}

/* Alpine.js cloak */
[x-cloak] {
  display: none !important;
}

/* Responsive adjustments for track lanes */
@media (max-height: 1920px) {
  .track-lane {
    min-height: 58px; /* 870px / 15 states */
  }
}

/* Removed starting and finish line indicators */