/*
 * Highlight Theme - 极简博客主题
 * Inspired by blog.imalan.cn
 * Design: Minimalist, Warm, Reading-focused
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
  --accent: #b74e4e;
  --bg: #F1F7F4;
  --bg-card: transparent;
  --text: #2c2c2c;
  --text-secondary: #888;
  --border: #e2efe6;
  /* 思源宋体 (Source Han Serif SC) - 免费开源，可商用 */
  --title-font: "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", Georgia, serif;
  --body-font: "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", Georgia, serif;
  /* 更窄的宽度 - 参照失眠海峡 */
  --max-width: 560px;
  --spacing-unit: 1rem;
}

/* ========================================
   Reset & Base
   ======================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--body-font);
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.9;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent);
}

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

/* ========================================
   Site Wrapper
   ======================================== */
.site-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   Header / Site Title
   ======================================== */
.site-header {
  margin-bottom: 4rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-family: var(--title-font);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}

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

.site-title a:hover {
  color: var(--accent);
}

.site-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.site-nav {
  margin-top: 1rem;
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--text-secondary);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.nav-link:hover {
  color: var(--accent);
}

.nav-link:hover::after {
  width: 100%;
}

/* ========================================
   Main Content Area
   ======================================== */
.main-content {
  flex: 1;
}

/* ========================================
   Post List (Home Page) - 核心样式，参照图片
   ======================================== */
.post-list {
  /* 无额外容器样式，保持极简 */
}

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

.post-item:first-child {
  padding-top: 0.5rem;
}

.post-item-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.post-cover {
  position: relative;
  width: 100%;
  height: 240px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.4s ease;
}

.post-item-link:hover .post-cover img {
  transform: scale(1.03);
}

.post-cover-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  display: flex;
  align-items: flex-end;
}

.post-cover-overlay .post-title {
  color: #fff !important;
  margin: 0;
  font-size: 1.4rem;
}

.post-item-inner {
  /* 内容区域 */
}

/* 分类标签 - 红棕色小写字母 */
.post-category {
  margin-bottom: 0.6rem;
}

.category-link {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  transition: opacity 0.2s ease;
}

.category-link:hover {
  color: var(--accent);
  opacity: 0.7;
}

