/* ============================================================
 * 知屿 · 个人知识分享博客样式
 * ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  color-scheme: light;
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --border: #e7e4de;
  --text: #2b2926;
  --text-2: #7a7469;
  --text-3: #a8a196;
  --accent: #0f766e;
  --accent-strong: #0b5c55;
  --accent-bg: #e9f4f2;
  --amber: #d97706;
  --amber-bg: #fdf3e3;
  --code-bg: #f6f8fa;
  --code-bar-bg: #eef1f5;
  --code-inline-bg: #f1f1ec;
  --shadow-sm: 0 1px 2px rgba(43, 41, 38, 0.05), 0 1px 3px rgba(43, 41, 38, 0.06);
  --shadow-md: 0 4px 12px rgba(43, 41, 38, 0.08), 0 2px 4px rgba(43, 41, 38, 0.05);
  --shadow-lg: 0 12px 32px rgba(43, 41, 38, 0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Noto Serif SC", "Source Han Serif SC", "Songti SC",
    "SimSun", serif;
  --font-mono: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
  --radius: 12px;
  --header-h: 64px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1a1d21;
  --surface-2: #21252b;
  --border: #2c3138;
  --text: #e6e4df;
  --text-2: #9aa1ab;
  --text-3: #6b7280;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-bg: #14323a;
  --amber: #f59e0b;
  --amber-bg: #3a2d14;
  --code-bg: #0d1117;
  --code-bar-bg: #161b22;
  --code-inline-bg: #24292e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

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

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

img {
  max-width: 100%;
  border-radius: 8px;
}

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

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

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

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.logo:hover {
  color: var(--text);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.site-nav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.site-nav a {
  position: relative;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--text-2);
  transition: color 0.2s, background 0.2s;
}

.site-nav a:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

.site-nav a.active {
  color: var(--accent);
  font-weight: 600;
}

.site-nav a.active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.progress-bar {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--amber));
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* ---------- 首页 Hero ---------- */
.hero {
  position: relative;
  text-align: center;
  padding: 76px 0 56px;
  overflow: hidden;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  pointer-events: none;
}

.hero::before {
  width: 420px;
  height: 420px;
  top: -140px;
  left: -120px;
  background: var(--accent-bg);
}

.hero::after {
  width: 380px;
  height: 380px;
  bottom: -160px;
  right: -100px;
  background: var(--amber-bg);
}

.hero-kicker {
  position: relative;
  display: inline-block;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.hero-title {
  position: relative;
  font-family: var(--font-serif);
  font-size: clamp(34px, 5.5vw, 54px);
  line-height: 1.25;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
}

.hero-sub {
  position: relative;
  margin-top: 16px;
  color: var(--text-2);
  font-size: 17px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.hero-search {
  position: relative;
  max-width: 560px;
  margin: 34px auto 0;
}

.hero-search svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--text-3);
  pointer-events: none;
}

.hero-search input {
  width: 100%;
  padding: 14px 18px 14px 46px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.hero-search input::placeholder {
  color: var(--text-3);
}

.hero-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}

.hero-tags {
  position: relative;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-tags a {
  color: var(--text-2);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: color 0.2s, border-color 0.2s;
}

.hero-tags a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- 区块与卡片 ---------- */
.section {
  padding: 8px 0 40px;
}

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

.section-head h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  position: relative;
  padding-left: 14px;
}

.section-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--amber));
}

.result-count {
  font-size: 13px;
  color: var(--text-3);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow-md);
}

.card-featured {
  border-top: 3px solid var(--amber);
}

.featured-badge {
  position: absolute;
  top: -11px;
  right: 18px;
  font-size: 12px;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  padding: 2px 10px;
  border-radius: 999px;
}

.card-meta {
  display: flex;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-3);
}

.card-title {
  font-size: 18.5px;
  line-height: 1.45;
}

.card-title a {
  color: var(--text);
  transition: color 0.2s;
}

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

.card-featured .card-title {
  font-family: var(--font-serif);
  font-size: 22px;
}

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

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.chip {
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  padding: 3px 11px;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.chip:hover {
  background: var(--accent);
  color: #fff;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 0;
  color: var(--text-3);
}

/* ---------- 文章详情 ---------- */
.back-link {
  display: inline-block;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 26px;
  transition: color 0.2s, transform 0.2s;
}

.back-link:hover {
  color: var(--accent);
  transform: translateX(-2px);
}

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

.article-meta {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-3);
  margin-bottom: 12px;
}

.article-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.35;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.toc {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  padding-right: 4px;
}

.toc-inner {
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

.toc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 12px;
}

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

.toc-inner a {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-2);
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  margin-left: -19px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.toc-inner a.toc-h3 {
  padding-left: 24px;
  font-size: 13px;
  color: var(--text-3);
}

.toc-inner a:hover {
  color: var(--accent);
  background: var(--accent-bg);
  border-left-color: var(--accent);
}

.article-body {
  min-width: 0;
}

