/* Total RV – Inventory listing and detail styles */

/* Mobile (<sm): three rows of cards, swipe horizontally */
@media (max-width: 639px) {
  /*
   * Break out of parent's px-6 (1.5 rem) so the rail spans the full viewport,
   * then add symmetric padding back inside the rail.
   * Using plain CSS here — not Tailwind — for guaranteed application.
   */
  .inventory-grid-scroll {
    margin-inline: -1.5rem;   /* escape parent padding */
    padding-inline: 1.5rem;   /* restore symmetric inner spacing */
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline-start: 1.5rem;
    padding-bottom: 0.75rem;
    /* hide scrollbar on mobile — navigation is via swipe / arrows */
    scrollbar-width: none;
  }
  .inventory-grid-scroll::-webkit-scrollbar { display: none; }

  @media (prefers-reduced-motion: no-preference) {
    .inventory-grid-scroll { scroll-behavior: smooth; }
  }

  #inventory-grid {
    display: grid !important;
    grid-template-columns: unset !important;
    grid-auto-flow: column;
    grid-template-rows: repeat(3, auto);
    /*
     * Card width = viewport − (left padding 1.5rem + right padding 1.5rem)
     * = perfectly centred with equal space visible on each side.
     */
    grid-auto-columns: calc(100vw - 3rem);
    column-gap: 1.25rem;
    row-gap: 1.25rem;
    width: max-content;
    max-width: none;
    align-items: stretch;
  }

  /* snap each column-group's first card to the left-edge snap point */
  #inventory-grid > .caravan-card:nth-child(3n + 1) {
    scroll-snap-align: start;
  }
}

.inventory-grid {
  display: grid;
  gap: var(--space-lg, 1.5rem);
}

@media (min-width: 48em) {
  .inventory-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

.inventory-card {
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.inventory-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.inventory-card-link:hover {
  color: var(--color-primary, #0066cc);
}

.inventory-card-link img {
  width: 100%;
  height: auto;
  display: block;
}

.inventory-card-body {
  padding: var(--space-md, 1rem);
}

.inventory-card-body h2 {
  margin: 0 0 var(--space-sm, 0.5rem);
  font-size: 1.25rem;
  overflow-wrap: break-word;
  min-width: 0;
}

.inventory-description {
  margin-top: 1rem;
}

/* Land Rover–style card CTAs */
.card-cta-primary {
  font-family: "Manrope", sans-serif;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.card-cta-primary:hover {
  opacity: 0.95;
}
.card-cta-secondary {
  font-family: "Manrope", sans-serif;
  font-weight: 500;
  text-decoration: none;
  color: #111111;
  letter-spacing: 0.05em;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.card-cta-secondary:hover {
  opacity: 0.8;
}

/* Touch-safe second image: visible on tap (active) and keyboard focus */
.inventory-card-link:focus-within .card-img-hover,
.inventory-card-link:active .card-img-hover {
  opacity: 1 !important;
}

/* Aspect-ratio image container — prevents CLS on all card images */
.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f3f4f6;
}

.card-img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.35s ease;
}
