/* =========================================
   Google Fonts
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =========================================
   CSS Variables — Light / Dark
   ========================================= */
:root {
  --bg:           #f9f9fb;
  --bg-card:      #ffffff;
  --bg-secondary: #f1f2f6;
  --border:       #e4e5ec;
  --text:         #111118;
  --text-muted:   #72748a;
  --accent:       #5b5ef4;
  --accent-hover: #4a4de0;
  --accent-light: #ededff;
  --tag-bg:       #ededff;
  --tag-text:     #5b5ef4;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:    0 12px 40px rgba(0,0,0,.12);

  --font-sans:  "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono:  "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;

  --radius:     10px;
  --radius-lg:  16px;
  --max-width:  800px;
  --sidebar-width: 220px;

  --header-bg:  rgba(249,249,251,.88);

  --transition: .18s cubic-bezier(.4,0,.2,1);
}

[data-color-scheme="dark"] {
  --bg:           #0d0d12;
  --bg-card:      #13131a;
  --bg-secondary: #1a1a24;
  --border:       #24243a;
  --text:         #eeeef5;
  --text-muted:   #8888a8;
  --accent:       #7b7ef8;
  --accent-hover: #9699fa;
  --accent-light: #1a1a38;
  --tag-bg:       #1a1a38;
  --tag-text:     #9699fa;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
  --shadow-md:    0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:    0 12px 40px rgba(0,0,0,.5);
  --header-bg:    rgba(13,13,18,.88);
}

/* =========================================
   Reset
   ========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; display: block; }

/* =========================================
   Page fade-in
   ========================================= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-main { animation: fadeUp .38s ease both; flex: 1; }

/* =========================================
   Header
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--border);
}

.site-header .inner {
  width: min(60%, 1400px);
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-logo::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--accent); }

.site-nav { display: flex; gap: 4px; align-items: center; }
.site-nav a {
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.site-nav a:hover { color: var(--text); background: var(--bg-secondary); }
.site-nav a.active { color: var(--accent); background: var(--accent-light); }

.search-trigger {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px 5px 10px;
  font-size: .825rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}
.search-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.search-trigger svg { width: 13px; height: 13px; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* =========================================
   Layout
   ========================================= */
.page-main {
  width: min(60%, 1400px);
  margin: 0 auto;
  padding: 52px 24px;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 52px;
  align-items: start;
}
.page-main.no-sidebar {
  grid-template-columns: 1fr;
}

.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 28px;
  font-size: .8rem;
  color: var(--text-muted);
  letter-spacing: .02em;
}
.footer-sep { margin: 0 6px; }
.icp-link { color: var(--text-muted); }
.icp-link:hover { color: var(--accent); }

/* =========================================
   Post Cards (index)
   ========================================= */
.posts-list { display: flex; flex-direction: column; gap: 10px; }

.post-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.post-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.45;
  letter-spacing: -.2px;
}
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); }

.post-card-excerpt {
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.65;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.post-views { color: var(--text-muted); }
.post-updated { color: var(--text-muted); }

/* =========================================
   Tags
   ========================================= */
.tag {
  display: inline-flex;
  align-items: center;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .775rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: all var(--transition);
}
.tag:hover { opacity: .8; color: var(--tag-text); }

/* =========================================
   Article Typography
   ========================================= */
.article-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.article-title {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.6px;
  margin-bottom: 16px;
}
.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: .85rem;
  color: var(--text-muted);
}

.article-body { font-size: 1.0625rem; line-height: 1.85; }

.article-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 2.4em 0 .85em;
  letter-spacing: -.3px;
  padding-bottom: .4em;
  border-bottom: 1px solid var(--border);
}
.article-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1.9em 0 .65em;
  letter-spacing: -.2px;
}
.article-body h4 { font-size: 1rem; font-weight: 600; margin: 1.5em 0 .5em; }
.article-body p { margin-bottom: 1.3em; }
.article-body ul, .article-body ol { margin: .8em 0 1.3em 1.6em; }
.article-body li { margin-bottom: .35em; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: .8em 1.4em;
  margin: 1.6em 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-style: italic;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: .9rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.article-body th, .article-body td {
  padding: .65em 1.1em;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.article-body tr:last-child td { border-bottom: none; }
.article-body th { background: var(--bg-secondary); font-weight: 600; font-size: .875rem; }

.article-body hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }

.article-body a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: border-color var(--transition);
}
.article-body a:hover { border-bottom-color: var(--accent); }

.article-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .18em .48em;
  color: #c026d3;
}

/* =========================================
   Code Blocks
   ========================================= */
.article-body pre {
  position: relative;
  margin: 1.6em 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid #1e2433;
  box-shadow: var(--shadow-md);
}
.article-body pre code {
  display: block;
  padding: 1.3em 1.5em;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.75;
  background: #0d1117;
  color: #c9d1d9;
}

