/* ============================================
   nav/common.css —— 全站公共层（定稿 v3）
   token / reset / 氛围光 / 导航 / 滑动指示器 / 滚动进度 / 页面过渡
   每个页面只引这一份，导航与氛围零重复
   ============================================ */

/* ---------- TOKENS ---------- */
:root {
  --brand: #ffca1d;
  --brand-light: rgba(255, 192, 0, 0.05);
  --brand-glow: rgba(255, 192, 0, 0.15);
  --white: #ffffff;
  --bg: #f5f5f7;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-bg-heavy: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: rgba(0, 0, 0, 0.06);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --transition: 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-fast: 0.2s ease;
  --font-display:
    "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-body:
    "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- RESET ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- AMBIENT BACKGROUND（全站氛围光斑） ---------- */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
}
body::before {
  width: 700px;
  height: 700px;
  background: rgba(255, 192, 0, 0.14);
  top: -150px;
  right: -200px;
}
body::after {
  width: 600px;
  height: 600px;
  background: rgba(255, 192, 0, 0.08);
  bottom: 200px;
  left: -200px;
}
.bg-decor {
  position: fixed;
  z-index: -1;
  pointer-events: none;
}
.bg-decor-1 {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255, 192, 0, 0.05);
  top: 50%;
  right: 5%;
  filter: blur(80px);
}
.bg-decor-2 {
  width: 200px;
  height: 400px;
  border-radius: 200px;
  background: rgba(255, 192, 0, 0.04);
  bottom: 10%;
  left: 10%;
  filter: blur(60px);
  transform: rotate(-20deg);
}

/* 导航栏收起动画：仅用于跳转主页时的过渡 */
.nav.home-transition {
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}
.nav.home-transition--active {
  transform: translateY(-100%);
}

/* ---------- SCROLL PROGRESS（顶部黄色进度条） ----------
   nav 的子元素（absolute 贴导航下边缘），回首页时随 nav 一起收起。
   两种状态由 data-mode 切换：
   scroll → 宽度跟随滚动（JS 写入，无 transition）
   load   → 充能模式：JS 写 width:100%，由下方 transition 平滑扫满，
            到边后停住不退，等新页面 reveal() 做满格淡出收尾 */
.scroll-progress {
  position: absolute;
  bottom: -3px;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), #ffca1d);
  z-index: 1001;
  border-radius: 0 3px 3px 0;
}
/* 充能模式：宽度变化参与过渡（时长与 JS 的 LOAD_MS 保持一致） */
.scroll-progress[data-mode="load"] {
  transition: width 1.6s cubic-bezier(0.3, 0.8, 0.3, 1);
}
/* 充能中：辉光增强，像真的在"灌能" */
.scroll-progress.loading {
  box-shadow: 0 0 16px rgba(255, 192, 0, 0.95);
}
/* 满格收尾：宽度钉死 100%（防止恢复滚动值时回缩），只淡出 */
.scroll-progress.load-done {
  width: 100% !important;
  animation: progressDone 1.95s ease 1.92s forwards;
}
@keyframes progressDone {
  to {
    opacity: 0;
  }
}
/* ---------- NAV（常驻，滚动只加阴影，绝不收起/隐藏） ---------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0 48px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--glass-bg-heavy);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  transition:
    box-shadow var(--transition),
    background var(--transition);
}
/* 滚动后：阴影浮起 + 玻璃再实一点，让"光影变化"可被看见 */
.nav.scrolled {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 30px var(--glass-shadow);
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity var(--transition-fast);
}
.nav-logo:hover {
  opacity: 0.72;
}
.nav-logo .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-block;
  animation: dotPulse 2.6s ease-in-out infinite;
}
@keyframes dotPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--brand-glow);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 192, 0, 0);
  }
}

/* ---------- NAV LINKS + 滑动指示器 ---------- */
.nav-links {
  display: flex;
  gap: 8px;
  list-style: none;
  position: relative; /* 滑块定位基准 */
}

