/* ═══════════════════════════════════════════════════════════
   CHILD / DROPDOWN MENU
   Append to style.css. Built to sit alongside the existing
   .nav / .nav__links / #0f766e teal + mint-button aesthetic.
   ═══════════════════════════════════════════════════════════ */

.nav__links {
  display: flex;
  align-items: center;
  gap: 2rem;
}

/* !important here is intentional: another stylesheet (pages.css, styles.css,
   service.css, etc.) may set `.nav li { position: static }` or similar with
   higher specificity, which strips position:relative from a nested <li>.
   When that happens, that item's own absolute-positioned child dropdown has
   no positioned ancestor to anchor to nearby, so the browser walks up the
   DOM until it finds one — usually the sticky header — and the dropdown
   renders detached way up at the top of the page instead of next to its
   parent item. Forcing this at every depth guarantees it can't happen. */
#navLinks .menu-item,
#navLinks .menu-item .menu-item {
  position: relative !important;
  list-style: none;
}

/* Invisible hover bridge: fills the visual gap between the link and the
   dropdown card below it, so the mouse never leaves a hoverable area while
   travelling down to the submenu. Without this, :hover is lost the instant
   the cursor exits the link, and the dropdown closes before you can reach it. */
.menu-item-has-children::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: max(100%, 230px); /* match .sub-menu's min-width so it sits directly under the card */
  height: 16px;            /* must match the gap set in .sub-menu's "top" value below */
}

/* Top-level links */
.nav__links > .menu-item > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  color: #1f2937;
  text-decoration: none;
  padding: 10px 2px;
  transition: color .2s ease;
}

.nav__links > .menu-item > a:hover,
.nav__links > .menu-item:hover > a,
.nav__links > .menu-item:focus-within > a {
  color: #0f766e;
}

/* Chevron, inserted by nav-dropdown.js only on items that have children */
.submenu-toggle {
  display: inline-flex;
  color: #0f766e;
  transition: transform .25s ease;
}

.menu-item-has-children:hover > a .submenu-toggle,
.menu-item-has-children:focus-within > a .submenu-toggle,
.menu-item-has-children.is-open > a .submenu-toggle {
  transform: rotate(180deg);
}

/* ── Dropdown panel ── */
.sub-menu {
  position: absolute;
  top: calc(100% + 16px);
  left: 50%;
  transform: translate(-50%, 8px);
  min-width: 230px;
  margin: 0;
  padding: 10px;
  list-style: none;
  background: #ffffff;
  border-radius: 14px;
  border-top: 3px solid #0f766e;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .14), 0 2px 8px rgba(15, 23, 42, .06);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
  z-index: 60;
}

/* little pointer triangle */
.sub-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}

.menu-item-has-children:hover > .sub-menu,
.menu-item-has-children:focus-within > .sub-menu,
.menu-item-has-children.is-open > .sub-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
  transition: opacity .22s ease, transform .22s ease;
}

.sub-menu .menu-item a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.sub-menu .menu-item a:hover,
.sub-menu .menu-item a:focus {
  background: #f0fdfa;
  color: #0f766e;
  transform: translateX(3px);
}

/* Grandchild dropdowns (if you ever go 3 levels deep) open to the side */
.sub-menu .sub-menu {
  top: -10px;
  left: 100%;
  transform: translate(8px, 0);
}
.sub-menu .menu-item-has-children:hover > .sub-menu,
.sub-menu .menu-item-has-children.is-open > .sub-menu {
  transform: translate(0, 0);
}

/* ═══════════════ MOBILE (accordion, tap to expand) ═══════════════ */
@media (max-width: 880px) {
  .nav__links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .nav__links .menu-item {
    border-bottom: 1px solid rgba(15, 23, 42, .06);
  }

  .nav__links > .menu-item > a {
    justify-content: space-between;
    width: 100%;
    padding: 14px 4px;
  }

  .sub-menu,
  .sub-menu .sub-menu {
    position: static;
    left: auto;
    top: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    box-shadow: none;
    border-top: none;
    border-radius: 0;
    padding: 0 0 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
  }

  .sub-menu::before { display: none; }

  .menu-item-has-children.is-open > .sub-menu {
    max-height: 600px;
  }

  .sub-menu .menu-item a {
    padding: 12px 8px;
  }
}