.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  padding: 16px 24px;
  background: transparent;
  transition: transform var(--duration-slow) var(--ease);
  will-change: transform;
}


@media (max-width: 1199.98px) {
  .site-header {
    padding: 12px;
  }
}

.site-header.is-hidden { transform: translateY(calc(-100% - 12px)); }

.site-header .navbar {
  --bs-navbar-padding-y: 0;
  --bs-navbar-padding-x: 0;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0;
}


.navbar-shell {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: stretch;
  gap: 8px;

  padding: 0 0 0 16px;
  background: linear-gradient(90deg, rgba(var(--white-rgb), .58) 0%, rgba(var(--white-rgb), .30) 60%, rgba(var(--white-rgb), .18) 100%);
  border: 2px solid rgba(var(--white-rgb), .55);
  border-radius: var(--radius-pill);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  transition: all var(--duration-base) var(--ease);
}


.site-header.is-stuck .navbar-shell {
  background: rgba(var(--white-rgb), .1);
  border-color: rgba(var(--white-rgb), .95);
  box-shadow: var(--shadow-sm);
}


.site-header .navbar-brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
}
.site-header .navbar-brand img {
  height: 48px;
  width: auto;
  object-fit: contain;
  display: block;
}


.site-header .navbar-nav {
  --bs-nav-link-padding-x: 16px;
  --bs-nav-link-padding-y: 0;
  gap: 2px;
}
.site-header .nav-link {
  display: flex;
  align-items: center;
  padding: 8px 12px !important;
  font-weight: var(--weight-medium);
  font-size: var(--text-base);
  color: var(--navy);
  white-space: nowrap;
  border-radius: var(--radius-pill);
  background: transparent;
  transition: background var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease);
}
.site-header .nav-link:hover,
.site-header .nav-link:focus,
.site-header .nav-link.active {
  background: rgba(var(--navy-rgb), .08);
  color: var(--navy);
}


.navbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}
.nav-login,
.nav-signup {
  display: flex;
  align-items: center;
  font-size: var(--text-base);
  color: var(--navy);
  border-radius: var(--radius-pill);
  transition: background var(--duration-fast) var(--ease),
              filter var(--duration-fast) var(--ease);
}
.nav-login {
  font-weight: var(--weight-medium);
  padding: 0 16px;
  background: transparent;
}
.nav-login:hover,
.nav-login:focus-visible,
.nav-login.active { background: var(--white); color: var(--navy); }

.nav-signup {
  font-weight: var(--weight-bold);
  padding: 0 32px;
  background: var(--white);
}
.nav-signup:hover,
.nav-signup:focus-visible,
.nav-signup.active { color: var(--navy); -webkit-filter: brightness(.97); filter: brightness(.97); }


/* Desktop: one sliding pill behind Login / Sign Up. It sits on Sign Up at
   rest (and when Sign Up is `.active`), and slides onto Login on hover,
   keyboard focus, or when Login is the current page. */
@media (min-width: 1200px) {
  .navbar-actions {
    position: relative;
    isolation: isolate;
    gap: 0;
  }

  .navbar-actions::before {
    content: "";
    position: absolute;
    z-index: 0;
    inset: 0 0 0 auto;
    width: var(--nav-action-width);
    border-radius: var(--radius-pill);
    background: var(--white);
    pointer-events: none;
    transition: transform var(--duration-base) var(--ease);
  }

  .navbar-actions .nav-login,
  .navbar-actions .nav-signup {
    position: relative;
    z-index: 1;
    width: var(--nav-action-width);
    justify-content: center;
    padding: 0 var(--space-md);
    background: transparent;
    transition: background var(--duration-base) var(--ease),
                color var(--duration-base) var(--ease),
                filter var(--duration-base) var(--ease);
  }

  .navbar-actions .nav-login:hover,
  .navbar-actions .nav-login:focus-visible,
  .navbar-actions .nav-login.active,
  .navbar-actions .nav-signup:hover,
  .navbar-actions .nav-signup:focus-visible,
  .navbar-actions .nav-signup.active {
    background: transparent;
    color: var(--navy);
    -webkit-filter: none;
            filter: none;
  }

  .navbar-actions:has(.nav-login:hover)::before,
  .navbar-actions:has(.nav-login:focus)::before,
  .navbar-actions:has(.nav-login:focus-visible)::before,
  .navbar-actions:has(.nav-login.active)::before { transform: translateX(-100%); }

  /* Login is the current page, so the pill starts on it. Hovering Sign Up
     should still send the pill back to the right. */
  .navbar-actions:has(.nav-login.active):has(.nav-signup:hover)::before,
  .navbar-actions:has(.nav-login.active):has(.nav-signup:focus)::before,
  .navbar-actions:has(.nav-login.active):has(.nav-signup:focus-visible)::before { transform: none; }
}


