/* ============================================================
   Haxfer — shared site navigation
   One stylesheet for the landing page (poster layout) and every
   content page, so the header is identical everywhere.

   Loaded after site.css. Scoped under .nav and self-contained:
   no dependency on either page's token set.

   Scaling: the header never scales. Above 1440px the landing page blows
   its poster layout up through --u, but the nav stays at its content-page
   size (72px bar, 60px logo, 14px links) so the header measures the same
   on every page. Its horizontal padding still follows the page grid, so
   the logo keeps lining up with the hero content.
   ============================================================ */

.nav {
  --nav-u: 1px;
  --nav-h: calc(72 * var(--nav-u));
  --nav-pad: calc(80 * var(--nav-u));
  --nav-gap: calc(40 * var(--nav-u));
  --nav-max: none;
  --nav-blur: 12px;
  --nav-plate-bg: rgba(255, 255, 255, 0.86);
  --nav-ink: #0b0d12;
  --nav-muted: #5b6472;
  --nav-accent: #2f6bff;
  --nav-line: rgba(10, 11, 13, 0.22);
  --nav-slab: rgba(255, 255, 255, 0.16);
  --nav-font: var(--font-inter, var(--sans, "Inter", -apple-system, "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif));

  position: sticky;
  top: 0;
  z-index: 50;
  font-family: var(--nav-font);
}

/* The landing page pins the header over a full-bleed hero. Size stays fixed;
   only the horizontal inset follows the poster grid so the logo still lines
   up with the hero copy at every width. */
.nav.is-fixed {
  position: fixed;
  inset-inline: 0;
  --nav-u: 1px;
  --nav-max: var(--page-width, 90rem);
  --nav-pad: var(--page-inset, 80px);
}

/* Content pages align the header with their content grid, which mirrors the
   landing page shell (see --shell-max / --shell-pad in tokens.css). */
.nav.nav--content {
  --nav-max: var(--shell-max, 1920px);
  --nav-pad: var(--shell-pad, 80px);
}

.nav-plate {
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--nav-plate-bg);
  -webkit-backdrop-filter: blur(var(--nav-blur)) saturate(1.4);
  backdrop-filter: blur(var(--nav-blur)) saturate(1.4);
  opacity: 0;
  transition: opacity 220ms ease;
}
/* The landing page drives plate opacity per frame from JS. */
.nav.is-fixed .nav-plate { transition: none; }
.nav.is-stuck .nav-plate { opacity: 1; }

.nav-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(18 * var(--nav-u));
  width: 100%;
  max-width: var(--nav-max);
  height: var(--nav-h);
  margin-inline: auto;
  padding-inline: var(--nav-pad);
}

.nav-brand { display: flex; align-items: center; flex: none; }
.nav .brand-wordmark { display: block; height: calc(60 * var(--nav-u)); width: auto; }

