/* Listing card. One component for both the homepage rail and the route-page grids.
   Replaces .listing-card + .route-listing-card, which differed only by drift
   (17px vs 12px radius, 190px vs 185px image, 14px vs 15px title) and used
   positional selectors (.route-card-body > div:last-child) on the route side. */

/* Horizontal rail. `overflow: hidden` used to clip the row, which meant the arrow
   buttons were the only way through it -- no swipe, no trackpad, no keyboard. With
   78 listings that hid ~20 screens of inventory. */
.listing-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 42px) / 4);
  gap: var(--space-4);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  /* room for the scrollbar and for the card lift on hover */
  padding-bottom: var(--space-3);
}
.listing-grid > * { scroll-snap-align: start; }
.listing-grid:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 4px; }

.listing-grid::-webkit-scrollbar { height: 6px; }
.listing-grid::-webkit-scrollbar-track { background: transparent; }
.listing-grid::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
.listing-grid::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* The static grids on route pages are not rails. */
.listing-grid--static {
  overflow: visible;
  scroll-snap-type: none;
  padding-bottom: 0;
}
.listing-grid--static {
  grid-auto-flow: row;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-columns: auto;
}

.listing-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.listing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.listing-image {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--surface-mint);
}
.listing-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 350ms ease; }
.listing-card:hover .listing-image img { transform: scale(1.05); }

.listing-badge {
  position: absolute;
  top: 11px;
  left: 11px;
  padding: 5px var(--space-2);
  color: var(--green-800);
  background: var(--white);
  border-radius: var(--radius-xs);
  font-size: var(--text-3xs);
  font-weight: 800;
  letter-spacing: .03em;
}

.save-button {
  position: absolute;
  top: 9px;
  right: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--white);
  background: rgba(0, 0, 0, .22);
  border: 1px solid var(--overlay-white-35);
  border-radius: var(--radius-round);
}
.save-button.saved { color: var(--orange); background: var(--white); }

/* Grow to fill the card so the footer can sit on the baseline, keeping prices
   aligned across a row even when one title wraps to two lines and another does not. */
.listing-info { display: flex; flex: 1; flex-direction: column; padding: var(--space-4); }

.listing-location {
  margin-bottom: 5px;
  color: var(--text-subtle);
  font-size: var(--text-3xs);
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.listing-info h3 { margin: 6px 0; font-size: var(--text-md); line-height: 1.28; }
/* min-height: 38px was not a multiple of the 15.5px line box, so it exposed 2.45
   lines -- a third line sliced through the middle of the glyphs. Chrome blockifies
   `display: -webkit-box` here, so the clamp cannot be relied on to hide it; an exact
   two-line height clips on the boundary whether or not the clamp applies. */
.listing-description {
  display: -webkit-box;
  height: 3.1em;
  margin-bottom: var(--space-3);
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-2xs);
  line-height: 1.55;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.listing-provider {
  display: flex;
  min-height: 35px;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.listing-provider > span:last-child { display: grid; gap: 2px; }
.listing-provider strong { color: var(--ink-soft); font-size: var(--text-3xs); }
.listing-provider small { color: var(--text-subtle); font-size: 8px; }

.listing-footer {
  display: flex;
  margin-top: auto;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.listing-price small, .listing-price strong { display: block; }
.listing-price small { color: var(--text-subtle); font-size: var(--text-3xs); }
.listing-price strong { margin-top: 2px; color: var(--green-800); font-size: var(--text-md); }
.listing-rating { color: var(--orange); font-size: var(--text-2xs); font-weight: 800; text-align: right; }
.listing-rating span {
  display: block;
  margin-top: 2px;
  color: var(--text-subtle);
  font-size: var(--text-3xs);
  font-weight: 500;
}

@media (max-width: 900px) {
  .listing-grid { grid-auto-columns: calc((100% - 28px) / 3); }
  .listing-grid--static { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .listing-grid { grid-auto-columns: calc((100% - 14px) / 2); }
  .listing-grid--static { grid-template-columns: 1fr; }
}
