/* ============================================================
   common.css - 全局样式（GitHub 灰白风格 + 深浅色模式）
   ============================================================ */

/* ---------- CSS 变量：浅色（默认） ---------- */
:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --border: #d0d7de;
  --text: #24292f;
  --text-muted: #57606a;
  --link: #0969da;
  --link-hover: #218bff;
  --sidebar-bg: #f6f8fa;
  --code-bg: #eff2f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --active-bg: #ddf4ff;
  --active-border: #0969da;
}

/* ---------- 深色模式 ---------- */
[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --link: #58a6ff;
  --link-hover: #79c0ff;
  --sidebar-bg: #161b22;
  --code-bg: #1f2428;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --nav-bg: rgba(22, 27, 34, 0.85);
  --active-bg: #1f6feb33;
  --active-border: #58a6ff;
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }

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

/* ---------- 顶部导航栏 ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 24px;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-nav .nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
}

.site-nav .nav-id {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}
.site-nav .nav-id:hover { color: var(--link); }

.site-nav .nav-items {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.site-nav .nav-item {
  position: relative;
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
}
.site-nav .nav-item::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  background: var(--active-border);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease;
}
.site-nav .nav-item:hover { color: var(--text); }
.site-nav .nav-item:hover::after { transform: scaleX(1); }
.site-nav .nav-item.active {
  color: var(--text);
  font-weight: 700;
}
.site-nav .nav-item.active::after { transform: scaleX(1); }

.site-nav .nav-spacer { flex: 1; }

.site-nav .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-nav .github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.site-nav .github-link:hover {
  border-color: var(--link);
  color: var(--link);
  transform: translateY(-1px);
}
.site-nav .github-link svg { width: 16px; height: 16px; }

/* 主题切换按钮 */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--link); color: var(--link); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

