/* ============================================================
   白思特- 个人网站 · 样式
   方向：「会说话的终端」—— 深色单主题，唯一强调色，动效预算收死
   令牌出处：Linear / Vercel / Raycast 线上实测值（详见项目 design 档案）

   动效预算（全站收死，新增交互先过这里）：
   1.  Hero 五组上台：translateY(14px)+opacity，0.3s cubic-bezier(.16,1,.3,1)，
       级差 70ms，仅 html.js 且 no-preference，只播一次 —— 全站唯一编排动画
   2.  终端光标闪烁：1.2s steps(2) infinite，no-preference 门控 —— 唯一循环动画
   3.  时间线/联系行 reveal：IO once-only，translateY(14px)+opacity，0.5s ease-out
   4.  时间线行 hover（仅 hover:hover + pointer:fine）：左缘 2px accent 条 scaleY
       0→1 + 日期变 accent，0.15s ease
   5.  其余一切：≤0.15s 的颜色/边框/背景过渡 + :active scale(.97) 按压
   6.  焦点反馈无过渡（当即达）；prefers-reduced-motion 下全部有静路
   ============================================================ */

:root {
  --bg: #08090a;
  --surface: #0f1011;
  --raised: #16181d;
  --text: #f7f8f8;
  --text-hi: #d0d6e0;
  --text-2: #8a8f98;
  --text-3: #7a7f87;
  --border: rgba(255, 255, 255, .06);
  --border-strong: rgba(255, 255, 255, .10);
  --accent: #4cb1ff;
  --accent-hover: #6fc0ff;
  --accent-tint: rgba(76, 177, 255, .10);
  --accent-underline: rgba(76, 177, 255, .35);
  --radius-s: 6px;
  --radius-l: 12px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Microsoft YaHei UI",
    "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --head-h: 64px;
  /* 扩展令牌（评委定稿收录）：--raised 为 Linear 面板档（注释卡/浮层），
     --text-hi 为方案 C 规格的次亮文字档，--accent-hover 为其 hover 档（10.12:1）。
     同一蓝灰家族，单色相规则不破。 */
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(76, 177, 255, .22); }

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

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

.wrap {
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: 24px;
}

.mono { font-family: var(--font-mono); font-variant-numeric: lining-nums tabular-nums; }
.num { font-variant-numeric: lining-nums tabular-nums; }
.prose, .foot-in { font-variant-numeric: lining-nums tabular-nums; }

.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;
  left: 16px; top: 12px;
  z-index: 100;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 8px 16px;
  font-size: 14px;
  transform: translateY(-64px);
  transition: transform .15s ease; /* 只动 transform，不动 top */
}
.skip-link:focus { transform: translateY(0); }

