/**
 * Primary masthead navigation — depends on :root in styles.css.
 */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-masthead {
  transition: box-shadow 0.22s ease;
}

.site-masthead.is-scrolled {
  box-shadow: 0 10px 36px rgba(13, 94, 168, 0.14);
}

.site-header {
  background: var(--nav-bar-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 30;
}

.site-nav {
  background: transparent;
}

/* Desktop: one row — Call Us | Logo | links + CTA (cluster) | Social */
.nav-shell {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(10px, 1.8vw, 22px);
  min-height: 88px;
  padding: 18px 0;
  position: relative;
}

.nav-call {
  order: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--nav-bar-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  transition: background 0.15s ease;
  white-space: nowrap;
}

.nav-call:hover {
  color: var(--nav-bar-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.2);
}

.site-masthead .nav-call {
  text-decoration: none;
}

.header-logo-link {
  order: 2;
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo-link:hover {
  text-decoration: none;
  opacity: 0.94;
}

body .site-masthead .site-header img.header-logo,
body .site-header img.header-logo {
  display: block;
  width: auto;
  height: auto;
  max-height: 64px;
  max-width: min(280px, 44vw);
  object-fit: contain;
  object-position: center center;
}

.nav-toggle {
  order: 5;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--nav-bar-text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-nav.is-open .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-nav.is-open .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.site-nav.is-open .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-social {
  order: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.nav-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--nav-bar-text);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-social-link:hover {
  color: var(--nav-bar-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.55);
}

.nav-social-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.nav-cluster {
  order: 3;
  flex: 1;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 20px);
  min-width: 0;
  overflow: visible;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 4px 6px;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  /* overflow must stay visible or dropdown panels are clipped (no bar under nav) */
  overflow: visible;
}

.nav-menu > li > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--nav-bar-text);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-menu > li > a:hover {
  color: var(--nav-bar-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.14);
}

.nav-menu > li > a.active {
  color: var(--nav-bar-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

a.nav-dropdown-parent {
  cursor: pointer;
}

.has-dropdown > a::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.85;
  margin-top: 2px;
}

.has-dropdown {
  position: relative;
  z-index: 1;
}

.has-dropdown:hover,
.has-dropdown:focus-within {
  z-index: 60;
}

.has-dropdown:hover > a,
.has-dropdown:focus-within > a {
  background: rgba(255, 255, 255, 0.14);
}

.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  min-width: 240px;
  margin: 0;
  margin-top: 2px;
  padding: 10px;
  list-style: none;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(13, 94, 168, 0.14), 0 4px 14px rgba(0, 0, 0, 0.06);
}

/* Invisible hit area so moving from the parent link into the panel does not lose :hover */
.dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 14px;
}

.has-dropdown:hover .dropdown,
.has-dropdown:focus-within .dropdown {
  display: block;
}

.dropdown li {
  margin: 0;
}

.dropdown li a {
  display: block;
  padding: 11px 14px;
  margin: 2px 0;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.dropdown li a:hover {
  color: var(--primary);
  text-decoration: none;
  background: #eef6ff;
}

.dropdown-wide {
  min-width: 300px;
}

.dropdown-wide li a {
  white-space: nowrap;
}

.header-cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--primary);
  background: var(--white);
  border: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.06), 0 8px 22px rgba(0, 0, 0, 0.1);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
}

.header-cta:hover {
  color: var(--primary);
  text-decoration: none;
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.05), 0 12px 28px rgba(0, 0, 0, 0.12);
}

.site-masthead .site-header a.header-cta {
  text-decoration: none;
}

@media (max-width: 1024px) {
  .nav-shell {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 12px;
    min-height: unset;
    padding: 14px 0 18px;
  }

  .nav-social {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    order: unset;
  }

  .nav-call {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    order: unset;
    max-width: 100%;
  }

  .nav-toggle {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    display: flex;
    order: unset;
  }

  .header-logo-link {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    order: unset;
    width: 100%;
    justify-content: center;
  }

  .nav-cluster {
    grid-column: 1 / -1;
    grid-row: 3;
    order: unset;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
  }

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

  .nav-menu {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex: none;
    overflow: visible;
    gap: 4px;
    width: 100%;
  }

  .nav-menu > li > a {
    width: 100%;
    justify-content: flex-start;
    border-radius: 12px;
    padding: 12px 14px;
    white-space: normal;
  }

  .has-dropdown > a::after {
    margin-left: auto;
  }

  .dropdown::before {
    display: none;
  }

  /* Ignore desktop hover/focus open on touch widths — only .is-open toggles */
  .has-dropdown:hover .dropdown,
  .has-dropdown:focus-within .dropdown {
    display: none;
  }

  .dropdown {
    position: static;
    display: none;
    margin-top: 6px;
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 14px;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.12);
    min-width: unset;
  }

  .has-dropdown.is-open .dropdown {
    display: block;
  }

  .has-dropdown.is-open > a {
    background: rgba(255, 255, 255, 0.18);
  }

  .dropdown li a {
    color: rgba(255, 255, 255, 0.95);
    white-space: normal;
  }

  .dropdown li a:hover {
    color: var(--nav-bar-text);
    background: rgba(255, 255, 255, 0.12);
  }

  .dropdown-wide li a {
    white-space: normal;
  }

  .header-cta {
    justify-content: center;
    width: 100%;
    padding: 14px 18px;
  }
}
