/* Base components */
.listing-card {
  min-width: 0;
  flex: 0 0 auto;
  overflow: hidden;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.listing-card:hover,
.listing-card:focus {
  box-shadow: 0 0 0 1px rgba(0, 72, 103, 0.25), 0 6px 14px rgba(0, 0, 0, 0.14);
  outline: none;
}

.listing-photo-frame {
  position: relative;
  overflow: hidden;
  background: #d9d9d9;
}

.listing-photo-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.listing-photo-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555555;
  font-size: var(--text-sm);
  font-weight: 700;
}

.listing-photo-button {
  position: absolute;
  top: 0;
  width: 35px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  cursor: pointer;
  z-index: 1;
}

.listing-photo-button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.54);
  transform: translate(-50%, -50%);
  transition: background 0.15s ease;
  z-index: -1;
}

.listing-photo-frame:hover .listing-photo-button,
.listing-photo-frame:focus-within .listing-photo-button {
  opacity: 1;
  pointer-events: auto;
}

.listing-photo-button:hover::before,
.listing-photo-button:focus::before {
  background: rgba(0, 0, 0, 0.72);
}

.listing-photo-button-previous {
  left: 0;
}

.listing-photo-button-next {
  right: 0;
}

.listing-photo-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.listing-card-price {
  color: #000000;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.15;
}

.listing-card-address,
.listing-card-details,
.listing-card-selected-description,
.listing-card-rationale {
  margin-top: 4px;
  color: #333333;
  font-size: 0.68rem;
  line-height: 1.25;
}

.listing-card-rank {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  align-self: flex-start;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  font-size: 1.15rem;
  font-weight: 850;
  line-height: 1;
}

.listing-card-rationale {
  flex: 1;
  margin: 0;
  color: #ffffff;
}

.listing-card-address {
  overflow: hidden;
}

.listing-card-address span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-card-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 2px;
  text-decoration: none;
}

.listing-card-link:hover,
.listing-card-link:focus {
  background: rgba(255, 255, 255, 0.72);
  text-decoration: none;
}

.listing-card-link img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

/* Unselected layout */
.listing-card:not(.is-selected) {
  display: flex;
  flex-direction: row;
  min-height: 132px;
}

.listing-card:not(.is-selected) .listing-photo-frame {
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
}

.listing-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
}

.listing-card-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
}

/* Selected layout */
.listing-card.is-selected {
  display: flex;
  flex-direction: column;
  /* border: 1.5px solid var(--color-neutral); */
  height: auto;
}

.listing-card.is-selected .listing-photo-frame {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
}

.listing-card.is-selected .listing-card-selected-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}

.listing-card.is-selected .listing-card-selected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.listing-card.is-selected .listing-card-address,
.listing-card.is-selected .listing-card-details {
  margin-top: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-card.is-selected .listing-card-selected-description {
  margin: 0;
}

.listing-card.is-selected .listing-card-rationale {
  margin: 0;
}

.listing-card.is-selected .listing-card-links {
  justify-content: flex-end;
}

/* Ranked layout */
.listing-card-ranked:not(.is-selected) {
  flex-direction: column;
  min-height: 0;
}

.listing-card-ranked-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
}

.listing-card-ranked-card {
  min-width: 0;
  display: flex;
}

.listing-card-ranked:not(.is-selected) .listing-card-ranked-card {
  flex-direction: row;
  min-height: 132px;
}

.listing-card-ranked.is-selected .listing-card-ranked-card {
  flex-direction: column;
}

@media (max-width: 840px) and (hover: none), (max-width: 840px) and (pointer: coarse) {
  .listing-photo-button {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 480px) {
  .listing-card:not(.is-selected) {
    min-height: 112px;
  }

  .listing-card:not(.is-selected) .listing-photo-frame {
    width: 112px;
    height: 112px;
  }

  .listing-card-ranked:not(.is-selected) .listing-card-ranked-card {
    min-height: 112px;
  }

  .listing-card-body,
  .listing-card.is-selected .listing-card-selected-content {
    padding: 8px;
  }

  .listing-card-price {
    font-size: 1rem;
  }
}
