/* =========================================================
   Resume site — minimal / Linear-inspired
   All colors live in CSS variables; never hard-code hex.
   ========================================================= */

:root {
  /* Accent: emerald (#10b981) */
  --accent: 16 185 129;
  --accent-soft: 52 211 153;

  /* Light theme tokens */
  --bg: 250 250 250;
  --surface: 255 255 255;
  --border: 229 231 235;
  --text: 10 10 10;
  --text-muted: 82 82 91;
  --text-faint: 113 113 122;
  --code-bg: 244 244 245;

  /* Background pattern tokens — 行业感：数据节点 + 安全光晕 */
  --dot: 10 10 10;          /* 点阵颜色（light = 黑色微粒） */
  --dot-alpha: 0.06;        /* 点阵透明度 */
  --dot-size: 0.7px;        /* 点直径 */
  --dot-grid: 24px;         /* 点间距 */
  --glow-alpha: 0.10;       /* 角部光晕透明度 */

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Layout */
  --container-max: 720px;
  --section-gap: 96px;
  --header-h: 64px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 320ms;
}

/* Dark theme overrides (toggled via [data-theme="dark"]) */
[data-theme="dark"] {
  --bg: 10 10 10;
  --surface: 23 23 23;
  --border: 39 39 42;
  --text: 250 250 250;
  --text-muted: 161 161 170;
  --text-faint: 113 113 122;
  --code-bg: 24 24 27;
  --dot: 250 250 250;       /* 点阵颜色（dark = 白色微粒） */
  --dot-alpha: 0.05;
  --glow-alpha: 0.16;
}

/* If user has not chosen and OS prefers dark, apply dark tokens.
   Handled in JS too, but this keeps the very first paint correct. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: 10 10 10;
    --surface: 23 23 23;
    --border: 39 39 42;
    --text: 250 250 250;
    --text-muted: 161 161 170;
    --text-faint: 113 113 122;
    --code-bg: 24 24 27;
    --dot: 250 250 250;
    --dot-alpha: 0.05;
    --glow-alpha: 0.16;
  }
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: rgb(var(--text));

  /* Layered background：
     1) 基底颜色（--bg）
     2) 右上角 emerald 光晕（fixed，滚动时停留在视口角部）
     3) 点阵网格（24px × 24px，scroll，随内容滚动）
     → 行业感：数据节点 + 安全光晕，不喧宾夺主 */
  background-color: rgb(var(--bg));
  background-image:
    radial-gradient(
      ellipse 90% 70% at 100% 0%,
      rgb(var(--accent) / var(--glow-alpha)),
      transparent 60%
    ),
    radial-gradient(
      circle at center,
      rgb(var(--dot) / var(--dot-alpha)) var(--dot-size),
      transparent calc(var(--dot-size) + 0.3px)
    );
  background-size: 100% 100%, var(--dot-grid) var(--dot-grid);
  background-position: 0 0, 0 0;
  background-repeat: no-repeat, repeat;
  background-attachment: fixed, scroll;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

/* Chinese typography: 中文稍大一点（+2%），行距 1.75；数字仍走 JetBrains Mono */
:lang(zh-CN) body { font-size: 16.32px; }
:lang(zh-CN) .prose,
:lang(zh-CN) .hero-bio,
:lang(zh-CN) .timeline-desc,
:lang(zh-CN) .card-desc {
  line-height: 1.75;
}

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

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
a:hover { color: rgb(var(--accent)); }

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

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

::selection {
  background: rgb(var(--accent) / 0.18);
  color: rgb(var(--text));
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: rgb(var(--text-faint)); }

/* ---------- Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding-top: var(--section-gap);
  padding-bottom: 0;
}
.section + .section { padding-top: var(--section-gap); }
.section:last-of-type { padding-bottom: var(--section-gap); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: rgb(var(--text));
  color: rgb(var(--bg));
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus { left: 16px; top: 16px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgb(var(--bg) / 0.72);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.site-header.is-scrolled { border-bottom-color: rgb(var(--border)); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-bottom: 0;
}
.brand:hover { color: inherit; }
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 999px;
  background: rgb(var(--accent));
  box-shadow: 0 0 0 4px rgb(var(--accent) / 0.12);
}

.primary-nav ul {
  display: flex;
  gap: 22px;
}
.primary-nav a {
  font-size: 14px;
  color: rgb(var(--text-muted));
  border-bottom: 0;
  position: relative;
  padding: 6px 2px;
}
.primary-nav a:hover { color: rgb(var(--text)); }
.primary-nav a.is-active {
  color: rgb(var(--text));
}
.primary-nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgb(var(--accent));
  border-radius: 2px;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: rgb(var(--text-muted));
  border: 1px solid rgb(var(--border));
  background: rgb(var(--surface));
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.theme-toggle:hover { color: rgb(var(--text)); border-color: rgb(var(--text-faint)); }
.theme-toggle:active { transform: scale(0.96); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Hero ---------- */
.hero { padding-top: calc(var(--section-gap) + var(--header-h)); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgb(var(--text-muted));
  margin: 0 0 24px;
  padding: 6px 12px;
  border: 1px solid rgb(var(--border));
  border-radius: 999px;
  background: rgb(var(--surface));
}
.dot-mark {
  width: 6px; height: 6px; border-radius: 999px;
  background: rgb(var(--accent));
  box-shadow: 0 0 0 3px rgb(var(--accent) / 0.18);
}

