/* ============================================
   Mobile Navigation - Modern Glassmorphism Design
   ============================================ */

/* -------------------------------------------
   1. 基础变量（深色主题）
   ------------------------------------------- */
:root {
  --nav-bg: rgba(26, 26, 26, 0.95);
  --nav-bg-solid: #1a1a1a;
  --nav-header-bg: rgba(30, 30, 30, 0.98);
  --nav-border: rgba(255, 255, 255, 0.08);
  --nav-text: #e0e0e0;
  --nav-text-muted: #888;
  --nav-text-hover: #fff;
  --nav-accent: #69c;
  --nav-accent-hover: #8ab4f8;
  --nav-submenu-bg: rgba(15, 15, 15, 0.6);
  --nav-search-bg: rgba(40, 40, 40, 0.8);
  --nav-search-border: rgba(255, 255, 255, 0.1);
  --nav-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --nav-backdrop: rgba(0, 0, 0, 0.6);
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* -------------------------------------------
   2. 汉堡菜单按钮
   ------------------------------------------- */
.mobile-menu-toggle {
  display: none;
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 999; /* 默认低于导航面板 */
  border-radius: 12px;
  transition: all 0.3s var(--transition-smooth);
  align-items: center;
  justify-content: center;
}

.mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mobile-menu-toggle:active {
  transform: translateY(-50%) scale(0.95);
}

.mobile-menu-toggle svg {
  width: 24px;
  height: 24px;
  color: var(--nav-text);
  transition: all 0.3s ease;
}

/* 菜单打开时：按钮变X并隐藏到导航面板后方 */
.mobile-menu-toggle.active {
  z-index: 998; /* 确保被导航面板(1000)盖住 */
  opacity: 0; /* 平滑淡出 */
  pointer-events: none; /* 防止误点 */
  transform: translateY(-50%) scale(0.8);
}

/* -------------------------------------------
   3. 遮罩层
   ------------------------------------------- */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: var(--nav-backdrop);
  backdrop-filter: blur(4px);
  z-index: 999; /* 与按钮同级，但按文档顺序在后 */
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s var(--transition-smooth);
}

.mobile-nav-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* -------------------------------------------
   4. 导航面板 - 玻璃拟态风格
   ------------------------------------------- */
.mobile-nav-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 85%;
  max-width: 360px;
  height: 100vh;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--nav-border);
  box-shadow: var(--nav-shadow);
  z-index: 1000; /* 高于按钮和遮罩 */
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.4s var(--transition-smooth);
  overflow: hidden;
}

.mobile-nav-panel.active {
  transform: translateX(0);
}

/* -------------------------------------------
   5. 面板头部 - 高度减半
   ------------------------------------------- */
.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;  /* 原来是 20px，减半为 10px */
  background: var(--nav-header-bg);
  border-bottom: 1px solid var(--nav-border);
  position: relative;
  flex-shrink: 0; /* 防止被压缩 */
}

.mobile-nav-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--nav-accent), transparent);
  opacity: 0.3;
}

.mobile-nav-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--nav-text);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-nav-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--nav-accent);
  border-radius: 2px;
}

/* 头部内的关闭按钮 */
.mobile-nav-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--nav-text-muted);
}

.mobile-nav-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--nav-text-hover);
  transform: rotate(90deg);
}

.mobile-nav-close svg {
  width: 20px;
  height: 20px;
}

/* -------------------------------------------
   6. 菜单内容区域
   ------------------------------------------- */
.mobile-nav-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;  /* 原来是 12px，减半为 6px */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.mobile-nav-content::-webkit-scrollbar {
  width: 4px;
}

.mobile-nav-content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

/* -------------------------------------------
   7. 菜单项样式 - 高度减半
   ------------------------------------------- */
.mobile-nav-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-nav-item {
  border-bottom: 1px solid var(--nav-border);
  position: relative;
  overflow: hidden;
}

.mobile-nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--nav-accent);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.mobile-nav-item:hover::before {
  transform: scaleY(1);
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  padding: 8px 24px;  /* 原来是 16px，减半为 8px */
  color: var(--nav-text);
  text-decoration: none;
  font-size: 15px;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  position: relative;
}

.mobile-nav-link:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--nav-text-hover);
  padding-left: 28px;
}

/* 带展开按钮的菜单项布局 */
.mobile-nav-item.has-children .mobile-nav-link-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-nav-item.has-children .mobile-nav-link {
  flex: 1;
}

/* 展开/收起按钮 - 高度减半 */
.mobile-nav-toggle {
  width: 44px;
  height: 36px;  /* 原来是 52px，减半为 36px */
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nav-text-muted);
  transition: all 0.3s ease;
  position: relative;
  flex-shrink: 0;
}

.mobile-nav-toggle:hover {
  color: var(--nav-accent);
  background: rgba(255, 255, 255, 0.03);
}

.mobile-nav-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s var(--transition-smooth);
}

