/**
 * Homele property card for listing Similar Properties.
 *
 * Source of truth for visual DNA: body.world .homele-* in
 * frontend/pages/home/home-world.css (locked homepage rails).
 *
 * This file mirrors those rules under .listing-similar-section
 * (listing.html has no body.world). Geometry/type use the same
 * homepage hierarchy with a modest readability bump only —
 * not a reinvented card.
 *
 * Homepage baseline → Similar (slight bump):
 *   card 310 → 328px | media 200 → 212px
 *   title 14.5 → 15.5px | price 15.5 → 16.5px | meta 12.5 → 13px
 * Markup: js/homele-property-card.js (DarweshHomele.propertyCard)
 * — same fields/interactions as homepage homelePropertyCard.
 */

.listing-similar-section {
  --w-gold: #B49A6A;
  --homele-rail-pad: 8px;
  --homele-card-w: 328px;
  --homele-card-gap: 18px;
  --homele-media-h: 212px;
  --homele-edge: 52px;
  --homele-title-size: 15.5px;
  --homele-price-size: 16.5px;
  --homele-meta-size: 13px;
  --homele-period-size: 11px;
  --homele-badge-size: 11px;
  --homele-copy-pad: 13px 15px 15px;
  --homele-copy-gap: 6px;
  --homele-card-min-h: 336px;
}

/* Three equal cards on wide rails; two on tablet; one + peek on mobile.
   Never stretch a single card to fill empty slots. */
@media (min-width: 1100px) {
  .listing-similar-section {
    --homele-card-w: min(328px, calc((100% - (2 * var(--homele-card-gap))) / 3));
  }
}
@media (max-width: 1099px) and (min-width: 768px) {
  .listing-similar-section {
    --homele-card-w: min(328px, calc((100% - var(--homele-card-gap)) / 2));
  }
}
@media (max-width: 767px) {
  .listing-similar-section {
    /* One readable card + small next-card peek (homepage DNA, not miniature). */
    --homele-card-w: calc(100% - 28px);
    --homele-card-gap: 14px;
    --homele-edge: 40px;
    --homele-media-h: 200px;
  }
}

/* ---- Stage / rail / outer arrows (homepage w-homele-* DNA) ---- */

.listing-similar-section .w-homele-stage {
  position: relative;
  padding-inline: var(--homele-edge);
}

