/* ============================================================
   个人主页样式 —— 纯静态、零依赖
   主题通过 CSS 变量切换：标准(Standard) / 液态玻璃(Liquid Glass)
   导航：侧栏仅作选择，点击后收起，内容在主区按视图切换
   ============================================================ */

/* ---------- 变量：标准主题（浅色） ---------- */
:root {
  --bg: #f4f5f7;
  --bg-grad: linear-gradient(135deg, #eef1f5, #f7f8fa);
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1f2329;
  --text-dim: #6b7280;
  --accent: #4f7cff;
  --accent-soft: #e7eeff;
  --border: #e3e6ea;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.05);
  --radius: 14px;
  --glass-bg: rgba(255,255,255,.7);
  --glass-border: rgba(255,255,255,.6);
  --glass-blur: 0px;            /* 标准主题不模糊 */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 60px;
  --topbar-h: 52px;
  --ease: cubic-bezier(.4,0,.2,1);
}

/* ---------- 深色模式（标准主题随系统） ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --bg-grad: linear-gradient(135deg, #15171c, #1c1f26);
    --surface: #1e2128;
    --surface-2: #262a33;
    --text: #e8eaed;
    --text-dim: #9aa0aa;
    --accent: #6f9bff;
    --accent-soft: #243049;
    --border: #2c313b;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
    --glass-bg: rgba(30,33,40,.7);
    --glass-border: rgba(255,255,255,.12);
  }
}

/* ---------- 液态玻璃主题 ---------- */
body.theme-glass {
  --bg: #0e1230;
  --bg-grad: radial-gradient(1200px 600px at 20% 10%, #5b8cff55, transparent),
              radial-gradient(900px 500px at 90% 30%, #b15bff44, transparent),
              linear-gradient(135deg, #0b0f2a, #161a3a);
  --surface: rgba(255,255,255,.10);
  --surface-2: rgba(255,255,255,.06);
  --text: #f4f6ff;
  --text-dim: #b9bfe0;
  --accent: #8fb2ff;
  --accent-soft: rgba(143,178,255,.18);
  --border: rgba(255,255,255,.18);
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --glass-bg: rgba(255,255,255,.10);
  --glass-border: rgba(255,255,255,.28);
  --glass-blur: 14px;
}
/* 流动光斑背景（仅液态玻璃主题；尊重 reduced-motion） */
body.theme-glass::before {
  content: ""; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 420px at 18% 22%, #5b8cff66, transparent 60%),
    radial-gradient(520px 380px at 82% 28%, #b15bff55, transparent 60%),
    radial-gradient(560px 440px at 50% 82%, #4fffe055, transparent 60%);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(-3%, -2%, 0) scale(1.05); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.12); }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg-grad);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .4s var(--ease), color .3s var(--ease);
}

/* ---------- 加载动画 ---------- */
.loader {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center;
  background: var(--bg);
  opacity: 1; transition: opacity .35s var(--ease);
}
.loader.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 布局 ---------- */
.layout { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: none; align-items: center; gap: 10px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 18px; line-height: 1;
  display: grid; place-items: center; transition: transform .15s var(--ease), background .2s;
}
.icon-btn:hover { transform: translateY(-1px); background: var(--accent-soft); }
.sidebar-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- 侧栏（导航） ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px; overflow-y: auto;
  transition: width .25s var(--ease), transform .25s var(--ease), background .4s var(--ease);
  z-index: 20;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
body.theme-glass .sidebar {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: .5px; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 10px 12px;
  background: transparent; border: 1px solid transparent; border-radius: 12px;
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .2s var(--ease), border-color .2s, transform .15s var(--ease);
}
.nav-item .ico { flex: none; font-size: 18px; line-height: 1; }
.nav-item:hover { background: var(--surface-2); transform: translateX(2px); }
.nav-item.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 折叠为窄条：仅显示图标，仍可导航 */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); padding: 16px 8px; }
.sidebar.collapsed .brand { display: none; }
.sidebar.collapsed .nav { align-items: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-item .lbl { display: none; }
.sidebar.collapsed .sidebar-head { justify-content: center; }

/* ---------- 主内容 ---------- */
.content { margin-left: var(--sidebar-w); padding: 40px 40px; min-height: 100vh; transition: margin-left .25s var(--ease); }
.sidebar.collapsed ~ .content { margin-left: var(--sidebar-w-collapsed); }

.view-head { margin-bottom: 22px; }
.view-title { font-size: 30px; margin: 0 0 4px; }
.view-sub { font-size: 14px; color: var(--text-dim); margin: 0; }

.view { animation: fadeUp .28s var(--ease); }
.view[hidden] { display: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 个人信息视图 */
.info-hero { display: flex; align-items: center; gap: 20px; padding: 18px; border-radius: var(--radius); margin-bottom: 16px; }
.avatar-box {
  width: 96px; height: 96px; flex: none; overflow: hidden;
  border: 2px solid var(--border); border-radius: 22px;
  display: grid; place-items: center; color: var(--text-dim); font-size: 13px; text-align: center;
  background: var(--surface);
}
.avatar-box img { width: 100%; height: 100%; max-width: 96px; max-height: 96px; object-fit: cover; }
.avatar-ph { padding: 8px; }
.info-hero-text { min-width: 0; }
.info-name { margin: 0 0 4px; font-size: 22px; }
.info-role { margin: 0 0 10px; color: var(--text-dim); font-size: 14px; }
.id-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

.about { padding: 16px 18px; border-radius: var(--radius); margin-bottom: 16px; }
.about h3 { margin: 0 0 8px; font-size: 16px; }
.about p { margin: 0 0 8px; font-size: 14px; line-height: 1.8; color: var(--text); }
.about p:last-child { margin-bottom: 0; }

.identity-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.identity-card { padding: 14px 16px; border-radius: 12px; }
.identity-card h3 { margin: 0 0 4px; font-size: 16px; }
.identity-card .tag { margin: 0 0 8px; color: var(--text-dim); font-size: 12px; }
.id-desc { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.6; }

/* GitHub 主页入口（内联 SVG，零外部依赖） */
.github-link {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600;
  transition: transform .15s var(--ease), border-color .2s, background .2s;
}
.github-link:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--accent-soft); }
.github-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.github-link .gh-mark { flex: none; color: var(--accent); }
.github-link .gh-url { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-dim); }

.motto {
  margin: 0; padding: 10px 12px; font-size: 13px; line-height: 1.7;
  border-left: 3px solid var(--accent); color: var(--text-dim);
  background: var(--accent-soft); border-radius: 0 8px 8px 0;
}

/* ---------- 彩蛋按钮 ---------- */
.egg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 4px 0 16px; padding: 8px 14px;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(79,124,255,.35);
  transition: transform .15s var(--ease), box-shadow .2s, background .2s;
  animation: pulse 2.2s ease-in-out infinite;
}
.egg-btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 18px rgba(79,124,255,.45); }
.egg-btn:active { transform: translateY(0) scale(.97); }
.egg-btn .egg-ico { display: inline-block; animation: wiggle 2.5s ease-in-out infinite; }
.egg-btn:disabled { opacity: .7; cursor: wait; }

/* ---------- 项目卡片 ---------- */
.proj-list { display: flex; flex-direction: column; gap: 10px; }
.proj-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; transition: transform .15s var(--ease), border-color .2s;
}
.proj-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.proj-card h4 { margin: 0 0 4px; font-size: 15px; }
.proj-card p { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

/* ---------- 工具箱树 ---------- */
.tree { font-size: 14px; }
.tree-root, .tree-children { list-style: none; margin: 0; padding: 0; }
.tree-children { padding-left: 16px; border-left: 1px dashed var(--border); margin-left: 6px; }
.tree-item { margin: 2px 0; }
.tree-folder {
  width: 100%; text-align: left; background: transparent; border: 0; color: var(--text);
  font: inherit; cursor: pointer; padding: 6px 6px; border-radius: 8px; display: flex; align-items: center; gap: 6px;
}
.tree-folder:hover { background: var(--surface-2); }
.tree-folder .arrow { transition: transform .2s var(--ease); color: var(--accent); }
.tree-folder[aria-expanded="true"] .arrow { transform: rotate(90deg); }
.tree-leaf {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text);
  padding: 6px 6px; border-radius: 8px;
}
.tree-leaf:hover { background: var(--surface-2); }
.tree-leaf .note { font-size: 11px; color: var(--text-dim); }

