.service-car-lane {
  position: absolute;
  pointer-events: none;
  container-type: inline-size;
}

.service-car-lane::before {
  content: "";
  position: absolute;
  inset: auto 0 1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--color-primary-rgb), 0.2) 72%, transparent);
}

.service-car-sprite {
  position: relative;
  width: var(--car-width);
  max-width: 100%;
  margin-left: auto;
}

.service-car-sprite img {
  display: block;
  width: 100%;
  height: auto;
}

/* The wheel faces are cropped from the same 352 × 138 photo as the body. */
.service-car-sprite::before,
.service-car-sprite::after {
  --rim-diameter: 42;
  content: "";
  position: absolute;
  left: calc(var(--rim-x) / 352 * 100%);
  top: calc(var(--rim-y) / 138 * 100%);
  width: calc(var(--rim-diameter) / 352 * 100%);
  aspect-ratio: 1;
  translate: -50% -50%;
  background-image: var(--wheel-art, none);
  background-repeat: no-repeat;
  background-size: calc(352 / var(--rim-diameter) * 100%) calc(138 / var(--rim-diameter) * 100%);
  background-position:
    calc((var(--rim-x) - var(--rim-diameter) / 2) / (352 - var(--rim-diameter)) * 100%)
    calc((var(--rim-y) - var(--rim-diameter) / 2) / (138 - var(--rim-diameter)) * 100%);
  mask-image: radial-gradient(circle closest-side, black 93%, transparent);
  opacity: 0;
}

.service-car-sprite::before {
  --rim-x: 70;
  --rim-y: 109;
}

.service-car-sprite::after {
  --rim-x: 294;
  --rim-y: 108;
}

.hero-car-lane {
  --car-width: clamp(196px, 20.5vw, 288px);
  z-index: 3;
  overflow: hidden;
  left: var(--page-gutter, var(--pad));
  right: calc(50% + 28px);
  bottom: clamp(16px, 2svh, 28px);
}

.hero-car-lane:not(.is-driving) {
  visibility: hidden;
}

.map-car-lane {
  --car-width: clamp(156px, 24%, 300px);
  z-index: 1;
  left: 9%;
  right: 12%;
  bottom: 1%;
}

@media (min-width: 901px) {
  #home.hero-with-car .hero-trust-signature {
    margin-top: 12px;
  }

  #home.hero-with-car.location-hero {
    height: 100svh;
  }

  #home.hero-with-car.location-hero .hero-message {
    translate: 0 -24px;
  }

  #home.hero-with-car.location-hero .hero-description {
    margin-top: clamp(10px, 2.2svh, 26px);
  }

  #home.hero-with-car.location-hero .hero-actions {
    margin-top: clamp(12px, 2svh, 20px);
  }
}

@media (min-width: 901px) and (max-height: 895px) {
  #home.hero-with-car.location-hero h1 {
    font-size: clamp(58px, min(6.6vw, 11svh), 92px);
  }
}

@media (min-width: 901px) and (max-height: 820px) {
  #home.hero-with-car.location-hero .hero-message {
    translate: 0 -50px;
  }
}

@media (min-width: 901px) and (max-height: 735px) {
  #home.hero-with-car.location-hero h1 {
    font-size: clamp(58px, min(6.1vw, 10.5svh), 84px);
  }
}

@media (min-width: 901px) and (max-height: 780px) {
  #home.hero-with-car:not(.location-hero) .hero-message {
    translate: 0 -32px;
  }
}

@media (max-width: 900px) {
  .map-car-lane {
    --car-width: clamp(117px, 18%, 225px);
  }

  #home.hero-with-car.location-hero {
    --location-car-art-space: clamp(300px, 72vw, 650px);
    --location-car-logo-lift: 8px;
  }

  #home.hero-with-car.location-hero .hero-copy {
    padding-bottom: calc(var(--location-car-art-space) + var(--location-car-logo-lift));
  }

  #home.hero-with-car.location-hero .hero-trust-signature {
    margin-top: calc(clamp(18px, 2.2vw, 26px) - var(--location-car-logo-lift));
  }

  .location-hero .hero-car-lane {
    bottom: calc(var(--location-car-art-space) - clamp(63px, 11vw, 86px));
  }
}

@media (min-width: 768px) and (max-width: 900px) {
  #home.hero-with-car:not(.location-hero) .hero-trust-signature {
    bottom: 62px;
  }

  .hero-car-lane {
    --car-width: 144px;
  }
}

@media (min-width: 768px) and (max-width: 900px) and (min-height: 660px) and (max-height: 759px) {
  #home.hero-with-car:not(.location-hero) h1 .care-line > span {
    display: inline;
  }

  #home.hero-with-car:not(.location-hero) h1 .hero-outline {
    margin-right: .12em;
  }

  #home.hero-with-car:not(.location-hero) .hero-trust-signature {
    bottom: calc(88px + 760px - 100svh);
  }

  .hero-with-car:not(.location-hero) .hero-car-lane {
    bottom: calc(100% - 100svh + 24px);
  }

  .hero-with-car:not(.location-hero) .hero-scroll-indicator {
    bottom: calc(100% - 100svh + 9px);
  }
}

