/* ========================================================================
   SpringOfAI · 个人主页样式
   零依赖、无构建。结构：
   1. 设计令牌（明/暗两套）  2. 基础重置  3. 背景层  4. 导航  5. Hero
   6. 通用版块/卡片          7. 技能/时间线/项目  8. 页脚
   9. AI 助手浮窗            10. 动效与响应式
   ======================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root {
  --bg: #05070f;
  --bg-soft: #0a0f1e;
  --text: #e9edf8;
  --text-soft: #aab3cc;
  --muted: #7c87a6;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.075);
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
  --brand-1: #6ea8ff;
  --brand-2: #a78bfa;
  --brand-3: #22d3ee;
  --ok: #34d399;
  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 1080px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --text: #0f1425;
  --text-soft: #3f4a63;
  --muted: #6b7490;
  --line: rgba(15, 20, 37, 0.1);
  --line-strong: rgba(15, 20, 37, 0.18);
  --card: rgba(255, 255, 255, 0.72);
  --card-hover: rgba(255, 255, 255, 0.92);
  --shadow: 0 24px 50px -30px rgba(20, 30, 60, 0.35);
  --brand-1: #2563eb;
  --brand-2: #7c3aed;
  --brand-3: #0891b2;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.5s var(--ease), color 0.5s var(--ease);
}

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--brand-1);
  color: #fff;
  border-radius: 10px;
}
.skip:focus { left: 16px; }

/* ---------- 3. 背景层 ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 46vw;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
  animation: drift 26s var(--ease) infinite alternate;
}

[data-theme="light"] .blob { opacity: 0.35; filter: blur(80px); }

.b1 { top: -14vw; left: -10vw; background: radial-gradient(circle, var(--brand-1), transparent 68%); }
.b2 { top: 26vh; right: -16vw; background: radial-gradient(circle, var(--brand-2), transparent 68%); animation-delay: -9s; }
.b3 { bottom: -22vw; left: 22vw; background: radial-gradient(circle, var(--brand-3), transparent 68%); animation-delay: -17s; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(4vw, 5vh, 0) scale(1.12); }
}

.grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  opacity: 0.5;
}

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

/* ---------- 4. 导航 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 24px;
  transition: background-color 0.35s var(--ease), border-color 0.35s, padding 0.35s;
  border-bottom: 1px solid transparent;
}

.nav.scrolled {
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-1) 22%, transparent);
}

.nav-links {
  display: flex;
  gap: 26px;
  margin-left: auto;
  font-size: 0.94rem;
  color: var(--text-soft);
}

.nav-links a {
  position: relative;
  padding: 4px 0;
  transition: color 0.25s;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-3));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}

.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after { transform: scaleX(1); }

.nav-actions { display: flex; gap: 8px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  cursor: pointer;
  transition: background-color 0.25s, border-color 0.25s, transform 0.25s var(--ease);
}

.icon-btn:hover { background: var(--card-hover); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .i-sun { display: none; }
[data-theme="light"] .icon-btn .i-sun { display: block; }
[data-theme="light"] .icon-btn .i-moon { display: none; }

/* ---------- 5. Hero ---------- */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(56px, 11vh, 132px) 24px clamp(64px, 9vh, 110px);
  position: relative;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-soft);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero h1 {
  margin-top: 22px;
  font-size: clamp(2.5rem, 7.4vw, 5.1rem);
  font-weight: 800;
  letter-spacing: -0.035em;
}

.grad {
  background: linear-gradient(100deg, var(--brand-1), var(--brand-2) 46%, var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 220% 100%;
  animation: shine 9s linear infinite;
}

@keyframes shine {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.lede {
  max-width: 46ch;
  margin-top: 26px;
  color: var(--text-soft);
  font-size: clamp(1rem, 1.6vw, 1.12rem);
}

.lede strong { color: var(--text); }

.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s, background-color 0.3s, border-color 0.3s;
}

.btn-primary {
  color: #04070f;
  background: linear-gradient(120deg, var(--brand-1), var(--brand-2));
  box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--brand-1) 70%, transparent);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -16px color-mix(in srgb, var(--brand-2) 70%, transparent); }

.btn-ghost {
  color: var(--text);
  background: var(--card);
  border-color: var(--line-strong);
}

.btn-ghost:hover { background: var(--card-hover); transform: translateY(-2px); }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 46px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.stats li { display: flex; flex-direction: column; gap: 2px; }
.stats b { font-size: 1.02rem; letter-spacing: -0.01em; }
.stats span { color: var(--muted); font-size: 0.84rem; }

.scroll-hint {
  position: absolute;
  right: 24px;
  bottom: 10px;
  width: 26px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  display: grid;
  place-items: start center;
  padding-top: 7px;
}

.scroll-hint span {
  width: 4px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand-3);
  animation: wheel 1.8s var(--ease) infinite;
}

@keyframes wheel {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- 6. 版块与卡片 ---------- */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(56px, 9vw, 104px) 24px;
}

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 34px;
}

.sec-no {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--brand-3);
  letter-spacing: 0.14em;
}

