/* ========================================
   现代化 CSS 重置
   ======================================== */

/* Box sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 移除默认边距 */
body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd {
  margin: 0;
}

/* 移除列表样式 */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* 设置核心根元素默认值 */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html:focus-within {
  scroll-behavior: smooth;
}

/* 设置核心 body 默认值 */
body {
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  line-height: var(--leading-normal);
  font-family: var(--font-primary);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
}

/* 使图片更易于处理 */
img,
picture,
svg {
  max-width: 100%;
  display: block;
}

/* 继承字体 */
input,
button,
textarea,
select {
  font: inherit;
}

/* 移除按钮默认样式 */
button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* 移除链接默认样式 */
a {
  text-decoration: none;
  color: inherit;
}

/* 移除文本区域的调整大小手柄 */
textarea {
  resize: vertical;
}

/* 移除 IE 10+ 中输入框的清除按钮 */
input::-ms-clear,
input::-ms-reveal {
  display: none;
}

/* 移除 Chrome 中输入框的自动填充背景色 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--bg-tertiary) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}

/* 移除 Firefox 中数字输入框的按钮 */
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type='number'] {
  -moz-appearance: textfield;
}

/* 移除 Safari 中搜索输入框的取消按钮 */
input[type='search']::-webkit-search-cancel-button,
input[type='search']::-webkit-search-decoration {
  -webkit-appearance: none;
}

/* 改善媒体元素的默认值 */
audio,
canvas,
iframe,
img,
svg,
video {
  vertical-align: middle;
}

/* 移除 fieldset 的默认样式 */
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

/* 允许 label 点击 */
label {
  cursor: pointer;
}

/* 隐藏元素但保持可访问性 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* 移除动画和过渡（如果用户偏好减少动画） */
@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }
  
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 选中文本的样式 */
::selection {
  background-color: var(--primary-color);
  color: var(--text-white);
}

::-moz-selection {
  background-color: var(--primary-color);
  color: var(--text-white);
}

/* 滚动条样式（仅 Webkit 浏览器） */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Firefox 滚动条样式 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-secondary);
}
