/* ============================================================================
 * tokens.css —— 设计令牌 / 全局基础 / 背景层 / 通用组件
 * ----------------------------------------------------------------------------
 * 想换配色只需要改下面的变量；想彻底去掉那一丝冷色，
 * 把 --tint 改成 `0 0% 100%` 即可得到纯黑白。
 * ==========================================================================*/

/* ── 设计令牌 ───────────────────────────────────────────────────────────── */
:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
               "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --maxw: 1140px;
  --pad: clamp(18px, 4vw, 40px);

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-full: 999px;

  --dur-1: .18s;
  --dur-2: .35s;
  --dur-3: .7s;
  --ease: cubic-bezier(.22, .68, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --blur: 22px;

  --fs-h1: clamp(2.7rem, 7.4vw, 5.1rem);
  --fs-h2: clamp(1.85rem, 3.6vw, 2.7rem);
  --fs-h3: clamp(1.05rem, 1.6vw, 1.22rem);
  --fs-body: clamp(.95rem, 1.05vw, 1.02rem);
  --fs-sm: .875rem;
  --fs-xs: .78rem;

  /* 极光里的那一点冷色 → 纯黑白请改成 `0 0% 100%` */
  --tint: 212 92% 64%;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050506;
  --bg-soft: #0a0a0c;
  --fg: #f2f2f5;
  --fg-2: #a4a4ae;
  --fg-3: #6c6c76;

  --line: rgb(255 255 255 / .08);
  --line-2: rgb(255 255 255 / .17);

  --glass: rgb(255 255 255 / .045);
  --glass-2: rgb(255 255 255 / .08);
  --glass-strong: rgb(255 255 255 / .065);
  --glass-brd: rgb(255 255 255 / .12);
  /* 近不透明底板：给导航、下拉菜单这类「压在正文上」的表面兜底，
     即使浏览器不支持 backdrop-filter 也保证文字清晰 */
  --panel: rgb(11 11 14 / .94);

  --rim: rgb(255 255 255 / .40);
  --rim-soft: rgb(255 255 255 / .09);
  --rim-weak: rgb(255 255 255 / .04);
  --spec: rgb(255 255 255 / .10);

  --invert-bg: #f4f4f7;
  --invert-fg: #08080a;

  --shadow-lg: 0 40px 90px -50px rgb(0 0 0 / .95);
  --shadow-sm: 0 14px 34px -22px rgb(0 0 0 / .9);

  --grid-c: rgb(255 255 255 / .05);
  --aurora-a: rgb(var(--tint) / .17);
  --aurora-b: rgb(255 255 255 / .10);
  --noise-op: .05;
  --spot: rgb(255 255 255 / .05);
  --vig: rgb(0 0 0 / .55);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f3f5;
  --bg-soft: #ffffff;
  --fg: #0b0b0d;
  --fg-2: #4c4c55;
  --fg-3: #86868f;

  --line: rgb(0 0 0 / .09);
  --line-2: rgb(0 0 0 / .18);

  --glass: rgb(255 255 255 / .58);
  --glass-2: rgb(255 255 255 / .78);
  --glass-strong: rgb(255 255 255 / .66);
  --glass-brd: rgb(255 255 255 / .75);
  --panel: rgb(253 253 254 / .95);

  --rim: rgb(255 255 255 / .95);
  --rim-soft: rgb(255 255 255 / .9);
  --rim-weak: rgb(255 255 255 / .5);
  --spec: rgb(255 255 255 / .6);

  --invert-bg: #0d0d10;
  --invert-fg: #f6f6f8;

  --shadow-lg: 0 34px 70px -46px rgb(15 23 42 / .28);
  --shadow-sm: 0 12px 28px -20px rgb(15 23 42 / .26);

  --grid-c: rgb(0 0 0 / .055);
  --aurora-a: rgb(var(--tint) / .22);
  --aurora-b: rgb(255 255 255 / .8);
  --noise-op: .035;
  --spot: rgb(0 0 0 / .035);
  --vig: rgb(120 120 130 / .16);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}

[hidden] { display: none !important; }

img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.16; letter-spacing: -.022em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
code, pre { font-family: var(--font-mono); }

::selection { background: var(--fg); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 6px;
}

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

/* ── 工具类 ─────────────────────────────────────────────────────────────── */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.mono { font-family: var(--font-mono); }

.eyebrow {
  font-size: var(--fs-xs);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 200;
  transform: translate(-50%, -200%);
  padding: .6em 1.2em;
  border-radius: var(--r-full);
  background: var(--invert-bg);
  color: var(--invert-fg);
  font-size: var(--fs-sm);
  transition: transform var(--dur-2) var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); }

.noscript {
  position: relative;
  z-index: 10;
  max-width: var(--maxw);
  margin: 120px auto 40px;
  padding: 18px 22px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--glass);
  font-size: var(--fs-sm);
}
.noscript code { font-size: .95em; }

/* ── 背景层：网格 / 极光 / 光点 / 噪点 / 暗角 ──────────────────────────── */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

