/**
 * WebDrive vehicle photography.
 * Canonical 4:3 presentation shared by Home, Listing and Detail.
 */

.vehicle-card__image {
  aspect-ratio: 4 / 3;
}

.vehicle-card__image picture,
.gallery-main picture,
.gallery-thumbs picture {
  display: block;
  width: 100%;
  height: 100%;
}

.vehicle-card__image img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  background: var(--wd-color-surface-alt);
}

.home-stock .vehicle-card__image img {
  height: 100%;
}

.vehicle-card__image::after {
  display: none;
}

.vehicle-card__media-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.vehicle-card__media-meta .vehicle-card__photos {
  position: static;
  padding: 0;
  background: transparent;
  color: var(--wd-muted);
  font-size: 11px;
  font-weight: 750;
}

.vehicle-card:hover .vehicle-card__image img {
  transform: none;
}

.gallery-main {
  aspect-ratio: 4 / 3;
}

.vehicle-gallery {
  min-width: 0;
}

.gallery-main__open {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.gallery-main__open:focus-visible {
  outline: 3px solid var(--wd-color-focus);
  outline-offset: -5px;
}

.gallery-main__open:disabled {
  cursor: default;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  background: var(--wd-color-surface-alt);
}

.gallery-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 9px;
  color: var(--wd-muted);
  font-size: 12px;
}

.gallery-meta span:first-child {
  color: var(--wd-ink);
  font-weight: 800;
}

.gallery-thumbs {
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 8px;
  margin-top: 12px;
  padding: 2px 0 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-gutter: stable;
}

.gallery-thumbs button {
  width: 96px;
  height: 72px;
  flex: 0 0 96px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--wd-color-surface-alt);
  cursor: pointer;
  scroll-snap-align: start;
}

.gallery-thumbs button.is-active {
  border-color: var(--wd-color-brand);
}

.gallery-thumbs button:focus-visible {
  outline: 3px solid var(--wd-color-focus);
  outline-offset: 1px;
}

.gallery-thumbs img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  background: var(--wd-color-surface-alt);
}

.vehicle-lightbox {
  width: min(calc(100% - 32px), 1440px);
  max-width: none;
  height: min(calc(100dvh - 32px), 960px);
  max-height: none;
  border: 0;
  padding: 0;
  background: #0b1824;
  color: #fff;
  box-shadow: 0 28px 80px rgb(0 0 0 / 45%);
}

.vehicle-lightbox::backdrop {
  background: rgb(5 13 20 / 82%);
}

.vehicle-lightbox__shell {
  display: grid;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 16px;
}

.vehicle-lightbox header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 12px;
}

.vehicle-lightbox h2 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  letter-spacing: -.02em;
}

.vehicle-lightbox header button,
.vehicle-lightbox__viewer > button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 50%;
  background: rgb(255 255 255 / 8%);
  color: #fff;
  font: 700 22px var(--wd-font);
  cursor: pointer;
}

.vehicle-lightbox button:hover {
  background: rgb(255 255 255 / 16%);
}

.vehicle-lightbox button:focus-visible {
  outline: 3px solid var(--wd-color-accent);
  outline-offset: 3px;
}

.vehicle-lightbox__viewer {
  display: grid;
  min-height: 0;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 12px;
  align-items: center;
}

.vehicle-lightbox__viewer picture {
  grid-column: 2;
  display: block;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.vehicle-lightbox__viewer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.vehicle-lightbox__viewer > button {
  justify-self: center;
}

.vehicle-lightbox__shell > p {
  margin: 10px 0 0;
  color: var(--wd-color-border);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 599px) {
  .gallery-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .gallery-thumbs button {
    width: 84px;
    height: 63px;
    flex-basis: 84px;
  }

  .vehicle-lightbox {
    width: 100%;
    height: 100dvh;
  }

  .vehicle-lightbox__shell {
    padding: 12px 8px;
  }

  .vehicle-lightbox__viewer {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 4px;
  }

  .vehicle-lightbox h2 {
    font-size: 15px;
  }

  .vehicle-lightbox header button,
  .vehicle-lightbox__viewer > button {
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-main img,
  .vehicle-card__image img {
    transition: none;
  }
}
