/**
 * PropGlen MOBILE-UX-CONSISTENCY-01
 * Targeted mobile spacing, glass-nav coexistence, Actions sheet, map clearance.
 * Does not redesign frozen Agents Directory / Agent Profile chrome.
 */

/* —— Shared mobile tokens —— */
@media (max-width: 900px) {
  :root {
    --pg-ux01-nav-h: 72px;
    --pg-ux01-nav-inset: calc(8px + env(safe-area-inset-bottom, 0px));
    --pg-ux01-nav-clearance: calc(var(--pg-ux01-nav-h) + var(--pg-ux01-nav-inset) + 10px);
    --pg-ux01-detail-cta-h: 64px;
  }

  /* Never raise bottom nav above native dialogs / sheets */
  .mobile-app-nav {
    z-index: 35;
  }

  dialog[open],
  .detail-quick-actions-dialog[open],
  .detail-enquiry-dialog[open] {
    z-index: 80;
  }

  body:has(dialog[open]) .mobile-app-nav,
  body:has(dialog[open]) .detail-mobile-cta {
    pointer-events: none;
  }
}

/* —— Detail: keep glass nav + stack sticky CTA above it —— */
@media (max-width: 959px) {
  body.listing-detail-page.has-detail-mobile-cta .mobile-app-nav {
    display: grid !important;
  }

  body.listing-detail-page.has-detail-mobile-cta .detail-mobile-cta {
    bottom: var(--pg-ux01-nav-clearance, var(--mobile-nav-clearance, 90px));
    padding-bottom: 10px;
    z-index: 36;
  }

  body.listing-detail-page.has-detail-mobile-cta {
    padding-bottom: calc(
      var(--pg-ux01-detail-cta-h, 64px) + var(--pg-ux01-nav-clearance, 90px)
    ) !important;
  }

  body.listing-detail-page.has-detail-mobile-cta .site-footer {
    padding-bottom: calc(
      var(--pg-ux01-detail-cta-h, 64px) + var(--pg-ux01-nav-clearance, 90px) + 16px
    );
  }

  /* Location map: keep attribution / controls above bottom chrome */
  body.listing-detail-page #detail-location,
  body.listing-detail-page .detail-location,
  body.listing-detail-page [data-detail-location] {
    scroll-margin-bottom: calc(
      var(--pg-ux01-detail-cta-h, 64px) + var(--pg-ux01-nav-clearance, 90px) + 16px
    );
  }

  body.listing-detail-page .leaflet-bottom,
  body.listing-detail-page .leaflet-control-attribution,
  body.listing-detail-page .detail-map-attribution,
  body.listing-detail-page .map-attribution {
    margin-bottom: 8px;
    padding-bottom: 2px;
  }

  body.listing-detail-page .leaflet-bottom.leaflet-right,
  body.listing-detail-page .leaflet-control-zoom {
    margin-bottom: 12px;
  }
}

/* —— Actions sheet: visible Close text —— */
.detail-quick-actions-close {
  width: auto;
  min-width: 44px;
  min-height: 44px;
  height: auto;
  padding: 0 14px;
  gap: 6px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 650;
}

.detail-quick-actions-close__x {
  font-size: 1.15rem;
  line-height: 1;
}

.detail-quick-actions-close__label {
  letter-spacing: 0.01em;
}

.detail-quick-actions-sheet {
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* —— Rent discovery toolbar: reduce crowding 320–430 —— */
@media (max-width: 430px) {
  .bayut-serp__toolbar {
    min-height: 0;
    gap: 8px;
    padding: 10px 10px 12px;
  }

  .bayut-serp__count {
    min-height: 0;
    padding-bottom: 6px;
    font-size: 0.9rem;
  }

  .bayut-serp__toolbar-actions {
    display: grid;
    /* Row 1: Saved + Sort · Row 2: List/Grid/Map full width — avoids R…/L… truncation */
    grid-template-columns: minmax(5.5rem, auto) minmax(0, 1fr);
    grid-template-areas:
      "saved sort"
      "views views";
    align-items: center;
    gap: 8px;
    margin-top: 0;
    min-height: 0;
  }

  .bayut-serp__toolbar-actions .bayut-saved-chip {
    grid-area: saved;
    max-width: none;
    justify-self: start;
    min-height: 44px;
    height: 44px;
    padding: 0 12px;
  }

  .bayut-serp__toolbar-actions .bayut-sort.filter-select {
    grid-area: sort;
    max-width: none;
    width: 100%;
    min-height: 44px;
    height: 44px;
  }

  .bayut-serp__toolbar-actions .bayut-view-toggle {
    grid-area: views;
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bayut-serp__toolbar-actions .bayut-view-toggle__btn {
    min-height: 44px;
    height: 44px;
    padding-inline: 6px;
    font-size: 0.8rem;
  }

  /* Keep sticky Filters clear of glass nav */
  .bayut-serp-page .bayut-filter-bar.is-stuck,
  .bayut-serp-page .bayut-filters.is-stuck {
    bottom: var(--pg-ux01-nav-clearance, var(--mobile-nav-clearance, 90px));
  }

  .bayut-serp__results {
    padding-bottom: 8px;
  }
}

@media (max-width: 360px) {
  .bayut-serp__toolbar-actions {
    grid-template-columns: 1fr;
    grid-template-areas:
      "saved"
      "sort"
      "views";
    gap: 8px;
  }

  .bayut-serp__toolbar-actions .bayut-saved-chip,
  .bayut-serp__toolbar .bayut-sort.filter-select,
  .bayut-serp__toolbar-actions .bayut-view-toggle {
    width: 100%;
    max-width: none;
  }
}

/* —— Homepage mobile spacing —— */
@media (max-width: 430px) {
  body.home-body .section,
  body.pg-home .section {
    padding-top: 40px;
    padding-bottom: 40px;
  }

  body.home-body .compact-section,
  body.pg-home .compact-section {
    padding-top: 28px;
    padding-bottom: 28px;
  }

  body.home-body main,
  body.pg-home main,
  body.home-body .site-footer,
  body.pg-home .site-footer {
    padding-bottom: calc(var(--pg-ux01-nav-clearance, 90px) + 8px);
  }

  body.home-body .hero,
  body.pg-home .hero,
  body.home-body .home-hero,
  body.pg-home .home-hero {
    padding-bottom: 1.25rem;
  }
}

/* —— Map page: glass nav clearance —— */
@media (max-width: 900px) {
  body.map-body .map-shell,
  body.map-page .map-shell,
  .unified-map-page .map-frame,
  .map-page #map,
  .map-body #map {
    padding-bottom: 0;
  }

  body.map-body .leaflet-bottom,
  body.map-page .leaflet-bottom,
  .unified-map-page .leaflet-bottom {
    margin-bottom: calc(var(--pg-ux01-nav-clearance, 90px) + 4px);
  }

  body.map-body .site-footer,
  body.map-page .site-footer {
    padding-bottom: calc(var(--pg-ux01-nav-clearance, 90px) + 12px);
  }
}

/* —— Agent Portal CTA remains visible in burger (staging uses /for-agents/) —— */
.nav-agent-login {
  min-height: 44px;
}

/* —— for-agents / for-developers holding pages —— */
.for-agents-page .content-card,
.for-developers-page .content-card {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.25rem 1.2rem 1.4rem;
}

.for-agents-page .button-group,
.for-developers-page .button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.nav-developer-reg {
  min-height: 44px;
}
