/* ============================================================
   linhut.cn — 全局样式（浅色为主，深色可切换）
   Astro 站点使用：public/css/style.css
   ============================================================ */

:root,
[data-theme="light"] {
  --bg: #fafafa;
  --bg-soft: #f0f2f5;
  --bg-card: #ffffff;
  --border: #e4e7ec;
  --text: #1f2329;
  --text-dim: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-2: #059669;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --code-bg: #f6f8fa;
  --radius: 12px;
  --maxw: 1000px;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-card: #1c2330;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --accent-2: #3fb950;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --code-bg: #161b22;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

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

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- 顶部导航 ---------- */
header.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.brand .logo-img { border-radius: 8px; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.brand .logo-img:hover { transform: scale(1.08); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
[data-theme="light"] .logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
.nav-links { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--text-dim); font-size: 15px; font-weight: 500; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--accent); font-weight: 600; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
[data-theme="light"] .icon-dark { display: none; }
[data-theme="dark"] .icon-light { display: none; }

/* ---------- Hero 介绍 ---------- */
.hero {
  padding: 80px 0 60px;
  text-align: center;
  background:
    radial-gradient(700px circle at 15% 0%, rgba(37, 99, 235, 0.08), transparent 45%),
    radial-gradient(700px circle at 85% 20%, rgba(5, 150, 105, 0.07), transparent 45%);
}
.hero h1 { font-size: 44px; font-weight: 800; letter-spacing: -1px; margin-bottom: 14px; }
.hero h1 .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p.tagline { color: var(--text-dim); font-size: 18px; max-width: 620px; margin: 0 auto 26px; }
.hero-badges { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.badge {
  padding: 7px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-card);
}
.cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn-ghost {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 区块 ---------- */
.section { padding: 44px 0; }
.section-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.section-head h2 { font-size: 25px; font-weight: 700; }
.section-head .line { flex: 1; height: 1px; background: var(--border); }
.section-head .sub { color: var(--text-dim); font-size: 14px; }
.section-head .sub a { color: var(--accent); }

/* ---------- 关于卡片 ---------- */
.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow);
}
.about-card p { margin: 10px 0; }

/* ---------- 项目卡片 ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.project-card .p-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.project-card h3 { font-size: 17px; font-weight: 700; }
.project-card .stars { font-size: 13px; color: var(--accent-2); }
.project-card .desc { color: var(--text-dim); font-size: 13.5px; margin-bottom: 12px; min-height: 42px; }
.project-card .lang { font-size: 12.5px; color: var(--text-dim); }
.tag {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}

/* ---------- 文章列表 ---------- */
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.post-row:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.post-row .pr-title { font-size: 16px; font-weight: 600; color: var(--text); }
.post-row:hover .pr-title { color: var(--accent); }
.post-row .pr-date { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* ---------- 列表页工具条 ---------- */
.list-toolbar { max-width: 780px; margin: 0 auto 24px; display: flex; flex-direction: column; gap: 14px; }
.search-box { position: relative; max-width: 420px; width: 100%; margin: 0 auto; }
.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box::before {
  content: "🔍";
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.6;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.filter-chips .chip {
  cursor: pointer;
  font-size: 12.5px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  user-select: none;
}
.filter-chips .chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chips .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-chips .chip .cnt { opacity: 0.7; font-size: 11px; margin-left: 3px; }

/* 年份分组 */
.year-group { max-width: 780px; margin: 0 auto 30px; }
.year-group .year-title { display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 700; margin-bottom: 14px; }
.year-group .year-title .count {
  font-size: 12.5px; font-weight: 500;
  color: var(--text-dim);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 999px;
}
.year-group .year-title .line { flex: 1; height: 1px; background: var(--border); }

/* 卡片式文章条目 */
.post-cards { display: flex; flex-direction: column; gap: 14px; }
.post-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.post-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }
.post-card .pc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.post-card .pc-title { font-size: 16.5px; font-weight: 700; color: var(--text); line-height: 1.45; }
.post-card:hover .pc-title { color: var(--accent); }
.post-card .pc-date { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }
.post-card .pc-summary { color: var(--text-dim); font-size: 13.5px; line-height: 1.6; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.post-card .pc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.post-card .pc-more { font-size: 13px; color: var(--accent); font-weight: 500; white-space: nowrap; }

.no-result { display: none; text-align: center; padding: 50px 0; color: var(--text-dim); }
.no-result.show { display: block; }

/* ---------- 列表页头 ---------- */
.page-head { padding: 56px 0 18px; text-align: center; }
.page-head h1 { font-size: 32px; font-weight: 800; }
.page-head p { color: var(--text-dim); margin-top: 6px; }

/* ---------- 文章页 ---------- */
.reading-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); z-index: 200; transition: width 0.1s linear; }
.article { padding: 40px 0 60px; }
.article-header { max-width: 780px; margin: 0 auto 24px; }
.article h1 { font-size: 30px; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.5px; }
.article .post-meta { color: var(--text-dim); font-size: 13.5px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.article-wrap { max-width: 780px; margin: 0 auto; display: flex; gap: 32px; align-items: flex-start; }
.article-body {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow);
  font-size: 15.5px;
  line-height: 1.85;
  word-break: break-word;
}
.article-body h2 { font-size: 22px; font-weight: 700; margin: 32px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); scroll-margin-top: 70px; }
.article-body h3 { font-size: 18.5px; font-weight: 700; margin: 26px 0 12px; scroll-margin-top: 70px; }
.article-body p { margin: 13px 0; }
.article-body ul, .article-body ol { margin: 13px 0 13px 26px; }
.article-body li { margin: 5px 0; }
.article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 13.5px;
  line-height: 1.6;
}
.article-body code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: rgba(31, 35, 41, 0.07);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
[data-theme="dark"] .article-body code { background: rgba(110, 118, 129, 0.2); }
.article-body pre code { background: none; padding: 0; }
.article-body blockquote {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 18px;
  margin: 16px 0;
  color: var(--text-dim);
  border-radius: 0 8px 8px 0;
}
.article-body img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); margin: 8px 0; }
.article-body table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 8px 13px; text-align: left; }
.article-body th { background: var(--bg-soft); font-weight: 600; }

