/**
 * 基础样式 - 全局样式与HTML元素样式
 * 版权所有 © 2025 米醋电子工作室
 *
 * 遵循KISS原则:简化的reset,只重置必要样式
 * 遵循可访问性标准:WCAG 2.1 AA级
 */

/* ========================================
   全局重置 (Simplified Reset)
   ======================================== */

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

/* ========================================
   根元素与文档样式
   ======================================== */

html {
  /* 平滑滚动 - 提升用户体验 */
  scroll-behavior: smooth;
  /* 防止字体大小调整 */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-primary);
  background: linear-gradient(to bottom, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
  background-attachment: fixed;
  /* 抗锯齿渲染 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 最小高度100vh */
  min-height: 100vh;
}

/* ========================================
   标题系统 (Heading System)
   遵循正确的语义层级
   ======================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: var(--space-4);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h1 {
  font-size: var(--font-size-3xl);
}

h2 {
  font-size: var(--font-size-xl);
}

h3 {
  font-size: var(--font-size-lg);
}

h4 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

h5,
h6 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

/* ========================================
   段落与文本
   ======================================== */

p {
  margin-bottom: var(--space-4);
}

p:last-child {
  margin-bottom: 0;
}

strong,
b {
  font-weight: var(--font-weight-semibold);
}

em,
i {
  font-style: italic;
}

small {
  font-size: var(--font-size-sm);
}

/* ========================================
   链接 (Links)
   ======================================== */

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

/* 无障碍:焦点样式 */
a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ========================================
   列表 (Lists)
   ======================================== */

ul,
ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

li {
  margin-bottom: var(--space-2);
}

li:last-child {
  margin-bottom: 0;
}

/* 去除list-style的列表 */
ul.list-none,
ol.list-none {
  list-style: none;
  padding-left: 0;
}

/* ========================================
   代码与预格式化文本
   ======================================== */

code,
pre,
kbd,
samp {
  font-family: var(--font-family-mono);
  font-size: 0.9em;
}

code {
  padding: 2px 6px;
  background-color: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
}

pre {
  padding: var(--space-4);
  background-color: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  padding: 0;
  background-color: transparent;
}

/* ========================================
   图片与媒体
   ======================================== */

img,
video,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ========================================
   按钮重置
   ======================================== */

button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* 无障碍:焦点样式 */
button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ========================================
   表单元素
   ======================================== */

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

/* ========================================
   分隔线
   ======================================== */

hr {
  margin: var(--space-8) 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

/* ========================================
   选中文本样式
   ======================================== */

::selection {
  background-color: var(--color-primary-light);
  color: var(--color-white);
}

::-moz-selection {
  background-color: var(--color-primary-light);
  color: var(--color-white);
}

/* ========================================
   滚动条样式 (仅Webkit)
   ======================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ========================================
   工具类 (Utility Classes)
   ======================================== */

/* 隐藏元素但保留给屏幕阅读器 */
.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;
}

/* 文本居中 */
.text-center {
  text-align: center;
}

/* 清除浮动 */
.clearfix::after {
  content: "";
  display: table;
  clear: both;
}
