/* =========================================================
   1. 变量：浅色 / 深色
   ========================================================= */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --text: #14161f;
  --text-soft: #6b7280;
  --text-dim: #9aa1ad;
  --line: rgba(20, 22, 31, .09);
  --accent: #6366f1;
  --accent-2: #a855f7;
  --accent-soft: rgba(99, 102, 241, .1);
  --ok: #16a34a;
  --shadow-sm: 0 2px 8px rgba(20, 22, 31, .05);
  --shadow-md: 0 10px 28px rgba(20, 22, 31, .09);
  --shadow-lg: 0 24px 56px rgba(20, 22, 31, .14);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #0d0f14;
  --surface: #171a22;
  --surface-2: #1c2029;
  --text: #e8eaed;
  --text-soft: #9aa3ad;
  --text-dim: #6b7280;
  --line: rgba(255, 255, 255, .09);
  --accent: #818cf8;
  --accent-2: #c084fc;
  --accent-soft: rgba(129, 140, 248, .14);
  --ok: #4ade80;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, .42);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, .55);
}

/* =========================================================
   2. 重置 & 基础
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

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

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: inherit; }

/* 主题切换时的全局平滑过渡 */
body.theme-transition,
body.theme-transition *,
body.theme-transition *::before,
body.theme-transition *::after {
  transition:
    background-color .35s ease,
    border-color .35s ease,
    color .35s ease !important;
}

/* =========================================================
   3. 顶部导航
   ========================================================= */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid transparent;
  transition: border-color .35s var(--ease), box-shadow .35s var(--ease);
}
.site-nav.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  padding: 7px 14px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 10px;
  white-space: nowrap;
  transition: background .3s ease, color .3s ease;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--accent-soft);
}
.nav-links a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.theme-toggle {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition:
    transform .35s var(--ease),
    color .3s ease,
    border-color .3s ease,
    box-shadow .35s var(--ease);
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* =========================================================
   4. 容器
   ========================================================= */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* =========================================================
   5. 页面标题区（内页用）
   ========================================================= */
.page-head { margin-bottom: 32px; }

.page-title {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.2;
}

.page-sub {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-soft);
}
.page-sub a {
  color: var(--accent);
  text-decoration: none;
}
.page-sub a:hover { text-decoration: underline; }

/* =========================================================
   6. 个人信息卡
   ========================================================= */
.profile-card {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 30px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition:
    transform .5s var(--ease),
    box-shadow .5s var(--ease),
    border-color .35s ease;
}
.profile-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.profile-avatar {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface);
  box-shadow:
    0 8px 26px rgba(99, 102, 241, .24),
    0 0 0 1px var(--line);
  transition: transform .7s var(--ease);
}
.profile-card:hover .profile-avatar { transform: scale(1.06); }

.profile-info { min-width: 0; }

.profile-name-wrapper {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-name-wrapper h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.handle-tag {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 999px;
}

.bio {
  margin-top: 8px;
  font-size: 15px;
  color: var(--text-soft);
  line-height: 1.7;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.meta span,
.meta a {
  font-size: 13px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 3px 11px;
  border-radius: 999px;
  text-decoration: none;
  transition: color .3s ease, border-color .3s ease;
}
.meta span:hover,
.meta a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* =========================================================
   7. 面板 & 区块标题
   ========================================================= */
.panel { margin-top: 44px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title > span {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.more-link {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  transition: color .3s ease, transform .4s var(--ease);
}
.more-link:hover {
  color: var(--accent);
  transform: translateX(3px);
}

/* =========================================================
   8. 卡片网格
   ========================================================= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* --- 项目卡（GitHub 动态渲染） --- */
.repo-card {
  display: block;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  transition:
    transform .5s var(--ease),
    box-shadow .5s var(--ease),
    border-color .35s ease;
}
.repo-card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  box-shadow: var(--shadow-md);
}

.repo-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
}

.repo-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  word-break: break-word;
}

.repo-desc {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lang i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.repo-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.repo-updated {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
}

/* 项目卡：加载 / 空 / 错误状态 */
.repo-loading,
.repo-empty,
.repo-error {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  font-size: 14.5px;
  color: var(--text-soft);
}
.repo-error a {
  color: var(--accent);
  text-decoration: none;
}
.repo-error a:hover { text-decoration: underline; }

/* --- 通用卡片（文档 / 分享 / 留言引导） --- */
.card {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  transition:
    transform .5s var(--ease),
    box-shadow .5s var(--ease),
    border-color .35s ease;
}
.card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  transition: color .3s ease;
}
.card:hover .card-title { color: var(--accent); }

.card-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-soft);
  flex: 1;
}

