/* ============================================================
   Listing card — shared list-view extensions
   ------------------------------------------------------------
   Base .listing-card (root, __thumb, __save, __body, __area,
   __title, __specs, __price, __per) is the canonical Design
   System card in shared.css §12. This file adds what every list
   view needs on top of it: the card is rendered by
   _listing-card.js (search, city pages) and by
   Views/Shared/Partials/_ListingCard.cshtml (favourites,
   matched homes, similar listings).

     .listing-grid              3 / 2 / 1 column result grid
     .listing-card__track       swipeable photo strip (scroll-snap)
     .listing-card__slide       one photo, itself a link
     .listing-card__nav         previous / next photo buttons
     .listing-card__dots        position indicator
     .listing-card__badge-row   badges over the photo, clear of the heart
     .listing-card__period      rental period pill over the photo
     .listing-card__tags        amenity tags
     .listing-card__footer      price above the two CTAs
     .listing-card__actions     "Se mer" + "Boka visning"
     .listing-card__cta         "Se mer"; stretched over the body
     .listing-card__book        "Boka visning"; above the stretch
   ============================================================ */

/* ── Grid ── */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
}

@media (max-width: 1024px) {
  .listing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .listing-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Gallery ── */
.listing-card__track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.listing-card__track::-webkit-scrollbar {
  display: none;
}

.listing-card__slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.listing-card__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface-raised);
  box-shadow: var(--shadow-1);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 1;
}

.listing-card__nav svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.listing-card__nav--prev { left: var(--s-2); }
.listing-card__nav--next { right: var(--s-2); }

/* Shown on hover and while the photo strip has keyboard focus (the arrow keys step
   it); hidden at the ends rather than greyed out. */
.listing-card:hover .listing-card__nav:not(:disabled),
.listing-card__thumb:has(.listing-card__track:focus-visible) .listing-card__nav:not(:disabled) {
  opacity: 1;
}

/* The card and the thumb clip their overflow, so the strip's ring is drawn inside the
   photo, above the slides, with a light edge that stays visible on dark photos. */
.listing-card__thumb:has(.listing-card__track:focus-visible)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--border-focus), inset 0 0 0 4px var(--surface-raised);
  pointer-events: none;
  z-index: 1;
}

.listing-card__thumb:has(.listing-card__track:focus-visible) .listing-card__track {
  outline: none;
  box-shadow: none;
}

.listing-card__nav:disabled {
  visibility: hidden;
}

/* Touch screens swipe; the buttons would only cover the photo. */
@media (hover: none) {
  .listing-card__nav {
    display: none;
  }
}

.listing-card__dots {
  position: absolute;
  bottom: var(--s-2);
  right: var(--s-2);
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.listing-card__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 0 2px rgba(0, 0, 0, .35);
  transition: background var(--transition-fast);
}

.listing-card__dot.is-active {
  background: var(--sam-white);
}

/* ── Overlays on the photo ── */
/* Wraps onto a second row rather than running under the heart (32px, shared.css). */
.listing-card__badge-row {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  right: calc(var(--s-2) * 2 + 32px);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}

.listing-card__period {
  position: absolute;
  bottom: var(--s-2);
  left: var(--s-2);
  background: rgba(49, 49, 49, .82);
  backdrop-filter: blur(4px);
  color: var(--sam-white);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ── Body ── */

/* Containing block for the CTA's stretched ::after. */
.listing-card__body {
  position: relative;
}

.listing-card__tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}

.listing-card__tags .tag {
  font-size: var(--text-xs);
  padding: 3px 8px;
  background: var(--sam-brown-light);
  border-radius: var(--radius-pill);
  font-weight: 600;
  color: var(--sam-brown-dark);
}

/* Price and "/mån" stay one line, above the CTAs; the footer is pushed to the bottom of
   the card so the buttons line up across a row of cards. */
.listing-card__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.listing-card__price {
  white-space: nowrap;
}

/* Two equal buttons; they stack when a long label ("Jag är intresserad") can't fit. */
.listing-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.listing-card__actions > .btn {
  flex: 1 1 0;
  min-width: max-content;
}

/* The whole body opens the listing through this link. position: static so the ::after
   is laid out against the body, not the button. */
.listing-card__cta {
  position: static;
}

/* Lifted above the "Se mer" ::after, which covers the whole body. */
.listing-card__book {
  position: relative;
  z-index: 1;
}

.listing-card__cta::after {
  content: '';
  position: absolute;
  inset: 0;
}

/* .btn lifts on hover with a transform, and a transformed element becomes the
   containing block of its ::after - the stretched area would collapse onto the button
   the moment the pointer entered it, and flicker. */
.listing-card__cta.btn:hover:not(:disabled):not([aria-disabled="true"]) {
  transform: none;
}

/* ── Loading skeleton (.skel-listing from _empty-state.css) ──
   Line widths echo the card: area, title, specs, price. */
.listing-grid .skel-listing__body > :nth-child(1) { width: 40%; }
.listing-grid .skel-listing__body > :nth-child(2) { width: 80%; }
.listing-grid .skel-listing__body > :nth-child(3) { width: 60%; }
.listing-grid .skel-listing__body > :nth-child(4) { width: 35%; margin-top: var(--s-2); }

/* No results / failed load, spanning the whole grid. */
.listing-grid__empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-secondary);
  padding: var(--s-7) 0;
  margin: 0;
}
