/* ==========================================================================
   base.css — 设计令牌、重置、排版、通用组件
   零依赖，原生 CSS，支持浅色 / 深色主题
   ========================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  /* 色彩：纯中性黑白灰，无彩度 */
  --bg: #f6f6f5;
  --bg-elev: #ffffff;
  --bg-sunken: #ededeb;
  --text: #0e0e0e;
  --text-soft: #565654;
  --text-faint: #737371;
  --line: #e2e2df;
  --line-strong: #c9c9c5;
  --accent: #0e0e0e;
  --accent-hover: #333332;
  --accent-wash: #e9e9e6;
  --accent-quiet: #8a8a87;
  --ink: #0e0e0e;

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: ui-serif, "Iowan Old Style", Georgia, "Songti SC",
    "Noto Serif CJK SC", "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono",
    Consolas, "Courier New", monospace;

  /* 尺度 */
  --page-max: 1180px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  /* 间距节奏 */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* 动效 */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 220ms;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(23, 24, 26, 0.06);
  --shadow: 0 4px 16px -6px rgba(23, 24, 26, 0.16);
  --shadow-lg: 0 22px 48px -24px rgba(23, 24, 26, 0.32);

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0c0c0c;
  --bg-elev: #151515;
  --bg-sunken: #050505;
  --text: #f0f0ee;
  --text-soft: #a6a6a3;
  --text-faint: #8a8a87;
  --line: #262625;
  --line-strong: #3b3b39;
  --accent: #f0f0ee;
  --accent-hover: #d0d0cd;
  --accent-wash: #1c1c1b;
  --accent-quiet: #8f8f8c;
  --ink: #f0f0ee;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 18px -6px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 52px -26px rgba(0, 0, 0, 0.8);

  color-scheme: dark;
}

/* 用户未手动选择时跟随系统 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0c;
    --bg-elev: #151515;
    --bg-sunken: #050505;
    --text: #f0f0ee;
    --text-soft: #a6a6a3;
    --text-faint: #8a8a87;
    --line: #262625;
    --line-strong: #3b3b39;
    --accent: #f0f0ee;
    --accent-hover: #d0d0cd;
    --accent-wash: #1c1c1b;
    --accent-quiet: #8f8f8c;
    --ink: #f0f0ee;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 18px -6px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 52px -26px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 锚点跳转时为固定页头留出空间 */
  scroll-padding-top: 5.5rem;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.72;
  letter-spacing: 0.006em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* 图片默认透明：占位底色交给各自的容器（.feature-visual / .app-figure） */

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

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

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

/* ---------- 排版 ---------- */
h1,
h2,
h3,
h4 {
  font-weight: 620;
  line-height: 1.14;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.6rem, 7.4vw, 5rem);
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.6rem);
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  letter-spacing: -0.012em;
}

p {
  text-wrap: pretty;
}

.lede {
  font-size: clamp(1.06rem, 1.6vw, 1.28rem);
  line-height: 1.68;
  color: var(--text-soft);
  max-width: 62ch;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.eyebrow::before {
  content: "";
  flex: none;
  width: 1.75rem;
  height: 1px;
  background: currentColor;
}

.muted {
  color: var(--text-soft);
}

.faint {
  color: var(--text-faint);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-variant-numeric: tabular-nums;
}

/* ---------- 布局工具 ---------- */
.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.stack > * + * {
  margin-top: var(--space-4);
}

.section {
  padding-block: clamp(3.5rem, 9vw, 7rem);
}

.section--tight {
  padding-block: clamp(2.5rem, 5vw, 4rem);
}

.rule {
  height: 1px;
  background: var(--line);
  border: 0;
}

/* ---------- 链接与按钮 ---------- */
.link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in oklab, var(--accent) 35%, transparent);
  transition: text-decoration-color var(--dur) var(--ease);
}

.link:hover {
  text-decoration-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 560;
  line-height: 1;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease),
    color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--ink);
  color: var(--bg);
}

.btn--primary:hover {
  background: var(--accent-hover);
  color: var(--bg);
}

.btn--ghost {
  border-color: var(--line-strong);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--text);
}

.btn svg {
  width: 1em;
  height: 1em;
}

/* 文字下划线滑动效果 */
.u-link {
  position: relative;
  display: inline-block;
}

.u-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.32s var(--ease);
}

.u-link:hover::after,
.u-link:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ---------- 标签 / 元信息 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-soft);
  background: var(--bg-elev);
  white-space: nowrap;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  font-size: 0.8125rem;
  color: var(--text-faint);
}

.meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

/* ---------- 无障碍 ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  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: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
