/* 全局颜色变量：统一维护亮色/暗色主题色值，便于整体调色。 */
:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --panel-soft: #f1f1f3;
  --text: #1b1b1d;
  --text-muted: #5f6368;
  --line: #e1e3e8;
  --shadow: 0 12px 36px rgba(17, 19, 24, 0.08);
}

/* 暗色主题变量：通过 data-theme 切换后自动生效。 */
html[data-theme="dark"] {
  --bg: #0f1012;
  --panel: #17181b;
  --panel-soft: #202228;
  --text: #eceef3;
  --text-muted: #a9adb8;
  --line: #2a2d34;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

/* 语言切换：只显示当前语言对应的内容块。 */
html[data-lang="zh"] .lang-en {
  display: none !important;
}

html[data-lang="en"] .lang-zh {
  display: none !important;
}

/* 基础排版：控制全站字体、行高和背景。 */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
}

/* 页面主骨架：左侧固定信息栏 + 右侧滚动内容区。 */
.site-shell {
  min-height: 100vh;
}

/* 左侧固定栏：约占 1/4 宽度，固定在视口中。 */
.site-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: min(342px, 23vw);
  min-width: 280px;
  height: 100vh;
  padding: 3rem 2rem 2rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* 头像样式：支持图片头像与首字母占位头像。 */
.avatar {
  width: 145px;
  height: 145px;
  border-radius: 30%;
  object-fit: cover;
  border: 2px solid var(--line);
}

.avatar-fallback {
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-soft);
}

.profile-block {
  display: grid;
  gap: 0.7rem;
}

.profile-name {
  margin: 0;
  font-size: 2.1rem;
}

/* 信息列表：名字下方展示位置/学校/专业/GitHub/邮箱。 */
.profile-facts {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.38rem;
}

.profile-fact-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1.35;
}

.fact-icon {
  width: 1.02rem;
  height: 1.02rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-0.02rem);
}

/* 本地 SVG 图标：统一尺寸，直接引用 assets/icons 下文件。 */
.fact-icon-img {
  width: 100%;
  height: 100%;
  display: block;
}

.fact-text {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.fact-text a {
  text-decoration: none;
  color: inherit;
}

.fact-text a:hover {
  text-decoration: underline;
}

/* 控制按钮容器：在左下角放置主题/语言两个切换按钮。 */
.controls-group {
  margin-top: auto;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* 通用控制按钮：风格统一，视觉上保持一组操作。 */
.control-btn {
  width: fit-content;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 0.58rem 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.control-btn:hover {
  transform: translateY(-1px);
}

/* 控制按钮图标：主题/语言切换使用本地 SVG 图标。 */
.control-btn-icon {
  width: 0.92rem;
  height: 0.92rem;
  display: block;
}

/* 文章页返回：首页入口放在标题下，便于快速返回列表。 */
.back-home-btn {
  display: inline-flex;
  align-items: center;
  margin-top: 0.25rem;
  padding: 0.22rem 0.62rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  line-height: 1.2;
}

.back-home-btn:hover {
  color: var(--text);
}

/* 右侧主区域：留出左侧固定栏的空间，并控制阅读宽度。 */
.site-main {
  margin-left: min(380px, 26vw);
  min-height: 100vh;
  padding: 3rem clamp(1.2rem, 3vw, 3rem);
}

/* 卡片网格：用于首页模块化信息展示。 */
.cards-grid {
  display: grid;
  gap: 1rem;
  max-width: 1100px;
}

/* 卡片样式：统一每个内容块的背景、边框与阴影。 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.35rem;
  box-shadow: var(--shadow);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  will-change: transform;
}

.card:hover,
.card:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 16px 42px rgba(17, 19, 24, 0.12);
  border-color: color-mix(in srgb, var(--line) 70%, var(--text-muted) 30%);
}

html[data-theme="dark"] .card:hover,
html[data-theme="dark"] .card:focus-within {
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }

  .card:hover,
  .card:focus-within {
    transform: none;
  }
}

.card h2,
.card h3,
.card h1 {
  margin-top: 0;
}

/* 首页内容排版：让经历/爱好/项目信息更清晰易读。 */
.content-stack {
  display: grid;
  gap: 0.72rem;
}

.feature-line {
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text-muted);
  font-size: 0.92rem;
}

.clean-list {
  margin: 0;
  padding-left: 1.05rem;
  display: grid;
  gap: 0.45rem;
}

.clean-list li {
  color: var(--text-muted);
}

.project-grid {
  display: grid;
  gap: 0.85rem;
}

.project-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: var(--panel-soft);
}

.project-item h3 {
  margin: 0 0 0.35rem;
}

.project-item p {
  margin: 0 0 0.45rem;
  color: var(--text-muted);
}

.project-item a {
  text-decoration: none;
  font-weight: 600;
}

.project-item a:hover {
  text-decoration: underline;
}

/* 技术栈标签：低饱和度配色，与黑白灰主题保持协调。 */
.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.tech-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.26rem 0.62rem;
  font-size: 0.82rem;
  line-height: 1.2;
  border: 1px solid transparent;
}

