nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 247, 0.9);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background .3s ease;
}

nav.scrolled {
  border-bottom-color: var(--line);
}

.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-mark {
  width: 36px;
  height: auto;
  display: block;
}

.logo-word {
  /* MATLEX wordmark has a stouter ~7.8:1 ratio, so we bump height up
     to keep the rendered width similar to the old METALLIX lockup. */
  height: 16px;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.nav-links a {
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-radius: 9999px;
  transition: background .2s, color .2s;
  letter-spacing: -0.005em;
}

.nav-links a:hover {
  background: rgba(211, 242, 192, 0.5);
}

.nav-links a.current {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.nav-ctas {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* === Mobile hamburger + drawer ======================================
   Desktop: burger is hidden, nav-links visible, both CTAs visible.
   Mobile (≤860px):
     - nav-links inside the top bar are hidden
     - "查看数据表" ghost CTA is hidden (duplicates the nav drawer link)
     - burger shown; tapping it toggles body.nav-open → drawer slides in
*/
.nav-burger {
  display: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
  border-radius: 10px;
  flex-shrink: 0;
}
.nav-burger:hover { background: var(--bg-soft); }
.nav-burger-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .22s ease, opacity .22s ease, top .22s ease;
}
.nav-burger-bar:nth-child(1) { top: 15px; }
.nav-burger-bar:nth-child(2) { top: 21px; }
.nav-burger-bar:nth-child(3) { top: 27px; }
body.nav-open .nav-burger-bar:nth-child(1) { top: 21px; transform: rotate(45deg); }
body.nav-open .nav-burger-bar:nth-child(2) { opacity: 0; }
body.nav-open .nav-burger-bar:nth-child(3) { top: 21px; transform: rotate(-45deg); }

/* Drawer — slides down from under the nav, covers the viewport. */
.nav-drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(14, 15, 18, 0.3);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity .24s ease;
  pointer-events: none;
  visibility: hidden;
}
.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(88vw, 360px);
  background: var(--bg-card);
  z-index: 95;
  box-shadow: -12px 0 40px rgba(14, 15, 18, 0.12);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  display: flex;
  flex-direction: column;
  padding: 80px 22px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  visibility: hidden;
}
body.nav-open .nav-drawer-scrim {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
body.nav-open .nav-drawer {
  transform: translateX(0);
  visibility: visible;
}

.nav-drawer-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-drawer-list a {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 14px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  font-size: 19px;
  text-decoration: none;
  transition: background .15s;
}
.nav-drawer-list a:hover,
.nav-drawer-list a:active {
  background: var(--bg-soft);
}
.nav-drawer-list a .k {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
  width: 28px;
  flex-shrink: 0;
}
.nav-drawer-list a.nav-drawer-sub {
  margin-top: 8px;
  padding: 16px 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 16px;
  justify-content: center;
}
.nav-drawer-list a.nav-drawer-sub .v { width: 100%; text-align: center; }
.nav-drawer-foot {
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
  margin-top: 12px;
}

/* Lock body scroll while drawer is open so it feels native. */
body.nav-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-inner { padding: 14px 18px; gap: 10px; }
  .nav-ctas { gap: 6px; }
  /* On mobile we lean on the drawer for secondary actions. Compound
     selectors (.nav-ctas .nav-cta-*) raise specificity above the global
     .btn rule that loads after this file, so display:none actually wins. */
  .nav-ctas .nav-cta-alt,
  .nav-ctas .nav-cta-primary { display: none; }
  .nav-burger { display: block; }
}

@media (max-width: 560px) {
  /* Everything already accommodated by the 860 breakpoint. */
}
