/* ==========================================================================
   基础层 v7：重置 / 字体基线 / 焦点 / 滚动 / 通用工具
   只放「所有页面都必须一致」的规则，具体到某个屏的样式不进来。
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: var(--lh);
  font-feature-settings:
    'kern' 1,
    'liga' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}
ul,
ol {
  list-style: none;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
img {
  display: block;
  max-width: 100%;
}
svg {
  display: block;
}

h1,
h2,
h3 {
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}

/* hidden 必须压过组件的 display：否则 .chip { display:inline-flex } 会让它显形 */
[hidden] {
  display: none !important;
}
b,
strong {
  font-weight: 600;
}

::selection {
  background: var(--amber-100);
  color: #5a3a10;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) {
  outline: none;
}

@media (pointer: fine) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--line-3) transparent;
  }
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: var(--line-3);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--faint);
    background-clip: content-box;
  }
}

/* ---------- 通用工具 ---------- */
.num,
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.serif {
  font-family: var(--serif);
  letter-spacing: 0.01em;
}
.hair {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 入场：只有脚本可用时才隐藏待入场元素 */
.js .fade {
  opacity: 0;
  transform: translateY(10px);
}
.js .fade.in {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-4) var(--ease),
    transform var(--dur-4) var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .js .fade {
    opacity: 1;
    transform: none;
  }
}
