/* =========================
   Header / Nav
========================= */

body.has-mobile-menu {
  overflow: hidden;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  min-height: 78px;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
}

.nav__brandLogo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
}

.site-header .nav__logoImg {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: block;
}

.nav__logoFallback {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 11px;
  letter-spacing: 0.09em;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, #2b639e 100%);
}

.nav__brandText {
  font-family: var(--font-display);
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--primary-strong);
}

.nav__center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.nav__menu {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav__menu li {
  position: relative;
}

.nav__menu a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 999px;
  color: #0f2744;
  font-size: 0.95rem;
  font-weight: 560;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav__menu a:hover {
  background: rgba(21, 52, 91, 0.08);
}

.nav__menu .current-menu-item > a,
.nav__menu .current-menu-parent > a,
.nav__menu .current-menu-ancestor > a {
  background: rgba(21, 52, 91, 0.13);
}

.nav__menu .menu-item-has-children > a::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transform-origin: center;
  opacity: 0.75;
  transition: transform 0.18s ease;
}

.nav__menu li.is-open > a::after,
.nav__menu li:hover > a::after,
.nav__menu li:focus-within > a::after {
  transform: rotate(-135deg) translateY(0);
}

.nav__menu .sub-menu {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  z-index: 999;
  min-width: 242px;
  list-style: none;
  margin: 0;
  padding: 9px;
  border-radius: 14px;
  border: 1px solid rgba(15, 39, 68, 0.1);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-md);
  display: none;
}

.nav__menu > li:last-child > .sub-menu {
  left: 0;
  right: auto;
}

.nav__menu > li.menu-item-has-children:last-of-type > .sub-menu {
  left: 0;
  right: auto;
}

.nav__menu .sub-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

.nav__menu .sub-menu a {
  display: block;
  border-radius: 9px;
}

.nav__menu li:hover > .sub-menu,
.nav__menu li:focus-within > .sub-menu,
.nav__menu li.is-open > .sub-menu {
  display: block;
}

.nav__right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav__right .btn {
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s ease, box-shadow 0.2s ease;
}

.nav__right .btn:hover {
  transform: scale(1.04);
}

.nav__login {
  color: #102845;
  font-weight: 560;
  font-size: 0.94rem;
  opacity: 0.9;
  transition: opacity 0.18s ease;
}

.nav__login:hover {
  opacity: 1;
}

.nav__toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(15, 39, 68, 0.14);
  background: #ffffff;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.nav__toggle span {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: #163961;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav.is-mobile-open .nav__toggle span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav.is-mobile-open .nav__toggle span:nth-child(2) {
  opacity: 0;
}

.nav.is-mobile-open .nav__toggle span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 980px) {
  .nav {
    min-height: 72px;
  }

  .nav__toggle {
    display: inline-flex;
    position: relative;
    z-index: 1502;
  }

  .nav__center {
    position: fixed;
    inset: 0;
    display: grid;
    justify-items: start;
    align-items: start;
    padding: 84px 14px 14px;
    background: rgba(9, 19, 33, 0.52);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    z-index: 1500;
  }

  .nav.is-mobile-open .nav__center {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .nav__menu {
    width: min(100%, 380px);
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 18px 12px 16px;
    border: 1px solid rgba(15, 39, 68, 0.09);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: var(--shadow-md);
    transform: translateX(-16px);
    transition: transform 0.22s ease;
    /* Keep the panel compact; scroll only if it exceeds the viewport. */
    max-height: calc(100dvh - 84px - 14px);
    overflow: auto;
  }

  .nav.is-mobile-open .nav__menu {
    transform: translateX(0);
  }

  .nav__menu a {
    justify-content: space-between;
    border-radius: 12px;
    padding: 12px 12px;
    font-size: 0.97rem;
  }

  .nav__menu .sub-menu {
    position: static;
    min-width: 0;
    margin-top: 4px;
    padding: 5px 0 6px 10px;
    border: 0;
    border-left: 1px solid rgba(15, 39, 68, 0.13);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    display: none;
  }

  /* On touch widths, avoid "sticky hover" causing accidental expansions. */
  .nav__menu li:hover > .sub-menu,
  .nav__menu li:focus-within > .sub-menu {
    display: none;
  }

  .nav__menu li.is-open > .sub-menu {
    display: block;
  }

  .nav__menu .sub-menu::before {
    display: none;
  }

  .nav__menu .sub-menu a {
    font-size: 0.92rem;
    border-radius: 9px;
  }

  .nav__menu > li > a {
    font-weight: 640;
  }

  .nav__right .btn {
    padding: 10px 14px;
  }

  .nav__right .nav__login {
    display: none;
  }
}

@media (max-width: 620px) {
  .nav__brandText {
    max-width: 17ch;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav__right .btn {
    display: none;
  }
}
