/* ============================================================
   bestxiao.asia — 设计系统
   概念：Two Readers（两位读者）
     人类 → 暖金 gold     机器 → 信号青 signal
   同一份内容，两种呈现。色彩承载语义，不作装饰。
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  /* 底色（中性偏冷，比旧版更沉） */
  --ink-0: #08080c;
  --ink-1: #0d0d13;
  --ink-2: #131319;
  --ink-3: #1b1b24;

  /* 人类色 —— 暖金（品牌色） */
  --gold: #c9a84c;
  --gold-hi: #e8d08a;
  --gold-line: rgba(201, 168, 76, 0.22);
  --gold-wash: rgba(201, 168, 76, 0.05);

  /* 机器色 —— 信号青 */
  --signal: #4ec9b0;
  --signal-line: rgba(78, 201, 176, 0.24);
  --signal-wash: rgba(78, 201, 176, 0.05);

  /* 文本 */
  --text: #eae8e2;
  --text-2: #9c9991;
  --text-3: #62605a;

  /* 线 */
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo,
    Consolas, "Liberation Mono", monospace;

  /* 尺度（流体） */
  --step--1: 0.8125rem;
  --step-0: 1.0625rem;
  --step-1: 1.1875rem;
  --step-2: 1.4375rem;
  --step-3: clamp(1.6rem, 2.6vw, 2.1rem);
  --step-display: clamp(1.95rem, 7.2vw, 4.25rem);

  /* 布局 */
  --wrap: 1120px;
  --measure: 62ch;
  --gutter: clamp(1.25rem, 5vw, 4.5rem);
  --sect: clamp(4.5rem, 11vw, 9.5rem);

  /* 动效 */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 420ms;
  --dur-slow: 900ms;

  /* 当前读者模式的主色（由 JS 切换 --reader） */
  --reader: var(--gold);
  --reader-line: var(--gold-line);
  --reader-wash: var(--gold-wash);
}

/* 读者模式的主色切换只作用于 Hero —— 其余区块保持暖金，克制 */
html[data-reader="machine"] .hero {
  --reader: var(--signal);
  --reader-line: var(--signal-line);
  --reader-wash: var(--signal-wash);
}

/* ---------- Base ---------- */
body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.72;
  color: var(--text);
  background: var(--ink-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* 极淡点阵：机器质感，几乎不可察觉 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
}

h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; letter-spacing: -0.011em; text-wrap: balance; }
p { text-wrap: pretty; }

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

::selection { background: var(--reader-wash); color: var(--reader); }

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

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;
  z-index: 1;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--gold);
  color: var(--ink-0);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
}
.skip:focus { left: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--ink-0) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 0.9rem var(--gutter);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.topbar__brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
  margin-right: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}
.topbar__brand span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0;
}
.topbar__links { display: flex; gap: 1.4rem; align-items: center; }
.topbar__links a {
  font-size: 0.9rem;
  color: var(--text-2);
  transition: color var(--dur) var(--ease);
  position: relative;
}
.topbar__links a:hover { color: var(--text); }

/* 机器入口徽标 */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--signal-line);
  border-radius: 999px;
  color: var(--signal) !important;
  background: var(--signal-wash);
}
.ai-badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 8px var(--signal);
}

.nav-toggle { display: none; }

/* ---------- Hero ---------- */
.hero {
  padding: clamp(3.5rem, 9vw, 7rem) 0 clamp(2.5rem, 5vw, 4rem);
  border-bottom: 1px solid var(--line);
}

/* 读者开关 —— 全站的记忆点 */
.reader-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: clamp(2rem, 5vw, 3.25rem);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}
.reader-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.reader-switch button[aria-selected="true"] { color: var(--ink-0); }
.reader-switch button[aria-selected="true"]::before { background: currentColor; }
.reader-switch button::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background var(--dur) var(--ease);
}
.reader-switch__human[aria-selected="true"] { background: var(--gold); }
.reader-switch__machine[aria-selected="true"] { background: var(--signal); }

/* 两种视图叠放，用 data-reader 控制显隐（无 JS 时默认人类视图） */
.hero__view { display: none; }
.hero__view[data-active] { display: block; }

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--reader);
  letter-spacing: 0.02em;
  margin-bottom: 1.1rem;
}
.hero__title {
  font-size: var(--step-display);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}
