/* ============================================================
   personal-site stylesheet
   light/dark themes via [data-theme] on <html>
   ============================================================ */

:root {
  --bg: #f7f8fa;
  --bg-soft: #eef0f4;
  --card: #ffffff;
  --text: #1a1e28;
  --text-2: #444b5a;
  --muted: #7b8494;
  --border: #e3e6ec;
  --border-strong: #cfd4dd;
  --accent: #3b5bfd;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(59, 91, 253, 0.08);
  --code-bg: #f2f4f8;
  --pre-bg: #f6f8fa;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.04), 0 4px 16px rgba(20, 24, 40, 0.06);
  --shadow-lift: 0 2px 4px rgba(20, 24, 40, 0.06), 0 10px 28px rgba(20, 24, 40, 0.10);
  --header-bg: rgba(247, 248, 250, 0.85);
  --radius: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;
  /* highlight.js — light (github-like) */
  --hl-comment: #6a737d;
  --hl-keyword: #d73a49;
  --hl-string: #032f62;
  --hl-number: #005cc5;
  --hl-title: #6f42c1;
  --hl-built: #e36209;
  --hl-attr: #e36209;
  --hl-type: #005cc5;
}

[data-theme="dark"] {
  --bg: #0e1218;
  --bg-soft: #151b24;
  --card: #161d28;
  --text: #e4e8f0;
  --text-2: #b4bdcc;
  --muted: #7d8798;
  --border: #232c3a;
  --border-strong: #313c4e;
  --accent: #6e8bff;
  --accent-2: #a78bfa;
  --accent-soft: rgba(110, 139, 255, 0.10);
  --code-bg: #1b2330;
  --pre-bg: #151c27;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(14, 18, 24, 0.85);
  /* highlight.js — dark (one-dark-like) */
  --hl-comment: #7d8590;
  --hl-keyword: #c678dd;
  --hl-string: #98c379;
  --hl-number: #d19a66;
  --hl-title: #61afef;
  --hl-built: #e5c07b;
  --hl-attr: #d19a66;
  --hl-type: #56b6c2;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
}

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 15px;
}

.site-nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.site-nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.site-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.nav-rss svg { position: relative; top: 1px; }

.theme-toggle {
  flex: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }

/* ---------- hero ---------- */

.hero {
  position: relative;
  padding: 88px 0 64px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -220px;
  right: -120px;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-2);
  font-size: 13px;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

.hero-title {
  margin: 0 0 14px;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--text) 35%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-tagline {
  margin: 0 0 34px;
  font-size: clamp(1.05rem, 2.4vw, 1.3rem);
  color: var(--text-2);
  max-width: 560px;
}

.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(59, 91, 253, 0.28);
}
.btn-primary:hover { box-shadow: 0 8px 24px rgba(59, 91, 253, 0.38); }

.btn-ghost {
  color: var(--text-2);
  border-color: var(--border-strong);
  background: var(--card);
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }

.hero-social { display: flex; gap: 18px; margin-top: 26px; flex-wrap: wrap; }
.hero-social .social-link {
  color: var(--muted);
  font-size: 14px;
  border-bottom: 1px dashed transparent;
}
.hero-social .social-link:hover { color: var(--accent); text-decoration: none; border-bottom-color: currentColor; }

.hero-stats {
  display: flex;
  gap: 44px;
  margin-top: 52px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); letter-spacing: 0.05em; }

/* ---------- sections ---------- */

.section { padding: 44px 0 8px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
}

.section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-more { font-size: 14px; color: var(--muted); }
.section-more:hover { color: var(--accent); }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-title { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.01em; }

/* ---------- cards / article grid ---------- */

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--border-strong);
}

.card-meta {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 6px;
}

.card-title { margin: 0; font-size: 17.5px; font-weight: 700; line-height: 1.4; }

.card-summary {
  margin: 0;
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
  padding-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.dot { color: var(--muted); }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.6;
  cursor: default;
}
a.tag-chip, button.tag-chip { cursor: pointer; }
a.tag-chip:hover, button.tag-chip:hover {
  text-decoration: none;
  color: var(--accent);
  border-color: var(--accent);
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-cloud-chip sup { color: var(--muted); font-size: 10px; margin-left: 3px; }

/* ---------- articles list page ---------- */

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 260px;
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  color: var(--text);
  width: 100%;
}
.search-box input::placeholder { color: var(--muted); }

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.tag-filter-chip {
  background: var(--card);
  font-family: inherit;
}
.tag-filter-chip sup { color: var(--muted); font-size: 10px; margin-left: 2px; }
.tag-filter-chip.is-active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}
.tag-filter-chip.is-active sup { color: rgba(255, 255, 255, 0.8); }

.year-group { margin-bottom: 34px; }

.year-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.12em;
  margin: 0 0 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.article-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 18px 18px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text);
  transition: background-color 0.15s, border-color 0.15s;
}
.article-item:hover { background: var(--card); border-color: var(--border); text-decoration: none; }

