/* =========================================================
   lovou — 极简现代中文博客主题
   ========================================================= */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-header: rgba(255, 255, 255, 0.82);
  --text: #1f2328;
  --text-secondary: #6b7280;
  --text-faint: #9ca3af;
  --link: #2563eb;
  --border: #e8eaee;
  --border-strong: #d5d8dd;
  --code-bg: #f6f8fa;
  --code-text: #24292f;
  --selection: rgba(37, 99, 235, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto,
    "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas,
    "Liberation Mono", Menlo, monospace;
  --content-width: 44rem;
  --radius: 8px;
  --transition: 0.25s ease;
}

[data-theme="dark"] {
  --bg: #101317;
  --bg-soft: #171b20;
  --bg-header: rgba(16, 19, 23, 0.82);
  --text: #dfe3e8;
  --text-secondary: #9aa3ad;
  --text-faint: #6b7480;
  --link: #8ab4f8;
  --border: #262c33;
  --border-strong: #38404a;
  --code-bg: #1a1e24;
  --code-text: #d5dae2;
  --selection: rgba(138, 180, 248, 0.22);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* ---------- 基础 ---------- */
* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.9;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--transition), color var(--transition);
}

::selection {
  background: var(--selection);
}

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

a:hover {
  opacity: 0.75;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

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

/* ---------- 顶部导航 ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  position: relative;
  color: var(--text-secondary);
  font-size: 0.92rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-soft);
  opacity: 1;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-left: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), transform var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  transform: rotate(15deg);
}

.icon-moon {
  display: none;
}

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

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

/* ---------- 主区域 ---------- */
.main {
  min-height: calc(100vh - 12rem);
  padding-top: 2.5rem;
  padding-bottom: 4rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
}

.page-title-suffix {
  color: var(--text-secondary);
  font-weight: 400;
}

/* ---------- 文章列表（首页） ---------- */
.post-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:last-child {
  border-bottom: none;
}

.post-item-title {
  font-size: 1.22rem;
  font-weight: 600;
  line-height: 1.6;
  margin: 0 0 0.35rem;
}

.post-item-title a {
  color: var(--text);
}

.post-item-meta {
  font-size: 0.82rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.post-item-cat {
  color: var(--text-faint);
}

.meta-sep {
  color: var(--text-faint);
}

.post-item-excerpt {
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-item-more {
  font-size: 0.85rem;
  color: var(--link);
  display: inline-block;
  margin-top: 0.4rem;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2.5rem;
  font-size: 0.9rem;
}

.page-link {
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}

.page-link:hover {
  border-color: var(--border-strong);
  background: var(--bg-soft);
  opacity: 1;
}

.page-link.disabled {
  color: var(--text-faint);
  pointer-events: none;
}

.page-info {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- 文章页 ---------- */
.post-title {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 0.6rem;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 2rem;
}

.post-meta-cat {
  color: var(--text-faint);
}

/* 文章内容排版 */
.post-content {
  word-wrap: break-word;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  font-weight: 700;
  line-height: 1.5;
  margin: 2em 0 0.8em;
}

.post-content h1 { font-size: 1.55rem; }
.post-content h2 {
  font-size: 1.35rem;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border);
}
.post-content h3 { font-size: 1.18rem; }
.post-content h4 { font-size: 1.05rem; }
.post-content h5,
.post-content h6 { font-size: 1rem; }

.post-content p {
  margin: 1em 0;
}

.post-content blockquote {
  margin: 1.5em 0;
  padding: 0.1em 1.2em;
  border-left: 3px solid var(--link);
  color: var(--text-secondary);
  background: var(--bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.post-content blockquote p {
  margin: 0.8em 0;
}

.post-content ul,
.post-content ol {
  padding-left: 1.6em;
  margin: 1em 0;
}

.post-content li {
  margin: 0.35em 0;
}

.post-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2.5em 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 0.5em 0.9em;
  text-align: left;
}

.post-content th {
  background: var(--bg-soft);
  font-weight: 600;
  white-space: nowrap;
}

.post-content img {
  display: block;
  margin: 1.5em auto;
  box-shadow: var(--shadow);
}

/* 行内代码 */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}

/* ---------- 代码块（Hexo 服务端高亮） ---------- */
figure.highlight {
  margin: 1.5em 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--code-bg);
}

figure.highlight pre {
  margin: 0;
  padding: 1em 1.2em;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.7;
}

figure.highlight .gutter {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  user-select: none;
}

figure.highlight .gutter pre {
  color: var(--text-faint);
  text-align: right;
}

figure.highlight table,
figure.highlight tr,
figure.highlight td {
  border: none;
  padding: 0;
}

figure.highlight figcaption {
  padding: 0.5em 1.2em;
  font-size: 0.8rem;
  color: var(--text-faint);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

/* 高亮配色（明） */
.highlight .c, .highlight .cd, .highlight .cm, .highlight .c1, .highlight .cs,
.highlight .comment { color: #8b949e; font-style: italic; }
.highlight .k, .highlight .kc, .highlight .kd, .highlight .kp, .highlight .kr,
.highlight .keyword { color: #cf222e; }
.highlight .s, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .s2,
.highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr,
.highlight .s1, .highlight .ss, .highlight .string { color: #0a3069; }
.highlight .n, .highlight .na, .highlight .nb, .highlight .nc, .highlight .nd,
.highlight .ne, .highlight .nf, .highlight .nl, .highlight .nn, .highlight .no,
.highlight .nt, .highlight .nv, .highlight .nx, .highlight .name { color: #953800; }
.highlight .m, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il,
.highlight .mo, .highlight .mb, .highlight .mx, .highlight .number { color: #0550ae; }
.highlight .l, .highlight .ld, .highlight .literal { color: #116329; }
.highlight .o, .highlight .ow, .highlight .operator { color: #0550ae; }
.highlight .t, .highlight .tn, .highlight .type { color: #8250df; }
.highlight .v, .highlight .vg, .highlight .vi, .highlight .variable { color: #953800; }
.highlight .w, .highlight .whitespace { color: inherit; }
.highlight .bp, .highlight .builtin { color: #8250df; }
.highlight .a, .highlight .attribute { color: #0550ae; }
.highlight .title { color: #8250df; }
.highlight .params { color: inherit; }
.highlight .addition { color: #116329; }
.highlight .deletion { color: #82071e; }

/* 高亮配色（暗） */
[data-theme="dark"] .highlight .c, [data-theme="dark"] .highlight .comment { color: #7d8590; }
[data-theme="dark"] .highlight .keyword { color: #ff7b72; }
[data-theme="dark"] .highlight .string { color: #a5d6ff; }
[data-theme="dark"] .highlight .name { color: #ffa657; }
[data-theme="dark"] .highlight .number,
[data-theme="dark"] .highlight .operator { color: #79c0ff; }
[data-theme="dark"] .highlight .literal { color: #7ee787; }
[data-theme="dark"] .highlight .type,
[data-theme="dark"] .highlight .builtin { color: #d2a8ff; }
[data-theme="dark"] .highlight .attribute { color: #79c0ff; }
[data-theme="dark"] .highlight .title { color: #d2a8ff; }

/* ---------- 目录 TOC ---------- */
.toc {
  margin: 0 0 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-size: 0.92rem;
}

.toc-title {
  padding: 0.6em 1.1em;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
  list-style: none;
}

.toc-title::-webkit-details-marker {
  display: none;
}

.toc-title::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5em;
  transition: transform var(--transition);
}

.toc[open] .toc-title::before {
  transform: rotate(90deg);
}

.toc-body {
  padding: 0.2em 1.1em 0.8em;
  max-height: 20rem;
  overflow-y: auto;
}

.toc-list {
  padding-left: 1.2em;
  margin: 0;
}

.toc-list ol {
  padding-left: 1.2em;
}

.toc-list li {
  margin: 0.25em 0;
}

.toc-list a {
  color: var(--text-secondary);
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  vertical-align: bottom;
}

.toc-list a:hover {
  color: var(--link);
}

/* ---------- 文章底部 ---------- */
.post-footer {
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0.15em 0.7em;
  border-radius: 999px;
  transition: border-color var(--transition), color var(--transition);
}

.tag:hover {
  color: var(--link);
  border-color: var(--link);
  opacity: 1;
}

.tag-count {
  color: var(--text-faint);
  font-size: 0.78em;
}

.post-license {
  margin-top: 1.2rem;
  font-size: 0.82rem;
  color: var(--text-faint);
}

/* ---------- 上下篇导航 ---------- */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
}

.post-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color var(--transition), background var(--transition);
}

.post-nav-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-soft);
  opacity: 1;
}

.post-nav-item.next {
  text-align: right;
}

.post-nav-item.placeholder {
  visibility: hidden;
}

.post-nav-label {
  font-size: 0.78rem;
  color: var(--text-faint);
}

.post-nav-title {
  font-size: 0.92rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 归档 ---------- */
.archive-year {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.6rem;
  position: sticky;
  top: 4rem;
}

.archive-year:first-of-type {
  margin-top: 0.5rem;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0;
  color: var(--text);
  border-bottom: 1px dashed var(--border);
}

.archive-item:hover {
  opacity: 1;
  color: var(--link);
}

.archive-date {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.archive-title {
  font-size: 0.98rem;
}

/* ---------- 分类 / 标签页 ---------- */
.category-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.2rem;
  border-bottom: 1px solid var(--border);
}

.category-list-link {
  color: var(--text);
  font-size: 1rem;
}

.category-list-count {
  font-size: 0.82rem;
  color: var(--text-faint);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 0 0.6em;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.empty-tip {
  color: var(--text-faint);
}

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 2.5rem;
  font-size: 0.82rem;
  color: var(--text-faint);
  background: var(--bg-soft);
}

.footer p {
  margin: 0.3em 0;
}

.footer a {
  color: var(--text-secondary);
}

.footer a:hover {
  color: var(--link);
}

/* ---------- 返回顶部 ---------- */
.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 2.6rem;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  box-shadow: var(--shadow);
  transition: opacity var(--transition), transform var(--transition),
    color var(--transition);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  color: var(--link);
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .header-inner {
    height: 3.2rem;
  }

  .nav {
    gap: 0.1rem;
  }

  .nav-link {
    font-size: 0.85rem;
    padding: 0.3rem 0.4rem;
  }

  .site-title {
    font-size: 1.05rem;
  }

  .post-title {
    font-size: 1.5rem;
  }

  .post-item-title {
    font-size: 1.1rem;
  }

  .post-nav {
    flex-direction: column;
  }

  .post-nav-item.next {
    text-align: left;
  }

  .archive-item {
    flex-direction: row;
    gap: 0.7rem;
  }
}

/* ---------- 可访问性 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ---------- 文章双栏布局（右侧目录） ---------- */
.container-wide {
  max-width: 60rem;
}

.container-wide .post {
  max-width: 44rem;
  min-width: 0;
}

.toc-aside {
  display: none;
}

@media (min-width: 1200px) {
  .post-layout {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
  }

  .toc-aside {
    display: block;
    order: 2;
    position: sticky;
    top: 4.5rem;
    width: 13rem;
    flex-shrink: 0;
  }

  .toc-aside .toc {
    margin: 0;
  }

  .toc-aside .toc-body {
    max-height: calc(100vh - 12rem);
  }
}

/* ---------- 评论区 ---------- */
.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.comments-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
}

/* ---------- 友链（卡片式） ---------- */
.links-intro {
  margin-bottom: 2rem;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition),
    transform var(--transition);
}

.link-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  opacity: 1;
}

.link-avatar {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.link-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.link-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-desc {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 分享 ---------- */
.post-share {
  margin-bottom: 1.2rem;
}

.share-label {
  font-size: 0.85rem;
  color: var(--text-faint);
  display: block;
  margin-bottom: 0.7rem;
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.83rem;
  color: var(--text-secondary);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35em 0.95em;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition),
    background var(--transition);
}

.share-btn:hover {
  color: var(--link);
  border-color: var(--link);
  opacity: 1;
}

.share-btn.copied {
  color: #16a34a;
  border-color: #16a34a;
}

.share-btn svg {
  flex-shrink: 0;
}