.hero__sub {
  color: var(--text-2);
  max-width: 26em;
  margin-bottom: 2rem;
}
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
  cursor: pointer;
}
.btn--primary {
  background: var(--reader);
  color: var(--ink-0);
}
.btn--primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn--ghost {
  border-color: var(--line-2);
  color: var(--text);
}
.btn--ghost:hover { border-color: var(--reader); color: var(--reader); }

/* 机器视图的终端 */
.terminal {
  border: 1px solid var(--signal-line);
  border-radius: 10px;
  background: #0a0f0e;
  overflow: hidden;
  max-width: 640px;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.75;
}
.terminal__bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid rgba(78, 201, 176, 0.14);
  color: var(--text-3);
  font-size: 0.72rem;
}
.terminal__dot { width: 9px; height: 9px; border-radius: 50%; }
.terminal__body { padding: 1rem 1.1rem; overflow-x: auto; }
.terminal__body .cmd { color: var(--signal); }
.terminal__body .key { color: var(--signal); }
.terminal__body .val { color: var(--text); }
.terminal__body .dim { color: var(--text-3); }
.terminal__body .cmt { color: #4a5a56; }

/* Hero 入场编排 —— 唯一的一次动效 */
.hero__enter { animation: rise var(--dur-slow) var(--ease) both; }
.hero__enter:nth-child(2) { animation-delay: 70ms; }
.hero__enter:nth-child(3) { animation-delay: 140ms; }
.hero__enter:nth-child(4) { animation-delay: 210ms; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 区块 ---------- */
.section { padding: var(--sect) 0; }
.section + .section { border-top: 1px solid var(--line); }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: clamp(2rem, 4vw, 3.25rem);
  flex-wrap: wrap;
}
.section__title {
  font-size: var(--step-3);
  letter-spacing: -0.015em;
}
.section__title::before {
  content: "";
  display: inline-block;
  width: 1.75rem;
  height: 2px;
  background: var(--reader);
  vertical-align: middle;
  margin-right: 0.7rem;
  transform: translateY(-0.28em);
}
.section__note { color: var(--text-3); font-size: 0.92rem; max-width: 20em; }

/* ---------- 关于 ---------- */
.about { display: grid; grid-template-columns: 1.4fr 1fr; gap: clamp(2rem, 5vw, 4.5rem); }
.about__lede { font-size: var(--step-1); color: var(--text); line-height: 1.68; max-width: var(--measure); }
.about__lede + p { margin-top: 1.1rem; color: var(--text-2); max-width: var(--measure); }
.about__meta { display: flex; flex-direction: column; gap: 1.6rem; }
.meta-block__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-3);
  margin-bottom: 0.6rem;
}
.meta-block__note {
  margin-top: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--text-3);
}
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font-size: 0.82rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text-2);
}
.chip--cert { border-color: var(--gold-line); color: var(--gold); }

/* 时间线（真实序列，用竖线与节点） */
.timeline { margin-top: clamp(2.5rem, 5vw, 3.5rem); border-left: 1px solid var(--line-2); padding-left: clamp(1.25rem, 3vw, 2rem); }
.timeline__item { position: relative; padding-bottom: 1.75rem; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: calc(-1 * clamp(1.25rem, 3vw, 2rem) - 4px);
  top: 0.6rem;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-0);
  border: 1px solid var(--gold-line);
}
.timeline__item:first-child::before { background: var(--gold); border-color: var(--gold); }
.timeline__period { font-family: var(--font-mono); font-size: 0.74rem; color: var(--gold); }
.timeline__role { font-size: 1.05rem; font-weight: 600; margin: 0.15rem 0 0.25rem; }
.timeline__desc { color: var(--text-2); font-size: 0.94rem; }

/* ---------- 作品 ---------- */
.work-list { display: flex; flex-direction: column; }
.work {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem 2rem;
  align-items: start;
  padding: 1.75rem 0;
  border-top: 1px solid var(--line);
  transition: padding-left var(--dur) var(--ease);
  position: relative;
}
.work:last-child { border-bottom: 1px solid var(--line); }
.work:hover { padding-left: 0.75rem; }
.work::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--reader);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform var(--dur) var(--ease);
}
.work:hover::before { transform: scaleY(1); }
.work__tag { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); }
.work__title { font-size: 1.32rem; margin: 0.35rem 0 0.5rem; letter-spacing: -0.01em; }
.work__desc { color: var(--text-2); font-size: 0.96rem; max-width: 46em; }
.work__tech { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.9rem; }
.work__tech span { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); }
.work__go {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
  transition: color var(--dur) var(--ease);
  padding-top: 0.35rem;
}
.work:hover .work__go { color: var(--reader); }

