/* =========================================================
   在线个人主页 —— 样式表（复刻参考站设计令牌：黑白极简灰阶）
   设计令牌来自参考站 CSS 变量（oklch 灰阶 + Geist/Noto Sans SC）
   1. 主题变量
   2. 基础
   3. 组件：按钮 / 卡片 / 图标
   4. 导航
   5. Hero
   6. 区块：关于 / 教育 / 经历 / 技能 / 页脚
   7. 入场动画
   8. 响应式 & 动效偏好
   ========================================================= */

/* ============ 1. 主题变量 ============ */
:root {
  --font-sans: Geist, 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --background: oklch(99% 0 0);
  --foreground: oklch(0% 0 0);
  --card: oklch(100% 0 0);
  --primary: oklch(0% 0 0);
  --primary-foreground: oklch(100% 0 0);
  --secondary: oklch(94% 0 0);
  --secondary-foreground: oklch(0% 0 0);
  --muted: oklch(97% 0 0);
  --muted-foreground: oklch(44% 0 0);
  --accent: oklch(94% 0 0);
  --border: oklch(92% 0 0);

  --radius-lg: 0.75rem;   /* rounded-xl */
  --radius: 0.5rem;       /* rounded-lg */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
  --header-h: 4rem;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark {
  --background: oklch(0% 0 0);
  --foreground: oklch(100% 0 0);
  --card: oklch(14% 0 0);
  --primary: oklch(100% 0 0);
  --primary-foreground: oklch(0% 0 0);
  --secondary: oklch(25% 0 0);
  --secondary-foreground: oklch(100% 0 0);
  --muted: oklch(23% 0 0);
  --muted-foreground: oklch(72% 0 0);
  --accent: oklch(32% 0 0);
  --border: oklch(26% 0 0);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
}

/* ============ 2. 基础 ============ */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

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

/* ============ 3. 组件 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: opacity 0.15s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { opacity: 0.9; }
.btn-outline {
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--accent); }

.card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}
.card-text {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.625;
}

.external-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--foreground);
}
.external-link:hover { text-decoration: underline; }

/* ============ 4. 导航 ============ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  transition: all 0.3s var(--ease);
  background: transparent;
}
.site-header.is-scrolled {
  background: color-mix(in srgb, var(--background) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
@media (min-width: 640px) { .nav { padding: 0 1.5rem; } }

.brand {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--foreground);
  opacity: 0.6;
  transition: opacity 0.2s var(--ease);
}
.brand:hover { opacity: 1; }

.nav-links { display: none; align-items: center; gap: 0.25rem; }
.nav-link {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  transition: color 0.15s var(--ease);
}
.nav-link:hover, .nav-link.active { color: var(--foreground); }

.icon-btn {
  padding: 0.5rem;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  display: inline-flex;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.icon-btn:hover { color: var(--foreground); background: var(--accent); }

.nav-theme { margin-left: 0.5rem; }

/* 主题图标 */
.i-sun { display: none; }
html.dark .i-sun { display: block; }
html.dark .i-moon { display: none; }

.nav-mobile-actions { display: flex; align-items: center; gap: 0.5rem; }
.i-close { display: none; }
.menu-open .i-close { display: block; }
.menu-open .i-menu { display: none; }

.mobile-menu {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
}
/* 关键：作者样式的 display:flex 会覆盖 UA 的 [hidden]{display:none}，必须显式声明 */
.mobile-menu[hidden] { display: none; }

/* 菜单展开时导航条保持不透明，避免顶部透明穿透 */
.site-header.menu-open {
  background: var(--background);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom-color: transparent;
}
.mobile-link {
  padding: 0.75rem 0.5rem;
  font-size: 0.9375rem;
  color: var(--muted-foreground);
  border-radius: var(--radius);
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.mobile-link:hover, .mobile-link.active { color: var(--foreground); background: var(--accent); }

/* ============ 5. Hero ============ */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-bg { position: absolute; inset: 0; z-index: 0; }
.hero-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.6;
}
html.dark .hero-bg-img { opacity: 0.3; }
.hero-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--background) 50%, transparent),
    color-mix(in srgb, var(--background) 70%, transparent),
    var(--background)
  );
}