/* ---------- 顶栏 ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease;
}
.site-head.scrolled {
  background: rgba(8, 9, 10, .9);
  border-bottom-color: var(--border);
}
.head-in {
  height: var(--head-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.head-name {
  font-size: 15px;
  font-weight: 600;
}
.head-nav { display: flex; gap: 24px; }
.head-nav a {
  font-size: 14px;
  color: var(--text-2);
  transition: color .15s ease;
  padding: 10px 8px; /* 命中区 ≥44px */
}
.head-nav a:hover { color: var(--text); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
}
/* 静态氛围层：网格 + 顶部光斑，全部零动画 */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 30% 0%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 60% at 30% 0%, #000 30%, transparent 75%);
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 50% 50% at 30% 0%, rgba(76, 177, 255, .12), transparent 70%);
  pointer-events: none;
}
.hero-in {
  position: relative;
  z-index: 1;
  padding-top: clamp(72px, 12vh, 120px);
  padding-bottom: clamp(72px, 10vh, 112px);
}
.eyebrow {
  font-size: 14px;
  color: var(--text-2);
}
.hero h1 {
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  margin-top: 8px;
  display: flex;
  align-items: baseline;
}
/* H1 行尾光标块：全站唯一循环动画（no-preference 门控） */
.h1-cursor {
  display: inline-block;
  width: .28em;
  height: .82em;
  margin-left: .12em;
  background: var(--accent);
  transform: translateY(.08em);
}
@media (prefers-reduced-motion: no-preference) {
  .h1-cursor { animation: blink 1.2s steps(2) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }

.subline {
  margin-top: 16px;
  font-size: 17px;
  color: var(--text-hi);
}
.badge {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 4px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 13px;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.lede {
  margin-top: 24px;
  max-width: 42em;
  color: var(--text-2);
}
.hero-links {
  margin-top: 24px;
  display: flex;
  gap: 24px;
}
.hero-links a,
.ct-val {
  color: var(--text-hi);
  text-decoration: underline;
  text-decoration-color: var(--accent-underline);
  text-underline-offset: 4px;
  padding: 10px 0; /* 命中区 ≥44px */
  transition: color .15s ease, text-decoration-color .15s ease;
}
.hero-links a:hover,
.ct-val:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ---------- 术语注释（纯 CSS，无 JS 依赖） ---------- */
.note {
  color: var(--text);
  text-decoration: underline dotted var(--accent-underline);
  text-underline-offset: 4px;
  cursor: help;
  position: relative;
}
.note::after {
  content: attr(data-note);
  content: attr(data-note) / ''; /* 支持替代语法的浏览器不把伪内容读给读屏（正文 sr-only 已带全文） */
  position: absolute;
  left: 0; /* 从触发词左缘向右展开：任何桌面宽度都不会出界（居中锚定会） */
  top: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: min(300px, calc(100vw - 48px));
  padding: 10px 14px;
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  box-shadow: 0 4px 8px -4px rgba(0, 0, 0, .5);
  font-size: 13px;
  line-height: 1.6;
  font-weight: 400;
  color: var(--text-hi);
  text-decoration: none;
  white-space: normal;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
}
.note:hover::after,
.note:focus::after {
  opacity: 1;
  transform: none;
}
@media (max-width: 1080px) {
  /* 窄窗口下气泡贴边必然出界被裁：改走底部固定卡片，永不裁切。
     宽度用显式 calc —— 本页 fixed 伪元素上 width:auto 会被解析成
     max-content（Chrome 实测），不能用 auto。 */
  .note:hover::after,
  .note:focus::after {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    top: auto;
    width: calc(100vw - 32px);
    max-width: none;
    transform: none;
  }
}

/* ---------- 上台动画（全站唯一编排） ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .rise {
    opacity: 0;
    transform: translateY(14px);
    animation: rise .3s var(--ease) forwards;
  }
  .js .rise-1 { animation-delay: 0ms; }
  .js .rise-2 { animation-delay: 70ms; }
  .js .rise-3 { animation-delay: 140ms; }
  .js .rise-4 { animation-delay: 210ms; }
  .js .rise-5 { animation-delay: 280ms; }
}
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- 终端卡 ---------- */
.term {
  margin-top: 40px;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: inset 0 1px rgba(255, 255, 255, .08); /* Raycast 顶缘光，不用投影 */
  transition: border-color .15s ease;
}
.term:hover,
.term:focus-within {
  border-color: var(--border-strong);
}
.term:focus-within {
  /* 隐藏输入框获得焦点时的补偿指示：2px accent 实环（accent 对 surface 8.2:1） */
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 0 0 2px var(--accent);
}
.term-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.term-title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}
.term-skip {
  position: relative;
  font-size: 12px;
  color: var(--text-2);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 4px 10px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.term-skip::before {
  /* 命中区扩展到 ≥44px，不改变视觉尺寸 */
  content: '';
  position: absolute;
  inset: -10px -12px;
}
.term-skip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.term-skip:active { transform: scale(.97); }
.term-body {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
}
.tb { margin-bottom: 12px; }
.tb:last-child { margin-bottom: 0; }
.tb-cmd { color: var(--text); }
.t-p { color: var(--accent); }
.tb-out { color: var(--text-2); padding-left: 1.2em; }
.tb-out p { margin: 0; }
.tb-hint { color: var(--text-3); margin-top: 8px; }
.tb-out a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-underline);
  text-underline-offset: 3px;
}
.tb-out a:hover { color: var(--accent-hover); }

/* 输入行（桌面精确指针可见） */
.term-inrow {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--text);
  padding-top: 4px;
}
.t-echo {
  flex: 1 1 auto;
  min-width: 0; /* 长输入在卡内折行，不撑破页面 */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.t-caret {
  display: inline-block;
  width: .6em;
  height: 1.1em;
  background: var(--accent);
  margin-left: 1px;
  vertical-align: text-bottom;
}
@media (prefers-reduced-motion: no-preference) {
  .t-caret { animation: blink 1.2s steps(2) infinite; }
}
.term-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  font: inherit;
  font-size: 16px; /* 隐藏输入框不可见；16px 防指针触控设备（iPad+触控板）聚焦缩放 */
  cursor: pointer;
}

/* 命令条（触屏 / 窄屏可见） */
.term-chips {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
}
.term-chips button {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-hi);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  min-height: 44px; /* 移动端主输入方式，命中区达标 */
  padding: 8px 16px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.term-chips button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.term-chips button:active { transform: scale(.97); }
@media (hover: none), (pointer: coarse), (max-width: 768px) {
  .term-inrow { display: none; }
  .term-chips { display: flex; }
}

