/* ================================================================
 * ui-kit.css — 财商大陆 统一组件库（暗色玻璃体系）
 * 依据：docs/ui-unify-PRD.md §4（14 个组件 + 规格 §4.2）
 * 所有取值一律 var(--*)，不写死品牌色 / 间距 / 圆角 / 字号。
 * 链接顺序：responsive.css → font-fix.css → design-tokens.css → ui-kit.css → 页面专属
 * 断点不引入 token，直接用媒体查询。
 * ================================================================ */

/* ----------------------------------------------------------------
 * 页面容器 .app-shell
 * ---------------------------------------------------------------- */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 var(--space-4) var(--space-6);
  color: var(--text-body);
  font-family: var(--font-sans);
  position: relative;
  z-index: 1;
}

/* ----------------------------------------------------------------
 * 背景层 .app-bg / .app-grain（置于 .app-shell 之前，z-index:0）
 * ---------------------------------------------------------------- */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 30% 0%, rgba(139, 92, 246, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 70% 40%, rgba(192, 132, 252, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 20% 70%, rgba(251, 191, 36, 0.04) 0%, transparent 50%),
    var(--bg-base);
}
.app-grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.015;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ----------------------------------------------------------------
 * 顶部标题栏 .app-header
 * ---------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(180deg, rgba(6, 3, 13, 0.98) 60%, rgba(6, 3, 13, 0));
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
.app-header__back {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--space-2);
  font-family: inherit;
}
.app-header__title {
  flex: 1;
  font-size: var(--fs-title);
  font-weight: var(--fw-extra);
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ----------------------------------------------------------------
 * 内容区块 .section / .section__title
 * ---------------------------------------------------------------- */
.section {
  margin: var(--space-4) 0;
}
.section__title {
  font-size: var(--fs-section);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ----------------------------------------------------------------
 * 玻璃卡片 .card / .card--glass / .card--light
 * ---------------------------------------------------------------- */
.card {
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
}
.card--glass {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(167, 139, 250, 0.05));
  border: 1px solid var(--border-purple);
}
.card--light {
  /* 过渡期保留：浅色实色卡（白底），用于高对比阅读场景，最终收敛为玻璃 */
  background: #fff;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------------
 * 按钮 .btn / .btn--primary / .btn--ghost / .btn--outline
 * ---------------------------------------------------------------- */
.btn {
  display: block;
  width: 100%;
  padding: var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: transform 0.1s;
  color: var(--text-primary);
  text-decoration: none;
}
.btn:active {
  transform: scale(0.97);
}
.btn--primary {
  background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-deep));
  color: #fff;
}
.btn--ghost {
  background: rgba(255, 255, 255, 0.20);
  border: 1px solid var(--glass-border-strong);
  color: var(--text-primary);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.btn--outline {
  background: transparent;
  border: 1.5px solid var(--border-purple);
  color: var(--brand-purple);
}

/* ----------------------------------------------------------------
 * 底部导航 .bottom-nav（单一组件，由 js/ui-bottom-nav.js 渲染）
 * ---------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 100;
  background: var(--bg-overlay);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  display: flex;
  padding: var(--space-2) 0 env(safe-area-inset-bottom, 6px);
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: var(--fs-caption);
  text-decoration: none;
  font-family: inherit;
}
.bottom-nav__item-icon {
  font-size: 20px;
  line-height: 1.1;
}
.bottom-nav__item-label {
  font-size: var(--fs-caption);
}
.bottom-nav__item--active {
  color: var(--brand-purple-soft);
}

/* ----------------------------------------------------------------
 * 徽章 .badge / .badge--gold / .badge--success / .badge--new
 * ---------------------------------------------------------------- */
.badge {
  display: inline-block;
  font-size: var(--fs-caption);
  font-weight: var(--fw-semi);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.badge--gold {
  background: var(--status-warning-bg);
  color: var(--accent-gold);
}
.badge--success {
  background: var(--status-success-bg);
  color: var(--status-success);
}
.badge--new {
  background: rgba(255, 152, 0, 0.15);
  color: #ff9800;
}

/* ----------------------------------------------------------------
 * 状态标签 .tag / .status-tag
 * ---------------------------------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-caption);
}
.status-tag {
  display: inline-block;
  font-size: var(--fs-caption);
  font-weight: var(--fw-semi);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
}
.status-tag--locked {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}
.status-tag--unlocked {
  background: var(--status-success-bg);
  color: var(--status-success);
}

/* ----------------------------------------------------------------
 * 榜单 .rank / .rank__item / .rank__medal
 * ---------------------------------------------------------------- */
.rank__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}
.rank__medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  background: var(--glass-bg-2);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.rank__medal--1 { background: var(--accent-gold); color: #1a1a2e; }
.rank__medal--2 { background: var(--text-secondary); color: #1a1a2e; }
.rank__medal--3 { background: var(--accent-gold-deep); color: #1a1a2e; }

/* ----------------------------------------------------------------
 * 进度条 .progress / .progress__bar
 * ---------------------------------------------------------------- */
.progress {
  height: var(--space-2);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand-purple), var(--brand-purple-soft));
  transition: width 0.5s;
}

/* ----------------------------------------------------------------
 * 头像 .avatar
 * ---------------------------------------------------------------- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-round);
  background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-deep));
  border: 2px solid rgba(139, 92, 246, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------
 * 统计网格 .stat-grid / .stat-cell
 * ---------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-3);
}
.stat-cell {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}

/* ----------------------------------------------------------------
 * 胶囊 / 芯片 .chip
 * ---------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-3);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: var(--fs-caption);
}

/* ----------------------------------------------------------------
 * 响应式：容器随断点放宽（断点不引入 token，用媒体查询）
 * 移动默认 480；平板 ≥768 → 800；桌面 ≥1024 → 960
 * ---------------------------------------------------------------- */
@media (min-width: 768px) {
  .app-shell { max-width: 800px; padding: 0 var(--space-5) var(--space-6); }
}
@media (min-width: 1024px) {
  .app-shell { max-width: 960px; }
  .app-header__title,
  .section__title { font-size: var(--fs-subtitle); }
}
