/* =========================================================
   导航栏 v5 —— 纯文字导航 + 滑动短下划线 + 紧凑下拉
   设计原则：单一颜色、无渐变、无高光、无胶囊容器
   结构由 js/nav.js 在运行时生成，无需改各页面 HTML
   ========================================================= */

/* ---------- 色板（全部纯色） ---------- */
:root {
  --nh-bar: var(--haitang-bg, var(--bg, #fffcf5));
  --nh-card: #ffffff;
  --nh-hover: #f6f0e4;
  --nh-line: rgba(74, 56, 32, 0.1);
  --nh-text: var(--haitang-text, var(--text, #2a2620));
  --nh-muted: var(--haitang-text-light, var(--text-light, #7a6a56));
  --nh-accent: var(--haitang-accent, var(--accent, #c18a4a));
  --nh-shadow: 0 14px 34px -18px rgba(58, 42, 20, 0.28), 0 2px 6px -3px rgba(58, 42, 20, 0.08);
}

[data-theme="dark"] {
  --nh-bar: var(--haitang-bg, #17140f);
  --nh-card: #221e18;
  --nh-hover: #2c2720;
  --nh-line: rgba(255, 255, 255, 0.09);
  --nh-shadow: 0 16px 36px -18px rgba(0, 0, 0, 0.7), 0 2px 6px -3px rgba(0, 0, 0, 0.4);
}

/* ---------- 顶栏 ---------- */
.main-navigation-bar {
  height: 68px;
  padding: 0 28px;
  background: var(--nh-bar);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom: 1px solid var(--nh-line);
}
.main-navigation-bar.scrolled {
  box-shadow: none;
}

.nav-inner { gap: 14px; }
.nav-left { gap: 10px; }
.nav-avatar {
  width: 36px;
  height: 36px;
  font-size: 15px;
}
.nav-name { font-size: 16px; white-space: nowrap; }
.nav-subtitle { font-size: 10px; margin-top: 1px; letter-spacing: 0.12em; }

.nav-right { gap: 8px; }
.nav-right .nav-clock { font-size: 12px; letter-spacing: 0.02em; }
.theme-toggle { width: 32px; height: 32px; }

.nav-right > .btn-primary {
  padding: 7px 16px !important;
  font-size: 12.5px !important;
  border-radius: 999px !important;
}

/* ---------- 导航区：无容器，纯文字排布 ---------- */
.nav-center {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.nh-nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* ---------- 滑动短下划线 ---------- */
.nh-glide {
  position: absolute;
  bottom: 7px;
  left: 0;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--nh-accent);
  opacity: 0;
  transform: translateX(0);
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.18s ease;
  pointer-events: none;
  z-index: 0;
}

/* ---------- 链接 ---------- */
.nh-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 10px 11px;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--nh-muted);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease;
  animation: nhFadeIn 0.4s ease backwards;
  animation-delay: calc(var(--i, 0) * 26ms);
}

.nh-link:hover { color: var(--nh-text); }
.nh-link.is-active, .nh-link.is-open { color: var(--nh-text); font-weight: 600; }

@keyframes nhFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 新功能小圆点 */
.nh-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--nh-accent);
  align-self: flex-start;
  margin-top: 1px;
  margin-left: 1px;
}

/* 分组箭头 */
.nh-caret {
  width: 10px;
  height: 10px;
  margin-left: 1px;
  opacity: 0.55;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.nh-link:hover .nh-caret { opacity: 0.85; }
.nh-link.is-open .nh-caret { transform: rotate(180deg); opacity: 1; }

/* ---------- 下拉卡片 ---------- */
.nh-menu {
  position: absolute;
  /* 顶到导航底边，靠 padding-top 做视觉间距：鼠标下移时不会经过「空白缝隙」而丢失 hover */
  top: 100%;
  left: 0;
  z-index: 8;
  padding-top: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -4px);
  pointer-events: none;
  transition:
    opacity 0.16s ease,
    visibility 0s linear 0.16s,
    transform 0.24s ease;
}

.nh-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  pointer-events: auto;
  transition:
    opacity 0.18s ease,
    visibility 0s,
    transform 0.26s ease;
}

.nh-menu-card {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 168px;
  padding: 5px;
  border-radius: 12px;
  background: var(--nh-card);
  border: 1px solid var(--nh-line);
  box-shadow: var(--nh-shadow);
}

/* ---------- 菜单项（单行） ---------- */
.nh-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--nh-muted);
  text-decoration: none;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.nh-menu.is-open .nh-item {
  animation: nhItemIn 0.26s ease backwards;
  animation-delay: calc(var(--i, 0) * 26ms + 30ms);
}

@keyframes nhItemIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.nh-item:hover { background: var(--nh-hover); color: var(--nh-text); }
.nh-item.is-active { color: var(--nh-text); }
.nh-item.is-active .nh-item-t { font-weight: 600; }

.nh-item-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--nh-muted);
  transition: color 0.16s ease;
}
.nh-item-ic svg { width: 15px; height: 15px; }
.nh-item:hover .nh-item-ic,
.nh-item.is-active .nh-item-ic { color: var(--nh-accent); }

.nh-item-t { flex: 1; min-width: 0; white-space: nowrap; }

.nh-item-ar {
  flex: none;
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  color: var(--nh-accent);
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity 0.16s ease, transform 0.2s ease;
}
.nh-item-ar svg { width: 11px; height: 11px; }
.nh-item:hover .nh-item-ar { opacity: 1; transform: none; }

/* ---------- 紧凑模式（宁可缩小，也不折叠） ---------- */
.nh-nav.is-compact .nh-link { padding: 10px 8px; font-size: 13px; }
.nh-nav.is-compact .nh-caret { width: 9px; height: 9px; }

.nh-nav.is-tight .nh-link { padding: 10px 6px; font-size: 12.4px; gap: 2px; }
.nh-nav.is-tight .nh-dot { display: none; }
.nh-nav.is-tight .nh-caret { width: 8px; height: 8px; margin-left: 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
  .nav-subtitle { display: none; }
  .nav-right .nav-clock { display: none; }
}

@media (max-width: 1024px) {
  .main-navigation-bar { padding: 0 18px; }
  .nav-name { font-size: 15px; }
  .nh-link { padding: 10px 9px; font-size: 13px; }
}

@media (max-width: 900px) {
  .nav-name { display: none; }
}

@media (max-width: 768px) {
  .nav-center { display: none; }
  .nav-subtitle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nh-link,
  .nh-glide,
  .nh-menu,
  .nh-item {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}
