/* Reset & Base */
:root {
    --adas-color-camera: #00C00C99;
    --adas-color-radar: #0089CF99;
    --adas-color-ultrasonic: #FDB91399;
    --adas-color-internal: #aaa9;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@font-face {
    font-family: 'Poppins';
    src: url('fonts/poppins-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

body {
  background: #111119;
  font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  color: #e0e0e0;
}

ul {
    padding-inline-start: 1.5em;
    margin-top: -16px;
    font-size: 15px;
    line-height: 1.7;
    color: #444;
    margin-bottom: 20px;
}

.app {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Road */
.road {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  padding: 6vh 0;
}

.road::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  /* viewport width + 2 tile widths (270vh each) so the element covers the
     viewport at all points during the animation, including the reset frame */
  width: calc(100vw + 540vh);
  background-image: url('images/road.jpg');
  background-repeat: repeat-x;
  background-size: auto 100%;
  will-change: transform;
  animation: scroll-road 3s linear infinite;
  z-index: 0;
}

@keyframes scroll-road {
  from { transform: translateX(0); }
  to   { transform: translateX(-270vh); }
}

/* Lanes */
.lane {
  flex: 1;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

/* Cars */
.car {
  height: 80%;
  width: auto;
  flex-shrink: 0;
  user-select: none;
  filter: drop-shadow(-20px 10px 4px #0004);
}

/* Lane Cars Container - scrolling lanes */
.lane-cars {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 8vw;
  position: absolute;
  left: 0;
  top: 0;
  padding: 0 4vw;
  will-change: transform;
}

/* Top lane - fast, opposite direction */
.lane--top .lane-cars {
  animation: scroll-right 10s linear infinite;
}

/* Bottom lane - slow */
.lane--bottom .lane-cars {
  animation: scroll-left 25s linear infinite;
}

@keyframes scroll-left {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes scroll-right {
  from {
    transform: translateX(-50%);
  }
  to {
    transform: translateX(0);
  }
}

/* Center lane - static, centered */
.lane-cars--center {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10vw;
  width: 100%;
  padding: 0;
}

/* Cars in front/behind center - subtle drift */
.car--behind {
  animation: drift-behind 3s ease-in-out infinite alternate;
}

.car--ahead {
  animation: drift-ahead 3.5s ease-in-out infinite alternate;
}

@keyframes drift-behind {
  from { transform: translateX(-6px); }
  to   { transform: translateX(6px); }
}

@keyframes drift-ahead {
  from { transform: translateX(5px); }
  to   { transform: translateX(-5px); }
}

/* Center Car Wrapper */
.center-car-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 80%;
}

.car--main {
  height: 100%;
  width: auto;
  position: relative;
  z-index: 1;
}

/* Individual ADAS sensor shape SVGs - positioned on .road by JS */
.adas-shape {
  position: absolute;
  pointer-events: none;
  overflow: visible;
}

.adas-shape path {
    stroke-width: 1px;
    stroke: #fff5;
}

.adas-shape .shape-hit {
  pointer-events: all;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.25s ease, filter 0.25s ease;
}

.adas-shape .shape-hit:hover {
  opacity: 0.85;
  filter: brightness(1.5);
}

/* Help button */
.help-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.45);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s, color 0.2s;
}

.help-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
}

/* Legend */
.legend {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  background: linear-gradient(135deg, rgb(19, 74, 122) 1%, rgb(3, 30, 55) 100%);
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
  font-size: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-item[data-modal] {
  cursor: pointer;
}

.legend-item[data-modal]:hover {
  opacity: 0.8;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* Brands Bar */
.brands-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgb(19, 74, 122) 1%, rgb(3, 30, 55) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 24px;
  color: #e0e0e0;
  font-size: 1rem;
  cursor: pointer;
  white-space: nowrap;
  z-index: 10;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
}

.brands-bar:hover {
    filter: brightness(1.1);
  color: #fff;
}

/* Brands Grid */
.brands-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.brand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: #f5f5f7;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 8px;
}

.brand-logo {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e8ec;
  border-radius: 6px;
  overflow: hidden;
}

.brand-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-name {
  font-size: 11px;
  color: #555;
  text-align: center;
  line-height: 1.4;
}

/* Modal */
dialog.modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 90%;
  max-width: 800px;
  height: fit-content;
  max-height: 80vh;
  background: #fff;
  border-radius: 4px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  color: #1a1a2e;
}

dialog.modal[open] {
  animation: modal-in 0.3s ease forwards;
}

@keyframes modal-in {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 16px;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: #666;
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  z-index: 2;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #111;
}

/* Modal Header */
.modal-header {
  padding: 28px 28px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
}

.modal-sensor-badge {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a2e;
  line-height: 1.3;
}

/* Modal Body */
.modal-body {
  padding: 24px 28px 28px;
}

.modal-type {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  margin-bottom: 12px;
  opacity: 0.7;
}

.modal-description {
  font-size: 15px;
  line-height: 1.7;
  color: #444;
  margin-bottom: 20px;
}

.modal-section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  color: #999;
  margin-bottom: 10px;
}

.modal-gallery {
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (min-width: 850px) {
    .modal-gallery {
        display:grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 10px;
    }
}

.modal-gallery img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
}

.modal-how {
  font-size: 14px;
  line-height: 1.7;
  color: #b0b0ba;
  margin-bottom: 24px;
}

.modal-gallery figcaption {
    text-transform: uppercase;
    text-align: center;
    font-weight: 600;
    font-size: .9em;
    line-height: 1.2;
}

/* Responsive */
@media (max-width: 768px) {
  .car {
    height: 65%;
  }

  .center-car-wrapper {
    height: 65%;
  }

  .car--main {
    height: 100%;
  }

  .legend {
    gap: 12px;
    padding: 8px 16px;
    font-size: 11px;
    top: 10px;
  }

  .brands-bar {
    bottom: 10px;
    padding: 8px 16px;
    font-size: 11px;
  }

  .brands-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  dialog.modal {
    max-width: 95%;
    max-height: 85vh;
  }

  .modal-header {
    padding: 20px 20px 16px;
  }

  .modal-body {
    padding: 16px 20px 20px;
  }

  .modal-title {
    font-size: 17px;
  }
}

@media (max-width: 480px) {
  .car {
    height: 55%;
  }

  .center-car-wrapper {
    height: 55%;
  }

  .car--main {
    height: 100%;
  }

  .lane-cars {
    gap: 5vw;
  }

  .lane-cars--center {
    gap: 4vw;
  }

  .legend {
    gap: 8px;
    padding: 6px 12px;
    font-size: 10px;
  }

  .brands-bar {
    padding: 6px 12px;
    font-size: 10px;
  }

  .brands-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.hidden {
    display: none !important;
}