.site-header .navbar-toggler {
  border: 0;
  padding: 0;
  width: 46px;
  height: 46px;
  margin-left: auto;
  align-self: center;
  color: var(--navy);
  box-shadow: none;
}
.site-header .navbar-toggler:focus { box-shadow: none; }
.site-header .navbar-toggler svg { display: block; pointer-events: none; }


@media (min-width: 1200px) {
  .site-header .navbar-collapse {
    align-items: stretch;
    gap: 8px;
  }

  .site-header .navbar-nav { align-items: center; margin-left: auto; margin-right: -16px;}
  .site-header .nav-link { margin: 12px 0; }
  .navbar-actions { align-items: stretch; }

  .navbar-shell { overflow: hidden; }
}

/* The expanded bar needs ~1134px of brand + links + actions. Between 1200 and
   1399 the shell is narrower than that, so the links tighten rather than
   overflow; above 1400 they sit at full size. */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  .site-header .navbar-nav { --bs-nav-link-padding-x: 8px; }
  .site-header .nav-link { padding: 8px 8px !important; }
  .site-header .nav-link,
  .nav-login { font-size: var(--text-sm); }
  .nav-login  { padding: 0 12px; }
  .nav-signup { padding: 0 20px; }
  .site-header .navbar-brand img { height: 40px; }
}


@media (max-width: 1199.98px) {
  .site-header .navbar-toggler { display: inline-flex; align-items: center; justify-content: center; }

  .navbar-shell {
    flex-wrap: wrap;
    align-items: center;
    padding: 8px;
    position: relative;
    min-height: auto;
    border-radius: var(--radius-2xl);
  }
  .site-header .navbar-brand img { height: 36px; }


  .site-header .navbar-collapse.show,
  .site-header .navbar-collapse.collapsing {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    background: var(--white);
    padding: 16px;
    margin-top: 8px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    flex-basis: 100%;
  }
  .site-header .navbar-nav { margin-left: 0; }
  .site-header .nav-link { margin: 0; padding: 12px 18px; justify-content: flex-start; }
  .navbar-actions {
    justify-content: space-between;
    gap: 6px;
    padding: 4px;
    background: var(--grad-brand);
    border-radius: var(--radius-2xl);
  }
  .nav-login,
  .nav-signup {
    padding: 12px 18px;
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* The active pill is `background: var(--white)`, which reads on the tinted
     header bar at desktop but is invisible inside this dropdown — the panel
     is white too. On the panel it becomes a tinted pill with a bolder label
     and a marker, so the current page is clear from the colour, the weight
     and the marker rather than any one of them alone. */
  .site-header .nav-link.active {
    position: relative;
    background: rgba(var(--navy-rgb), .08);
    color: var(--navy);
    font-weight: var(--weight-semibold);
  }
  .site-header .nav-link.active::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: var(--radius-lg);
    background: var(--grad-brand);
  }

  /* Sign Up is already a solid white pill on the panel, so it needs the
     opposite treatment: the brand gradient, as it has on the header bar. */
  .nav-signup.active {
    background: var(--grad-brand);
    color: var(--white);
    -webkit-filter: none;
            filter: none;
  }

  /* Login is the transparent half of the gradient bar, so the current-page
     state is a white pill — the same rest treatment Sign Up already has. */
  .nav-login.active {
    background: var(--white);
    color: var(--navy);
  }

  /* Hover must not repaint the active item back to plain white. */
  .site-header .nav-link:hover,
  .site-header .nav-link:focus,
  .nav-login:hover { background: rgba(var(--navy-rgb), .05); }
  .site-header .nav-link.active:hover { background: rgba(var(--navy-rgb), .12); }
  .nav-login.active:hover { background: var(--white); }
}


@media (prefers-reduced-motion: reduce) {
  .site-header,
  .navbar-shell,
  .navbar-actions::before,
  .nav-login,
  .nav-signup { transition: none; }
}
