/* Costa Rica Relocation Group — Mobile navigation v3
   Purpose: make the closed menu completely absent from layout on iOS/Safari
   and use a stable dropdown panel anchored below the sticky header. */

@media screen and (max-width: 768px) {
  /* Never allow the closed navigation to take up space or leak links. */
  .site-header .main-nav:not(.open) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Open state: simple panel below the sticky header. Avoid fixed + transform
     inside a backdrop-filtered sticky header, which is unreliable on iOS. */
  .site-header .main-nav.open {
    display: flex !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    max-height: calc(100vh - var(--header-height)) !important;
    max-height: calc(100dvh - var(--header-height)) !important;
    margin: 0 !important;
    padding: 0.75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)) !important;
    background: #FFFFFF !important;
    border-top: 1px solid var(--color-border) !important;
    border-left: 0 !important;
    box-shadow: 0 14px 28px rgba(15, 34, 56, 0.16) !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: none !important;
    z-index: 1100 !important;
  }

  .site-header .main-nav.open > .nav-link,
  .site-header .main-nav.open > .nav-dropdown {
    width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
  }

  .site-header .main-nav.open > .nav-link,
  .site-header .main-nav.open .nav-dropdown > .dropdown-trigger {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-height: 52px !important;
    padding: 0.8rem 0.25rem !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--color-border) !important;
    font-size: 1rem !important;
    font-weight: 650 !important;
    line-height: 1.25 !important;
    color: var(--color-primary) !important;
    text-decoration: none !important;
  }

  .site-header .main-nav.open > .nav-link::after,
  .site-header .main-nav.open .nav-dropdown > .dropdown-trigger::after {
    display: none !important;
  }

  .site-header .main-nav.open > .nav-link.active {
    color: var(--color-accent) !important;
  }

  .site-header .main-nav.open .dropdown-menu {
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0.35rem 0 0.6rem 0.75rem !important;
    background: var(--color-bg-alt) !important;
    border: 0 !important;
    border-bottom: 1px solid var(--color-border) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: none !important;
  }

  .site-header .main-nav.open .nav-dropdown.active > .dropdown-menu {
    display: block !important;
  }

  .site-header .main-nav.open .dropdown-item {
    display: block !important;
    padding: 0.72rem 0.6rem !important;
    font-size: 0.92rem !important;
    line-height: 1.35 !important;
  }

  /* Keep the hamburger above the open panel and turn it into an X. */
  .mobile-toggle {
    position: relative !important;
    z-index: 1101 !important;
  }

  .mobile-toggle.is-open svg {
    display: none !important;
  }

  .mobile-toggle.is-open::before {
    content: '×' !important;
    display: block !important;
    font-size: 2rem !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    color: var(--color-primary) !important;
  }

  body.mobile-menu-open {
    overflow: hidden !important;
  }

  body.mobile-menu-open::before {
    content: '';
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 34, 56, 0.38);
    z-index: 900;
  }

  body.mobile-menu-open .mobile-sticky-bar {
    opacity: 0 !important;
    pointer-events: none !important;
  }
}