/* ---------- 主容器 ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.container.wide { max-width: 1280px; }

/* 标题行 flex 布局*/
.profile-name-wrapper {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

/* 小标签样式 */
.handle-tag {
  font-size: 14px;
  font-weight: 400;
  color: #8e9aaf;
  background: #f0f2f5;
  padding: 2px 12px 3px 12px;
  border-radius: 30px;
  white-space: nowrap;
  line-height: 1.6;
  user-select: none;
}

/* ---------- 大卡片面板（包装区块） ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}
.panel > .section-title {
  margin-bottom: 20px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--link);
}

/* ---------- 项目卡片网格 ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
/* 每行 2 列（首页精选项目水平平铺） */
.project-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
/* 每行 3 列 */
.project-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.project-card {
  display: flex;
  flex-direction: column;
}
.project-card .pc-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.project-card .pc-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 44px;
}
.project-card .pc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.project-card .pc-tag {
  font-size: 12px;
  padding: 2px 8px;
  background: var(--code-bg);
  color: var(--text-muted);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.project-card .pc-tag-loading {
  opacity: 0.6;
}
.project-card .pc-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.project-card .pc-meta .star {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.project-card .pc-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
}

/* ---------- 精选 Wiki 卡片 ---------- */
.wiki-card {
  display: flex;
  flex-direction: column;
}
.wiki-card .wc-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.wiki-card .wc-excerpt {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  flex: 1;
}
.wiki-card .wc-actions {
  display: flex;
  margin-top: auto;
  padding-top: 14px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.btn:hover {
  color: var(--link);
  border-color: var(--link);
  transform: translateY(-1px);
}
.btn-primary {
  background: var(--link);
  color: #fff;
  border-color: var(--link);
}
.btn-primary:hover {
  background: var(--link-hover);
  border-color: var(--link-hover);
  color: #fff;
}
.btn[disabled], .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- 区块标题 ---------- */
.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title .more-link {
  font-size: 14px;
  font-weight: 500;
}

/* ---------- 首页：个人信息 ---------- */
.profile-card {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
  opacity: 0;
  transform: translateY(8px);
  animation: fadeInUp 0.5s ease forwards;
}
.profile-card .profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.profile-card .profile-info h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.profile-card .profile-info .bio {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 6px;
}
.profile-card .profile-info .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.profile-card .profile-info .meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@keyframes fadeInUp {
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.5s ease forwards; }

/* ---------- Wiki 布局 ---------- */
.docs-layout {
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

.docs-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 56px;
  align-self: flex-start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}
.docs-sidebar h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 8px 12px;
}
.docs-sidebar .sidebar-link {
  display: block;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-muted);
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.docs-sidebar .sidebar-link:hover {
  color: var(--link);
  background: var(--active-bg);
}
.docs-sidebar .sidebar-link.active {
  color: var(--link);
  font-weight: 700;
  background: var(--active-bg);
  border-left-color: var(--active-border);
}

.docs-content {
  flex: 1;
  padding: 32px 40px 64px;
  min-width: 0;
}
.docs-content h1 { font-size: 26px; margin-bottom: 16px; }
.docs-content h2 { font-size: 20px; margin: 24px 0 10px; }
.docs-content h3 { font-size: 17px; margin: 20px 0 8px; }
.docs-content p { margin-bottom: 14px; color: var(--text); }
.docs-content ul, .docs-content ol { margin: 0 0 14px 24px; }
.docs-content li { margin-bottom: 6px; }
.docs-content code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.docs-content pre {
  background: var(--code-bg);
  padding: 14px 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.docs-content pre code { background: none; padding: 0; }
.docs-content blockquote {
  border-left: 3px solid var(--active-border);
  padding: 4px 14px;
  color: var(--text-muted);
  margin-bottom: 14px;
  background: var(--active-bg);
  border-radius: 0 6px 6px 0;
}

/* ---------- 文章分页导航 ---------- */
.docs-pagination {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.docs-pagination .page-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.docs-pagination .page-btn:hover:not(.disabled) {
  color: var(--link);
  border-color: var(--link);
}
.docs-pagination .page-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.docs-pagination .page-btn .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.docs-pagination .page-btn .title {
  font-size: 14px;
  font-weight: 600;
}
.docs-pagination .page-btn.prev { text-align: left; }
.docs-pagination .page-btn.next { text-align: right; }
.docs-pagination .page-divider {
  width: 1px;
  background: var(--border);
  margin: 0 12px;
}

/* ---------- Wiki 目录页 ---------- */
.docs-index-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.docs-index-list .doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.docs-index-list .doc-item:hover {
  transform: translateX(4px);
  border-color: var(--link);
  box-shadow: var(--shadow-md);
}
.docs-index-list .doc-item .doc-title {
  font-weight: 600;
  color: var(--text);
}
.docs-index-list .doc-item .doc-arrow {
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}
.docs-index-list .doc-item:hover .doc-arrow {
  color: var(--link);
  transform: translateX(4px);
}

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

/* ---------- 加载/错误状态 ---------- */
.status-box {
  padding: 14px 18px;
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--text-muted);
  font-size: 14px;
  border: 1px solid var(--border);
}

/* ---------- 公告条 ---------- */
.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.5;
}
.notice-text {
  flex: 1;
  min-width: 0;
}
/* 黄色警示样式 */
.notice-bar-warn {
  color: #7a5b00;
  background: #fff8db;
  border-bottom: 1px solid #f0d48a;
}
[data-theme="dark"] .notice-bar-warn {
  color: #ffe08a;
  background: #3b3200;
  border-bottom: 1px solid #55471c;
}
/* 红色 X 关闭按钮 */
.notice-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #d33;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.notice-close:hover { background: rgba(221, 51, 51, 0.12); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .docs-layout { flex-direction: column; }
  .docs-sidebar {
    width: 100%;
    position: relative;
    top: 0;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .docs-content { padding: 24px 16px 48px; }
  .project-grid { grid-template-columns: 1fr; }
  .project-grid-2, .project-grid-3 { grid-template-columns: 1fr; }
  .site-nav { padding: 0 12px; gap: 8px; }
  .site-nav .nav-id { display: none; }
  .site-nav .gitee-link { display: none; }
}
