/* nav.css - owned by the nav section. Fixed top bar, email pill, active-section rule. */

.nav {
  /* The bar height is a nav-local fact, not a page spacing step: 64 at rest on
     phones, 84 at rest on desktop, 56 / 64 once scrolled. One constant feeds the
     padding so the content box stays 36px (the pill) at every size. */
  --nav-h: 64px;
  --nav-h-scrolled: 56px;
  --nav-cta-h: 36px;
  --nav-pad: calc((var(--nav-h) - var(--nav-cta-h) - 1px) / 2);

  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 100;
  padding-block: var(--nav-pad);
  background-color: transparent;
  border-bottom: 1px solid transparent;
  transition:
    padding-block var(--dur-ui) var(--ease),
    background-color var(--dur-ui) var(--ease),
    border-bottom-color var(--dur-ui) var(--ease),
    transform var(--dur-move) var(--ease-move);
}

/* Past 40px the bar gains its own surface so copy can pass under it legibly.
   The veil is the surface token mixed with transparency, never a new colour. */
.nav--scrolled {
  --nav-pad: calc((var(--nav-h-scrolled) - var(--nav-cta-h) - 1px) / 2);
  background-color: var(--surface);
  background-color: color-mix(in srgb, var(--surface) 82%, transparent);
  border-bottom-color: var(--ink-08);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* Scroll down: the bar leaves. Scroll up: it comes back. Never inside 200px. */
.nav--hidden {
  transform: translateY(-100%);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.nav-wordmark {
  /* Lowercase t carries a left sidebearing; this seats the mark optically on the
     gutter line that every section edge shares. */
  margin-left: -0.035em;
  padding-block: var(--sp-1);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: auto;
}

.nav-links {
  position: relative;
  display: none;
  align-items: center;
  gap: var(--sp-4);
}

.nav-link {
  /* Negative margin keeps the flow height at the type size while the hit area
     grows to 36px, the same height as the pill. */
  padding-block: 12px;
  margin-block: -12px;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--tr-mono);
  text-transform: uppercase;
  color: var(--ink-56);
  transition: color var(--dur-color) var(--ease);
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link[aria-current] {
  color: var(--ink);
}

/* One accent appearance: the 1px rule that slides between active sections.
   Base box is 1x1 and scaled on X, so the travel is transform only. */
.nav-rule {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  background-color: var(--accent);
  transform-origin: left center;
  pointer-events: none;
  opacity: 0;
  transition:
    transform var(--dur-ui) var(--ease),
    opacity var(--dur-color) var(--ease);
}

/* ---------- email pill ---------- */

.nav-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--nav-cta-h);
  padding-left: 46px;
  padding-right: 18px;
  border-radius: var(--r-pill);
  background-color: var(--surface);
  color: var(--ink);
  overflow: hidden;
  transition: background-color var(--dur-ui) var(--ease);
}

/* The disc sits at the pill's left edge and grows to the pill's full width.
   Clipped by the pill, so its left end keeps the pill's own curve. */
.nav-cta-disc {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--nav-cta-h);
  height: var(--nav-cta-h);
  border-radius: var(--r-pill);
  background-color: var(--ink);
  color: var(--surface);
  transition: width var(--dur-ui) var(--ease);
}

.nav-cta-arrow {
  /* The head carries its mass to the top right; 1px back recovers the optical
     centre of the disc. */
  position: relative;
  left: -1px;
  transition:
    opacity 220ms var(--ease),
    transform 220ms var(--ease);
}

.nav-cta-label {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--tr-mono);
  white-space: nowrap;
  color: var(--ink);
  /* The label sits 46 / 18 inside the pill. Half that difference is 14, which is
     exactly how far it travels to centre itself once the ink has landed. */
  transition:
    color 220ms linear 140ms,
    transform var(--dur-ui) var(--ease);
}

.nav-cta:hover .nav-cta-disc,
.nav-cta:focus-visible .nav-cta-disc {
  width: 100%;
}

.nav-cta:hover .nav-cta-arrow,
.nav-cta:focus-visible .nav-cta-arrow {
  opacity: 0;
  transform: scale(0.6);
}

.nav-cta:hover .nav-cta-label,
.nav-cta:focus-visible .nav-cta-label {
  color: var(--surface);
  transform: translateX(-14px);
}

/* ---------- breakpoints ---------- */

@media (min-width: 768px) {
  .nav {
    --nav-h: 84px;
    --nav-h-scrolled: 64px;
  }

  .nav-actions {
    gap: var(--sp-4);
  }

  .nav-links {
    display: flex;
  }
}

@media (min-width: 1200px) {
  .nav-links {
    gap: var(--sp-5);
  }
}

/* Static path: no slide, no hide, no fill animation. Everything stays visible. */
@media (prefers-reduced-motion: reduce) {
  .nav,
  .nav--hidden,
  .nav-cta,
  .nav-cta-disc,
  .nav-cta-arrow,
  .nav-cta-label,
  .nav-link,
  .nav-rule {
    transition: none;
  }

  .nav--hidden {
    transform: none;
  }

  .nav-cta:hover .nav-cta-label,
  .nav-cta:focus-visible .nav-cta-label {
    transform: none;
  }
}
