/* =========================================================
   CUTLER BAY PLUMBING
   HEADER AND NAVIGATION
   ========================================================= */

/* HEADER */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-inner {
  position: relative;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

/* LOGO */
.logo {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  text-decoration: none;
}

.site-logo {
  display: block;
  width: auto;
  height: 58px;
}

/* MAIN NAVIGATION */
.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--navy-dark);
  font-size: 15px;
  font-weight: 900;
}

.main-nav > a,
.nav-dropdown-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 0;
  color: var(--navy-dark);
  font: inherit;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.main-nav > a:hover,
.main-nav > a:focus-visible,
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle:focus-visible {
  color: var(--green);
}

/* UNDERLINE EFFECT */
.main-nav > a:not(.nav-cta)::after,
.nav-dropdown-toggle::after {
  position: absolute;
  right: 100%;
  bottom: 4px;
  left: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--green);
  content: "";
  transition: right 0.2s ease;
}

.main-nav > a:not(.nav-cta):hover::after,
.main-nav > a:not(.nav-cta):focus-visible::after,
.nav-dropdown-toggle:hover::after,
.nav-dropdown-toggle:focus-visible::after,
.nav-dropdown.is-open .nav-dropdown-toggle::after {
  right: 0;
}

/* CTA */
.nav-cta {
  padding: 13px 19px !important;
  border-radius: 999px;
  background: var(--blue);
  color: #fff !important;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.nav-cta:hover,
.nav-cta:focus-visible {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

/* DROPDOWNS */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.dropdown-arrow {
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.nav-dropdown.is-open .dropdown-arrow {
  margin-top: 4px;
  transform: rotate(225deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  z-index: 1001;
  width: max-content;
  min-width: 280px;
  max-width: 340px;
  padding: 10px;
  visibility: hidden;
  opacity: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(5, 35, 75, 0.18);
  transform: translate(-50%, 10px);
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    transform 0.2s ease;
}

.dropdown-menu::before {
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: 12px;
  content: "";
}

.dropdown-menu a {
  display: block;
  padding: 11px 14px;
  border-radius: 9px;
  color: var(--navy-dark);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  white-space: normal;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus-visible {
  background: rgba(29, 168, 125, 0.1);
  color: var(--green);
}

/* OPEN DROPDOWN */
.nav-dropdown:hover > .dropdown-menu,
.nav-dropdown:focus-within > .dropdown-menu,
.nav-dropdown.is-open > .dropdown-menu {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

/* MOBILE MENU BUTTON */
.mobile-menu-toggle {
  display: none;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  cursor: pointer;
}

.mobile-menu-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  margin: 5px 0;
  border-radius: 999px;
  background: #fff;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

/* HAMBURGER OPEN STATE */
.mobile-menu-toggle.is-open span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

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

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

/* =========================================================
   TABLET AND MOBILE
   ========================================================= */

@media (max-width: 1100px) {
  .header-inner {
    min-height: 82px;
  }

  .site-logo {
    height: 52px;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .main-nav {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: 0;
    z-index: 1000;
    display: none;
    max-height: calc(100vh - 110px);
    overflow-x: hidden;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav > a,
  .nav-dropdown-toggle {
    width: 100%;
    min-height: 52px;
    padding: 15px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .main-nav > a:not(.nav-cta)::after,
  .nav-dropdown-toggle::after {
    display: none;
  }

  .nav-dropdown-toggle {
    justify-content: space-between;
  }

  .nav-dropdown {
    width: 100%;
  }

/* Keep closed mobile dropdowns hidden */
.nav-dropdown:not(.is-open):hover > .dropdown-menu,
.nav-dropdown:not(.is-open):focus-within > .dropdown-menu {
  visibility: hidden;
  opacity: 0;
}

  .dropdown-menu {
    position: static;
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: 0;
    padding: 0 10px;
    visibility: hidden;
    overflow: hidden;
    opacity: 0;
    border: 0;
    border-radius: 0;
    background: #f6f9fc;
    box-shadow: none;
    transform: none;
    transition:
      max-height 0.3s ease,
      padding 0.3s ease,
      opacity 0.2s ease,
      visibility 0.2s ease;
  }

  .dropdown-menu::before {
    display: none;
  }

  .nav-dropdown.is-open > .dropdown-menu {
    max-height: 800px;
    padding: 8px 10px 12px;
    visibility: visible;
    opacity: 1;
    transform: none;
  }

  .dropdown-menu a {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(5, 35, 75, 0.08);
    border-radius: 7px;
  }

  .dropdown-menu a:last-child {
    border-bottom: 0;
  }

  .nav-cta {
    display: block !important;
    min-height: auto !important;
    margin: 12px 8px 8px;
    padding: 15px 18px !important;
    border-bottom: 0 !important;
    text-align: center !important;
  }
}

/* MOBILE */
@media (max-width: 768px) {
  .header-inner {
    min-height: 76px;
    gap: 14px;
  }

  .site-logo {
    max-width: calc(100vw - 100px);
    height: 46px;
  }

  .main-nav {
    top: calc(100% + 6px);
    right: 10px;
    left: 10px;
    max-height: calc(100vh - 94px);
  }
}

/* SMALL MOBILE */
@media (max-width: 420px) {
  .site-logo {
    height: 41px;
  }

  .mobile-menu-toggle {
    width: 43px;
    height: 43px;
    flex-basis: 43px;
  }
}