.tech-tag-slate { color: #3f4956; background: #eef1f5; border-color: #d9e0e7; }
.tech-tag-indigo { color: #4a4664; background: #efedf7; border-color: #ddd8ee; }
.tech-tag-blue { color: #2f4f68; background: #eaf2f8; border-color: #d4e5f1; }
.tech-tag-emerald { color: #2f5a4f; background: #eaf4f1; border-color: #d2e6df; }
.tech-tag-amber { color: #66553a; background: #f7f2e8; border-color: #ebe0cc; }
.tech-tag-rose { color: #65454f; background: #f6edf0; border-color: #ead9df; }

html[data-theme="dark"] .tech-tag-slate { color: #c9d0da; background: #252a32; border-color: #363d48; }
html[data-theme="dark"] .tech-tag-indigo { color: #cec8e3; background: #2a2736; border-color: #3b3750; }
html[data-theme="dark"] .tech-tag-blue { color: #c3d6e4; background: #202f3b; border-color: #2f4556; }
html[data-theme="dark"] .tech-tag-emerald { color: #bdd8ce; background: #1f322d; border-color: #2d4941; }
html[data-theme="dark"] .tech-tag-amber { color: #dccfb6; background: #352f24; border-color: #4c4434; }
html[data-theme="dark"] .tech-tag-rose { color: #ddc3ca; background: #34272c; border-color: #4b383f; }

.post-list {
  margin: 0;
  padding-left: 1.1rem;
}

.post-link {
  text-decoration: none;
  font-weight: 600;
}

.post-link:hover {
  text-decoration: underline;
}

.post-meta {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Markdown 正文：统一优化标题、段落、表格、代码块、引用和图片。 */
.post-article,
.page-article {
  max-width: 900px;
}

.post-content,
.page-content {
  font-size: 1rem;
  line-height: 1.86;
}

.post-content p,
.page-content p {
  margin: 0.78rem 0;
}

.post-content h2,
.post-content h3,
.post-content h4,
.page-content h2,
.page-content h3,
.page-content h4 {
  margin-top: 2rem;
  margin-bottom: 0.55rem;
  line-height: 1.35;
}

.post-content h2,
.page-content h2 {
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.post-content ul,
.post-content ol,
.page-content ul,
.page-content ol {
  margin: 0.5rem 0 1rem;
  padding-left: 1.25rem;
}

.post-content li,
.page-content li {
  margin: 0.22rem 0;
}

.post-content a,
.page-content a {
  color: #2e5f8a;
  text-underline-offset: 2px;
}

html[data-theme="dark"] .post-content a,
html[data-theme="dark"] .page-content a {
  color: #89b9e1;
}

.post-content blockquote,
.page-content blockquote {
  margin: 1rem 0;
  padding: 0.35rem 0.95rem;
  border-left: 3px solid var(--line);
  background: var(--panel-soft);
  color: var(--text-muted);
  border-radius: 0 8px 8px 0;
}

.post-content code,
.page-content code {
  padding: 0.08rem 0.35rem;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.post-content pre,
.page-content pre {
  margin: 0.95rem 0;
  padding: 0.9rem 1rem;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}

.post-content pre code,
.page-content pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

/* 代码高亮：基于 Rouge 的 token class，按语言自动着色。 */
.post-content .highlight,
.page-content .highlight {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.post-content .highlight pre,
.page-content .highlight pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #111317;
  color: #e8ecf3;
}

html[data-theme="light"] .post-content .highlight pre,
html[data-theme="light"] .page-content .highlight pre {
  background: #161a21;
}

.highlight .c,
.highlight .cm,
.highlight .c1,
.highlight .cs { color: #7f8b99; font-style: italic; }
.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt { color: #c792ea; }
.highlight .o,
.highlight .ow { color: #89ddff; }
.highlight .s,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx { color: #ecc48d; }
.highlight .m,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .mo { color: #f78c6c; }
.highlight .na,
.highlight .nb,
.highlight .nc,
.highlight .nd,
.highlight .ne,
.highlight .nf,
.highlight .nl,
.highlight .nn,
.highlight .nt,
.highlight .nv,
.highlight .vc,
.highlight .vg,
.highlight .vi { color: #82aaff; }
.highlight .err { color: #ff6b6b; background: rgba(255, 107, 107, 0.12); }

.post-content table,
.page-content table {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.95rem;
}

.post-content thead,
.page-content thead {
  background: var(--panel-soft);
}

.post-content th,
.post-content td,
.page-content th,
.page-content td {
  padding: 0.56rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.post-content tr:last-child td,
.page-content tr:last-child td {
  border-bottom: 0;
}

.post-content img,
.page-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.post-content hr,
.page-content hr {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 1.25rem 0;
}

/* 移动端布局：取消左侧固定栏，改为上下结构。 */
@media (max-width: 960px) {
  .site-sidebar {
    position: static;
    width: auto;
    min-width: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 2rem 1.2rem 1.2rem;
  }

  .site-main {
    margin-left: 0;
    padding: 1.2rem;
  }

  /* 手机端主页：顶部只保留名字和信息列表，头像隐藏。 */
  .is-home .avatar,
  .is-home .avatar-fallback {
    display: none;
  }

  /* 手机端主页：主题/语言切换改为更小的悬浮按钮。 */
  .is-home .controls-group {
    position: fixed;
    right: 0.8rem;
    bottom: 0.9rem;
    margin-top: 0;
    gap: 0.35rem;
    z-index: 60;
  }

  .is-home .control-btn {
    padding: 0.42rem;
    border-radius: 10px;
    gap: 0;
    min-width: 0;
  }

  .is-home .theme-toggle-text,
  .is-home .lang-toggle-text {
    display: none;
  }

  .is-home .control-btn-icon {
    width: 0.82rem;
    height: 0.82rem;
  }

  /* 手机端文章页：隐藏左侧信息栏，正文全宽阅读。 */
  .is-post .site-sidebar {
    display: none;
  }

  .is-post .site-main {
    margin-left: 0;
    padding: 1rem;
  }
}