.article-item-body { flex: 1; min-width: 0; }
.article-item-title { margin: 0 0 4px; font-size: 16.5px; font-weight: 650; line-height: 1.45; }
.article-item:hover .article-item-title { color: var(--accent); }
.article-item-summary {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-item-arrow { color: var(--muted); flex: none; opacity: 0; transform: translateX(-6px); transition: opacity 0.15s, transform 0.15s; }
.article-item:hover .article-item-arrow { opacity: 1; transform: translateX(0); color: var(--accent); }

.search-empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* ---------- article page ---------- */

.article { padding: 48px 0 24px; }

.article-head { margin-bottom: 36px; }

.article-title {
  margin: 0 0 14px;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 56px;
  align-items: start;
}

.article-content { max-width: 760px; }

/* table of contents */
.toc {
  position: sticky;
  top: 92px;
  border-left: 2px solid var(--border);
  padding-left: 18px;
  font-size: 13.5px;
  max-height: calc(100vh - 130px);
  overflow: auto;
}

.toc-title {
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  margin-bottom: 10px;
}

.toc-nav { display: flex; flex-direction: column; gap: 6px; }

.toc-link {
  color: var(--text-2);
  line-height: 1.5;
  border-left: 2px solid transparent;
  margin-left: -20px;
  padding-left: 18px;
}
.toc-link:hover { color: var(--accent); text-decoration: none; }
.toc-link.toc-h3 { padding-left: 32px; }
.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* prev/next pager */
.article-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.pager-link:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.pager-next { text-align: right; }
.pager-label { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.pager-title { font-size: 15px; font-weight: 650; color: var(--accent); }
.pager-spacer { display: none; }

/* ---------- markdown body ---------- */

.markdown-body { font-size: 16.5px; line-height: 1.85; color: var(--text); }

.markdown-body > *:first-child { margin-top: 0; }

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-weight: 700;
  line-height: 1.4;
  margin: 1.8em 0 0.7em;
  letter-spacing: -0.01em;
  scroll-margin-top: 90px;
}
.markdown-body h1 { font-size: 1.7em; }
.markdown-body h2 { font-size: 1.42em; padding-bottom: 0.35em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.22em; }
.markdown-body h4 { font-size: 1.08em; }

.markdown-body p { margin: 0.95em 0; }

.markdown-body a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.markdown-body a:hover { text-decoration-color: var(--accent); }

.markdown-body ul, .markdown-body ol { padding-left: 1.6em; }
.markdown-body li { margin: 0.35em 0; }
.markdown-body li::marker { color: var(--accent); }

.markdown-body blockquote {
  margin: 1.4em 0;
  padding: 2px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  color: var(--text-2);
}
.markdown-body blockquote p { margin: 0.6em 0; }

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15em 0.42em;
}

.markdown-body pre {
  position: relative;
  margin: 1.5em 0;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--pre-bg);
  overflow-x: auto;
  line-height: 1.6;
  font-size: 14px;
}
.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 1em;
  color: var(--text);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-strong);
  padding: 9px 14px;
}
.markdown-body th { background: var(--bg-soft); font-weight: 650; }
.markdown-body tr:nth-child(2n) td { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }

.markdown-body img {
  max-width: 100%;
  border-radius: 10px;
  margin: 1.2em 0;
}

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

.markdown-body kbd {
  font-family: var(--font-mono);
  font-size: 0.82em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  background: var(--card);
}

/* highlight.js tokens */
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-subst { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-doctag { color: var(--hl-string); }
.hljs-number, .hljs-literal, .hljs-symbol { color: var(--hl-number); }
.hljs-title, .hljs-section, .hljs-name, .hljs-selector-id, .hljs-selector-class { color: var(--hl-title); }
.hljs-built_in, .hljs-builtin-name, .hljs-type { color: var(--hl-type); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-params { color: var(--hl-attr); }
.hljs-meta { color: var(--hl-comment); }
.hljs-deletion { color: var(--hl-keyword); }
.hljs-addition { color: var(--hl-string); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- empty / error states ---------- */

.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-2);
}
.empty-hint { color: var(--muted); font-size: 14px; word-break: break-all; }
.empty-hint code { font-size: 12.5px; }

.error-state { padding: 90px 20px; }
.error-code {
  font-size: 88px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 72px;
  padding: 34px 0 38px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.footer-line { margin: 0 0 6px; text-align: center; color: var(--muted); font-size: 13.5px; }

.beian-link {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.beian-link:hover { color: var(--accent); }
.police-icon { opacity: 0.75; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 720px) {
  .hero { padding: 56px 0 44px; }
  .hero-stats { gap: 30px; margin-top: 38px; }
  .header-inner { gap: 14px; }
  .brand-name { font-size: 16px; }
  .site-nav { font-size: 14px; gap: 2px; }
  .site-nav a { padding: 6px 8px; }
  .nav-rss span { display: none; }
  .search-box { min-width: 100%; }
  .article-pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
  .article { padding-top: 28px; }
}
