/* 自定义Header组件样式 */

/* 滚动效果 */
#header-bg.scrolled {
  backdrop-filter: blur(6px);
  background: rgba(249, 250, 251, 0.8);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.04),
    0 4px 8px rgba(0, 0, 0, 0.04);
}

/* 黑暗模式样式 */
[data-theme="dark"] #header-bg.scrolled {
  background: rgba(15, 23, 42, 0.8);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3),
    0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

/* 添加导航高亮背景的过渡动画 */
#nav-primary-highlight,
#nav-secondary-highlight {
  transition: left 0.3s ease, top 0.3s ease, width 0.3s ease, height 0.3s ease, opacity 0.3s ease;
}

/* 改进子菜单的动画效果 */
.nav-group-items {
  transition: opacity 0.3s ease;
}

.nav-group-items.menu-hidden {
  opacity: 0;
  pointer-events: none;
}

/* 二级菜单展开状态 */
.nav-group-items.menu-visible {
  display: block;
  opacity: 1;
  z-index: 21;
  transition: opacity 0.3s ease;
}

/* 一级菜单按钮在二级菜单展开时隐藏 - 保留这个类以确保JavaScript功能正常 */
.nav-group-toggle {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.nav-group-toggle.menu-up {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition: opacity 0.3s ease;
}

/* 导航项的文字颜色过渡 */
.nav-item, .nav-subitem, .nav-group-toggle {
  transition: color 0.3s ease, font-weight 0.15s ease;
}

/* 页面加载时立即显示高亮，无需等待JavaScript */
.nav-selector[data-has-active="true"] #nav-primary-highlight,
.nav-selector[data-has-active="true"] #nav-secondary-highlight {
  opacity: 1;
}

/* 汉堡菜单动画样式 */
.hamburger-menu {
  width: 24px;
  height: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.hamburger-line {
  width: 100%;
  height: 2px;
  background-color: currentColor;
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}

/* 菜单打开时的样式 */
[aria-expanded="true"] .hamburger-menu .line-1 {
  transform: translateY(8px) rotate(45deg);
}

[aria-expanded="true"] .hamburger-menu .line-2 {
  opacity: 0;
}

[aria-expanded="true"] .hamburger-menu .line-3 {
  transform: translateY(-8px) rotate(-45deg);
}

/* 移动端子菜单展开动画 */
.mobile-menu-arrow {
  transition: transform 0.3s ease;
}

/* 移动端菜单图标容器 */
.mobile-menu-icon {
  position: relative;
  transition: transform 0.3s ease;
}

/* 子菜单展开/收起动画 - 完全重写 */
.mobile-submenu {
  height: auto;
  max-height: 0;
  visibility: hidden;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-10px);
  transition: 
    max-height 0.3s ease, 
    opacity 0.3s ease, 
    transform 0.3s ease,
    visibility 0s linear 0.3s,  /* 延迟visibility变化 */
    padding 0.3s ease;
  padding-top: 0;
  padding-bottom: 0;
}

.mobile-submenu.menu-visible {
  max-height: 500px; /* 足够大以容纳所有内容 */
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: 
    max-height 0.3s ease, 
    opacity 0.3s ease, 
    transform 0.3s ease,
    visibility 0s linear 0s, /* 立即改变visibility */
    padding 0.3s ease;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}