.bg__grid {
  position: absolute;
  inset: -1px;
  background-image:
    linear-gradient(var(--grid-c) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-c) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(125% 85% at 50% 0%, #000 5%, transparent 72%);
  mask-image: radial-gradient(125% 85% at 50% 0%, #000 5%, transparent 72%);
}

.bg__aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  will-change: transform;
}
.bg__aurora--a {
  width: 62vw; height: 62vw;
  top: -24vw; left: -12vw;
  background: radial-gradient(circle at 50% 50%, var(--aurora-a), transparent 66%);
  animation: drift-a 36s ease-in-out infinite alternate;
}
.bg__aurora--b {
  width: 52vw; height: 52vw;
  right: -14vw; top: 26vh;
  background: radial-gradient(circle at 50% 50%, var(--aurora-b), transparent 66%);
  animation: drift-b 46s ease-in-out infinite alternate;
}

.bg__spot {
  position: absolute;
  left: 0; top: 0;
  width: 880px; height: 880px;
  margin: -440px 0 0 -440px;
  background: radial-gradient(circle, var(--spot), transparent 62%);
  opacity: 0;
  transition: opacity .8s var(--ease);
  will-change: transform;
}
.bg__spot.is-on { opacity: 1; }

.bg__noise {
  position: absolute;
  inset: 0;
  opacity: var(--noise-op);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bg__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(115% 95% at 50% 0%, transparent 34%, var(--vig) 100%);
}

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(9vw, 8vh, 0) scale(1.12); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.06); }
  to   { transform: translate3d(-10vw, -6vh, 0) scale(.95); }
}

/* 顶部滚动进度条 */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  z-index: 90;
  width: 100%;
  height: 2px;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, transparent, var(--fg), transparent);
  opacity: .5;
}

/* ── 玻璃 ───────────────────────────────────────────────────────────────── */
.glass {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--rim-soft);
  isolation: isolate;
}

/* 边缘高光：模拟玻璃棱边的折射亮线 */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(155deg, var(--rim) 0%, transparent 42%, transparent 58%, var(--rim-weak) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: .75;
  pointer-events: none;
}

/* 高光随鼠标移动（由 ui.js 写入 --mx / --my） */
.glass[data-glass]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%), var(--spec), transparent 62%);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
  pointer-events: none;
}
.glass[data-glass]:hover::after { opacity: 1; }

.glass--strong {
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--rim-soft);
}

/* ── 按钮 ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .55em;
  padding: .74em 1.3em;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  font-size: .93rem;
  font-weight: 500;
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: transform var(--dur-1) var(--ease), background-color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn .icon { width: 1.05em; height: 1.05em; }

.btn--primary {
  background: var(--invert-bg);
  color: var(--invert-fg);
  box-shadow: 0 16px 34px -20px rgb(0 0 0 / .8);
}
.btn--primary:hover { box-shadow: 0 20px 42px -20px rgb(0 0 0 / .85); }

.btn--ghost {
  background: var(--glass);
  border-color: var(--glass-brd);
  color: var(--fg);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}
.btn--ghost:hover { background: var(--glass-2); }

/* 图标按钮 */
.iconbtn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  color: var(--fg-2);
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease);
}
.iconbtn:hover { color: var(--fg); background: var(--glass-2); }
.iconbtn .icon { width: 18px; height: 18px; }

.icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--fill { fill: currentColor; stroke: none; }

/* ── 标签 / 药丸 ────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .26em .68em;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--glass);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--fg-2);
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .3em .8em .3em .65em;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--glass);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}
.pill__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 0 0 0 var(--line-2);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgb(255 255 255 / .28); }
  70%  { box-shadow: 0 0 0 7px rgb(255 255 255 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(255 255 255 / 0); }
}

/* ── 入场动画（仅在 JS 可用时启用，避免无 JS 时内容消失）─────────────── */
.js .reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out);
}
.js .reveal.in { opacity: 1; transform: none; }
.js .reveal[data-delay="1"] { transition-delay: .09s; }
.js .reveal[data-delay="2"] { transition-delay: .18s; }
.js .reveal[data-delay="3"] { transition-delay: .27s; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 120;
  transform: translate(-50%, 140%);
  padding: .7em 1.2em;
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-full);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-sm);
  opacity: 0;
  transition: transform .45s var(--ease-out), opacity .35s var(--ease);
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }

/* ── 不支持背景模糊时的兜底 ─────────────────────────────────────────────── */
@supports not ((-webkit-backdrop-filter: blur(2px)) or (backdrop-filter: blur(2px))) {
  .nav__bar,
  .nav__links { background: var(--panel); }
  .glass { background: var(--glass-2); }
}

/* ── 降低动态效果 ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .bg__aurora { animation: none; }
}

/* ── 打印 ───────────────────────────────────────────────────────────────── */
@media print {
  .bg, .nav, .scroll-progress, .toast, .scroll-hint { display: none !important; }
  body { background: #fff; color: #000; }
  .glass, .card { box-shadow: none; background: none; border-color: #ccc; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
