/* ============================================================
   components/base.css — 全局重置 / 基础排版 / 可访问性
   依赖：tokens.css
   职责：仅做全局底层设定，不含任何业务组件样式。
   ============================================================ */

/* ---- Reset ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 主题切换平滑过渡 */
  transition: background-color var(--transition-base);
}

body {
  font-family: var(--f-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
}

/* 移除默认列表样式（按需自行添加） */
ul,
ol {
  list-style: none;
}

/* 图片默认块级，避免底部缝隙 */
img {
  max-width: 100%;
  display: block;
}

/* 链接：继承文字色，去掉下划线，显式焦点环 */
a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* ---- 基础排版 ---- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--text);
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); }

p {
  line-height: var(--lh-relaxed);
}

code,
pre,
kbd {
  font-family: var(--f-mono);
  font-size: .92em;
}

/* 等宽数字：表格 / 指标对齐 */
.tnum,
table,
.kpi-value,
.kpi-change {
  font-variant-numeric: tabular-nums;
}

/* ---- 可访问性（a11y） ---- */

/* 键盘焦点：统一可见焦点环（满足 WCAG 2.4.7） */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* 屏幕阅读器专用文本（视觉隐藏） */
.u-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 跳转链接：键盘聚焦时显形 */
.u-skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: var(--z-modal);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: top var(--transition-fast);
}
.u-skip-link:focus {
  top: var(--space-2);
}

/* 减少动效偏好（WCAG 2.3.3） */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- 关键帧（入场 / 状态） ---- */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 状态点脉冲（LIVE 指示） */
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(21, 128, 61, .4); }
  50%      { opacity: .7; box-shadow: 0 0 0 4px rgba(21, 128, 61, 0); }
}
