/* Mingrui Blog — 克制版静态主题
   零依赖：不引外部字体，不引 CDN，图标直接用内联 SVG。
   深色模式由 CSS 变量 + 一段几十行的原生 JS 实现。 */

/* ---------- 配色 ---------- */

:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --fg: #000000;
  --fg-soft: #525252;
  --fg-faint: #a3a3a3;
  --line: #e5e5e5;
  --line-soft: #f2f2f2;
  --line-hover: #d4d4d4;
  --radius: 14px;
  --radius-sm: 8px;
  --content: 54rem;
  --ease: cubic-bezier(.4, 0, .2, 1);

  --code-keyword: #a626a4;
  --code-string: #50a14f;
  --code-number: #986801;
  --code-func: #4078f2;
  --code-comment: #a0a1a7;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-soft: #141414;
  --fg: #e5e5e5;
  --fg-soft: #a3a3a3;
  --fg-faint: #737373;
  --line: #262626;
  --line-soft: #1b1b1b;
  --line-hover: #404040;

  --code-keyword: #c678dd;
  --code-string: #98c379;
  --code-number: #d19a66;
  --code-func: #61afef;
  --code-comment: #7f848e;
}

/* ---------- 基础 ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: -.003em;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}

.site {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 1.5rem;
}

img { max-width: 100%; height: auto; }

a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 3rem 0;
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 2.5rem 0 2rem;
}

.site-brand { display: flex; align-items: center; gap: .75rem; }
.site-brand:hover { text-decoration: none; }

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

.site-title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

.site-nav { display: flex; align-items: center; gap: 1.5rem; font-size: .9rem; color: var(--fg-soft); }
.site-nav a.active { color: var(--fg); font-weight: 500; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--fg-soft);
  cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.theme-toggle:hover { border-color: var(--line-hover); color: var(--fg); }
.theme-toggle svg { width: 15px; height: 15px; }

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

/* ---------- 中英切换 ---------- */

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

.lang-toggle { font-size: .6875rem; font-weight: 600; letter-spacing: .02em; line-height: 1; }

/* ---------- Hero / 首页开场 ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: 3rem;
  padding: 2.5rem 0 3.5rem;
}

.hero-left { flex: 1 1 auto; min-width: 0; }

.hero-hi {
  font-size: 3rem;
  line-height: 1.1;
  letter-spacing: -.04em;
  margin: 0 0 1.125rem;
  font-weight: 700;
}

.hero-slogan {
  margin: 0 0 .875rem;
  font-size: 1.0625rem;
  font-weight: 600;
}

.hero-desc {
  margin: 0;
  color: var(--fg-soft);
  max-width: 34rem;
  line-height: 1.8;
}

.hero-social {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 1.5rem;
}
.hero-social a {
  display: inline-flex;
  color: var(--fg-soft);
  transition: color .15s var(--ease);
}
.hero-social a:hover { color: var(--fg); text-decoration: none; }
.hero-social svg { width: 20px; height: 20px; }

.hero-right { flex: 0 0 auto; }
.hero-photo {
  width: 220px;
  height: 220px;
  object-fit: cover;
  aspect-ratio: 1;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

/* ---------- 虚线分隔 + 胶囊标签 ---------- */

.divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 3rem 0 2.5rem;
}
.divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px dashed var(--line-hover);
}
.divider-label {
  position: relative;
  padding: .375rem .875rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg-soft);
  font-size: .8125rem;
  letter-spacing: .05em;
}

.section-more {
  margin: 1.5rem 0 0;
  text-align: right;
  font-size: .875rem;
  color: var(--fg-soft);
}

.site-main { min-height: 45vh; padding-bottom: 4rem; }

.page-title { font-size: 1.75rem; letter-spacing: -.025em; margin: 0 0 .625rem; font-weight: 600; }
.page-lede { color: var(--fg-soft); margin: 0 0 3rem; }

.section { margin-top: 3rem; }

/* 首页分区块：标题 + “全部 →” 一行，下接细分割线 */
.home-section { margin-top: 2rem; }
.home-section + .home-section { margin-top: 3.5rem; }

.home-section .section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin: 0 0 1.75rem;
  padding-bottom: .875rem;
  border-bottom: 1px solid var(--line);
}
.home-section .section-head h2 {
  font-size: .8125rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: .12em;
  color: var(--fg-soft);
}
.home-section .section-head a {
  font-size: .8125rem;
  color: var(--fg-faint);
  transition: color .15s var(--ease);
}
.home-section .section-head a:hover { color: var(--fg); text-decoration: none; }
.section-count { color: var(--fg-faint); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.section-note { margin: -.5rem 0 1.5rem; color: var(--fg-soft); font-size: .875rem; }

.empty-note {
  padding: 1.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--fg-soft);
  font-size: .9375rem;
}

/* ---------- 文章列表（行式） ---------- */

.post-list { display: flex; flex-direction: column; }

.post-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.125rem 0;
  border-bottom: 1px solid var(--line-soft);
  transition: padding-left .2s var(--ease);
}
.post-row:first-child { padding-top: .25rem; }
.post-row:last-child { border-bottom: none; }
.post-row:hover { text-decoration: none; padding-left: .5rem; }

.post-row-main { flex: 1 1 auto; min-width: 0; }
.post-row-title {
  margin: 0 0 .375rem;
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--fg);
  transition: text-decoration-color .2s var(--ease);
}
.post-row:hover .post-row-title {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}
.post-row-summary {
  margin: 0;
  color: var(--fg-soft);
  font-size: .9375rem;
  line-height: 1.65;
}
.post-row-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .3125rem;
  color: var(--fg-faint);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.post-row-cat {
  padding: .0625rem .5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg-soft);
  font-size: .6875rem;
}

