/* ============================================================
   Component · Site Navigation
   Sticky frosted header. Active indicator slides between items
   (single 2px orange line, CSS translate). Mobile = full-viewport
   overlay with stagger-in items.
   ============================================================ */

.nav {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: var(--z-nav);
  background: color-mix(in srgb, var(--color-white) 92%, transparent);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: var(--rule-weight) solid transparent;
  transition:
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  height: 80px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-inline: var(--grid-gutter);
  transition: height var(--duration-normal) var(--ease-out);
}

/* Scrolled state — applied by nav.js after 100px */
.nav.is-scrolled {
  border-bottom-color: var(--rule-color);
}
.nav.is-scrolled .nav__inner { height: 56px; }

/* === Logo =============================================== */
.nav__logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  color: var(--color-ink);
  transition: opacity var(--duration-fast) var(--ease-out);
}
.nav__logo:hover { opacity: 0.7; }
.nav__logo img {
  height: 32px;
  width: auto;
  transition: height var(--duration-normal) var(--ease-out);
}
.nav.is-scrolled .nav__logo img { height: 26px; }

/* === Primary list ======================================= */
/* The list and its items stretch to the full header height so a link's
   bottom edge IS the header's bottom edge — that's what lets the hover
   underline sit flush on the border-bottom rule with no gap. Both stretch
   values are needed: align-self stretches the list inside .nav__inner,
   align-items stretches the items inside the list. */
.nav__list {
  display: none;
  align-self: stretch;
  align-items: stretch;
  gap: var(--space-lg);
  position: relative;
}
@media (min-width: 768px) {
  .nav__list { display: flex; }
}

.nav__item {
  position: relative;
  display: flex;
}

/* No vertical padding — the link fills the item and centres its own text,
   so the full column height is the hover target. */
.nav__link {
  position: relative;
  display: flex;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--color-ink);
  transition: color var(--duration-fast) var(--ease-out);
}
.nav__link:hover {
  color: var(--color-accent);
}

/* Hover underline — pinned to bottom:0, which after the stretch above is
   the header's bottom edge, so it lands directly on the border-bottom.
   Wipes in from the left rather than fading, matching the rule-drawing
   motion used elsewhere. */
.nav__link::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--duration-fast) var(--ease-out);
}
.nav__link:hover::after,
.nav__link:focus-visible::after {
  transform: scaleX(1);
}

/* Active indicator — single thin orange line, position via translate.
   Flush with the header bottom too, so it and the hover underline occupy
   the same rule line instead of stacking. */
.nav__indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: var(--indicator-width, 0);
  transform: translateX(var(--indicator-x, 0));
  background: var(--color-accent);
  transition:
    transform var(--duration-normal) var(--ease-out),
    width var(--duration-normal) var(--ease-out);
  pointer-events: none;
}

/* === Contact CTA in nav (outlined button) =============== */
/* Hidden on mobile — Contact lives inside the overlay menu instead. */
.nav__cta {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--color-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-ink);
  background: transparent;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}
.nav__cta:hover {
  background: var(--color-ink);
  color: var(--color-white);
}
@media (min-width: 768px) {
  .nav__cta { display: inline-flex; }
}

/* === Mobile toggle ====================================== */
.nav__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  position: relative;
  border: var(--rule-weight) solid var(--color-border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-white) 55%, transparent);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}
.nav__toggle:hover,
.nav__toggle:focus-visible {
  border-color: var(--color-ink);
}
@media (min-width: 768px) {
  .nav__toggle { display: none; }
}
.nav__toggle-bar {
  position: absolute;
  left: 13px;
  right: 13px;
  height: 2px;
  background: var(--color-ink);
  transition: transform var(--duration-normal) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}
.nav__toggle-bar:nth-child(1) { top: 15px; }
.nav__toggle-bar:nth-child(2) { top: 21px; }
.nav__toggle-bar:nth-child(3) { top: 27px; }

.nav.is-menu-open .nav__toggle-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav.is-menu-open .nav__toggle-bar:nth-child(2) { opacity: 0; }
.nav.is-menu-open .nav__toggle-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* === Mobile overlay ===================================== */
/* NB: .nav has backdrop-filter, which makes it the containing block for
   position:fixed descendants — so inset:0 would collapse to the header box.
   Pin the top and set an explicit viewport height to cover the full screen. */
.nav__overlay {
  position: fixed;
  inset: 0 0 auto 0;
  height: 100vh;
  height: 100dvh;
  z-index: calc(var(--z-nav) - 1);
  background: var(--color-white);
  padding: 80px var(--grid-gutter) var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}
@media (min-width: 768px) { .nav__overlay { display: none; } }

.nav.is-menu-open .nav__overlay {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

/* Close — labeled return control (mirrors the header toggle, more legible) */
.nav__overlay-close {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-ink-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  opacity: 0;
  transform: translateX(20px);
  transition:
    opacity var(--duration-normal) var(--ease-spring),
    transform var(--duration-normal) var(--ease-spring),
    color var(--duration-fast) var(--ease-out);
}
.nav__overlay-close span[aria-hidden] {
  display: inline-block;
  transition: transform var(--duration-fast) var(--ease-out);
}
.nav__overlay-close:hover,
.nav__overlay-close:focus-visible {
  color: var(--color-ink);
}
.nav__overlay-close:hover span[aria-hidden] {
  transform: translateX(-3px);
}
.nav.is-menu-open .nav__overlay-close {
  opacity: 1;
  transform: translateX(0);
}

.nav__overlay-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-lg);
  border-top: var(--rule-weight) solid var(--rule-color);
}
.nav__overlay-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--space-md) 0;
  border-bottom: var(--rule-weight) solid var(--color-border-light);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-ink);
  opacity: 0;
  transform: translateX(20px);
  transition:
    opacity var(--duration-normal) var(--ease-spring),
    transform var(--duration-normal) var(--ease-spring);
}
.nav.is-menu-open .nav__overlay-link {
  opacity: 1;
  transform: translateX(0);
}
/* Stagger via index */
.nav.is-menu-open .nav__overlay-link:nth-child(1) { transition-delay: 60ms; }
.nav.is-menu-open .nav__overlay-link:nth-child(2) { transition-delay: 120ms; }
.nav.is-menu-open .nav__overlay-link:nth-child(3) { transition-delay: 180ms; }
.nav.is-menu-open .nav__overlay-link:nth-child(4) { transition-delay: 240ms; }

.nav__overlay-link .num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
}

/* Contact — the one differentiated action in the menu (filled title-block CTA) */
.nav__overlay-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--color-ink);
  color: var(--color-white);
  border: var(--rule-weight) solid var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0;
  transform: translateX(20px);
  transition:
    opacity var(--duration-normal) var(--ease-spring),
    transform var(--duration-normal) var(--ease-spring),
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}
.nav__overlay-cta[aria-current="page"] {
  background: transparent;
  color: var(--color-ink);
}
.nav__overlay-cta:hover {
  background: var(--color-ink-light);
}
.nav.is-menu-open .nav__overlay-cta {
  opacity: 1;
  transform: translateX(0);
  transition-delay: 300ms;
}

.nav__overlay-foot {
  margin-top: auto;
  padding-top: var(--space-lg);
  border-top: var(--rule-weight) solid var(--color-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-ink-muted);
}
