/* ==========================================================================
   base.css · 重置 + 基础排版 + 无障碍
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

/* 标题：600 字重配 -0.01em 字距。中文系统字体（微软雅黑只有常规与粗体两档）
   遇到 600 会落到粗体，字距收得太紧会挤，所以只收 0.01em。 */
h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { text-wrap: pretty; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { background: none; border: 0; cursor: pointer; }

ul, ol { list-style: none; padding: 0; }

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

hr { border: 0; border-top: 1px solid var(--border); }

::selection { background: color-mix(in srgb, var(--brand-1) 45%, transparent); color: #fff; }

/* 统一焦点样式。不在这里加 box-shadow 光环：命令面板、首页搜索框等输入框
   用 outline: none 自己画聚焦态，全局 box-shadow 会绕过它们的 outline: none 再叠一圈。
   需要光环的组件自己用 --focus-ring（如 .hero__search:focus-within）。 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* 自定义滚动条（Chromium / WebKit） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }

/* 屏幕阅读器专用 */
.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;
}

.skip-link {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transform: translateY(-160%);
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

/* 滚动显现动画
   注意：这里不再常驻 will-change。常驻会让每个 [data-reveal] 元素在整页生命周期内
   都保留一个合成层，元素一多就白占显存与内存。改为由 main.js 在即将入场时临时加上
   （.is-animating），过渡结束后立即移除。 */
[data-reveal] {
  opacity: 0;
  transform: translateY(var(--reveal-y, 18px));
  transition:
    opacity var(--reveal-dur, 720ms) var(--ease-out),
    transform var(--reveal-dur, 720ms) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-animating { will-change: opacity, transform; }
[data-reveal].is-visible { opacity: 1; transform: none; }

/* 尊重系统"减少动态效果" */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}
/* 用户在「主题设置 → 动效」里手动选了"减少动效"：与系统偏好同一套降级 */
:root[data-motion="reduce"] { scroll-behavior: auto; }
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
:root[data-motion="reduce"] [data-reveal] { opacity: 1; transform: none; }

@media print {
  .site-header, .back-to-top, .palette, .toast-stack, .aurora, .scroll-progress { display: none !important; }
  body { background: #fff; color: #000; }
}