.copy-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 500;
  color: #8b9ab3;
  cursor: pointer;
  transition: all var(--transition);
}
.copy-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.copy-btn.copied { color: #4ade80; border-color: rgba(74,222,128,.4); }

/* =========================================
   Sidebar
   ========================================= */
.sidebar { position: sticky; top: 76px; }

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}

.sidebar-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.toc-list { list-style: none; }
.toc-list li { margin-bottom: 1px; }
.toc-list a {
  font-size: .84rem;
  color: var(--text-muted);
  padding: 4px 8px;
  display: block;
  border-radius: 6px;
  transition: all var(--transition);
}
.toc-list a:hover { color: var(--text); background: var(--bg-secondary); }
.toc-list a.active { color: var(--accent); background: var(--accent-light); }
.toc-list .toc-h3 { padding-left: 10px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

/* =========================================
   Reading progress bar
   ========================================= */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #a78bfa, #38bdf8);
  z-index: 999;
  transition: width .08s linear;
}

/* =========================================
   Search overlay
   ========================================= */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.6);
  padding: 72px 24px 24px;
  backdrop-filter: blur(6px);
}
.search-overlay-inner {
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .2s ease both;
}
.search-close {
  margin-top: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition);
}
.search-close:hover { color: var(--text); background: var(--bg-secondary); }

.search-input {
  width: 100%;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: .975rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.search-input:focus { border-color: var(--accent); background: var(--bg-card); }
.search-box-wrap { margin-bottom: 10px; }
.search-results { max-height: 400px; overflow-y: auto; }
.search-result-item {
  display: block;
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 3px;
  color: var(--text);
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-secondary); color: var(--text); }
.search-result-title { font-weight: 600; font-size: .95rem; margin-bottom: 3px; }
.search-result-subs { font-size: .8rem; color: var(--text-muted); margin-bottom: 3px; }
.search-result-subs .sep { margin: 0 5px; opacity: .5; }
.search-result-meta { font-size: .76rem; color: var(--text-muted); }
.search-result-item mark { background: var(--accent-light); color: var(--accent); border-radius: 2px; padding: 0 2px; font-style: normal; }
.search-empty { color: var(--text-muted); font-size: .9rem; text-align: center; padding: 24px 0; }

:root {
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-font: var(--font-sans);
  --pagefind-ui-border-radius: 8px;
}

/* =========================================
   Comments
   ========================================= */
.comments-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -.2px;
}
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: .9rem;
  resize: vertical;
  transition: border-color var(--transition), background var(--transition);
  box-sizing: border-box;
}
.comment-form input:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-card);
}
.comment-form-footer { display: flex; justify-content: space-between; align-items: center; }
.comment-hint { font-size: .78rem; color: var(--text-muted); }
.comment-form button[type="submit"] {
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--transition);
}
.comment-form button[type="submit"]:hover { background: var(--accent-hover); transform: translateY(-1px); }
.comment-form button[type="submit"]:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.comment-msg { font-size: .82rem; margin: 0; }
.comment-msg--success { color: #16a34a; }
.comment-msg--error   { color: #dc2626; }

.comment-item { padding: 18px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.comment-author {
  font-weight: 700;
  font-size: .875rem;
  background: var(--accent-light);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 20px;
}
.comment-time   { font-size: .78rem; color: var(--text-muted); }
.comment-content { font-size: .9rem; line-height: 1.75; white-space: pre-wrap; }
.comments-empty {
  color: var(--text-muted);
  font-size: .9rem;
  text-align: center;
  padding: 32px 0;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 820px) {
  .page-main { width: 100%; max-width: none; grid-template-columns: 1fr; padding: 28px 18px; gap: 32px; }
  .sidebar { display: none; }
  .article-title { font-size: 1.65rem; }
  .site-header .inner { width: 100%; max-width: none; padding: 0 18px; }
}
@media (max-width: 480px) {
  .post-card { padding: 18px; }
  .article-title { font-size: 1.45rem; }
}

/* =========================================
   About Page
   ========================================= */
.about-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 0 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}
.about-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 18px;
  border: 3px solid var(--border);
  box-shadow: var(--shadow-md);
}
.about-name {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 8px;
}
.about-tagline { color: var(--text-muted); font-size: .95rem; }

/* =========================================
   Tags Page
   ========================================= */
.tag-page-header { margin-bottom: 32px; }
.tag-page-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -.3px; }
.tag-page-title span { color: var(--accent); }
.tag-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  transition: color var(--transition);
}
.tag-back:hover { color: var(--accent); }

/* =========================================
   404 Page
   ========================================= */
.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 96px 0 64px;
}
.not-found-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--border);
  line-height: 1;
  letter-spacing: -4px;
}
.not-found-title { font-size: 1.4rem; font-weight: 700; margin: 16px 0 8px; }
.not-found-desc { color: var(--text-muted); margin-bottom: 32px; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  padding: 10px 28px;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
  transition: all var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; transform: translateY(-1px); }
