/* ==========================================================================
   base.css — 现代化 reset + 根变量消费
   ==========================================================================
   仅消费 tokens.css 中登记的设计令牌（R6.1/R6.7），不出现硬编码原始值。
   依赖加载顺序：tokens.css 必须先于本文件加载。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Box model 与 reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* --------------------------------------------------------------------------
   2. 文档根 — 消费令牌
   -------------------------------------------------------------------------- */
body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-normal);
  line-height: var(--lh-normal);
  color: var(--fg-default);
  background-color: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* --------------------------------------------------------------------------
   3. 排版元素
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--fg-default);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
h5,
h6 { font-size: var(--fs-base); }

p {
  line-height: var(--lh-normal);
}

small {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-standard);
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   4. 媒体与嵌入元素
   -------------------------------------------------------------------------- */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

svg {
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   5. 表单元素继承字体
   -------------------------------------------------------------------------- */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

button:disabled {
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   6. 列表与表格
   -------------------------------------------------------------------------- */
ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* --------------------------------------------------------------------------
   7. 全局可见焦点指示（键盘可达性，R6.6 / R7.3）
   焦点环对相邻背景 ≥ 3:1（见 tokens.css 对比度登记表）
   -------------------------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   8. 选区与滚动条
   -------------------------------------------------------------------------- */
::selection {
  background-color: var(--accent-muted);
  color: var(--fg-default);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-base);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

/* --------------------------------------------------------------------------
   9. 减弱动效偏好（无障碍）
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