/* ---------- 文章 ---------- */
.writing-list { display: flex; flex-direction: column; }
.post {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 1.35rem 0;
  border-top: 1px solid var(--line);
  transition: padding-left var(--dur) var(--ease);
}
.post:last-child { border-bottom: 1px solid var(--line); }
.post:hover { padding-left: 0.75rem; }
.post__date { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-3); white-space: nowrap; padding-top: 0.2rem; }
.post__main { flex: 1; }
.post__title { font-size: 1.12rem; font-weight: 600; transition: color var(--dur) var(--ease); }
.post:hover .post__title { color: var(--reader); }
.post__excerpt { color: var(--text-2); font-size: 0.9rem; margin-top: 0.25rem; max-width: 46em; }
.post__cat { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); white-space: nowrap; }

/* ---------- 工具箱 ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr)); gap: 0.75rem; }
.tool {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tool:hover { border-color: var(--gold-line); background: var(--gold-wash); }
.tool__icon { width: 26px; height: 26px; flex: none; color: var(--gold); }
.tool__name { font-size: 0.95rem; font-weight: 600; }
.tool__tag { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-3); }
.toolbox__note {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ---------- 连接 ---------- */
.connect__text { font-size: var(--step-1); max-width: 40ch; color: var(--text); }
.connect__text em { font-style: normal; color: var(--gold); }
.links { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1.5rem; }
.links a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-2);
  font-size: 0.95rem;
  transition: color var(--dur) var(--ease);
  width: fit-content;
}
.links a:hover { color: var(--gold); }
.links svg { width: 17px; height: 17px; flex: none; }

/* ---------- 页脚：机器可读入口 ---------- */
.footer { border-top: 1px solid var(--line); padding: clamp(3rem, 6vw, 4.5rem) 0 2.5rem; }
.footer__machine {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  padding: 1.15rem 1.35rem;
  border: 1px solid var(--signal-line);
  border-radius: 10px;
  background: var(--signal-wash);
  margin-bottom: 2.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.footer__machine-label { color: var(--signal); display: inline-flex; align-items: center; gap: 0.5rem; }
.footer__machine-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 8px var(--signal); }
.footer__machine a { color: var(--text-2); transition: color var(--dur) var(--ease); }
.footer__machine a:hover { color: var(--signal); }
.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-3);
}
.footer__bottom a { color: var(--text-3); }
.footer__bottom a:hover { color: var(--gold); }

/* 人类彩蛋 —— 安静的、藏在角落的一句 */
.human-egg {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-3);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.footer:hover .human-egg { opacity: 1; }

/* ---------- 响应式 ---------- */

@media (max-width: 860px) {
  /* 数据源里用 \n 指定的断行：宽屏生效，窄屏交给浏览器自然折行，
     避免「流程里。」这类孤字成行 */
  .soft-br { display: none; }
  .about { grid-template-columns: 1fr; }
  .work { grid-template-columns: 1fr; }
  .work__go { padding-top: 0; }
  .hero__title { max-width: none; }
}

@media (max-width: 620px) {
  .topbar__links { gap: 1rem; }
  .section__head { flex-direction: column; gap: 0.35rem; }
  .section__note { max-width: none; }
  .topbar__links a:not(.ai-badge) { display: none; }
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: 0;
    cursor: pointer;
    padding: 6px;
  }
  .nav-toggle span { width: 20px; height: 2px; background: var(--text-2); transition: var(--dur) var(--ease); }
  .topbar[data-open] .topbar__links {
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem var(--gutter) 1.5rem;
    background: var(--ink-1);
    border-bottom: 1px solid var(--line);
  }
  .topbar[data-open] .topbar__links a:not(.ai-badge) { display: block; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool { padding: 0.85rem 1rem; }
}

/* ---------- Reduced motion ---------- */
@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;
  }
  .hero__enter { opacity: 1; transform: none; }
}