/* 文章标题 - 衬线大字 */
.post-title {
  font-family: var(--title-font);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

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

.post-title a:hover {
  color: var(--accent);
}

/* 摘要文字 - 灰色小字 */
.post-excerpt {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* 日期 - 浅灰色小字 */
.post-date {
  display: block;
  font-size: 0.82rem;
  color: #aaa;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ========================================
   Pagination
   ======================================== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 3rem 0 1rem;
}

.pagination a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.pagination a:hover {
  color: var(--accent);
}

.pagination-next {
  margin-left: auto;
}

/* ========================================
   Article Page (Single Post)
   ======================================== */
.post-article {
  padding: 2rem 0;
}

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-article-title {
  font-family: var(--title-font);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

.post-meta a:hover {
  color: var(--accent);
}

/* Post Content - 文章正文排版 */
.post-content {
  font-size: 1.05rem;
  line-height: 1.85;
  word-wrap: break-word;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  font-family: var(--title-font);
  font-weight: 600;
  line-height: 1.4;
  margin-top: 2em;
  margin-bottom: 0.75em;
  letter-spacing: -0.01em;
}

.post-content h1 { font-size: 1.6rem; }
.post-content h2 { font-size: 1.35rem; }
.post-content h3 { font-size: 1.15rem; }
.post-content h4 { font-size: 1rem; }

.post-content p {
  margin-bottom: 1.3em;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.post-content a:hover {
  opacity: 0.75;
}

.post-content strong {
  font-weight: 600;
}

.post-content blockquote {
  margin: 1.5em 0;
  padding: 0.5em 1.25em;
  border-left: 3px solid var(--accent);
  background: rgba(184, 78, 78, 0.04);
  color: var(--text-secondary);
  font-style: italic;
}

.post-content code {
  font-family: "SF Mono", SFMono-Regular, "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.88em;
  background: rgba(45, 106, 79, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* ========================================
   Code Block - 代码块容器
   浅色主题，搭配薄荷绿背景 #F1F7F4
   ======================================== */
.post-content pre {
  position: relative;
  margin: 1.8em 0;
  padding: 1.25rem;
  padding-top: 2.4rem; /* 为标题栏留空间 */
  background: #eaf5ef !important;      /* 薄荷绿浅底 */
  color: #1a3a2a !important;           /* 深绿色文字 */
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.6;
  border: 1px solid #d1e7d8;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit !important;   /* 继承父元素颜色 */
  font-size: inherit;
  line-height: inherit;
  border-radius: 0;
}

/* 代码块语言标签 */
.post-content pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.9rem;
  line-height: 1.9rem;
  padding: 0 14px;
  background: #d4ecd9;          /* 标题栏稍深的薄荷绿 */
  color: #2d6a4f;               /* 深绿色文字 */
  font-family: var(--body-font);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}

/* ========================================
   Highlight.js 语法高亮 - 浅色薄荷绿主题
   适配 #eaf5ef 浅色代码块背景
   ======================================== */
.hljs,
.hljs-subst { color: #1a3a2a; }

.hljs-comment,
.hljs-quote { color: #5a8a6f; font-style: italic; }

.hljs-doctag,
.hljs-keyword,
.hljs-formula { color: #8b5cf6; }          /* 紫色 - 关键字 */

.hljs-deletion,
.hljs-name,
.hljs-section,
.hljs-selector-tag,
.hljs-template-variable,
.hljs-variable { color: #c45c4a; }           /* 红 - 变量/标签 */

.hljs-string,
.hljs-addition,
.hljs-attribute,
.hljs-meta-string,
.hljs-regexp,
.hljs-symbol { color: #2d7a5a; }              /* 绿 - 字符串 */

.hljs-built_in,
.hljs-class .hljs-title,
.hljs-number { color: #b07d2e; }               /* 橙 - 数字/类名 */

.hljs-params,
.hljs-title,
.hljs-title.function_ { color: #2563eb; }      /* 蓝 - 函数名 */

.hljs-builtin-name,
.hljs-link,
.hljs-selector-class,
.hljs-selector-id,
.hljs-type,
.hljs-title.class_ { color: #9a6a2e; }         /* 棕 - 类型 */

.hljs-strong { font-weight: bold; }
.hljs-em { font-style: italic; }
.hljs-literal { color: #0d9488; }                /* 青绿 */
.hljs-meta { color: #4a7a5a; }

/* ========================================
   Highlight.js 行号样式
   ======================================== */
table.hljs-ln {
  border: none;
  margin: 0;
  width: auto;
}

td.hljs-ln-numbers,
td.hljs-ln-code {
  border: none;
  padding: 0 12px 0 8px;
  vertical-align: top;
  white-space: nowrap;
}

td.hljs-ln-numbers {
  -webkit-user-select: none;
  user-select: none;
  text-align: right;
  color: #495162;
  min-width: 24px;
  font-size: 0.82em;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

tr:hover td.hljs-ln-numbers {
  opacity: 0.85;
}

/* ========================================
   代码块复制按钮
   ======================================== */
.post-content pre .code-copy-btn {
  position: absolute;
  top: 0.38rem;
  right: 10px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #c1ddd0;
  border-radius: 4px;
  color: #2d6a4f;
  font-family: var(--body-font);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.18s ease;
  pointer-events: auto;
  line-height: 1;
}

.post-content pre .code-copy-btn:hover {
  background: #fff;
  color: #1a5a3a;
  border-color: #a8d4bc;
}

.post-content pre .code-copy-btn.copied {
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.4);
  background: rgba(22, 163, 74, 0.1);
}

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

.post-content li {
  margin-bottom: 0.4em;
}

.post-content img {
  border-radius: 4px;
  margin: 1.5em auto;
}

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95rem;
}

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

.post-content th {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 600;
}

/* Post Footer */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.copyright-notice {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Post Navigation */
.post-nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-nav-prev,
.post-nav-next {
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.post-nav-prev:hover,
.post-nav-next:hover {
  color: var(--accent);
}

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

/* ========================================
   Page (Custom Page)
   ======================================== */
.page-article {
  padding: 1rem 0 3rem;
}

.page-title {
  font-family: var(--title-font);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-content {
  font-size: 1.05rem;
  line-height: 1.85;
}

.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4,
.page-content h5,
.page-content h6 {
  font-family: var(--title-font);
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
}

.page-content p {
  margin-bottom: 1.2em;
}

.page-content a {
  color: var(--accent);
  text-decoration: underline;
}

/* ========================================
   Footer
   ======================================== */
.site-footer {
  margin-top: 4rem;
}

.footer-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin-bottom: 1.25rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  padding-bottom: 2rem;
}

.footer-tech {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--body-font);
  font-size: 0.7rem;
  color: #bbb;
  letter-spacing: 0.03em;
}
.footer-license,
.footer-rss {
  font-family: var(--body-font);
  font-size: 0.7rem;
  color: #bbb !important;
  text-decoration: none !important;
  letter-spacing: 0.03em;
  transition: color 0.18s ease;
}

.footer-license:hover,
.footer-rss:hover {
  color: var(--accent);
}

.footer-tech a {
  color: #bbb;
  text-decoration: none;
  transition: color 0.18s ease;
}

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

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 640px) {
  .site-wrapper {
    padding: 1.25rem 1rem;
  }

  .site-header {
    margin-bottom: 2.5rem;
  }

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

  .post-item {
    padding: 2rem 0;
  }

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

  .post-article-title {
    font-size: 1.55rem;
  }

  .post-content {
    font-size: 1rem;
  }

  .page-title {
    font-size: 1.45rem;
  }
}

/* ========================================
   Selection Color
   ======================================== */
::selection {
  background: var(--accent);
  color: #fff;
}

::-moz-selection {
  background: var(--accent);
  color: #fff;
}

/* ========================================
   Search Button (Nav)
   ======================================== */
.search-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--body-font);
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0;
  letter-spacing: -0.01em;
}

.search-btn:hover {
  color: var(--accent);
}

/* ========================================
   Search Modal
   ======================================== */
.search-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.search-overlay.active {
  display: block;
}

.search-modal {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  max-height: 75vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-modal.active {
  opacity: 1;
  visibility: visible;
}

.search-modal-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #eee;
  gap: 0.75rem;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  font-size: 1.05rem;
  font-family: var(--body-font);
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
}

.search-input::placeholder {
  color: #bbb;
}

.search-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #999;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease;
  width: 32px;
  height: 32px;
  text-align: center;
}

.search-close:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.search-placeholder {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  color: #aaa;
  font-weight: 500;
}

.search-empty {
  padding: 3rem 1.25rem;
  text-align: center;
  color: #bbb;
  font-size: 0.95rem;
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  color: var(--text);
  transition: background 0.12s ease;
  text-decoration: none;
}

.search-result-item:hover {
  background: #fafafa;
  color: var(--text);
}

.result-icon {
  font-size: 1.1rem;
  margin-top: 2px;
  flex-shrink: 0;
  line-height: 1.35;
  color: var(--text);
  display: flex;
  align-items: center;
}

.result-body {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
  margin-bottom: 0.15rem;
  word-break: break-word;
}

.result-title mark {
  background: #fff3b0;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.result-excerpt {
  font-size: 0.82rem;
  color: #888;
  line-height: 1.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
}

.result-excerpt mark {
  background: #fff3b0;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* ========================================
   Scrollbar (Webkit)
   ======================================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d0ccc7;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #bfbaba;
}

/* ========================================
   Archives Page
   ======================================== */
.archives-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.page-title {
  font-family: var(--title-font);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.archive-year {
  margin-bottom: 2rem;
}

.year-title {
  font-family: var(--body-font);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.year-posts {
  display: flex;
  flex-direction: column;
}

.archive-post-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0;
  text-decoration: none;
  color: var(--text-secondary);
  transition: color 0.12s ease;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
}

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

.archive-post-item:hover {
  color: var(--accent);
}

.archive-date {
  font-size: 0.85rem;
  color: #bbb;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 3.5rem;
}

.archive-title {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 500;
  color: inherit;
  flex: 1;
  line-height: 1.45;
}

.archive-category {
  font-size: 0.78rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* ========================================
   Categories Page
   ======================================== */
.categories-list {
  display: flex;
  flex-direction: column;
}

.category-name {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 500;
  color: inherit;
  flex: 1;
  line-height: 1.45;
}

.category-count {
  font-size: 0.85rem;
  color: #bbb;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 2rem;
  text-align: right;
}

/* ========================================
   Mermaid Diagrams
   ======================================== */
.mermaid-container {
  margin: 2em auto;
  text-align: center;
  overflow-x: auto;
}

.mermaid-container svg {
  max-width: 100%;
  height: auto;
}

/* Mermaid error fallback */
.mermaid-error {
  border-radius: 8px;
}