.nav-links ul {
  display: flex;
  align-items: center;
  gap: var(--nav-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  /* The landing page scales its root font-size above 1440px, which would give
     each li a taller line box than the 28px link and nudge the text 1px down.
     Zero it so the link height is the only thing that counts. */
  line-height: 0;
}
.nav-links li { line-height: 0; }
.nav-links a {
  display: inline-block;
  padding: calc(4 * var(--nav-u)) 0;
  font-size: calc(14 * var(--nav-u));
  line-height: calc(20 * var(--nav-u));
  font-weight: 400;
  color: var(--nav-muted);
  white-space: nowrap;
  text-decoration: none;
  transition: color 150ms ease;
}
.nav-links a:hover { color: var(--nav-accent); }
.nav-links a[aria-current="page"] {
  color: var(--nav-ink);
  text-decoration: underline;
  text-decoration-color: rgba(47, 107, 255, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: calc(7 * var(--nav-u));
}

.nav-actions { display: flex; align-items: center; gap: calc(12 * var(--nav-u)); flex: none; }

/* ---------- language toggle ---------- */
.nav .lang-toggle,
.nav .lang {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: calc(3 * var(--nav-u)) calc(6 * var(--nav-u));
  border: 1px solid var(--nav-line);
  border-radius: 999px;
  background: var(--nav-slab);
  -webkit-backdrop-filter: blur(var(--nav-blur));
  backdrop-filter: blur(var(--nav-blur));
  color: var(--nav-ink);
  font: 600 calc(12 * var(--nav-u))/1 var(--nav-font);
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 180ms ease, background 180ms ease;
}
.nav .lang-toggle:hover,
.nav .lang:hover { border-color: rgba(47, 107, 255, 0.55); background: rgba(255, 255, 255, 0.5); }
.nav .lang-opt { opacity: 0.42; transition: opacity 180ms ease, color 180ms ease; }
.nav .lang-opt.is-active,
.nav .lang .on { opacity: 1; color: var(--nav-accent); font-weight: 700; }
.nav .lang-sep { opacity: 0.28; }

/* ---------- primary CTA (blue pill with ink sweep) ---------- */
.nav .cta,
.nav .pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: calc(40 * var(--nav-u));
  padding: 0 calc(24 * var(--nav-u));
  border-radius: 999px;
  background: var(--nav-accent);
  color: #ffffff;
  font-family: var(--nav-font);
  font-size: calc(14 * var(--nav-u));
  line-height: calc(20 * var(--nav-u));
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  filter: drop-shadow(0 calc(8 * var(--nav-u)) calc(14 * var(--nav-u)) rgba(47, 107, 255, 0.3));
}
.nav .cta .cta-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--nav-accent);
}
.nav .cta .cta-ink {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: linear-gradient(135deg, #2f6bff 0%, #7c3aed 100%);
  clip-path: inset(0 100% 0 0 round 999px);
}
.nav .cta .cta-label { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.nav .cta .cta-ink-label { display: inline-flex; align-items: center; justify-content: center; color: #ffffff; }
.nav .cta .chev {
  position: absolute;
  left: calc(100% + 0.32em);
  top: 50%;
  margin-top: -0.4em;
  width: 0.8em;
  height: 0.8em;
  opacity: 0;
  transform: translateX(-4px);
  color: #ffffff;
  flex: none;
}
.nav .cta .chev path { stroke: currentColor; stroke-width: 3; stroke-linecap: round; fill: none; }
.nav .cta .cta-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: conic-gradient(from 0deg, var(--nav-accent) var(--fill, 0%), transparent var(--fill, 0%));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* CSS-only version of the hover sweep for pages without the landing JS. */
@media (hover: hover) {
  .nav:not(.is-fixed) .cta .cta-fill,
  .nav:not(.is-fixed) .cta .cta-label { transition: opacity 340ms cubic-bezier(0.22, 0.61, 0.36, 1); }
  .nav:not(.is-fixed) .cta .cta-ink { transition: clip-path 340ms cubic-bezier(0.22, 0.61, 0.36, 1); }
  .nav:not(.is-fixed) .cta:hover .cta-fill { opacity: 0; }
  .nav:not(.is-fixed) .cta:hover .cta-label { opacity: 0; }
  .nav:not(.is-fixed) .cta:hover .cta-ink { clip-path: inset(0 0 0 0 round 999px); }
}

/* ---------- mobile menu ---------- */
.nav-menu-btn {
  display: none;
  position: relative;
  flex: none;
  width: calc(40 * var(--nav-u));
  height: calc(40 * var(--nav-u));
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(10, 11, 13, 0.1);
  background: rgba(10, 11, 13, 0.04);
  cursor: pointer;
}
.nav-menu-btn svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.nav-menu-btn .bar {
  stroke: rgba(10, 11, 13, 0.9);
  stroke-width: 2;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 220ms ease, opacity 160ms ease;
}

.nav-card {
  position: absolute;
  top: calc(8 * var(--nav-u));
  right: calc(8 * var(--nav-u));
  z-index: -1;
  width: min(calc(352 * var(--nav-u)), calc(100vw - 16px));
  padding: calc(48 * var(--nav-u)) calc(8 * var(--nav-u)) calc(8 * var(--nav-u));
  border: 1px solid rgba(10, 11, 13, 0.1);
  border-radius: calc(24 * var(--nav-u));
  background: #ffffff;
  box-shadow: 0 calc(24 * var(--nav-u)) calc(48 * var(--nav-u)) calc(-16 * var(--nav-u)) rgba(16, 24, 40, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.94);
  transform-origin: top right;
}
.nav-card ul { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-card a {
  display: flex;
  align-items: center;
  gap: calc(12 * var(--nav-u));
  padding: calc(10 * var(--nav-u));
  border-radius: calc(14 * var(--nav-u));
  color: var(--nav-ink);
  text-decoration: none;
}
.nav-card a:hover,
.nav-card a:focus-visible { background: rgba(10, 11, 13, 0.04); }
.nav-card .tile {
  display: grid;
  place-items: center;
  flex: none;
  width: calc(36 * var(--nav-u));
  height: calc(36 * var(--nav-u));
  border: 1px solid rgba(10, 11, 13, 0.1);
  border-radius: calc(11 * var(--nav-u));
  font-family: var(--mono, ui-monospace, monospace);
  font-size: calc(13 * var(--nav-u));
  color: var(--nav-muted);
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.nav-card a:hover .tile {
  border-color: rgba(76, 141, 255, 0.5);
  background: rgba(76, 141, 255, 0.1);
  color: var(--nav-accent);
}
.nav-card .lbl { display: block; font-size: calc(16 * var(--nav-u)); line-height: calc(24 * var(--nav-u)); font-weight: 500; }
.nav-card .note { display: block; font-size: calc(13.5 * var(--nav-u)); line-height: calc(20 * var(--nav-u)); color: var(--nav-muted); }
.nav-card a[aria-current="page"] .lbl { color: var(--nav-accent); }

/* Pages without the landing spring JS animate the card in CSS. */
.nav:not(.is-fixed) .nav-card { transition: opacity 200ms ease, transform 220ms ease, visibility 0s linear 220ms; }
.nav:not(.is-fixed) .nav-card.is-open {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: opacity 200ms ease, transform 220ms ease, visibility 0s;
}
.nav:not(.is-fixed) .nav-menu-btn[aria-expanded="true"] .b1 { transform: translateY(calc(6 * var(--nav-u))) rotate(45deg); }
.nav:not(.is-fixed) .nav-menu-btn[aria-expanded="true"] .b2 { opacity: 0; }
.nav:not(.is-fixed) .nav-menu-btn[aria-expanded="true"] .b3 { transform: translateY(calc(-5 * var(--nav-u))) rotate(-45deg) scaleX(1.6); }

/* Landing page reserves space for the fixed header. Must track the bar height
   exactly, which no longer scales with the poster unit. */
.nav-slot { height: 72px; }
@media (width <= 900px) { .nav-slot { height: 64px; } }
@media (width <= 580px) { .nav-slot { height: 56px; } }

/* ---------- breakpoints ---------- */
@media (width <= 1200px) {
  .nav { --nav-gap: calc(32 * var(--nav-u)); }
  .nav:not(.nav--content) { --nav-pad: calc(48 * var(--nav-u)); }
}
@media (width <= 900px) {
  .nav { --nav-gap: calc(24 * var(--nav-u)); }
  .nav:not(.nav--content) { --nav-pad: calc(32 * var(--nav-u)); }
  .nav { --nav-h: calc(64 * var(--nav-u)); }
  .nav .brand-wordmark { height: calc(46 * var(--nav-u)); }
  .nav-links { display: none; }
  .nav-menu-btn { display: block; }
  .nav .cta, .nav .pill {
    height: calc(36 * var(--nav-u));
    padding: 0 calc(16 * var(--nav-u));
    font-size: calc(13 * var(--nav-u));
  }
}
@media (width <= 580px) {
  .nav { --nav-h: calc(56 * var(--nav-u)); }
  .nav:not(.nav--content) { --nav-pad: calc(20 * var(--nav-u)); }
  .nav .brand-wordmark { height: calc(40 * var(--nav-u)); }
  .nav-actions { gap: calc(8 * var(--nav-u)); }
  .nav .cta, .nav .pill {
    height: calc(34 * var(--nav-u));
    padding: 0 calc(13 * var(--nav-u));
    font-size: calc(12.5 * var(--nav-u));
  }
  .nav .lang-toggle, .nav .lang { padding: calc(5 * var(--nav-u)) calc(7 * var(--nav-u)); font-size: calc(11 * var(--nav-u)); }
  .nav-menu-btn { width: calc(36 * var(--nav-u)); height: calc(36 * var(--nav-u)); }
  .nav-card { left: calc(8 * var(--nav-u)); width: auto; }
}