.card-foot {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  letter-spacing: .02em;
}

/* --- 留言卡（备用，首页静态展示时用） --- */
.note-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.note-card {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition:
    transform .5s var(--ease),
    box-shadow .5s var(--ease),
    border-color .35s ease;
}
.note-card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  box-shadow: var(--shadow-md);
}

.card-grid .note-card { height: 100%; }

.note-text {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text);
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-soft);
}

.note-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  flex-shrink: 0;
}

.note-name {
  font-weight: 600;
  color: var(--text);
}
.note-time {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 12.5px;
}

/* =========================================================
   9. 留言表单（备用）
   ========================================================= */
.guest-form {
  padding: 26px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 11px 15px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition:
    border-color .3s ease,
    box-shadow .3s ease,
    background .3s ease;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-dim); }

.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.7;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.form-hint {
  font-size: 13.5px;
  color: var(--text-soft);
  opacity: 0;
  transition: opacity .3s ease;
}
.form-hint.is-ok {
  opacity: 1;
  color: var(--ok);
}

/* =========================================================
   10. Giscus 留言板
   ========================================================= */
.giscus-wrap {
  padding: 24px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Giscus iframe 自动适应宽度 */
.giscus,
.giscus-frame {
  width: 100%;
  border: none;
  color-scheme: auto;
}

/* 加载占位（Giscus 加载期间显示） */
.giscus:empty::before {
  content: '正在加载留言板…';
  display: block;
  padding: 40px 0;
  text-align: center;
  font-size: 14.5px;
  color: var(--text-soft);
}

/* =========================================================
   11. 按钮
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform .4s var(--ease),
    box-shadow .4s var(--ease),
    background .3s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(99, 102, 241, .3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(99, 102, 241, .4);
}
.btn-primary:active { transform: translateY(0); }

/* =========================================================
   12. 留言说明块
   ========================================================= */
.note-help {
  padding: 18px 22px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.note-help strong { color: var(--text); }

/* =========================================================
   13. 页脚
   ========================================================= */
.site-footer {
  padding: 36px 24px;
  text-align: center;
  font-size: 14px;
  color: var(--text-soft);
  border-top: 1px solid var(--line);
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity .3s ease;
}
.site-footer a:hover { opacity: .7; }

/* =========================================================
   14. 入场动画
   ========================================================= */
[data-anim] {
  opacity: 0;
  animation: riseIn .9s var(--ease) forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity   .85s var(--ease) var(--d, 0ms),
    transform .85s var(--ease) var(--d, 0ms);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   15. 响应式
   ========================================================= */
@media (max-width: 640px) {
  .nav-inner { padding: 12px 16px; gap: 10px; }
  .brand { font-size: 15px; }
  .nav-links a { padding: 6px 11px; font-size: 13.5px; }
  .theme-toggle { width: 34px; height: 34px; }

  .container { padding: 24px 16px 48px; }
  .page-head { margin-bottom: 24px; }

  .profile-card {
    flex-direction: column;
    text-align: center;
    padding: 26px 20px;
    gap: 18px;
  }
  .profile-name-wrapper { justify-content: center; }
  .meta { justify-content: center; }
  .profile-avatar { width: 82px; height: 82px; }

  .card-grid { grid-template-columns: 1fr; gap: 14px; }
  .panel { margin-top: 36px; }

  .form-row { grid-template-columns: 1fr; }
  .guest-form { padding: 20px 18px; }
  .giscus-wrap { padding: 18px 16px; }

  .repo-updated { margin-left: 0; width: 100%; }
}

/* =========================================================
   16. 尊重「减少动画」偏好
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  [data-anim], .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}