@media (max-width: 767px) {
  #home.hero-with-car:not(.location-hero) .hero-trust-signature {
    bottom: calc(115px + max(0px, 760px - 100svh));
  }

  .hero-car-lane {
    --car-width: clamp(120px, 37.5vw, 174px);
    left: -8vw;
    right: min(calc(100% - 132px), 216px);
    --mobile-car-bottom: calc(max(0px, 100% - 100svh) + max(60px, env(safe-area-inset-bottom) + 46px) + 4px);
    bottom: var(--mobile-car-bottom);
  }

  .location-hero .hero-car-lane {
    right: min(calc(100% - 132px), 234px);
    bottom: min(var(--mobile-car-bottom), calc(var(--location-car-art-space) - clamp(63px, 11vw, 86px)));
  }
}

@media (max-width: 767px) and (max-height: 815px) and (orientation: portrait) {
  #home.hero-with-car:not(.location-hero) h1 .care-line > span {
    display: inline;
  }

  #home.hero-with-car:not(.location-hero) h1 .hero-outline {
    margin-right: .12em;
  }

  #home.hero-with-car .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 390px);
    gap: 8px;
    margin-top: 14px;
  }

  #home.hero-with-car .hero-actions a {
    width: 100%;
    min-width: 0;
    padding: 8px;
    gap: 5px;
    white-space: normal;
  }

  #home.hero-with-car .hero-description {
    margin-top: 12px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
  }
}

@media (max-width: 767px) and (min-height: 816px) and (max-height: 835px) and (orientation: portrait) {
  #home.hero-with-car:not(.location-hero) .hero-description {
    margin-top: 14px;
  }
}

@media (max-width: 350px) and (max-height: 620px) and (orientation: portrait) {
  #home.hero-with-car .hero-message {
    padding-top: 12px;
  }

  #home.hero-with-car:not(.location-hero) h1 {
    font-size: 48px;
  }

  #home.hero-with-car:not(.location-hero) .hero-trust-signature {
    bottom: calc(90px + max(0px, 760px - 100svh));
  }

  #home.hero-with-car.location-hero h1 {
    font-size: clamp(30px, 10vw, 35px);
    line-height: .92;
  }

  #home.hero-with-car.location-hero .hero-actions {
    margin-top: 10px;
  }

  #home.hero-with-car.location-hero .hero-description {
    margin-top: 8px;
    padding-block: 8px;
    line-height: 1.3;
  }

  .location-hero .hero-car-lane {
    bottom: min(var(--mobile-car-bottom), calc(var(--location-car-art-space) - 43px));
  }
}

@media (min-width: 600px) and (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
  #home.hero-with-car .hero-text-panel {
    width: 100%;
    max-width: none;
  }

  #home.hero-with-car .hero-text-panel > .hero-trust-signature {
    position: absolute;
    left: auto;
    right: 0;
    top: -6px;
    bottom: auto;
    width: min(40%, 310px);
    margin-top: 0;
  }

  .hero-with-car .hero-car-lane {
    --car-width: clamp(108px, 18vw, 162px);
    left: 36%;
    right: 216px;
    bottom: calc(100% - 100svh + 64px);
  }

  #home.hero-with-car.location-hero :is(h1, .hero-actions) {
    max-width: 53%;
  }

  #home.hero-with-car.location-hero h1 {
    font-size: clamp(32px, 5.4vw, 46px);
  }

  .location-hero.hero-with-car .hero-car-lane {
    left: 57%;
    right: var(--page-gutter, var(--pad));
  }
}

@keyframes service-car-drive {
  from { transform: translateX(-100cqi); }
  to { transform: translateX(0); }
}

@keyframes service-car-roll {
  from {
    opacity: 1;
    transform: rotate(calc(-1turn * var(--wheel-turns, 0)));
  }
  98% { opacity: 1; }
  to {
    opacity: 0;
    transform: rotate(0turn);
  }
}

@media (prefers-reduced-motion: no-preference) {
  html[data-hero-motion="animate"] .hero-car-lane.is-driving {
    --car-arrival: 1.65s cubic-bezier(.23,.47,.22,1) both;
  }

  html[data-hero-motion="animate"] .hero-car-lane.is-driving .service-car-sprite {
    animation: service-car-drive var(--car-arrival);
  }

  html[data-hero-motion="animate"] .hero-car-lane.is-driving .service-car-sprite::before,
  html[data-hero-motion="animate"] .hero-car-lane.is-driving .service-car-sprite::after {
    animation: service-car-roll var(--car-arrival);
  }

  html[data-hero-motion="animate"] .map-car-lane .service-car-sprite {
    transform: translateX(calc((100% - 100cqi) * (1 - var(--drive-progress, 1))));
  }

  html[data-hero-motion="animate"] .map-car-lane .service-car-sprite::before,
  html[data-hero-motion="animate"] .map-car-lane .service-car-sprite::after {
    opacity: min(1, (1 - var(--drive-progress, 1)) * 1000);
    transform: rotate(calc(1turn * var(--wheel-turns, 0) * (var(--drive-progress, 1) - 1)));
  }
}

