/* Listing gallery — carousel + square thumb grid (Zaki-style) */

.listing-gallery {
  margin: 0;
  min-width: 0;
  container-type: inline-size;
  container-name: listing-gallery;
}

.listing-gallery-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #1e2733;
  border-radius: 12px;
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.14));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.listing-gallery-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #141b24;
}

.listing-gallery-photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center;
  margin: 0 !important;
  background: #141b24;
  opacity: 0;
  transform: scale(1.06);
  transition:
    opacity 0.65s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
  z-index: 1;
}

.listing-gallery-photo.is-visible {
  opacity: 1;
  transform: scale(1);
  z-index: 2;
}

.listing-gallery-stage.is-paused .listing-gallery-progress {
  animation-play-state: paused;
}

.listing-gallery-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  z-index: 4;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--accent, #00ff9d), #00d4ff);
  box-shadow: 0 0 12px rgba(0, 255, 157, 0.45);
  pointer-events: none;
}

.listing-gallery-progress.is-running {
  width: 0;
  animation: listing-gallery-progress var(--gallery-autoplay-ms, 5000ms) linear forwards;
}

.listing-gallery-progress:not(.is-running) {
  width: 0;
}

@keyframes listing-gallery-progress {
  from { width: 0%; }
  to { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .listing-gallery-photo {
    transition: opacity 0.2s ease;
    transform: none;
  }

  .listing-gallery-photo.is-visible {
    transform: none;
  }

  .listing-gallery-progress {
    display: none;
  }
}

.listing-gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #1a2330;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.listing-gallery-arrow--prev {
  left: 12px;
}

.listing-gallery-arrow--next {
  right: 12px;
}

.listing-gallery-arrow:hover {
  background: #fff;
}

.listing-gallery-counter {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.75rem;
  font-family: var(--mono, ui-monospace, monospace);
  z-index: 3;
  pointer-events: none;
}

.listing-gallery-thumbs {
  --thumb-cols: 5;
  display: grid;
  grid-template-columns: repeat(var(--thumb-cols), minmax(0, 1fr));
  grid-auto-rows: auto;
  align-content: start;
  gap: 6px;
  margin-top: 10px;
  padding: 8px;
  max-height: 248px;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.14));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@container listing-gallery (min-width: 300px) {
  .listing-gallery-thumbs {
    --thumb-cols: 6;
  }
}

@container listing-gallery (min-width: 360px) {
  .listing-gallery-thumbs {
    --thumb-cols: 7;
  }
}

.listing-gallery-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #0f141c;
}

.listing-gallery-thumb:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.listing-gallery-thumb.is-active,
.listing-gallery-thumb.active {
  border-color: var(--accent, #00ff9d);
}

.listing-gallery-thumb.is-broken {
  display: none;
}

.listing-gallery-thumb-img,
.listing-gallery-thumb img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  min-width: 0;
  min-height: 0;
  max-width: none !important;
  object-fit: cover !important;
  pointer-events: none;
}

.listing-gallery-stage--empty {
  aspect-ratio: 4 / 3;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(180deg, #1a2330 0%, #121820 100%);
}

.listing-gallery-stage--empty .listing-gallery-photo {
  object-fit: contain !important;
  width: auto !important;
  height: auto !important;
  max-width: 72px !important;
  max-height: 72px !important;
  opacity: 0.35;
  margin-bottom: 8px !important;
}

.listing-gallery-empty {
  margin: 0;
  padding: 0 16px 16px;
  max-width: 240px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted, #8b9cb3);
}

/* Workspace split layout lives in ui-polish.css (container queries) */

@media (max-width: 599px) {
  .listing-gallery-arrow {
    width: 34px;
    height: 34px;
    font-size: 1.15rem;
  }
}
