/* ==========================================================================
   中育启智教育 · 公共组件样式（site.css）
   —— 依赖 tokens.css，必须先引用 tokens.css 再引用本文件
   —— 包含：基础重置 / 导航 / 页脚 / 按钮 / 卡片 / 徽章 / 表单 /
           步骤条 / 弹窗 / Toast / 子页面骨架
   —— 首页有自己的视觉扩展（home/css/style.css），本文件提供公共基座
   ========================================================================== */

/* ---------- 基础重置 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

/* ---------- 容器 ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ==========================================================================
   导航（.site-nav）
   —— 默认白底 + 阴影，适用于子页面（简化导航）
   —— 首页会在自己的样式里用 .site-nav--hero 覆盖为透明悬浮
   ========================================================================== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* LOGO：蓝色渐变方块 + 「启」字 */
.nav-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.nav-brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.nav-site {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}

.nav-page {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  color: var(--text-secondary);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.nav-links a:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-links a.is-active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-soft);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* 移动端汉堡按钮（默认隐藏，小屏显示） */
.nav-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  color: var(--text);
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   页脚（.site-footer）
   ========================================================================== */
.site-footer {
  background: #101a33;
  color: rgba(255, 255, 255, 0.65);
  padding: 36px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
}

.footer-slogan {
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.45);
}

.footer-copy {
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   按钮（.btn）
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast),
    border-color var(--dur-fast), box-shadow var(--dur-fast),
    transform var(--dur-fast);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 18px rgba(43, 90, 237, 0.3);
}

.btn-outline {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn-disabled,
.btn[aria-disabled="true"] {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 6px 14px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 32px;
  font-size: var(--fs-md);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   卡片（.card）
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   徽章（.badge）
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge-online {
  background: var(--success-soft);
  color: var(--success);
}

.badge-coming {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
}

.badge-test {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-domestic {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-intl {
  background: var(--accent-soft);
  color: #b45309;
}

/* ==========================================================================
   表单（.form-*）
   ========================================================================== */
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 90, 237, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  resize: vertical;
  min-height: 96px;
}

/* 拖拽上传区（各项目按需使用） */
.drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.drop:hover,
.drop.is-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* ==========================================================================
   步骤条（.steps）
   ========================================================================== */
.steps {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  flex-wrap: wrap;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.steps .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.steps li.is-active {
  color: var(--primary);
  font-weight: 600;
}

.steps li.is-active .step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.steps li.is-done .step-num {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.steps .step-arrow {
  color: var(--border-strong);
}

/* ==========================================================================
   弹窗（.modal）
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  padding: 24px;
}

.modal.is-open {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modal-in 0.25s var(--ease);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: var(--fs-lg);
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ==========================================================================
   Toast（.toast）
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  z-index: 1100;
  max-width: 90vw;
  padding: 12px 22px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: var(--fs-base);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base), transform var(--dur-base);
}

.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-success {
  background: rgba(22, 101, 52, 0.92);
}

.toast.is-error {
  background: rgba(153, 27, 27, 0.92);
}

/* ==========================================================================
   子页面骨架
   —— .app-main：页面主区域，占满剩余高度（页脚贴底）
   —— .page-head：子页面标题区
   ========================================================================== */
.app-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  width: 100%;
}

.page-head {
  padding: 28px 0 20px;
}

.page-head h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
}

.page-head p {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: var(--fs-base);
}

/* ==========================================================================
   响应式：小屏导航折叠
   ========================================================================== */
@media (max-width: 860px) {
  .site-nav .nav-links {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 12px 16px;
    display: none;
  }

  /* .nav-open 加在 .site-nav 上 */
  .site-nav.nav-open .nav-links {
    display: flex;
  }

  .site-nav .nav-links a {
    display: block;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
  }

  .nav-menu-btn {
    display: flex;
  }

  .nav-page {
    display: none;
  }
}

/* ==========================================================================
   子页顶部渐变横幅（.page-hero）
   —— 蓝色调渐变，上方悬浮 .site-nav--page 透明导航
   —— 用法：<section class="page-hero">
              <div class="container page-hero-inner">
                <h1 class="page-hero-title">页面标题</h1>
                <p class="page-hero-sub">一句话说明</p>
              </div>
            </section>
   ========================================================================== */
.page-hero {
  position: relative;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #38bdf8 100%);
  color: #fff;
  overflow: hidden;
}

.page-hero-inner {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* 顶部为悬浮导航留出 --nav-height 的空间 */
  padding-top: calc(var(--nav-height) + 20px);
  padding-bottom: 36px;
}

.page-hero-title {
  color: #fff;
  font-size: var(--fs-3xl);
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.25;
}

.page-hero-sub {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--fs-md);
  letter-spacing: 1px;
}

/* ==========================================================================
   子页导航：透明悬浮变体（.site-nav--page）
   —— 白字悬浮于 .page-hero 之上，hover 白底蓝字
   —— 复用上方 .nav-open 汉堡面板机制，交互由 site.js 的 initNavToggle 提供
   —— 所有规则均以 .site-nav--page 作用域限定，不影响首页与其他页面
   ========================================================================== */
.site-nav--page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: transparent;
  border-bottom-color: transparent;
}

.site-nav--page .nav-site {
  color: #fff;
}

.site-nav--page .nav-page {
  color: rgba(255, 255, 255, 0.7);
}

.site-nav--page .nav-menu-btn {
  color: #fff;
}

.site-nav--page .nav-links a {
  color: rgba(255, 255, 255, 0.85);
}

/* 子页导航 hover：白底蓝字 */
.site-nav--page .nav-links a:hover {
  color: var(--primary);
  background: #fff;
}

.site-nav--page .nav-links a.is-active {
  color: var(--primary);
  font-weight: 600;
  background: #fff;
}

/* ---------- 子页导航「智能体」下拉 ---------- */
.site-nav--page .nav-dropdown {
  position: relative;
}

.site-nav--page .nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.site-nav--page .dd-caret {
  transition: transform var(--dur-fast);
}

.site-nav--page .nav-dropdown:hover .dd-caret,
.site-nav--page .nav-dropdown.is-open .dd-caret {
  transform: rotate(180deg);
}

.site-nav--page .nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translate(-50%, 6px);
  min-width: 264px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast), transform var(--dur-fast),
    visibility var(--dur-fast);
  z-index: 20;
}

