:root {
  --nav-h: 100px;
  --nav-h-scrolled: 82px;
  --nav-pad: 22px 0;
  --nav-pad-scrolled: 16px 0;
  --border-nav: solid 1px var(--col-border-cards);
  --nav-offset: var(--nav-h);
  --nav-z: 1000;
}

@media (max-width: 1024px) {
  :root {
    --nav-h: 88px;
    --nav-h-scrolled: 72px;
  }
}

@media (max-width: 640px) {
  :root {
    --nav-h: 64px;
    --nav-h-scrolled: 56px;
    --nav-pad: 12px 0;
    --nav-pad-scrolled: 12px 0;
  }

  .nav-toggle {
    scale: 0.85;
  }
}

/* Sticky container */
.sticky-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--nav-z);
  background: var(--col-bg-nav);
  border-bottom: var(--border-nav);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  padding-top: env(safe-area-inset-top, 0);
}

/* Smooth motion */
.sticky-nav .navigation {
  height: var(--nav-h);
  width: 100%;
  flex: auto;
  padding: var(--nav-pad, 22px 0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition:
    height 0.25s ease,
    padding 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
  .sticky-nav .navigation {
    transition: none;
  }
}

/* Shrink on scroll (toggle .scrolled in JS) */
.nav-scrolled .navigation {
  height: var(--nav-h-scrolled);
  padding: var(--nav-pad-scrolled);
}

/* Ensure links/buttons remain tappable even when shrunk */
.navigation a,
.navigation button {
  padding-block: 10px;
}

.logo {
  height: 100%;
}

.logo img {
  height: 100%;
}

/* Nav links */

.nav-links {
  display: none;
  gap: 32px;
  align-items: center;
}

.nav-links-menu {
  position: fixed;
  top: calc(var(--nav-h-scrolled) - 1px);
  right: 8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 2rem;
  gap: 16px;
  background-color: white;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  box-shadow:
    0px 4px 8px color-mix(in srgb, #18181b 10%, transparent),
    0px 0px 1px color-mix(in srgb, #18181b 30%, transparent);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.3s ease,
    opacity 0.2s ease;
}

.nav-links-menu.is-open {
  display: flex;
  opacity: 1;
}

.nav-links-menu .nav-link {
  padding: 8px 4px;
}

.nav-links a {
  color: var(--col-menu-txt);
  text-decoration: none;
  font-size: 15px;
  position: relative;
  display: inline-flex;
  align-items: center;
  transition: color 300ms ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--col-primary);
}

/* Center-growing underline (mirrors footer pattern) */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 100%;
  height: 3px;
  background: currentColor;
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  transition: transform 200ms ease;
}

/* Current page: orange text + animate underline on load */
.nav-links a[aria-current="page"] {
  color: var(--col-primary);
}

.nav-links a[aria-current="page"]::after {
  animation: navUnderlineIn 0.3s ease-out both;
  animation-delay: 0.2s;
}

.nav-link-ext {
  font-weight: 500;
  padding-left: 24px;
  border-left: 1px solid #ebebeb;
  white-space: nowrap;
}

.nav-links-menu .nav-link:last-of-type {
  border-top: 1px solid #ebebeb;
  padding-top: 20px;
  font-weight: 500;
}

.nav-link-ext:hover .external-icon,
.nav-link-ext:focus-visible .external-icon {
  opacity: 1;
}

@keyframes navUnderlineIn {
  from {
    transform: translateX(-50%) scaleX(0);
  }

  to {
    transform: translateX(-50%) scaleX(1);
  }
}

/* Reduced motion users get the underline shown without animation */
@media (prefers-reduced-motion: reduce) {
  .nav-links a[aria-current="page"]::after {
    animation: none;
    transform: translateX(-50%) scaleX(1);
  }
}

/* Hamburger button */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  border-radius: 10000rem;
  background-color: currentColor;
  transition:
    transform 0.25s ease,
    opacity 0.25s ease;
}

/* Animate hamburger → X */
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (min-width: 1024.1px) {
  .navigation {
    flex-wrap: wrap;
    align-items: center;
  }

  .nav-links {
    display: inline-flex;
  }

  .nav-links-menu {
    display: none;
  }

  .nav-toggle {
    display: none;
  }
}