.sec-head h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 26px;
  transition: background-color 0.35s, border-color 0.35s, transform 0.4s var(--ease), box-shadow 0.4s;
}

.glass {
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}

.card:not(.contact):hover {
  background: var(--card-hover);
  border-color: var(--line-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.two-col {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: start;
}

.two-col .card p + p { margin-top: 14px; }
.two-col .card { color: var(--text-soft); }

.facts { display: grid; gap: 2px; padding: 10px 22px; }
.facts li {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}
.facts li:last-child { border-bottom: 0; }
.facts .k { color: var(--muted); min-width: 44px; }
.facts .v { color: var(--text); }

/* ---------- 7. 技能 / 时间线 / 项目 ---------- */
.skill-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.skill-groups h3 { font-size: 1rem; margin-bottom: 16px; color: var(--text); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }

.tags li {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.86rem;
  color: var(--text-soft);
  background: color-mix(in srgb, var(--bg-soft) 40%, transparent);
  transition: color 0.25s, border-color 0.25s, background-color 0.25s;
}

.tags li:hover { color: var(--text); border-color: var(--line-strong); }
.tags.small li { font-size: 0.8rem; padding: 4px 11px; }

.timeline { position: relative; display: grid; gap: 6px; padding-left: 22px; }

.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: linear-gradient(to bottom, var(--brand-1), var(--brand-3), transparent);
  opacity: 0.6;
}

.timeline li { position: relative; padding: 14px 0 18px 18px; }

.timeline li::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 22px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--brand-1);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-1) 14%, transparent);
}

.timeline .when {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--brand-3);
  letter-spacing: 0.08em;
}

.timeline h3 { font-size: 1.06rem; margin: 6px 0 6px; }
.timeline p { color: var(--text-soft); font-size: 0.95rem; max-width: 62ch; }

.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

.project { display: flex; flex-direction: column; gap: 14px; }

.p-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.p-top h3 { font-size: 1.14rem; }

.badge {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-3);
  border: 1px solid color-mix(in srgb, var(--brand-3) 40%, transparent);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.project p { color: var(--text-soft); font-size: 0.95rem; }

.code-mini {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.9;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-soft) 65%, transparent);
  color: var(--text-soft);
  overflow-x: auto;
  white-space: nowrap;
}
.code-mini .k { color: var(--brand-1); }
.code-mini .s { color: var(--ok); }

.link {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--brand-1);
  width: fit-content;
}

.link:hover { color: var(--brand-3); }

/* ---------- 8. 联系 / 页脚 ---------- */
.contact p { color: var(--text-soft); }
.contact-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.fine { color: var(--muted); font-size: 0.82rem; margin-top: 18px; }

.foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 24px 56px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.foot a { color: var(--text-soft); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 9. AI 助手 ---------- */
.fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  color: #04070f;
  background: linear-gradient(120deg, var(--brand-3), var(--brand-1));
  box-shadow: 0 18px 40px -16px color-mix(in srgb, var(--brand-1) 75%, transparent);
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}

.fab:hover { transform: translateY(-2px) scale(1.02); }
.fab svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }

.chat {
  position: fixed;
  right: 22px;
  bottom: 84px;
  z-index: 50;
  width: min(380px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-origin: bottom right;
  animation: pop 0.3s var(--ease);
}

.chat[hidden] { display: none; }

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.chat-id { display: flex; align-items: center; gap: 10px; }
.chat-id b { font-size: 0.92rem; display: block; }
.chat-id small { color: var(--muted); font-size: 0.74rem; }

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #04070f;
  background: linear-gradient(135deg, var(--brand-3), var(--brand-2));
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  animation: msgIn 0.25s var(--ease);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg.bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.msg.me {
  align-self: flex-end;
  color: #04070f;
  background: linear-gradient(120deg, var(--brand-1), var(--brand-2));
  border-bottom-right-radius: 5px;
}

.msg .src {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-suggests {
  display: flex;
  gap: 6px;
  padding: 0 14px 10px;
  flex-wrap: wrap;
}

.chat-suggests button {
  padding: 6px 11px;
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-soft);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.chat-suggests button:hover { background: var(--card-hover); border-color: var(--line-strong); }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  color: var(--text);
  font-size: 0.9rem;
}

.chat-form input::placeholder { color: var(--muted); }
.chat-form input:focus { outline: none; border-color: color-mix(in srgb, var(--brand-1) 55%, transparent); }
.chat-form .send { width: 42px; height: 42px; border-radius: 12px; }

/* ---------- 10. 动效与响应式 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.reveal.in { opacity: 1; transform: none; }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .skill-groups { grid-template-columns: 1fr 1fr; }
  .projects { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .scroll-hint { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .skill-groups { grid-template-columns: 1fr; }
  .hero { padding-top: 40px; }
  .stats { gap: 20px; }
  .stats li { flex: 1 1 40%; }
  .card { padding: 20px; }
  .chat { right: 12px; left: 12px; width: auto; bottom: 78px; }
  .fab { right: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
