/**
 * Layout stability — mobile list/map, sticky CTA, alert form, reviews overflow.
 * Load last. v20260581
 */

body.site-zillow {
  overflow-x: hidden;
}

[hidden],
.hidden {
  display: none !important;
}

/* —— Mobile: natural page scroll for listings (no empty flex panel) —— */
@media (max-width: 768px) {
  .results-wrapper,
  .results-panel,
  .list-view,
  .map-view {
    min-height: 0 !important;
  }

  .site-premium #homes-explorer.zillow-explorer,
  .zillow-explorer.results-panel {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible;
  }

  .zillow-explorer:not(.show-map-mobile) .zillow-map-col.map-view {
    display: none !important;
  }

  .zillow-explorer.show-map-mobile .zillow-list-col.list-view {
    display: none !important;
  }

  .zillow-explorer.show-map-mobile {
    max-height: none !important;
  }

  .zillow-explorer.show-map-mobile .zillow-map-col.map-view {
    display: block !important;
    position: relative;
    height: min(42vh, 320px);
    min-height: 220px;
    max-height: min(42vh, 320px);
  }

  .zillow-explorer.show-map-mobile .zillow-map-col .homes-map {
    position: absolute;
    inset: 0;
    height: 100%;
    min-height: 220px;
  }

  .zillow-list-col.list-view {
    display: flex;
    flex-direction: column;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible;
    border: none;
  }

  .list-view {
    height: auto !important;
  }

  .site-premium .homes-list--zillow {
    flex: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }

  .site-premium .homes-list-more {
    flex-shrink: 0;
    margin: 0.35rem 0.45rem 0.65rem;
    width: calc(100% - 0.9rem);
    align-self: stretch;
  }

  .zillow-card {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100%;
    min-height: 0;
  }

  .zillow-card-body {
    display: flex !important;
    flex-direction: column;
    visibility: visible;
    opacity: 1;
  }

  .zillow-card-address {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  /* Reviews: horizontal scroll contained */
  .reviews-compact .container {
    overflow-x: hidden;
    max-width: 100%;
  }

  .reviews-wall--three {
    overflow: hidden;
    max-width: 100%;
  }

  .reviews-wall--three .reviews-wall-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 0.6rem;
    padding: 0 0.15rem 0.35rem;
    margin: 0;
    max-width: 100%;
  }

  .reviews-wall--three .review-card {
    flex: 0 0 min(82vw, 280px);
    scroll-snap-align: start;
    min-width: 0;
  }

  /* Sticky CTA clearance — listing-cards-mobile.css sets final values */

  body.has-expert-cta main {
    padding-bottom: 0.5rem;
  }

  body.lead-modal-open .expert-cta-bar {
    display: none !important;
  }
}

/* —— Desktop: compact alert form (no giant white card) —— */
@media (min-width: 769px) {
  .lead-capture-band--promo {
    padding: 1.65rem 0 2rem;
  }

  .listing-alerts-promo {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(400px, 560px);
    max-width: 1100px;
  }

  .listing-alerts-promo__form {
    align-self: start;
    height: auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
  }

  .home-lead-form--promo,
  .alert-form-card,
  .lead-form-card,
  .form-wrapper {
    height: auto !important;
    min-height: 0 !important;
    max-height: none;
    min-width: 380px;
    max-width: 560px;
    width: 100%;
    margin: 0;
    align-self: start;
  }

  .home-lead-form--promo .btn-gold,
  .home-lead-form--promo .btn-outline-navy,
  .home-lead-form--promo #home-lead-next {
    width: 100%;
    font-size: 0.95rem;
    padding: 0.65rem 1rem;
  }

  body.has-expert-cta {
    padding-bottom: calc(3.25rem + env(safe-area-inset-bottom, 0px));
  }

  .expert-cta-bar {
    padding: 0.4rem 0.75rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  }

  .expert-cta-bar__primary {
    font-size: 0.88rem;
    padding: 0.55rem 0.85rem;
  }

  .expert-cta-bar__icon {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1rem;
  }
}

/* —— Featured carousel (Zillow-style) + list pagination —— */
.featured-band--carousel {
  padding: 1rem 0 1.1rem;
  border-bottom: 1px solid var(--zillow-border, #d1d5db);
  background: var(--white, #fff);
}

.featured-band--carousel h2 {
  font-size: 1.05rem;
  margin: 0 0 0.2rem;
}

.featured-band--carousel .section-sub {
  font-size: 0.8rem;
  margin: 0 0 0.55rem;
  color: var(--text-muted, #5c6570);
}

.featured-carousel {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0 0.35rem;
  scrollbar-width: thin;
}

/* Mobile carousel card width — listing-cards-mobile.css */

@media (min-width: 769px) {
  .featured-carousel > * {
    flex: 0 0 248px;
    scroll-snap-align: start;
  }
}

.homes-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-top: 1rem;
  background: #fff;
  border: 1px solid var(--zillow-border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(7, 21, 38, 0.06);
  position: relative;
  z-index: 6;
  pointer-events: auto;
}

.homes-pagination .homes-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.55rem 1.2rem;
  margin: 0;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  border-radius: 999px;
  border: 1px solid #c5cad1;
  background: #fff;
  color: var(--navy, #071526);
  cursor: pointer;
  box-shadow: none;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.homes-pagination .homes-page-btn__icon {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.85;
}

.homes-pagination .homes-page-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--gold, #c9a24d);
  background: #fafbfc;
  box-shadow: 0 4px 14px rgba(7, 21, 38, 0.1);
  color: var(--navy, #071526);
}

.homes-pagination .homes-page-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(7, 21, 38, 0.08);
}

.homes-pagination .homes-page-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  border-color: #e5e7eb;
  background: #f3f4f6;
  color: #9ca3af;
}

.homes-page-status {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  padding: 0 0.5rem;
}

.homes-page-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  line-height: 1.3;
}

.homes-page-info__pages {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--navy, #071526);
  letter-spacing: -0.01em;
}

.homes-page-info__range {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted, #6b7280);
}

@media (max-width: 520px) {
  .homes-pagination {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .homes-pagination .homes-page-btn {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 7.5rem;
  }

  .homes-page-status {
    flex: 1 1 100%;
    order: -1;
    padding-bottom: 0.15rem;
  }
}