/* ---------- 章节通用 ---------- */
.sec {
  border-top: 1px solid var(--border);
  padding-block: clamp(64px, 10vh, 96px);
  scroll-margin-top: calc(var(--head-h) + 16px);
}
.sec-title {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 24px;
}
.sec-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.sec-sub {
  margin-top: 12px;
  font-size: 15px;
  color: var(--text-2);
  max-width: 42em;
}

/* ---------- 关于（长文） ---------- */
.prose {
  margin-top: 32px;
  max-width: 792px;
}
.prose p { margin-top: 16px; }
.prose h3 {
  margin-top: 40px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
}
.prose a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent-underline);
  text-underline-offset: 4px;
  transition: color .15s ease, text-decoration-color .15s ease;
}
.prose a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.prose blockquote {
  margin-top: 32px;
  padding-left: 20px;
  border-left: 2px solid var(--accent);
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-hi);
}

/* ---------- 时间线 ---------- */
.tl {
  margin-top: 32px;
  list-style: none;
}
.tl-item {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 24px;
  padding-block: 28px;
}
.tl-item + .tl-item { border-top: 1px solid var(--border); }
.tl-date {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text-2);
  padding-top: 5px;
  transition: color .15s ease;
}
.tl-body {
  position: relative;
  border-left: 1px solid var(--border);
  padding-left: 24px;
}
.tl-body::before {
  /* 轨道圆点 */
  content: '';
  position: absolute;
  left: -3.5px;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .20);
  background: var(--bg);
}
.tl-body::after {
  /* hover 左缘 accent 条（桌面精确指针） */
  content: '';
  position: absolute;
  left: -1px;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .15s ease;
}
@media (hover: hover) and (pointer: fine) {
  .tl-item:hover .tl-body::after { transform: scaleY(1); }
  .tl-item:hover .tl-date { color: var(--accent); }
}
.tl-body h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
}
.tl-body p {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-2);
  max-width: 42em;
}
.tl-meta {
  font-size: 13px;
  color: var(--text-3);
}

/* ---------- 联系 ---------- */
.contact-list {
  margin-top: 32px;
  max-width: 792px;
}
.ct-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 16px;
  align-items: center;
  padding-block: 16px;
}
.ct-row + .ct-row { border-top: 1px solid var(--border); }
.ct-row dt {
  font-size: 13px;
  color: var(--text-3);
}
.ct-row .ct-val {
  font-size: 15px;
  justify-self: start;
}
.ct-sub {
  display: inline-block;
  margin-left: 12px;
  font-size: 13px;
  color: var(--text-3);
}
.copy-btn {
  position: relative;
  font-size: 13px;
  color: var(--text-2);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 6px 12px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.copy-btn::before {
  /* 命中区扩展到 ≥44px，不改变视觉尺寸 */
  content: '';
  position: absolute;
  inset: -9px -10px;
}
.copy-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.copy-btn:active { transform: scale(.97); }
.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent-underline);
}

/* ---------- 滚动显现（仅时间线条目与联系行） ---------- */
/* 无 JS 时输入行/命令条是死的：一并隐藏，只留静态会话 */
html:not(.js) .term-inrow,
html:not(.js) .term-chips { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .js .rv {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .5s ease-out, transform .5s ease-out;
  }
  .js .rv.is-visible {
    opacity: 1;
    transform: none;
  }
}
/* 无 IntersectionObserver 的老内核：全部直接显示 */
.no-io .rv { opacity: 1 !important; transform: none !important; }

/* ---------- 404 ---------- */
.nf-title { font-size: clamp(34px, 6vw, 52px); font-weight: 600; line-height: 1.2; }

/* ---------- 页脚 ---------- */
.foot {
  border-top: 1px solid var(--border);
  padding-block: 40px;
}
.foot-in {
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.foot-in a {
  color: var(--text-2);
  transition: color .15s ease;
}
.foot-in a:hover { color: var(--text); }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .tl-item { grid-template-columns: 1fr; gap: 4px; }
  .tl-date { padding-top: 0; }
  .ct-row { grid-template-columns: 64px 1fr auto; gap: 12px; }
  .ct-row .ct-val { font-size: 14px; overflow-wrap: anywhere; }
  .ct-sub { display: block; margin-left: 0; }
}
@media (max-width: 480px) {
  .wrap { padding-inline: 20px; }
  .hero-links { gap: 20px; }
}

/* ---------- 减弱动效：全部静路 ---------- */
@media (prefers-reduced-motion: reduce) {
  .h1-cursor, .t-caret { animation: none; }
  .skip-link, .note::after, .tl-body::after { transition: none; }
  .note::after { transform: none; } /* 保持终态，仅去掉过渡 */
  * { scroll-behavior: auto; }
}
