/* ==========================================================================
   base.css — 重置 + 排版基线
   --------------------------------------------------------------------------
   严格对齐 apanzinc.top：
     - 根字号 16px（不用 em 阶梯，靠 clamp 做流体缩放）
     - body 字重 450、行高 1.7 —— 这两个值决定了整体"呼吸感"
     - 滚动条完全隐藏（靠滚动位置提供反馈，不用滚动条）
   ========================================================================== */

/* MiSans 字体接入
   ----------------------------------------------------------------------------
   原站从小米 CDN 拉取 MiSans，方式是一个 713KB 的 CSS，
   内含 392 个 @font-face 分片（按 unicode-range 切分，每个字重 56 片）。

   为什么照原样用 @import：
     这是唯一能拿到"完整 MiSans"的方式。若只引一两个分片，
     页面上的生僻字会掉回系统字体，出现"同一个标题里两种字体"的穿帮。

   为什么要加 preconnect：
     713KB CSS + 多个 woff2 分片都在 cdn-font / cdn-file 两个域名下，
     不预连接的话要额外走两次 DNS + TCP + TLS 握手。

   注意 @import 必须写在文件最前面（在任何规则之前），否则浏览器会忽略。 */
@import url("https://cdn-font.hyperos.mi.com/font/css?family=MiSans:100,200,300,400,500,600,700:Chinese_Simplify,Latin&display=swap");

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  /* 450 是"比常规 400 略重、但不至于到 500"的中间值。
     MiSans 是可变字体，这个值能精确生效，是质感的关键细节。 */
  font-weight: 450;
  line-height: 1.7;
  overflow-x: hidden;
  /* 主题切换过渡 */
  transition: background-color 0.25s var(--ease-out),
    color 0.25s var(--ease-out);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s var(--ease-out);
}

a:hover {
  color: var(--accent);
}

button {
  cursor: pointer;
  background: 0 0;
  border: none;
  font-family: inherit;
  color: inherit;
}

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

ul,
ol {
  list-style: none;
}

/* ---------- 滚动条完全隐藏 ----------
   原站的做法：连 Firefox 的 scrollbar-width 也设为 none。
   视觉上更干净，代价是用户失去"我在页面什么位置"的参照 ——
   所以导航栏里必须保留路由高亮来补偿这一点。 */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

::-webkit-scrollbar {
  background: 0 0;
  display: none;
  width: 0 !important;
  height: 0 !important;
}

html,
body {
  overflow: hidden auto;
}

/* ---------- 选中文字 ---------- */
::selection {
  background: var(--accent);
  color: var(--bg-primary);
}

/* ---------- 焦点 ----------
   只在键盘导航时显示，1px 主色描边即可 —— 不要用默认的粗蓝框。 */
:focus {
  outline: none;
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  :before,
  :after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---------- 触屏优化 ----------
   touch-action: manipulation 去掉 300ms 点击延迟 */
a,
button {
  touch-action: manipulation;
}

/* ---------- iOS 惯性滚动 ---------- */
@supports (-webkit-overflow-scrolling: touch) {
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- iOS 输入框放大修正 ----------
   iOS 上 font-size < 16px 的输入框聚焦时会自动放大页面 */
input,
textarea,
select {
  font-size: 16px;
}

/* ---------- 刘海屏安全区 ---------- */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(var(--spacing-md), env(safe-area-inset-left));
    padding-right: max(var(--spacing-md), env(safe-area-inset-right));
  }

  @media (width <= 768px) {
    .container {
      padding-left: max(var(--spacing-sm), env(safe-area-inset-left));
      padding-right: max(var(--spacing-sm), env(safe-area-inset-right));
    }
  }

  @media (width <= 480px) {
    .container {
      padding-left: max(var(--spacing-sm), env(safe-area-inset-left));
      padding-right: max(var(--spacing-sm), env(safe-area-inset-right));
    }
  }
}

/* ---------- 工具类 ---------- */
.visually-hidden {
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  position: absolute;
  overflow: hidden;
}

/* 跳过导航链接：键盘用户按 Tab 第一个出现（原站位于左侧 16px） */
.skip-link {
  z-index: 10001;
  background: var(--accent);
  color: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
  position: absolute;
  top: -100%;
  left: 16px;
}

.skip-link:focus {
  top: var(--spacing-sm);
}