/* 会滑动的黄色外边框：淡黄底(芯) + 黄描边(框) + 底部小黄点(锚) */
.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: var(--brand-light);
  border: 1px solid rgba(255, 192, 0, 0.4);
  border-radius: 100px;
  box-shadow:
    0 2px 12px rgba(255, 192, 0, 0.12),
    0 0 0 3px rgba(255, 192, 0, 0.06);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  transition:
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    /* 带一点回弹 */ width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
}
.nav-indicator::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 6px var(--brand-glow);
}
.nav-links li {
  position: relative;
  z-index: 1; /* 文字浮在滑块之上 */
}
.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 100px;
  display: block;
  position: relative;
  /* 颜色与字重都参与过渡：切换当前项时，文字"变黑变粗"是滑过去的，不是跳变的 */
  transition:
    color var(--transition-fast),
    font-weight var(--transition-fast);
}
.nav-links a:hover {
  color: var(--text-primary);
}
/* 当前项：文字更黑更粗（视觉重量↑），背景交给滑块，不重复画 */
.nav-links a.active {
  color: var(--text-primary);
  font-weight: 600;
}
/* ---------- NAV TOGGLE（移动） ---------- */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  position: relative;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  position: absolute;
  left: 8px;
  transition:
    top var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
}
.nav-toggle span:nth-child(1) {
  top: 12px;
}
.nav-toggle span:nth-child(2) {
  top: 17px;
}
.nav-toggle span:nth-child(3) {
  top: 22px;
}
.nav-toggle.open span:nth-child(1) {
  top: 17px;
  transform: rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  top: 17px;
  transform: rotate(-45deg);
}

/* ==========================================
   新增：联系按钮动画 (Contact Button Animation)
   ========================================== */
@keyframes popAndReturn {
  0% {
    transform: scale(1);
  }
  50% {
    /* 放大并向上微移，模拟“弹起” */
    transform: scale(1.15) translateY(-4px);
  }
  100% {
    /* 恢复原位 */
    transform: scale(1) translateY(0);
  }
}

/* 当 JS 添加 .pop 类时触发动画 */
.nav-links a.contact-btn.pop {
  animation: popAndReturn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ---------- PAGE TRANSITION ----------
   只淡"内容"，不淡导航：导航与进度条是全站常驻家具，
   跳转时留在原地，内容淡出/淡入，毛玻璃与进度条的观感不被打断。
   ★ 兜底：JS 没跑时，1.6s 后此动画也会强制点亮整页，杜绝永久透明。 */
html {
  opacity: 0;
  animation: pageReveal 0.6s ease 1.6s forwards;
}
@keyframes pageReveal {
  to {
    opacity: 1;
  }
}
/* 离场：内容整体上移淡出（导航及其内部的进度条除外） */
body.page-leaving > *:not(.nav) {
  opacity: 0 !important;
  transform: translateY(-14px) !important;
  transition:
    opacity 0.28s ease,
    transform 0.28s ease !important;
}
/* 进场：内容从下方浮现（导航已在，不参与） */
body.page-entering > *:not(.nav) {
  animation: contentIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes contentIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ---------- RESPONSIVE（导航部分） ---------- */
@media (max-width: 768px) {
  .nav {
    padding: 0 24px;
  }
  .nav-links {
    display: none;
  }
  .nav-toggle {
    display: block;
  }
  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-bottom: 1px solid var(--glass-border);
    padding: 16px 24px;
    gap: 4px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
  }
  .nav-links.mobile-open .nav-indicator {
    display: none;
  }
  .nav-links.mobile-open a.active {
    background: var(--brand-light);
    box-shadow: inset 3px 0 0 var(--brand);
  }
}

/* ---------- 减弱动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  html {
    scroll-behavior: auto;
    opacity: 1;
  }
}

/* ---- Logo（v3.6 图片版） ---- */
.nav-logo {
  display: inline-flex;
  align-items: center;
  line-height: 0; /* 消除 img 基线空隙 */
}
.nav-logo-img {
  height: 200px; /* ← 用高度控制 logo 大小，宽度自适应 */
  width: auto;
  display: block;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.nav-logo:hover .nav-logo-img {
  transform: translateY(-1px);
}
.nav-logo:active .nav-logo-img {
  transform: scale(0.96);
}
