/* ==================== 2. Header (吸顶 + 变色) ==================== */
header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2000;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.1)); /* 初始透明 */
  color: #fff;
  transition: all 0.3s ease;
}

/* 页面滚动后的状态：变为品牌色背景 */
header.scrolled {
  background: var(--primary-color);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 菜单打开时的状态：深色背景 */
header.menu-open {
  background: var(--dark-bg);
}
header.menu-open .top-bar {
  height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
}

/* 顶部小条 */
.top-bar {
  height: 40px;
  font-size: 12px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  overflow: hidden; /* 确保高度变0时内容不溢出 */
}
.top-bar a {
  margin-left: 20px;
  opacity: 0.9;
}
.top-bar a:hover {
  opacity: 1;
}
header.scrolled .top-bar,
header.menu-open .top-bar {
  height: 0;
  opacity: 0;
  border-bottom: none; /* 去除边框防止留下一条线 */
  margin: 0;
  padding: 0;
}

/* 主导航栏 */
.main-nav {
  height: 80px;
  display: flex;
  align-items: center;
}

/* Logo 区域：右侧 margin-auto 将导航推向右侧 */
.logo-area {
  margin-right: auto;
  padding-right: 20px;
  flex-shrink: 0;
}

.logo-area img {
  max-width: 600px;
}

/* ==================== 3. 导航菜单 (适配优化) ==================== */
.nav-links {
  display: flex;
  gap: 20px; /* 减小间距以容纳更长的英文 */
  align-items: center;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease;
  flex-wrap: nowrap;
}

/* 菜单打开时隐藏导航文字 */
header.menu-open .nav-links {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.nav-item {
  position: relative;
  height: 80px;
  display: flex;
  align-items: center;
}
.nav-item > a {
  display: block;
  max-width: 85px;
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: 0.3s;
  white-space: nowrap; /* 强制不换行 */
}
.nav-item:hover > a {
  color: var(--accent-yellow);
}
.arrow-icon {
  font-size: 12px;
  margin-top: 2px;
  transition: transform 0.3s;
}
.nav-item:hover .arrow-icon {
  transform: rotate(180deg);
}

/* 二级菜单 */
.dropdown-menu {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #fff;
  min-width: 200px; /* 增加最小宽度适配长单词 */
  width: auto; /* 允许根据内容自适应 */
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
  border-top: 3px solid var(--accent-yellow); /* 黄色顶边框 */
  border-radius: 0 0 4px 4px;
  padding: 5px 0;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
}
.dropdown-menu::before {
  content: "";
  position: absolute;
  top: -20px;
  left: 0;
  width: 100%;
  height: 20px;
}
.nav-item:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.dropdown-menu li {
  position: relative;
}

/* 菜单项：文字居中 */
.dropdown-menu li a {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 12px 15px;
  color: #333;
  font-size: 14px;
  white-space: normal; /* 允许下拉菜单内长文本换行 */
  line-height: 1.4;
  transition: 0.2s;
  position: relative;
}
/* 悬停：背景变主题紫，文字变白 */
.dropdown-menu li:hover > a {
  background-color: var(--primary-color);
  color: #fff;
}

/* 三级菜单 */
.dropdown-submenu {
  position: absolute;
  top: -3px;
  left: 100%;
  background: #fff;
  min-width: 180px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
  border-top: 3px solid var(--accent-yellow);
  border-radius: 0 0 4px 4px;
  padding: 5px 0;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  transform: translateX(-10px);
}
.has-submenu:hover .dropdown-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.arrow-right {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #999;
  transition: 0.2s;
}
.dropdown-menu li:hover > a .arrow-right {
  color: #fff;
}

/* Mobile nav panel (desktop hidden) */
.mobile-menu-panel {
  display: none;
}
.mobile-search {
  display: none;
}
.mobile-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mobile-nav-item {
  border-bottom: 1px solid #f1f1f1;
  position: relative;
}
.mobile-nav-link {
  display: block;
  padding: 16px;
  font-size: 16px;
  color: #111;
}
.mobile-nav-link:hover {
  color: var(--primary-color);
}
.mobile-toggle-btn {
  position: absolute;
  right: 12px;
  top: 28px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
}
.mobile-toggle-btn::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-right: 2px solid #999;
  border-bottom: 2px solid #999;
  transform: rotate(45deg);
  transition: transform 0.25s ease;
}
.mobile-submenu {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0 16px 12px;
  background: #fff;
}
.mobile-nav-item.has-children.open > .mobile-submenu {
  display: block;
}
.mobile-nav-item.has-children.open > .mobile-toggle-btn::before {
  transform: rotate(-135deg);
}
.mobile-submenu a {
  display: block;
  padding: 10px 0;
  color: #111;
  font-size: 14px;
}
.mobile-nav-item.nested .mobile-nav-link {
  padding: 12px 0;
  font-size: 15px;
}
.mobile-bottom-links {
  display: none;
}

/* 汉堡按钮 */
.menu-btn {
  position: absolute;
  top: 10px;
  right: 0;
  font-size: 24px;
  cursor: pointer;
  padding: 10px;
  width: 70px;
  height: 60px;
  text-align: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 30px 0 0 30px;
}
header.menu-open .menu-btn {
  color: var(--accent-yellow);
}

/* ==================== 4. 全屏下拉大菜单 (i18n 优化) ==================== */
.mega-dropdown {
  position: fixed;
  top: 80px;
  left: 0;
  width: 100%;
  height: 0;
  background: linear-gradient(135deg, #1a1e2e 0%, #2a1f30 100%);
  z-index: 1900;
  overflow-y: auto;
  transition: height 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
/* 激活：高度占满剩余屏幕 */
.mega-dropdown.active {
  height: calc(100vh - 80px);
}

.fm-content {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 60px 20px;
  /* [优化] 自动填充网格，适应不同长度内容 */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.4s ease 0.2s;
}
.mega-dropdown.active .fm-content {
  opacity: 1;
  transform: translateY(0);
}

.fm-col {
  padding: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  height: 100%; /* 高度自适应 */
}
/* 移除最后一个的边框 */
.fm-col:last-child {
  border-right: none;
}
.fm-col:hover {
  background: rgba(255, 255, 255, 0.05);
}

.fm-title {
  font-size: 16px;
  margin-bottom: 20px;
  font-weight: bold;
  color: #fff;
  border-bottom: 2px solid var(--accent-yellow);
  padding-bottom: 8px;
  display: inline-block;
  white-space: normal;
  line-height: 1.4;
}
.fm-list li {
  margin-bottom: 10px;
}
.fm-list a {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  display: block;
  line-height: 1.4;
}
.fm-list a:hover {
  color: #fff;
  padding-left: 5px;
}
.fm-sub-group {
  margin-bottom: 15px;
}
.fm-sub-group h4 {
  font-size: 14px;
  color: #ddd;
  margin-bottom: 8px;
}
.fm-sub-group h4:hover {
  cursor: pointer;
}

.fm-bg-img {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("https://picsum.photos/1920/600?grayscale&blur=2") no-repeat bottom center/cover;
  opacity: 0.1;
  pointer-events: none;
  z-index: -1;
}

/* ==================== 5. 全屏检索弹层 ==================== */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.search-modal {
  width: 90%;
  max-width: 640px;
  background: rgba(10, 16, 32, 0.96);
  border-radius: 16px;
  padding: 48px 28px 26px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  position: relative;
  color: #fff;
}

.search-title {
  font-size: 22px;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input-wrapper {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-radius: 999px;
  overflow: hidden;
  background: transparent;
}

.search-input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  background: #fff;
  color: #111;
  font-size: 15px;
  padding: 10px 14px;
}

.search-input-wrapper input::placeholder {
  color: #9ca3af;
}

.search-submit {
  min-width: 60px;
  padding: 0 18px;
  border: none;
  background: var(--primary-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
}

.search-submit i {
  font-size: 16px;
}

.search-submit:hover {
  background: #3343a3; /* 比主题色略深一点的悬停状态，如需可调整 */
  transform: translateY(-1px);
}

.search-tip {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.search-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
}

.search-close:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.02);
}

.search-close i {
  font-size: 16px;
}

/* --- 3. 手机端 (小于 768px) --- */
@media screen and (max-width: 768px) {
  /* 顶部 TopBar 隐藏 (手机屏幕宝贵) */
  .top-bar {
    display: none;
  }

  .nav-links {
    display: none; /* mobile uses custom panel */
  }
  .nav-item > a {
    color: #111;
  }
  .nav-item:hover > a {
    color: var(--primary-color);
  }
  .arrow-icon {
    color: #111;
  }

  /* 调整 Header 高度 */
  .main-nav,
  .nav-item {
    height: 3.75rem;
  }
  .logo-area img {
    height: 1.875rem; /* 缩小 Logo */
  }
  .logo-area span {
    display: none; /* 手机端隐藏认证小字，避免拥挤 */
  }

  /* 调整菜单按钮位置和大小 */
  .menu-btn {
    height: 3.75rem;
    width: 3.75rem;
    top: 0; /* 因为 TopBar 没了，直接顶头 */
    font-size: 1.25rem;
    background: #fff;
    color: #111;
    border: 1px solid #e9e9e9;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
  }
  header.menu-open .menu-btn {
    color: var(--primary-color);
  }

  /* 调整下拉大菜单的位置 */
  .mega-dropdown {
    top: 3.75rem;
    background: #fff;
    color: #111;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.12);
  }
  .mega-dropdown.active {
    height: calc(100vh - 3.75rem);
  }
  .mega-dropdown .fm-content {
    display: none;
  }
  .mega-dropdown .fm-bg-img {
    display: none;
  }
  .mobile-menu-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    min-height: calc(100vh - 3.75rem);
  }
  .mobile-search {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 5;
  }
  .mobile-search input {
    flex: 1;
    height: 2.5rem;
    border: 1px solid #e2e5ea;
    border-radius: 0.5rem;
    padding: 0 0.75rem;
    font-size: 0.875rem;
  }
  .mobile-search button {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: var(--primary-color);
    color: #fff;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-nav-list {
    background: #fff;
  }
  .mobile-nav-item {
    border-bottom: 1px solid #f0f0f0;
  }
  .mobile-nav-link {
    background: #fff;
    color: #111;
  }
  .mobile-submenu {
    background: #fff;
    border-top: 1px solid #f5f5f5;
  }
  .mobile-submenu *,
  .mobile-submenu a {
    color: #999;
  }
  .mobile-bottom-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem 0.5rem;
    padding: 0.875rem 1rem 1.5rem;
    border-top: 1px solid #eee;
  }
  .mobile-bottom-links a {
    color: var(--primary-color);
    font-size: 0.875rem;
    flex: 1;
    text-align: center;
  }

  /* 大菜单改为单列显示（桌面内容隐藏时不生效，仅保留以防需要） */
  .fm-content {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .fm-col {
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    min-height: auto;
    padding: 0.9375rem 0;
  }

  /* 字体调整 */
  .section-title {
    font-size: 1.375rem;
  }
  .news-date-large {
    font-size: 1.75rem;
  }

  /* 调整 Tab 标题 */
  .tab-title {
    font-size: 1rem;
    margin: 0 0.625rem;
  }
  .divider-v {
    margin: 0 0.3125rem;
  }

  .student-grid {
    display: flex;
    flex-direction: column;
    gap: 0.9375rem;
    padding-bottom: 2.5rem;
  }
  .stu-item {
    width: 100%;
    height: 12.5rem; /* 统一高度 */
  }
  /* 恢复特定卡片的特殊高度 */
  .stu-item-4 {
    height: 18.75rem;
  }
}

@media screen and (max-width: 1400px) {
  .logo-area {
    margin-right: unset;
  }
  .top-bar {
      margin-right: 70px;
   }
}