/* ---------- 更多动效 ---------- */
/* 视图内元素依次上浮入场 */
.view:not([hidden]) > * { animation: popIn .35s var(--ease) both; }
.view:not([hidden]) > *:nth-child(1) { animation-delay: .03s; }
.view:not([hidden]) > *:nth-child(2) { animation-delay: .06s; }
.view:not([hidden]) > *:nth-child(3) { animation-delay: .09s; }
.view:not([hidden]) > *:nth-child(4) { animation-delay: .12s; }
.view:not([hidden]) > *:nth-child(5) { animation-delay: .15s; }
.view:not([hidden]) > *:nth-child(6) { animation-delay: .18s; }
.view:not([hidden]) > *:nth-child(7) { animation-delay: .21s; }

/* 项目卡片 stagger */
.proj-card { animation: fadeUp .35s var(--ease) both; }
.proj-card:nth-child(1) { animation-delay: .05s; }
.proj-card:nth-child(2) { animation-delay: .10s; }
.proj-card:nth-child(3) { animation-delay: .15s; }
.proj-card:nth-child(4) { animation-delay: .20s; }
.proj-card:nth-child(5) { animation-delay: .25s; }

/* chip 微 hover */
.chip { transition: transform .15s var(--ease), background .2s; }
.chip:hover { transform: translateY(-1px); }