.listing-similar-section .w-homele-rail,
.listing-similar-section .lsim-rail {
  display: flex;
  gap: var(--homele-card-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  margin-inline: 0;
  padding-block: 4px var(--homele-rail-pad);
  min-width: 0;
  scrollbar-width: none;
}

.listing-similar-section .lsim-rail::-webkit-scrollbar { display: none; }
.listing-similar-section .lsim-rail > * { scroll-snap-align: start; }

@media (prefers-reduced-motion: reduce) {
  .listing-similar-section .lsim-rail { scroll-behavior: auto; }
}

.listing-similar-section .w-homele-edge {
  position: absolute;
  top: 50%;
  z-index: 6;
  transform: translateY(-50%);
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: rgba(244, 241, 234, 0.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.listing-similar-section .w-homele-edge-face {
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid color-mix(in oklab, rgba(185, 154, 99, 0.42) 60%, rgba(210, 200, 180, 0.35));
  background:
    linear-gradient(160deg,
      rgba(28, 32, 38, 0.42) 0%,
      rgba(18, 22, 28, 0.55) 48%,
      rgba(12, 14, 18, 0.62) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 -1px 0 rgba(0, 0, 0, 0.18) inset,
    0 8px 22px -14px rgba(8, 10, 14, 0.45);
  backdrop-filter: blur(12px) saturate(1.05);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.listing-similar-section .w-homele-edge svg,
.listing-similar-section .w-homele-edge .w-edge-glass-ico,
.listing-similar-section .w-homele-edge path {
  pointer-events: none !important;
  width: 18px;
  height: 18px;
  display: block;
}

.listing-similar-section .w-homele-edge--left { left: 0; right: auto; }
.listing-similar-section .w-homele-edge--right { right: 0; left: auto; }

.listing-similar-section .w-homele-edge:hover:not(:disabled) .w-homele-edge-face {
  background:
    linear-gradient(160deg,
      rgba(40, 46, 54, 0.52) 0%,
      rgba(24, 28, 34, 0.62) 100%);
  border-color: color-mix(in oklab, rgba(185, 154, 99, 0.55) 65%, rgba(230, 220, 200, 0.4));
}

.listing-similar-section .w-homele-edge:active:not(:disabled) {
  transform: translateY(-50%) scale(0.96);
}

.listing-similar-section .w-homele-edge:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--w-gold) 75%, rgba(185, 154, 99, 0.5));
  outline-offset: 2px;
}

html[dir="rtl"] .listing-similar-section .w-homele-edge svg { transform: none; }

.listing-similar-section .w-homele-edge:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

html[data-dg-theme="light"] .listing-similar-section .w-homele-edge { color: #2F2A26; }
html[data-dg-theme="light"] .listing-similar-section .w-homele-edge-face {
  background:
    linear-gradient(160deg,
      rgba(255, 252, 247, 0.88) 0%,
      rgba(244, 241, 234, 0.92) 100%);
  border-color: color-mix(in oklab, rgba(185, 154, 99, 0.45) 55%, rgba(47, 42, 38, 0.14));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 8px 18px -12px rgba(47, 42, 38, 0.28);
}

/* ---- Card (exact homepage structure; tokens above for slight bump) ---- */

.listing-similar-section .lsim-rail > .homele-card {
  flex: 0 0 min(var(--homele-card-w), 100%);
  width: min(var(--homele-card-w), 100%);
  max-width: 100%;
  min-width: 0;
  height: auto;
  min-height: var(--homele-card-min-h);
}

.listing-similar-section .homele-card {
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: #14181f;
  border: 1px solid rgba(244, 241, 234, 0.08);
  box-shadow: 0 16px 36px -22px rgba(0, 0, 0, 0.72);
  color: #F4F1EA;
  text-decoration: none;
}

.listing-similar-section .homele-media {
  position: relative;
  flex: none;
  margin: 10px 10px 0;
  height: var(--homele-media-h);
  min-height: var(--homele-media-h);
  border-radius: 16px;
  overflow: hidden;
  background: #10141a;
}

.listing-similar-section .homele-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  pointer-events: none;
}

.listing-similar-section .homele-slide.is-active { display: block; }

.listing-similar-section .homele-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.listing-similar-section .homele-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  text-align: center;
  color: #A8A29A;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 11px;
  line-height: 1.35;
  background:
    radial-gradient(80% 80% at 50% 20%, rgba(185, 154, 99, 0.16), transparent 60%),
    #12161c;
}

.listing-similar-section .homele-fallback[hidden] { display: none; }

.listing-similar-section .homele-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  left: auto;
  z-index: 3;
  pointer-events: none;
  background: #e11d48;
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: var(--homele-badge-size);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.listing-similar-section .homele-badge.is-rent,
.listing-similar-section .homele-badge.is-sale { background: #e11d48; }

.listing-similar-section .homele-photo-btn {
  position: absolute;
  top: 50%;
  z-index: 3;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.94);
  color: #1c1917;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  pointer-events: auto;
}

.listing-similar-section .homele-photo-btn--prev { left: 8px; right: auto; }
.listing-similar-section .homele-photo-btn--next { right: 8px; left: auto; }
.listing-similar-section .homele-photo-btn svg,
.listing-similar-section .homele-photo-btn path { pointer-events: none !important; display: block; }
html[dir="rtl"] .listing-similar-section .homele-photo-btn svg { transform: none; }

.listing-similar-section .homele-photo-btn:hover { background: #fff; }
.listing-similar-section .homele-photo-btn:focus-visible {
  outline: 2px solid var(--w-gold);
  outline-offset: 2px;
}

.listing-similar-section .homele-dots {
  position: absolute;
  left: 44px;
  right: 44px;
  bottom: 10px;
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.listing-similar-section .homele-dot {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.listing-similar-section .homele-dot::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.listing-similar-section .homele-dot.is-active::after {
  background: #fff;
  width: 6px;
  height: 6px;
}

.listing-similar-section .homele-copy {
  display: flex;
  flex-direction: column;
  gap: var(--homele-copy-gap);
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--homele-copy-pad);
  text-decoration: none;
  color: inherit;
}

.listing-similar-section .homele-copy:focus-visible {
  outline: 2px solid var(--w-gold);
  outline-offset: -2px;
}

.listing-similar-section .homele-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.listing-similar-section .homele-title {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: var(--homele-title-size);
  font-weight: 650;
  line-height: 1.35;
  color: #F4F1EA;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-similar-section .homele-pricebox { flex: none; text-align: end; }

.listing-similar-section .homele-price,
.listing-similar-section .homele-period,
.listing-similar-section .homele-loc {
  margin: 0;
}

.listing-similar-section .homele-price {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: var(--homele-price-size);
  font-weight: 700;
  line-height: 1.3;
  color: #F4F1EA;
  white-space: nowrap;
}

.listing-similar-section .homele-period {
  font-size: var(--homele-period-size);
  line-height: 1.3;
  color: #A8A29A;
}

.listing-similar-section .homele-loc {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 1.25em;
  min-width: 0;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: var(--homele-meta-size);
  line-height: 1.35;
  color: #A8A29A;
}

.listing-similar-section .homele-loc-ico {
  flex: none;
  display: inline-flex;
  opacity: 0.85;
}

.listing-similar-section .homele-loc-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-similar-section .homele-specs {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 18px;
  margin-top: auto;
  padding-top: 4px;
  color: #C8C2B8;
}

.listing-similar-section .homele-spec {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: var(--homele-meta-size);
  line-height: 1;
  white-space: nowrap;
}

.listing-similar-section .homele-spec svg { flex: none; opacity: 0.85; }

html[data-dg-theme="light"] .listing-similar-section .homele-card {
  background: #fff;
  border-color: rgba(47, 42, 38, 0.1);
  box-shadow: 0 14px 32px -20px rgba(47, 42, 38, 0.28);
  color: #1C1814;
}

html[data-dg-theme="light"] .listing-similar-section .homele-media { background: #F3EEE6; }
html[data-dg-theme="light"] .listing-similar-section .homele-title,
html[data-dg-theme="light"] .listing-similar-section .homele-price { color: #1C1814; }
html[data-dg-theme="light"] .listing-similar-section .homele-loc,
html[data-dg-theme="light"] .listing-similar-section .homele-period,
html[data-dg-theme="light"] .listing-similar-section .homele-specs { color: #6E6258; }
html[data-dg-theme="light"] .listing-similar-section .homele-fallback {
  color: #6E6258;
  background: #F6F1E8;
}
html[data-dg-theme="light"] .listing-similar-section .homele-badge {
  background: #e11d48;
  color: #fff;
}