/* 侧边目录 TOC */
.toc { position: sticky; top: 76px; width: 230px; flex-shrink: 0; max-height: calc(100vh - 100px); overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; }
.toc-title { font-weight: 700; font-size: 13px; color: var(--text-dim); margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { margin-left: 13px; }
.toc a { display: block; color: var(--text-dim); padding: 4px 6px; border-radius: 6px; line-height: 1.5; border-left: 2px solid transparent; }
.toc a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }

/* 上下篇导航 */
.post-nav { max-width: 780px; margin: 26px auto 0; display: flex; gap: 14px; }
.post-nav .nav-card { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; transition: border-color 0.2s, box-shadow 0.2s; }
.post-nav .nav-card:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.post-nav .nav-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.post-nav .nav-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.post-nav .nav-card:hover .nav-title { color: var(--accent); }
.post-nav .nav-card.next { text-align: right; }

/* 返回顶部 */
.back-top { position: fixed; right: 24px; bottom: 24px; width: 42px; height: 42px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.2s; box-shadow: var(--shadow); z-index: 150; }
.back-top.show { opacity: 1; visibility: visible; }
.back-top:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 页脚 ---------- */
footer { border-top: 1px solid var(--border); padding: 32px 0; margin-top: 30px; color: var(--text-dim); font-size: 14px; text-align: center; }
footer .links { display: flex; gap: 20px; justify-content: center; margin-bottom: 10px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .toc { display: none; }
  .nav-links { gap: 14px; }
}
@media (max-width: 640px) {
  .hero h1 { font-size: 32px; }
  .hero p.tagline { font-size: 16px; }
  .post-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .article-body { padding: 20px 18px; }
  .projects-grid { grid-template-columns: 1fr; }
}
