/* ==========================================================================
   base.css — 设计 token、重置、排版基础、响应式基建
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 设计 token
   -------------------------------------------------------------------------- */
:root {
  /* 颜色 */
  --c-bg: #ffffff;
  --c-surface: #f1f1f1;
  --c-surface-2: #f8f8f8;
  --c-text: #000000;
  --c-text-muted: #6e6e6e;
  --c-border: #e4e4e4;
  --c-accent: #2e90fa;
  --c-black: #000000;
  --c-white: #ffffff;

  /* 圆角 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-pill: 999px;

  /* 流式间距：随视口宽度平滑缩放，不做断点跳变 */
  --gutter: clamp(1.25rem, 5vw, 5rem);      /* 容器左右留白 */
  --section-gap: clamp(4rem, 8vw, 7.5rem);  /* 区块垂直间距 */
  --card-gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --container-max: 1280px;

  /* 流式字号 */
  --fs-display: clamp(2.75rem, 11vw, 7.5rem);  /* 全屏宣言大字 */
  --fs-h1: clamp(2rem, 5.5vw, 4rem);
  --fs-h2: clamp(1.75rem, 4vw, 3rem);
  --fs-h3: clamp(1.25rem, 2.2vw, 1.75rem);
  --fs-lead: clamp(1rem, 1.6vw, 1.375rem);
  --fs-body: clamp(0.9375rem, 1.1vw, 1.0625rem);
  --fs-sm: clamp(0.8125rem, 1vw, 0.9375rem);

  /* 字体栈 */
  --font-en: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    Arial, sans-serif;
  --font-zh: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;

  /* 标题字重（中文模式下会被下调） */
  --fw-heading: 700;
  --tracking-heading: -0.02em;

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

  /* 顶栏高度，供 scroll-padding 与锚点定位使用 */
  --nav-h: 64px;
}

/* 中文模式：几何无衬线的超粗字重在中文下过于笨重，降一级并放开字距 */
body.lang-zh {
  --font-body: var(--font-zh);
  --fw-heading: 600;
  --tracking-heading: 0.01em;
  --fs-display: clamp(2.25rem, 8.5vw, 5.5rem);
}

body.lang-en {
  --font-body: var(--font-en);
}

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

html {
  -webkit-text-size-adjust: 100%;   /* 防止 iOS 横屏时自动放大字号 */
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body, var(--font-en));
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;               /* 兜底：页面永不横向滚动 */
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-heading);
  letter-spacing: var(--tracking-heading);
  line-height: 1.1;
}

p {
  margin: 0;
}

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

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

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

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

table {
  border-collapse: collapse;
  width: 100%;
}

input {
  font: inherit;
}

/* 键盘导航可见焦点，鼠标点击不显示 */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* 尊重系统「减少动态效果」设置 */
@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;
  }
}

/* --------------------------------------------------------------------------
   3. 布局基元
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: calc(var(--container-max) + var(--gutter) * 2);
  margin-inline: auto;
  /* iOS 刘海屏：横屏时左右安全区叠加到留白上 */
  padding-inline: max(var(--gutter), env(safe-area-inset-left));
}

.section {
  padding-block: var(--section-gap);
}

.section--tight {
  padding-block: calc(var(--section-gap) * 0.6);
}

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

/* --------------------------------------------------------------------------
   4. 排版工具类
   -------------------------------------------------------------------------- */
.t-display { font-size: var(--fs-display); line-height: 0.95; }
.t-h1      { font-size: var(--fs-h1); }
.t-h2      { font-size: var(--fs-h2); }
.t-h3      { font-size: var(--fs-h3); }
.t-lead    { font-size: var(--fs-lead); line-height: 1.45; }
.t-sm      { font-size: var(--fs-sm); }
.t-muted   { color: var(--c-text-muted); }
.t-center  { text-align: center; }

/* 区块标题：MacPaw 的标志性用法，标题两段之间插一个大空格 */
.section-title {
  font-size: var(--fs-h1);
  max-width: 20ch;
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
}

.section-title--center {
  margin-inline: auto;
  text-align: center;
}

/* --------------------------------------------------------------------------
   5. 滚动进场动画
   -------------------------------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* 文案切换全部由 i18n.js 直接替换 textContent 完成，
   不用 CSS 显隐双语节点（那会误伤 data-lang 的语言切换按钮）。 */
