/* =========================================================
   tech-theme 基础样式
   结构：变量 → 基础 → 头部 → 列表 → 文章 → 代码 → 分页 → 页脚
   ========================================================= */

:root {
  --bg: #f5f7fb;
  --bg-elevated: #ffffff;
  --text: #1b2433;
  --text-soft: #5b6678;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --header-bg: rgba(255, 255, 255, 0.86);
  --code-bg: #0f172a;
  --code-inline-bg: #eef2f7;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.06);
  --radius: 12px;
  --max-width: 860px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, Monaco, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --bg-elevated: #111a2e;
    --text: #e5eaf3;
    --text-soft: #9aa7bd;
    --border: #1f2a3f;
    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --accent-soft: rgba(96, 165, 250, 0.12);
    --header-bg: rgba(11, 17, 32, 0.86);
    --code-bg: #080d19;
    --code-inline-bg: #1a2439;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.28);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 420px at 50% -120px, var(--accent-soft), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
}

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

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

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

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

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

.container {
  width: min(calc(100% - 48px), var(--max-width));
  margin-inline: auto;
}

/* ===============
   头部
   =============== */

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 66px;
}

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

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

.brand-name {
  font-size: 17px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.site-nav a {
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--text-soft);
  font-size: 14px;
}

.site-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

/* ===============
   主体与列表
   =============== */

.site-main {
  flex: 1;
  width: min(calc(100% - 48px), var(--max-width));
  margin-inline: auto;
  padding: 40px 0 72px;
}

.page-heading {
  margin-bottom: 28px;
}

.page-heading h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.page-desc {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.post-list {
  display: grid;
  gap: 18px;
}

.post-card {
  padding: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.post-card-title {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.45;
}

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

.post-card-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.meta-divider {
  color: var(--border);
}

.meta-link {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 12px;
}

.meta-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.post-summary {
  margin: 14px 0 16px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.8;
}

.read-more {
  font-size: 14px;
  font-weight: 600;
}

.read-more:hover {
  text-decoration: none;
}

.empty {
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  text-align: center;
}

/* ===============
   文章详情 / 独立页面
   =============== */

.post {
  padding: 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.post-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.post-title {
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.post-content {
  font-size: 16px;
  line-height: 1.9;
  overflow-wrap: break-word;
}

/* 正文目录（由 toc() 生成） */
.post-toc {
  margin: 0 0 2.2em;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  font-size: 14px;
  line-height: 1.7;
}

.post-toc-title {
  margin: 0 0 0.6em;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-soft);
  text-transform: uppercase;
}

.post-toc-list,
.post-toc-list-child {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.post-toc-list-child {
  padding-left: 1.1em;
}

.post-toc-list-item {
  margin: 0.3em 0;
}

.post-toc-list-link {
  display: block;
  color: var(--text-soft);
}

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

.post-toc-list-level-2 > .post-toc-list-link {
  color: var(--text);
}

.post-toc-list-number {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 2em 0 0.75em;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.post-content h1 {
  font-size: 26px;
}

.post-content h2 {
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  font-size: 22px;
}

.post-content h3 {
  font-size: 19px;
}

.post-content h4 {
  font-size: 17px;
}

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

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

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

.post-content a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-content blockquote {
  margin: 1.5em 0;
  padding: 12px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  color: var(--text-soft);
}

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

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

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

/* 动图转成 webm 后是 <video>，样式与图片保持一致 */
.post-content video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5em auto;
  border-radius: 10px;
}

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

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

.post-content th {
  background: var(--accent-soft);
  font-weight: 600;
}

/* ===============
   代码
   =============== */

.post-content code {
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--code-inline-bg);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.post-content pre {
  margin: 1.5em 0;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--code-bg);
  color: #e2e8f0;
  line-height: 1.7;
}

.post-content pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: 13.5px;
}

figure.highlight {
  margin: 1.5em 0;
  overflow: hidden;
  border-radius: 10px;
  background: var(--code-bg);
}

figure.highlight table {
  width: 100%;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  font-size: 13.5px;
}

figure.highlight td {
  padding: 0;
  border: 0;
  vertical-align: top;
}

figure.highlight pre {
  margin: 0;
  padding: 16px 18px;
  border-radius: 0;
  background: none;
  color: #e2e8f0;
}

figure.highlight .gutter {
  width: 1%;
  background: rgba(255, 255, 255, 0.04);
  user-select: none;
}

figure.highlight .gutter pre {
  padding-inline: 12px;
  color: #64748b;
  text-align: right;
}

figure.highlight .comment,
figure.highlight .quote {
  color: #7c8ba1;
}

figure.highlight .keyword,
figure.highlight .selector-tag,
figure.highlight .built_in,
figure.highlight .type,
figure.highlight .tag {
  color: #93c5fd;
}

figure.highlight .string,
figure.highlight .regexp,
figure.highlight .addition {
  color: #a5d6a7;
}

figure.highlight .number,
figure.highlight .literal,
figure.highlight .bullet {
  color: #fdba74;
}

figure.highlight .title,
figure.highlight .section,
figure.highlight .function,
figure.highlight .attr,
figure.highlight .attribute {
  color: #f0abfc;
}

figure.highlight .variable,
figure.highlight .template-variable,
figure.highlight .link,
figure.highlight .symbol {
  color: #fca5a5;
}

/* ===============
   标签 / 文章导航
   =============== */

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.post-tags a {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 13px;
}

.post-tags a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
}

.post-nav-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.post-nav-link:only-child {
  grid-column: 1 / -1;
}

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

.post-nav-label {
  color: var(--text-soft);
  font-size: 12px;
}

.post-nav-title {
  font-size: 14px;
  font-weight: 600;
}

/* ===============
   分页
   =============== */

.pagination,
.paginator {
  margin-top: 28px;
  text-align: center;
}

.page-number,
.extend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  margin: 0 3px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-soft);
  font-size: 14px;
}

.page-number:hover,
.extend:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.page-number.current {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.space {
  margin: 0 4px;
  color: var(--text-soft);
}

/* ===============
   页脚
   =============== */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 32px;
  color: var(--text-soft);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}

.footer-inner p {
  margin: 0;
}

/* ===============
   响应式
   =============== */

@media (max-width: 640px) {
  .container,
  .site-main {
    width: calc(100% - 32px);
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 0;
  }

  .site-main {
    padding: 28px 0 56px;
  }

  .post-card,
  .post {
    padding: 20px;
  }

  .post-title {
    font-size: 26px;
  }

  .post-nav {
    grid-template-columns: 1fr;
  }

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

  .footer-inner {
    flex-direction: column;
  }
}