/* css/mobile.css
 *
 * Site-wide MOBILE rules (phones: 768px and below). Loaded on every page after nav.css (layouts/head.php). Desktop is untouched: every rule here
 * sits inside a max-width media query, or hides something that only exists for phones. Page-specific mobile layouts live next to their page's own
 * styles (home.css, search.css, listing-detail.css, comps.css).
 *
 *   1. Form controls: 16px, so iOS Safari does not zoom into a focused input/select/textarea.
 *   2. Footer: link groups collapse to tap-to-expand sections (layouts/footer.php: <details open>; js/mobile.js closes them on phones). The links
 *      stay in the HTML, so nothing is hidden from crawlers.
 *   3. Page padding for the sticky bars (listing page action bar, search map button): see the --mobile-bar-h variable set by those pages.
 */

/* ---- Spacing scale (8px base), used by every phone layout: 8 / 12 / 16 / 24 / 32.
   16 = page side gutter and the gap between a card's blocks, 12 = gap between cards (search grid, swipe rows, nearby) and under a section
   heading, 32 = gap between page sections. Pages read these as var(--sp-N, fallback). ---- */
:root {
  --sp-1: 8px;
  --sp-2: 12px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
}

/* ---- Footer groups: plain lists on desktop (the summary is only for phones) ---- */
.footer-details > summary {
  display: none;
}

@media (max-width: 768px) {
  /* 1. no iOS zoom-on-focus: every text-like control is at least 16px */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="file"]),
  select,
  textarea {
    font-size: 16px !important;
  }

  /* tap targets: at least 44px. Visually small controls get an invisible larger hit area. */
  .sr-save-btn::after {
    content: "";
    position: absolute;
    inset: -6px;
  }

  /* 44px hit area around the 32px hamburger lines (keeps nav.css's column layout) */
  .sn-hamburger {
    width: 44px;
    height: 44px;
    padding: 0 6px;
    box-sizing: border-box;
    margin-right: -6px;
  }

  .sr-pagination-page,
  .sr-pagination-arrow {
    min-width: 44px;
    height: 44px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .hp-section-cta,
  .sr-filters-actions select {
    min-height: 44px;
  }

  /* 2. Footer */
  .footer-dark {
    padding-top: 28px;
    padding-bottom: 8px;
  }

  .footer-wrapper .grid {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    padding-top: 0;
  }

  .footer-wrapper .grid .image-4,
  .footer-wrapper .grid .image-5 {
    width: auto;
    max-width: none;
    height: 40px;
    margin: 0;
  }

  .footer-content {
    width: 100%;
    margin-top: 20px;
    grid-row-gap: 0;
    justify-items: stretch;
  }

  .footer-details {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  }

  .footer-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0;
    font-size: 15px;
    font-weight: 700;
    color: #FFFFFF;
    cursor: pointer;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
  }

  .footer-details > summary::-webkit-details-marker {
    display: none;
  }

  .footer-details > summary::after {
    content: "";
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-right: 4px;
    border-right: 2px solid #FFFFFF;
    border-bottom: 2px solid #FFFFFF;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
  }

  .footer-details[open] > summary::after {
    transform: rotate(-135deg);
  }

  .footer-details .footer-block {
    align-items: flex-start;
    padding: 0 0 12px;
  }

  .footer-details .footer-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    margin: 0;
    font-size: 15px;
    line-height: 1.3;
  }

  /* the group's own first link repeats the summary text */
  .footer-details .footer-block > .footer-link:first-child strong {
    font-weight: 600;
  }

  .footer-social-block {
    display: flex;
    margin: 8px 0 0;
  }

  .footer-social-link {
    margin-left: 0;
    margin-right: 20px;
  }

  /* "Homes for Sale by Area": the summary replaces the inline label, the links stack */
  .footer-details.footer-areas {
    margin-top: 0 !important;
    text-align: left !important;
    line-height: 1.4 !important;
  }

  .footer-areas .footer-areas-label {
    display: none;
  }

  .footer-areas .footer-link {
    display: flex !important;
    margin: 0 !important;
  }

  .flex {
    padding: 14px 16px;
    gap: 8px 16px;
    font-size: 13px;
    line-height: 1.4;
  }

  /* pages with a sticky bottom bar (listing page): the last footer line stays reachable */
  body.has-sticky-bar .flex {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---- sticky contact bar: listing page and comps page (views/listing-detail.php, views/comps.php) ----
   "Request a Showing" | Call | Chat. Chat opens the Tawk.to widget (js/mobile.js hides its own bubble on these pages). */
.ld-action-bar { display: none; }

@media (max-width: 768px) {
  .ld-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: flex;
    gap: var(--sp-1, 8px);
    padding: var(--sp-1, 8px) var(--wrap-gutter, 16px) calc(var(--sp-1, 8px) + env(safe-area-inset-bottom, 0px));
    background: #FFFFFF;
    border-top: 1px solid #E2E7EE;
    box-shadow: 0 -2px 10px rgba(18, 35, 61, 0.08);
  }

  .ld-action-bar-showing {
    flex: 1 1 auto;
    min-width: 0;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border: none;
    border-radius: 10px;
    background: #1E40AF;
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }

  .ld-action-bar-call,
  .ld-action-bar-chat {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 48px;
    padding: 0 12px;
    box-sizing: border-box;
    border: 2px solid #1E40AF;
    border-radius: 10px;
    background: #FFFFFF;
    color: #1E40AF;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
  }

  .ld-action-bar-call svg,
  .ld-action-bar-chat svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
  }

  /* the reCAPTCHA badge (fixed, bottom right) rides above the bar instead of covering it */
  body.has-sticky-bar .grecaptcha-badge {
    bottom: 84px !important;
  }
}

@media print {
  .ld-action-bar { display: none !important; }
}
