/**
 * Homepage Hero Slideshow
 * Full-bleed crossfading photos with a slow zoom, a model caption and
 * clickable progress dots. Text and CTAs come from scrub-hero.css.
 */

.home-hero {
  --hh-duration: 6500ms;
  background-color: #0a0a0a;
}

/* ===========================================
   Slides
   =========================================== */

.hh-slides {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hh-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.hh-slide.is-active {
  opacity: 1;
  z-index: 1;
}

.hh-slide picture,
.hh-slide img {
  display: block;
  width: 100%;
  height: 100%;
}

.hh-slide img {
  object-fit: cover;
  /* Slides with an off-centre car set --hh-pos so narrow screens crop the empty side */
  object-position: var(--hh-pos, 50%) 50%;
  transform: scale(1.06);
  transition: transform 1.2s ease;
}

/* Slow push-in while a slide is on screen */
.hh-slide.is-active img {
  transform: scale(1);
  transition: transform calc(var(--hh-duration) + 1200ms) linear;
}

/* Same readability gradient the static hero used */
.hh-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.05) 35%,
    rgba(0, 0, 0, 0.05) 58%,
    rgba(0, 0, 0, 0.68) 100%
  );
}

/* ===========================================
   Caption + dots
   =========================================== */

.hh-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--container-padding) 4.5vh;
  pointer-events: none;
}

.hh-controls > * {
  pointer-events: auto;
}

.hh-caption {
  position: absolute;
  left: max(var(--container-padding), calc((100% - var(--container-max)) / 2 + var(--container-padding)));
  bottom: 4.5vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #ffffff;
  text-decoration: none;
  transition: opacity 0.35s ease;
}

.hh-caption.is-changing {
  opacity: 0;
}

.hh-caption-label {
  font-size: 11px;
  font-weight: var(--font-semibold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.hh-caption-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.hh-caption-cta svg {
  transition: transform 0.25s ease;
}

.hh-caption:hover .hh-caption-cta svg {
  transform: translateX(4px);
}

.hh-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 44px-tall hit area around a slim bar */
.hh-dot {
  position: relative;
  width: 28px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: width 0.4s ease;
}

.hh-dot::before,
.hh-dot-fill {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
}

.hh-dot::before {
  right: 0;
  background: rgba(255, 255, 255, 0.4);
  transition: background-color 0.25s ease;
}

.hh-dot:hover::before {
  background: rgba(255, 255, 255, 0.75);
}

.hh-dot.is-active {
  width: 56px;
}

.hh-dot-fill {
  width: 0;
  background: #ffffff;
}

/* Fill runs for the slide's duration; restarted by JS */
.hh-dot.is-active .hh-dot-fill {
  animation: hh-progress var(--hh-duration) linear forwards;
}

.home-hero.is-paused .hh-dot.is-active .hh-dot-fill {
  animation-play-state: paused;
}

@keyframes hh-progress {
  from { width: 0; }
  to   { width: 100%; }
}

.hh-dot:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===========================================
   Responsive
   =========================================== */

@media (max-width: 768px) {
  .hh-caption {
    display: none;
  }

  .hh-controls {
    padding-bottom: 3vh;
  }

  /* Mobile crops are already centred on the car */
  .hh-slide img {
    object-position: 50% 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hh-slide,
  .hh-slide img,
  .hh-slide.is-active img {
    transition: none;
    transform: none;
  }

  .hh-dot.is-active .hh-dot-fill {
    animation: none;
    width: 100%;
  }
}