.hero-name {
  font-size: clamp(40px, 6.5vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0 0 16px;
}
.hero-title {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: clamp(18px, 2.2vw, 22px);
  color: rgb(var(--text-muted));
  margin: 0 0 16px;
}
.dot-sep { color: rgb(var(--text-faint)); }

.hero-bio {
  font-size: 17px;
  color: rgb(var(--text-muted));
  max-width: 56ch;
  margin: 0 0 28px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  border-bottom: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: rgb(var(--text));
  color: rgb(var(--bg));
  border-color: rgb(var(--text));
}
.btn-primary:hover {
  background: rgb(var(--accent));
  border-color: rgb(var(--accent));
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: rgb(var(--text));
  border-color: rgb(var(--border));
}
.btn-ghost:hover { border-color: rgb(var(--text-faint)); color: rgb(var(--text)); }

/* ---------- Section title ---------- */
.section-title {
  display: flex; align-items: baseline; gap: 12px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
}
.section-mark {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: rgb(var(--accent));
  padding: 3px 8px;
  border: 1px solid rgb(var(--accent) / 0.35);
  border-radius: 6px;
  background: rgb(var(--accent) / 0.06);
}

.prose {
  font-size: 17px;
  color: rgb(var(--text-muted));
  max-width: 62ch;
  margin: 0 0 28px;
}

/* ---------- About: fact grid ---------- */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 28px;
  border-top: 1px solid rgb(var(--border));
  padding-top: 24px;
}
.fact-grid li {
  display: flex; flex-direction: column; gap: 4px;
}
.fact-label {
  font-size: 12px;
  color: rgb(var(--text-faint));
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.fact-value {
  font-size: 15px;
  color: rgb(var(--text));
}

/* ---------- Timeline (Experience / Education) ---------- */
.timeline { display: flex; flex-direction: column; gap: 28px; }
.timeline-item {
  border-left: 1px solid rgb(var(--border));
  padding-left: 20px;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -5px; top: 6px;
  width: 9px; height: 9px;
  border-radius: 999px;
  background: rgb(var(--bg));
  border: 2px solid rgb(var(--accent));
}

.timeline-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
  color: rgb(var(--text-faint));
  margin-bottom: 6px;
}
.timeline-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--border));
  color: rgb(var(--text-muted));
}
.timeline-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}
.timeline-desc {
  margin: 0;
  color: rgb(var(--text-muted));
  font-size: 15px;
}

/* ---------- Cards (Projects) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.card {
  border: 1px solid rgb(var(--border));
  border-radius: 14px;
  background: rgb(var(--surface));
  padding: 18px 18px 16px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover {
  border-color: rgb(var(--text-faint));
  transform: translateY(-2px);
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
}
.card-year { font-size: 12px; color: rgb(var(--text-faint)); }
.card-desc { font-size: 14px; color: rgb(var(--text-muted)); margin: 0 0 12px; }

/* Project key-result badge — 关键成果数字徽章 */
.result-badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgb(var(--accent) / 0.10);
  color: rgb(var(--accent));
  border: 1px solid rgb(var(--accent) / 0.30);
  margin-bottom: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ---------- Tags ---------- */
.tag-list {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tag-list li {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgb(var(--code-bg));
  color: rgb(var(--text-muted));
  border: 1px solid rgb(var(--border));
}

/* ---------- Skills grid ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  border-top: 1px solid rgb(var(--border));
  padding-top: 24px;
}
.skills-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(var(--text-faint));
  margin: 0 0 10px;
  font-weight: 500;
}

/* ---------- Contact ---------- */
.contact-list {
  display: flex; flex-direction: column; gap: 10px;
  margin: 0 0 28px;
  border-top: 1px solid rgb(var(--border));
  padding-top: 20px;
}
.contact-list li {
  display: flex; align-items: center; gap: 16px;
}
.contact-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(var(--text-faint));
  width: 96px;
  flex-shrink: 0;
}
.contact-value {
  color: rgb(var(--text));
  border-bottom: 1px solid rgb(var(--border));
  padding-bottom: 2px;
}
.contact-value:hover {
  color: rgb(var(--accent));
  border-bottom-color: rgb(var(--accent));
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid rgb(var(--border));
  padding: 28px 0;
  font-size: 12px;
  color: rgb(var(--text-faint));
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}

/* ---------- Reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 600ms var(--ease), transform 600ms var(--ease);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  :root { --section-gap: 64px; --header-h: 56px; }

  .container { padding: 0 20px; }

  .primary-nav { display: none; } /* Simple mobile: collapse to brand + actions */

  .hero-name { font-size: 40px; }
  .hero-title { font-size: 17px; }
  .hero-bio { font-size: 16px; }

  .fact-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: 1fr; gap: 16px; }

  .contact-label { width: 80px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .section-title { font-size: 20px; }
  .btn { padding: 9px 14px; }
}