.hero-content {
  position: relative;
  z-index: 10;
  max-width: 56rem;
  margin: 0 auto;
  padding: 5rem 1rem 3rem;
  text-align: center;
}
@media (min-width: 640px) { .hero-content { padding-left: 1.5rem; padding-right: 1.5rem; } }

.hero-title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}
.hero-subtitle {
  font-size: 1.125rem;
  color: var(--muted-foreground);
  margin-bottom: 2rem;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}
.pill {
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
}

.hero-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
}

.hero-scroll {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  color: var(--muted-foreground);
  transition: color 0.15s var(--ease);
}
.hero-scroll:hover { color: var(--foreground); }

.animate-bounce { animation: bounce 1s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
  50% { transform: none; animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

/* ============ 6. 区块 ============ */
.section { padding: 5rem 0; }
.section-soft { background: color-mix(in srgb, var(--secondary) 30%, transparent); }

.container-lg { max-width: 72rem; }
.container-md { max-width: 64rem; }
.container-lg, .container-md {
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 640px) {
  .container-lg, .container-md { padding: 0 1.5rem; }
}

.section-head { text-align: center; margin-bottom: 3rem; }
.section-title {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}
.section-sub { color: var(--muted-foreground); }

/* --- 关于我 --- */
.about-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 4rem;
}
.about-icon {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.about-icon img {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
}
html.dark .about-icon img { filter: invert(100%); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.stat {
  text-align: center;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}
.stat-label { font-size: 0.75rem; color: var(--muted-foreground); }

/* --- 教育经历（中轴时间线） --- */
.timeline { position: relative; }
.timeline-line {
  position: absolute;
  left: 1rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-items { display: flex; flex-direction: column; gap: 2rem; }

.timeline-item { position: relative; }
.timeline-dot {
  position: absolute;
  left: 1rem;
  top: 1.4rem;
  transform: translateX(-50%);
  z-index: 10;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 9999px;
  background: var(--foreground);
  border: 2px solid var(--background);
}

.timeline-side { margin-left: 3rem; }
.edu-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.edu-period {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  margin-bottom: 0.25rem;
}
.edu-school { font-size: 1rem; font-weight: 600; color: var(--foreground); }
.edu-major { font-size: 0.875rem; color: var(--muted-foreground); margin-top: 0.25rem; }

/* --- 经历卡片 --- */
.exp-list { display: flex; flex-direction: column; gap: 2rem; }

.exp-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s var(--ease);
}
.exp-card:hover { box-shadow: var(--shadow-md); }

.exp-cover {
  position: relative;
  height: 10rem;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--secondary);
}
.exp-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
html.dark .exp-cover img {
  filter: invert(100%);
  opacity: 0.4;
}

.exp-body { padding: 1.5rem; }

.exp-head {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.exp-title { font-size: 1.25rem; font-weight: 700; color: var(--foreground); }
.exp-role { font-size: 0.875rem; color: var(--muted-foreground); }
.exp-period {
  align-self: flex-start;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  background: var(--secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.exp-overview {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.625;
  margin-bottom: 1rem;
}

.exp-points { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.exp-points li {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
}
.exp-points .dot {
  color: var(--muted-foreground);
  margin-top: 0.125rem;
  flex: none;
}
.exp-points span:last-child {
  color: var(--muted-foreground);
  line-height: 1.625;
}

/* --- 项目成果：数据化展示 --- */
.result-box {
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
  border: 1px solid var(--border);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}
html.dark .result-box { background: color-mix(in srgb, var(--primary) 10%, transparent); }

.result-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--foreground);
}
.result-head .icon { width: 15px; height: 15px; }
.result-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--foreground);
}
.result-tag {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* 指标卡 */
.result-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.metric {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--background);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

/* 核心指标：反色强调 */
.metric-featured {
  background: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
}
.metric-featured:hover { box-shadow: var(--shadow-md); }

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.metric-featured .metric-value { font-size: 2.25rem; }
.metric-unit {
  font-size: 0.5em;
  font-weight: 600;
  margin-left: 0.25em;
  letter-spacing: 0;
}
.metric-label {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted-foreground);
}
.metric-featured .metric-label {
  color: color-mix(in srgb, var(--background) 72%, transparent);
}

/* 优化前 / 优化后 对比条 */
.compare {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.compare-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
}
.compare-label {
  width: 3.25rem;
  flex: none;
  color: var(--muted-foreground);
}
.compare .bar {
  flex: 1;
  height: 0.5rem;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--foreground) 10%, transparent);
  overflow: hidden;
}
.compare .bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 9999px;
  background: var(--foreground);
  transition: width 1.1s var(--ease);
}
/* 随卡片入场一起填充（.visible 由 reveal 引擎添加） */
.reveal-up.visible .compare .bar i { width: var(--w, 0%); }
.compare-value {
  flex: none;
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--foreground);
}