/* ---------- Markdown 排版 ---------- */
.markdown {
  font-size: 16.5px;
  line-height: 1.9;
  color: var(--text);
}

.markdown h2,
.markdown h3,
.markdown h4 {
  scroll-margin-top: calc(var(--header-h) + 20px);
  font-family: var(--font-serif);
  line-height: 1.4;
}

.markdown h2 {
  font-size: 1.5em;
  margin: 2em 0 0.75em;
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--border);
}

.markdown h3 {
  font-size: 1.22em;
  margin: 1.7em 0 0.6em;
}

.markdown h4 {
  font-size: 1.08em;
  margin: 1.5em 0 0.5em;
}

.markdown p {
  margin: 1em 0;
}

.markdown strong {
  font-weight: 700;
  color: var(--text);
}

.markdown em {
  color: var(--text);
}

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

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

.markdown li {
  margin: 0.4em 0;
}

.markdown li::marker {
  color: var(--accent);
}

.markdown blockquote {
  position: relative;
  margin: 1.4em 0;
  padding: 0.8em 1.2em;
  background: var(--accent-bg);
  border-radius: 0 10px 10px 0;
  border-left: 4px solid var(--accent);
  color: var(--text-2);
}

.markdown blockquote p {
  margin: 0.3em 0;
}

.markdown blockquote strong {
  color: var(--accent-strong);
}

.markdown code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-inline-bg);
  padding: 0.18em 0.45em;
  border-radius: 5px;
}

.markdown pre {
  position: relative;
  margin: 1.5em 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--code-bg);
}

.markdown pre code {
  display: block;
  padding: 18px 20px 20px;
  padding-top: 50px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.7;
  background: transparent;
}

.markdown pre code.hljs {
  background: transparent;
}

.codebar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--code-bar-bg);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-3);
  text-transform: uppercase;
}

.copy-btn {
  font-size: 12px;
  font-family: inherit;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}

.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}

.markdown table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95em;
  line-height: 1.6;
}

.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: 0.55em 0.9em;
  text-align: left;
  white-space: nowrap;
}

.markdown th {
  background: var(--surface-2);
  font-weight: 600;
}

.markdown tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2) 50%, transparent);
}

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

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

/* ---------- 上一篇 / 下一篇 ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.pager-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.pager-link span {
  font-size: 12px;
  color: var(--text-3);
}

.pager-link.next {
  text-align: right;
  align-items: flex-end;
}

/* ---------- 标签页 ---------- */
.page-head {
  padding: 48px 0 8px;
  text-align: center;
}

.page-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 4vw, 38px);
  margin: 10px 0 8px;
}

.page-head p {
  color: var(--text-2);
  font-size: 15px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  padding: 40px 0 60px;
  max-width: 760px;
  margin: 0 auto;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.tag-chip span {
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
}

.tag-chip.lg {
  font-size: 17px;
  padding: 10px 22px;
}

.tag-chip.xl {
  font-size: 20px;
  padding: 13px 26px;
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}

.tag-chip:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-md);
}

/* ---------- 关于页 ---------- */
.about-page {
  padding: 48px 0 60px;
}

.about-card {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 44px;
  box-shadow: var(--shadow-sm);
}

.about-avatar {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-family: var(--font-serif);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.about-card h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  margin-bottom: 14px;
}

.about-lead {
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.9;
}

.about-section {
  margin-top: 34px;
}

.about-section h2 {
  font-family: var(--font-serif);
  font-size: 19px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.about-section p,
.about-section ul {
  color: var(--text-2);
  line-height: 1.9;
}

.about-section ul {
  padding-left: 1.3em;
}

.about-section li {
  margin: 6px 0;
}

.stack-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stack-chips span {
  font-size: 13.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
}

.contact-links {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.contact-links a {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
}

.contact-links a:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.about-foot {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
  color: var(--text-3);
  font-size: 14px;
  text-align: center;
}

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 36px;
  margin-top: 60px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
}

.site-footer p + p {
  margin-top: 6px;
}

.footer-links a {
  color: var(--text-2);
  margin: 0 6px;
  transition: color 0.2s;
}

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

/* ---------- 返回顶部 ---------- */
.back-top {
  position: fixed;
  right: 26px;
  bottom: 30px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
  z-index: 40;
}

.back-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-top:hover {
  background: var(--accent-strong);
  transform: translateY(-2px);
}

/* ---------- 入场动画 ---------- */
.js .card,
.js .page-head,
.js .hero-inner,
.js .section,
.js .about-card {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.js .in {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .js .card,
  .js .page-head,
  .js .hero-inner,
  .js .section,
  .js .about-card {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .toc {
    display: none;
  }

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

  .about-card {
    padding: 32px 24px;
  }
}

@media (max-width: 560px) {
  .wrap {
    padding: 0 18px;
  }

  .hero {
    padding: 52px 0 40px;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .site-nav a {
    padding: 7px 10px;
  }

  .logo-text {
    display: none;
  }
}
