/* ================================
   CSS 初始化
   ================================ */

/* 1. 盒模型统一 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 2. 清除默认外边距 */
html,
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
figure,
dl,
dd,
ul,
ol {
  margin: 0;
}

/* 3. 清除列表默认样式 */
ul,
ol {
  padding: 0;
  list-style: none;
}

/* 4. 页面基础设置 */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;        /* 横向溢出保护：任何断点都不出现横向滚动条 */
}

body {
  overflow-x: hidden;        /* 双保险：防止 fixed/absolute 元素造成横向滚动 */
}

/* 锚点跳转时让顶部内容不被固定导航遮挡（跳过顶部 var(--nav-h) 高度） */
[id] {
  scroll-margin-top: var(--nav-h, 76px);
}

/* 5. Body 基础样式 */
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1f2937;
  background-color: #ffffff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 6. 标题统一 */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: inherit;
  font-weight: inherit;
}

/* 7. 图片、视频等媒体自适应 */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* 8. 图片防止出现基线空隙 */
img {
  height: auto;
}

/* 9. 表单元素继承字体 */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* 10. 按钮初始化 */
button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* 11. 输入框初始化 */
input,
textarea {
  border: 0;
  outline: none;
}

/* 12. textarea 禁止横向拉伸 */
textarea {
  resize: vertical;
}

/* 13. 链接初始化 */
a {
  color: inherit;
  text-decoration: none;
}

/* 14. 表格初始化 */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* 15. 引用初始化 */
blockquote,
q {
  quotes: none;
}

blockquote::before,
blockquote::after,
q::before,
q::after {
  content: "";
}

/* 16. HTML5 元素统一 */
article,
aside,
details,
figcaption,
figure,
footer,
header,
main,
nav,
section,
summary {
  display: block;
}

/* 17. 隐藏属性 */
[hidden] {
  display: none !important;
}

/* 18. 防止按钮、输入框在移动端出现奇怪的点击高亮 */
button,
input,
textarea,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

/* 19. 聚焦状态 */
:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* 20. 选中文本样式 */
::selection {
  color: #ffffff;
  background-color: #2563eb;
}