.result-text {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.625;
}

.exp-body > .external-link { margin-top: 0.25rem; }

/* --- 技能 --- */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 3rem;
}
.skill-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  transition: box-shadow 0.3s var(--ease);
}
.skill-tile:hover { box-shadow: var(--shadow-sm); }
.skill-tile img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
}
html.dark .skill-tile img { filter: invert(100%); }
.skill-tile span {
  font-size: 0.625rem;
  text-align: center;
  color: var(--muted-foreground);
  line-height: 1.25;
}

.cert-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 1rem;
  text-align: center;
}
.cert-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}
.chip {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* --- 页脚 / 联系 --- */
.footer {
  position: relative;
  padding: 5rem 0;
  overflow: hidden;
}
.footer-bg { position: absolute; inset: 0; z-index: 0; }
.footer-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
}
html.dark .footer-bg-img { opacity: 0.2; }
.footer-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--background) 50%, transparent),
    var(--background)
  );
}

.footer-content {
  position: relative;
  z-index: 10;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1rem;
  text-align: center;
}
.footer-content .section-head { margin-bottom: 0; }
.footer-content > .reveal { margin-bottom: 2rem; }

.footer-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  transition: color 0.15s var(--ease);
}
.footer-link:hover { color: var(--foreground); }

.footer-copy {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

/* ============ 7. 入场动画（与参考站 reveal 引擎一致） ============ */
html.reveal-ready :is(.reveal, .reveal-up) {
  opacity: 0;
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  transition-delay: var(--reveal-delay, 0ms);
}
html.reveal-ready .reveal-up { transform: translateY(24px); }
html.reveal-ready :is(.reveal, .reveal-up).visible {
  opacity: 1;
  transform: none;
}

/* ============ 8. 响应式 ============ */
@media (min-width: 640px) {
  .hero-title { font-size: 3.75rem; }
  .hero-subtitle { font-size: 1.25rem; }
  .hero-actions { flex-direction: row; }
  .footer-actions { flex-direction: row; }
  .section { padding: 7rem 0; }
  .exp-cover { height: 12rem; }
  .exp-body { padding: 2rem; }
  .exp-head {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
  .exp-period { align-self: auto; }
  .skill-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .skill-tile { padding: 1rem; }
  .skill-tile img { width: 2.5rem; height: 2.5rem; }
  .skill-tile span { font-size: 0.75rem; }
  .stat-value { font-size: 2.25rem; }
  .stat-label { font-size: 0.875rem; }

  /* 教育时间线切换为中轴左右交错 */
  .timeline-line { left: 50%; transform: translateX(-50%); }
  .timeline-dot { left: 50%; }
  .timeline-side { margin-left: 0; width: calc(50% - 2rem); }
  .timeline-item:first-child .timeline-side { margin-right: auto; padding-right: 2rem; }
  .timeline-item:last-child .timeline-side { margin-left: auto; padding-left: 2rem; }
}

@media (min-width: 768px) {
  .nav-links { display: flex; }
  .nav-mobile-actions { display: none; }
  .mobile-menu { display: none !important; }
  .about-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .skill-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}

/* 动效偏好降级 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.reveal-ready :is(.reveal, .reveal-up) { opacity: 1; transform: none; transition: none; }
  .animate-bounce { animation: none; }
}

/* 打印 */
@media print {
  .site-header, .hero-scroll, .mobile-menu { display: none !important; }
  .hero { min-height: auto; }
  .section { padding: 1.5rem 0; }
  html.reveal-ready :is(.reveal, .reveal-up) { opacity: 1 !important; transform: none !important; }
}