/* 关键帧 */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(79,124,255,.35); }
  50% { box-shadow: 0 4px 18px rgba(79,124,255,.65); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(-12deg); }
  20% { transform: rotate(10deg); }
  30% { transform: rotate(-6deg); }
  40% { transform: rotate(4deg); }
  50% { transform: rotate(0deg); }
}

/* ---------- 液态玻璃：表面玻璃化（仅 glass 主题，标准主题为实色） ---------- */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
}
/* 真正的 Liquid Glass：backdrop 经 SVG 位移滤镜折射扭曲 + 饱和 + 多层 inset 高光/反射
   参考 GitHub 开源实现（arsalan06106/liquid-glass-html-css）的 displacement + box-shadow 组合适配 */
body.theme-glass .glass {
  background: color-mix(in srgb, var(--glass-bg) 55%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) url(#lg-distort) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.18),
    inset 1.6px 2.4px 0 -1px rgba(255,255,255,.55),
    inset -2px -2px 0 -1px rgba(255,255,255,.45),
    inset -3px -8px 2px -5px rgba(255,255,255,.30),
    inset -0.4px -1px 4px 0 rgba(0,0,0,.18),
    inset -1.5px 2.5px 0 -1px rgba(0,0,0,.22),
    0 1px 6px 0 rgba(0,0,0,.20),
    0 10px 30px -6px rgba(0,0,0,.45);
}
/* 侧栏也走液态玻璃折射 */
body.theme-glass .sidebar {
  background: color-mix(in srgb, var(--glass-bg) 60%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) url(#lg-distort) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 10px 30px -6px rgba(0,0,0,.45);
}
/* 不支持 backdrop-filter 时降级为半透明纯色 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body.theme-glass .glass,
  body.theme-glass .sidebar { background: rgba(30,33,40,.92); }
}

/* ---------- 移动端遮罩 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 15;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1199px) {
  .content { padding: 36px 28px; }
  .view-title { font-size: 26px; }
}
@media (max-width: 767px) {
  .topbar { display: flex; }
  .sidebar {
    width: 240px; transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open-drawer { transform: translateX(0); }
  /* 移动端抽屉不受折叠态影响，始终 240px 且显示文字 */
  .sidebar.collapsed { width: 240px; padding: 16px 12px; }
  .sidebar.collapsed .brand { display: block; }
  .sidebar.collapsed .nav { align-items: stretch; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .sidebar.collapsed .nav-item .lbl { display: inline; }
  .content { margin-left: 0; padding: 20px 16px; padding-top: calc(var(--topbar-h) + 16px); }
  .sidebar.collapsed ~ .content { margin-left: 0; }
  .identity-grid { grid-template-columns: 1fr; }
}

/* ---------- 尊重减少动画 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
