/* ============================================================
   base.css — 重置、排版基线、通用布局
   ============================================================ */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* 菜单展开时锁定滚动 */
body.is-locked { overflow: hidden; }

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p { margin: 0; }

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

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

/* 标签筛选把卡片设为 hidden 时必须真的消失（覆盖组件里的 display） */
[hidden] { display: none !important; }

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

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

hr {
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--border);
}

/* ---------- 焦点可见性：键盘用户必须看得见 ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

::selection {
  background: rgba(79, 140, 255, 0.32);
  color: #fff;
}

/* ---------- 滚动条（桌面） ---------- */
@media (min-width: 901px) {
  ::-webkit-scrollbar { width: 10px; }
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb {
    background: #262a36;
    border: 3px solid var(--bg);
    border-radius: var(--r-full);
  }
  ::-webkit-scrollbar-thumb:hover { background: #343a4a; }
}

/* ============================================================
   布局容器
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--sp-9); }
.section--soft { background: var(--bg-soft); }
.section--tight { padding-block: var(--sp-8); }

/* 区块标题组 */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  margin-bottom: var(--sp-7);
}

.section-head__title { font-size: var(--fs-2xl); }

.section-head__desc {
  max-width: 52ch;
  margin-top: var(--sp-3);
  color: var(--text-muted);
  font-size: var(--fs-md);
  text-wrap: pretty; /* 避免末行只剩一两个字 */
}

/* ---------- 通用元素 ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.grad {
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ============================================================
   滚动显现动效（由 main.js 添加 .is-visible）
   ============================================================ */

/* 这里刻意用 @keyframes 而不是 transition：
   .card / .work-card 等组件自带 transition（components.css 加载更晚），
   若这里也用 transition 会被它们覆盖，淡入效果直接消失。
   animation-fill-mode 用 backwards 而非 forwards——动画结束后不保留 transform，
   否则会把组件自己的 :hover 位移也一起锁死。 */
/* 关键：初始隐藏只在 JS 可用时生效（<html> 上的 .js 由 <head> 内联脚本添加）。
   否则一旦用户禁用 JS，IntersectionObserver 不会运行，
   这些元素会永远停在 opacity:0 —— 整片内容直接消失。 */
.js .reveal { opacity: 0; }

.js .reveal.is-visible {
  opacity: 1;
  animation: reveal-in 0.7s var(--ease) backwards;
  animation-delay: var(--reveal-delay, 0s);
}

@keyframes reveal-in {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 无障碍辅助类 ---------- */
.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: -100px;
  left: var(--sp-4);
  z-index: 200;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.skip-link:focus { top: var(--sp-4); }

/* ============================================================
   尊重「减少动态效果」偏好
   ============================================================ */

@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;
  }

  .js .reveal { opacity: 1; transform: none; }
}
