/* Mobile / iOS layout — safe areas, hamburger menu, image containment */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  padding: 12px 10px;
  position: relative;
  z-index: 120;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.nav-toggle span {
  display: block;
  height: 1.5px;
  background: var(--white, #fff);
  margin-bottom: 6px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s, background 0.3s;
  transform-origin: center;
}

.nav-toggle span:last-child { margin-bottom: 0; }

body.nav-open {
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 768px) {
  :root {
    --nav-h: 96px;
    --nav-logo-h: 76px;
    --nav-logo-h-scrolled: 76px;
  }

  html,
  body {
    overflow-x: hidden;
    max-width: 100%;
  }

  /* Do not force height:auto on the nav logo — that made it differ by page. */
  img:not(.nav-logo-img),
  video,
  iframe {
    max-width: 100%;
    height: auto;
  }

  /* Nav & logos */
  .nav {
    position: fixed;
    top: var(--safe-top);
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--nav-h);
    padding: 0 max(16px, var(--safe-right)) 0 max(16px, var(--safe-left));
    gap: 12px;
    background: rgba(28, 28, 26, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    /* Avoid backdrop-filter on mobile — traps position:fixed descendants. */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .nav-logo {
    flex-shrink: 0;
  }

  .nav-right {
    margin-left: auto;
    margin-right: 0;
    gap: 8px;
    order: 2;
  }

  .nav-toggle {
    order: 3;
  }

  .nav-logo {
    order: 1;
  }

  .nav-contact,
  .nav-cta {
    display: none;
  }

  .nav-right {
    --nav-chip-h: 36px;
  }

  .nav-weather {
    height: var(--nav-chip-h);
    padding: 0 10px;
    gap: 6px;
  }

  .nav-weather-icon,
  .nav-weather-icon svg {
    width: 18px;
    height: 18px;
  }

  .nav-weather-place {
    display: none;
  }

  .nav-weather-text {
    gap: 0;
  }

  .nav-weather-temp {
    font-size: 1rem;
  }

  .nav-links {
    order: 4;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    position: fixed;
    top: calc(var(--safe-top) + var(--nav-h));
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100dvh - var(--safe-top) - var(--nav-h));
    min-height: calc(100svh - var(--safe-top) - var(--nav-h));
    z-index: 110;
    margin: 0;
    padding: 12px max(20px, var(--safe-right)) calc(28px + var(--safe-bottom)) max(20px, var(--safe-left));
    background: rgba(28, 28, 26, 0.98);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
  }

  .nav.is-open .nav-links {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-links li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-links a {
    display: block;
    padding: 18px 4px;
    font-size: 0.95rem;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.92);
  }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
  }

  .nav.is-open .nav-toggle span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
  }

  .nav.is-open .nav-toggle span:nth-child(2) {
    opacity: 0;
  }

  .nav.is-open .nav-toggle span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
  }

  .nav.scrolled .nav-toggle span,
  .nav.is-open .nav-toggle span {
    background: #fff;
  }

  .footer-logo img {
    height: 96px;
    width: auto;
    max-width: 100%;
  }

  /* Hero background slideshow */
  .hero {
    min-height: 76svh;
    min-height: 76dvh;
    align-items: center;
    padding: calc(var(--nav-h) + var(--safe-top) + 24px) max(16px, var(--safe-right)) calc(36px + var(--safe-bottom)) max(16px, var(--safe-left));
  }

  /* TrustBar already clears the fixed nav — avoid a second nav-sized gap */
  .trust-bar + .hero {
    padding-top: calc(var(--safe-top) + 24px);
  }

  .hero-bg,
  .hero-slides,
  .hero-slide {
    overflow: hidden;
    max-width: 100%;
  }

  .hero-slide img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: cover;
    object-position: center center;
  }

  .hero-overlay {
    background: linear-gradient(
      to bottom,
      rgba(28, 28, 26, 0.5) 0%,
      rgba(28, 28, 26, 0.72) 45%,
      rgba(28, 28, 26, 0.92) 100%
    );
  }

  .hero-brand {
    font-size: clamp(2.1rem, 12vw, 2.8rem);
  }

  .hero h1 {
    font-size: clamp(1.35rem, 5.5vw, 1.7rem);
    max-width: none;
  }

  .hero-layout {
    gap: 12px;
  }

  .hero-cta-row {
    width: 100%;
  }

  .hero-cta,
  .hero-cta-ghost {
    flex: 1;
    text-align: center;
    min-height: 48px;
  }

  .mls-strip {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .mls-strip-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
  }

  .closed-deals-grid {
    grid-template-columns: 1fr;
  }

  /* Disable Ken Burns — scaled transforms are costly / overflow on phones */
  .editorial-image img,
  .editorial-feature-media img,
  .listing-image img,
  .prop-image img {
    animation: none !important;
    transform: none !important;
    will-change: auto;
  }

  .editorial-image {
    min-height: 0;
    aspect-ratio: 16 / 10;
    max-height: 260px;
    position: relative;
  }

  .editorial-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .listing-image {
    aspect-ratio: 16 / 10;
    max-height: 240px;
  }

  .listing-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .about-image {
    max-width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 10;
    position: relative;
  }

  .about-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  section {
    padding: clamp(48px, 8vw, 64px) max(16px, var(--safe-left));
    padding-right: max(16px, var(--safe-right));
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .editorial-body {
    padding: 28px 20px;
  }

  .contact-map,
  .contact-map iframe {
    min-height: 240px;
    width: 100%;
    max-width: 100%;
  }

  .page-header {
    padding: 20px max(16px, var(--safe-right)) 24px max(16px, var(--safe-left));
  }

  .page-header-layout {
    grid-template-columns: 1fr;
  }

  .trust-bar {
    margin-top: calc(var(--nav-h) + var(--safe-top));
  }

  /* Listings search */
  .prop-image {
    overflow: hidden;
    max-height: 220px;
  }

  .prop-image img {
    position: relative;
    width: 100%;
    height: 220px;
    max-height: 220px;
    min-height: 0;
    object-fit: cover;
  }

  .search-panel,
  .results-bar,
  .listings-wrap {
    padding-left: max(16px, var(--safe-left));
    padding-right: max(16px, var(--safe-right));
  }

  .search-grid {
    grid-template-columns: 1fr;
  }

  .prop-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }
}

@media (max-width: 480px) {
  :root {
    --nav-h: 84px;
    --nav-logo-h: 68px;
    --nav-logo-h-scrolled: 68px;
  }

  .hero h1 {
    font-size: clamp(1.85rem, 8.5vw, 2.4rem);
  }

  .editorial-image {
    max-height: 220px;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    .hero {
      /* Keep the intentional ~24% lift; avoid full-viewport fill-available */
      min-height: 76svh;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-links,
  .nav-toggle span {
    transition: none;
  }
}