/* 桌面端：悬停展开（向上悬停连接区，避免移动鼠标时菜单消失） */
@media (min-width: 861px) {
  .site-nav--page .nav-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
  }

  .site-nav--page .nav-dropdown:hover .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }
}

/* 移动端：点击 .is-open 展开 */
.site-nav--page .nav-dropdown.is-open .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.site-nav--page .menu-label {
  padding: 8px 12px 4px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.site-nav--page .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--text);
  transition: background var(--dur-fast);
}

.site-nav--page .menu-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* 下拉面板为白底：菜单项强制深色，
   否则被上方白字规则（.site-nav--page .nav-links a）覆盖成白字而不可见 */
.site-nav--page .nav-links .menu-item {
  color: var(--text);
}

.site-nav--page .nav-links .menu-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- ≤860px：子页横幅收窄 + 汉堡面板内强制深色 ---------- */
@media (max-width: 860px) {
  .page-hero-inner {
    min-height: 180px;
    padding-top: calc(var(--nav-height) + 10px);
    padding-bottom: 26px;
  }

  .page-hero-title {
    font-size: var(--fs-2xl);
  }

  .page-hero-sub {
    font-size: var(--fs-sm);
  }

  /* 面板展开后为白底：链接强制深色 */
  .site-nav--page .nav-links a {
    color: var(--text-secondary);
  }

  .site-nav--page .nav-links a:hover,
  .site-nav--page .nav-links a.is-active {
    color: var(--primary);
    background: var(--primary-soft);
  }

  /* 移动端下拉：静态展开于面板内 */
  .site-nav--page .nav-dropdown-menu {
    position: static;
    transform: none;
    min-width: 0;
    margin-top: 6px;
    padding: 4px 8px 8px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: none;
    opacity: 1;
    visibility: visible;
  }

  .site-nav--page .nav-dropdown.is-open .nav-dropdown-menu {
    display: block;
    transform: none;
  }

  .site-nav--page .menu-item,
  .site-nav--page .nav-links .menu-item {
    color: var(--text-secondary);
  }

  .site-nav--page .menu-item:hover,
  .site-nav--page .nav-links .menu-item:hover {
    background: var(--primary-soft);
    color: var(--primary);
  }
}

/* 减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
