/* STX Vets – grouped navbar that follows theme tokens */

/* ---- Shell ---------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  --mobile-nav-top: 76px;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem 1.25rem;
  align-items: center;
}

.nav-underline {
  height: 1px;
  width: 100%;
  background: var(--border-subtle);
}

/* ---- Brand block ---------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
}

.brand-mark {
  height: 28px;
  width: auto;
  display: block;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.7));
}

.brand-text {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.02rem;
}

.brand-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-main);
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.63rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Primary nav ---------------------------------------------------------- */

.nav {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav li {
  position: relative;
  flex: 0 0 auto;
}

.nav a:not(.btn),
.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--nav-link);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

.nav-dropdown-trigger {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.nav a:not(.btn):hover,
.nav-dropdown-trigger:hover {
  background: var(--nav-hover);
}

.nav a:not(.btn).active {
  font-weight: 700;
  border-bottom: 2px solid var(--brand);
}

/* ---- Dropdowns ------------------------------------------------------------ */

.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  min-width: 180px;
  padding: 0.4rem 0.35rem;
  border-radius: 0.75rem;
  background: var(--bg-alt);
  box-shadow: 0 16px 30px rgba(2, 6, 23, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.35);
  z-index: 1001;

  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    max-height 0.18s ease-out,
    opacity 0.14s ease-out,
    transform 0.14s ease-out;
}

.nav-dropdown-menu li {
  flex: 0 0 auto;
}

.nav-dropdown-menu a {
  width: 100%;
  justify-content: flex-start;
  padding: 0.32rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 0.55rem;
  color: var(--nav-link);
}

.nav-dropdown-menu a:hover {
  background: var(--nav-hover);
}

.nav-dropdown:hover > .nav-dropdown-menu,
.nav-dropdown:focus-within > .nav-dropdown-menu {
  max-height: 600px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ---- Theme toggle --------------------------------------------------------- */

.theme-toggle {
  justify-self: end;
  border: 1px solid var(--border-weak);
  background: var(--control-bg);
  color: var(--text-main);
  padding: 0.35rem 0.55rem;
  border-radius: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--brand);
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
}

.nav-actions .nav-support {
  font-weight: 600;
}

.nav-actions .nav-downloads.is-active {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.45);
}

.nav-mobile-only {
  display: none;
}

.nav-mobile-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ---- Mobile toggle -------------------------------------------------------- */

.mobile-nav-toggle {
  display: none;
  border: 1px solid var(--border-weak);
  background: var(--control-bg);
  color: var(--text-main);
  border-radius: 0.6rem;
  padding: 0.35rem 0.55rem;
  font-size: 1.2rem;
  cursor: pointer;
}

body.nav-open .mobile-nav-toggle {
  border-color: var(--brand);
}

.nav-overlay {
  display: none;
}

body.nav-open .nav-overlay {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  z-index: 500;
}

/* ---- Responsive ----------------------------------------------------------- */

@media (max-width: 900px) {
  .nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: 0.85rem;
    gap: 0.5rem;
  }

  .brand {
    flex: 1 1 auto;
  }

  .brand-sub {
    display: none;
  }

  .nav-actions {
    flex: 0 0 auto;
  }

  .nav {
    width: auto;
    position: fixed;
    top: var(--mobile-nav-top, 76px);
    left: 12px;
    right: 12px;
    transform: none;
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    padding: 1rem;
    display: none;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    z-index: 1002;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6);
  }

  body.nav-open .nav {
    display: block;
  }

  .nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-menu {
    position: static;
    max-height: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0 0 0.35rem 0.75rem;
    display: none;
  }

  .nav-dropdown.open > .nav-dropdown-menu {
    display: block;
  }

  .nav li {
    width: 100%;
  }

  .nav a:not(.btn),
  .nav-dropdown-trigger {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-mobile-only {
    display: block;
  }

  .nav-mobile-stack .btn,
  .nav-mobile-stack .admin-link,
  .nav-mobile-stack .auth-inline-form,
  .nav-mobile-stack .auth-inline-form button {
    width: 100%;
  }

  .nav-mobile-stack .auth-inline-form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: stretch;
  }

  .nav-mobile-stack .auth-inline-form button {
    justify-content: center;
  }

  .nav-desktop-only {
    display: none !important;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .brand-title {
    font-size: 0.74rem;
    letter-spacing: 0.14em;
  }

  .brand-mark {
    height: 26px;
  }

  .nav a:not(.btn),
  .nav-dropdown-trigger {
    font-size: 0.74rem;
    padding: 0.2rem 0.65rem;
  }

  .nav-dropdown-menu {
    left: 0;
    right: auto;
  }
}