/* ---------- 项目网格 ---------- */

.project-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
}

.project-card {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}

/* 生产项目角标 */
.project-badge {
  position: absolute;
  top: .625rem;
  left: .625rem;
  z-index: 1;
  padding: .1875rem .625rem;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1.5;
}
.project-card:hover {
  border-color: var(--line-hover);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .06);
  text-decoration: none;
}
.project-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-soft); }
.project-card-body { padding: 1.125rem 1.375rem 1.375rem; }
.project-card-body h3 {
  margin: 0 0 .375rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--fg);
  transition: text-decoration-color .2s var(--ease);
}
.project-card:hover .project-card-body h3 {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.project-card-body p { margin: 0; color: var(--fg-soft); font-size: .875rem; line-height: 1.6; }

/* ---------- 文章正文 ---------- */

.post-header { margin-bottom: 2.5rem; }
.post-title { font-size: 2rem; letter-spacing: -.03em; line-height: 1.25; margin: 0 0 1rem; font-weight: 600; color: var(--fg); }
.post-meta {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  color: var(--fg-faint); font-size: .8125rem;
}
.tag {
  padding: .0625rem .5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg-soft);
  font-size: .75rem;
}
.tag:hover { text-decoration: none; border-color: var(--line-hover); }

.post-cover {
  margin-top: 1.75rem;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.post-content { font-size: 1.0625rem; line-height: 1.85; }
.post-content h2 {
  font-size: 1.3125rem;
  letter-spacing: -.015em;
  margin: 2.75rem 0 .875rem;
  font-weight: 600;
}
.post-content h3 { font-size: 1.0625rem; margin: 2rem 0 .625rem; font-weight: 600; }
.post-content p, .post-content ul, .post-content ol { margin: 0 0 1.125rem; }
.post-content ul, .post-content ol { padding-left: 1.375rem; }
.post-content li { margin: .3125rem 0; }
.post-content blockquote {
  margin: 1.5rem 0;
  padding: .25rem 0 .25rem 1.125rem;
  border-left: 2px solid var(--line);
  color: var(--fg-soft);
}
.post-content img { border-radius: var(--radius-sm); border: 1px solid var(--line-soft); }

.post-content :not(pre) > code {
  padding: .125rem .375rem;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  font-size: .875em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.post-content pre, .highlight pre {
  padding: 1.125rem 1.25rem;
  overflow-x: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: .8125rem;
  line-height: 1.7;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: .9375rem;
}
.post-content th, .post-content td {
  border: 1px solid var(--line);
  padding: .5rem .75rem;
  text-align: left;
}
.post-content th { background: var(--bg-soft); font-weight: 600; }

/* Rouge 代码高亮 */
.highlight .c, .highlight .cm, .highlight .c1 { color: var(--code-comment); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt { color: var(--code-keyword); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .dl { color: var(--code-string); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .il { color: var(--code-number); }
.highlight .nf, .highlight .nc, .highlight .na { color: var(--code-func); }
.highlight .o, .highlight .p { color: var(--fg-soft); }

/* ---------- 上一篇 / 下一篇 ---------- */

.post-nav {
  display: grid; gap: 1rem;
  margin-top: 3.5rem; padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.post-nav-item { display: flex; flex-direction: column; gap: .125rem; font-size: .9375rem; }
.post-nav-item span { color: var(--fg-faint); font-size: .75rem; }
.align-right { text-align: right; }

/* ---------- 归档 ---------- */

.archive-grouped { display: grid; gap: 2.5rem; }
.archive-section { }
.archive-cat {
  font-size: .875rem;
  font-weight: 600;
  color: var(--fg-soft);
  margin: 0 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px dashed var(--line-hover);
  letter-spacing: .02em;
}
.archive-list { list-style: none; padding: 0; margin: 0; }
.archive-list li {
  display: flex; gap: 1rem; align-items: baseline;
  padding: .75rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.archive-list li:last-child { border-bottom: none; }
.archive-list time { color: var(--fg-faint); font-size: .8125rem; flex: 0 0 5.5rem; font-variant-numeric: tabular-nums; }
.archive-list a { flex: 1 1 auto; min-width: 0; }
.archive-list .tag { margin-left: .25rem; }

/* ---------- Footer ---------- */

.site-footer {
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.footer-links { display: flex; gap: 1.25rem; font-size: .875rem; color: var(--fg-soft); }
.footer-meta { margin: 0; color: var(--fg-faint); font-size: .8125rem; }

/* ---------- 移动端 ---------- */

@media (max-width: 34rem) {
  body { font-size: 15.5px; }
  .site { padding: 0 1.25rem; }
  .site-header { padding: 1.75rem 0 1.5rem; }
  .site-nav { gap: 1.125rem; }
  .hero { flex-direction: column-reverse; gap: 1.75rem; padding: 1.5rem 0 2.5rem; }
  .hero-hi { font-size: 2.25rem; }
  .hero-photo { width: 140px; height: 140px; border-radius: 18px; }
  .hero-right { align-self: flex-start; }
  .post-title { font-size: 1.625rem; }
  .post-row { flex-direction: column; gap: .5rem; padding: 1rem 0; }
  .post-row:hover { padding-left: 0; }
  .post-row-meta { flex-direction: row; align-items: center; gap: .5rem; }
  .project-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