.mobile-nav-toggle.expanded svg {
  transform: rotate(180deg);
  color: var(--nav-accent);
}

/* -------------------------------------------
   8. 子菜单样式 - 高度减半
   ------------------------------------------- */
.mobile-submenu {
  max-height: 0;
  overflow: hidden;
  background: var(--nav-submenu-bg);
  transition: max-height 0.4s var(--transition-smooth);
}

.mobile-submenu.expanded {
  max-height: 500px;
}

.mobile-submenu-list {
  list-style: none;
  padding: 4px 0;  /* 原来是 8px，减半为 4px */
  margin: 0;
}

.mobile-submenu-item {
  position: relative;
}

.mobile-submenu-link {
  display: block;
  padding: 6px 24px 6px 48px;  /* 原来是 12px，减半为 6px */
  color: var(--nav-text-muted);
  text-decoration: none;
  font-size: 15px;
  letter-spacing: 0.03em;
  transition: all 0.3s ease;
  position: relative;
}

.mobile-submenu-link::before {
  content: '';
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border: 1.5px solid var(--nav-text-muted);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.mobile-submenu-link:hover {
  color: var(--nav-text-hover);
  background: rgba(255, 255, 255, 0.02);
  padding-left: 52px;
}

.mobile-submenu-link:hover::before {
  border-color: var(--nav-accent);
  background: var(--nav-accent);
  box-shadow: 0 0 8px var(--nav-accent);
}

/* -------------------------------------------
   9. 底部搜索框 - 高度减半
   ------------------------------------------- */
.mobile-nav-search {
  padding: 10px 24px;  /* 原来是 20px，减半为 10px */
  background: var(--nav-header-bg);
  border-top: 1px solid var(--nav-border);
  position: relative;
  flex-shrink: 0; /* 防止被压缩 */
}

.mobile-nav-search::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--nav-accent), transparent);
  opacity: 0.2;
}

.mobile-search-form {
  position: relative;
  display: flex;
  align-items: center;
}

.mobile-search-input {
  width: 100%;
  height: 36px;  /* 原来是 48px，减半为 36px */
  padding: 0 40px 0 16px;  /* 右侧padding稍微减少以适应新高度 */
  background: var(--nav-search-bg);
  border: 1px solid var(--nav-search-border);
  border-radius: 12px;
  color: var(--nav-text);
  font-size: 15px;
  letter-spacing: 0.02em;
  transition: all 0.3s ease;
  outline: none;
}

.mobile-search-input::placeholder {
  color: var(--nav-text-muted);
}

.mobile-search-input:focus {
  border-color: var(--nav-accent);
  background: rgba(40, 40, 40, 1);
  box-shadow: 0 0 0 3px rgba(105, 204, 204, 0.1);
}

.mobile-search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;  /* 原来是 36px，适当减小 */
  height: 28px;  /* 原来是 36px，适当减小 */
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nav-text-muted);
  transition: all 0.3s ease;
}

.mobile-search-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--nav-accent);
}

.mobile-search-btn svg {
  width: 16px;  /* 原来是 18px，稍微减小 */
  height: 16px;  /* 原来是 18px，稍微减小 */
}

/* -------------------------------------------
   10. 响应式显示控制
   ------------------------------------------- */
@media screen and (max-width: 1024px) {
  .mobile-menu-toggle {
    display: flex;
  }
  
  /* 调整顶部导航布局，为汉堡菜单留出空间 */
  #navigation {
    padding-left: 60px !important;
  }
}

/* -------------------------------------------
   11. 动画关键帧
   ------------------------------------------- */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 菜单项进入动画 */
.mobile-nav-panel.active .mobile-nav-item {
  animation: slideInLeft 0.4s var(--transition-smooth) backwards;
}

.mobile-nav-panel.active .mobile-nav-item:nth-child(1) { animation-delay: 0.05s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(2) { animation-delay: 0.1s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(3) { animation-delay: 0.15s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(4) { animation-delay: 0.2s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(5) { animation-delay: 0.25s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(6) { animation-delay: 0.3s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(7) { animation-delay: 0.35s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(8) { animation-delay: 0.4s; }
.mobile-nav-panel.active .mobile-nav-item:nth-child(9) { animation-delay: 0.45s; }

/* -------------------------------------------
   12. 特殊状态
   ------------------------------------------- */
/* 当前页面高亮 */
.mobile-nav-link.current {
  color: var(--nav-accent);
  background: rgba(105, 204, 204, 0.05);
}

.mobile-nav-link.current::before {
  transform: scaleY(1);
}

/* 禁用背景滚动 */
body.nav-open {
  overflow: hidden;
}

/* 触摸设备优化 */
@media (hover: none) {
  .mobile-nav-link:active {
    background: rgba(255, 255, 255, 0.05);
  }
  
  .mobile-submenu-link:active {
    background: rgba(255, 255, 255, 0.03);
  }
}