/* ============================================================
   知行笔记 — 全局样式
   设计原则：移动端优先、系统字体栈（不引外部字体，国内/微信秒开）、
   通过 CSS 自定义属性支持明/暗双主题。
   ============================================================ */

:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f0f0f6;
  --text: #1c1c28;
  --text-muted: #6b6b7b;
  --border: #e6e6ef;
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef0ff;
  --shadow: 0 6px 24px rgba(28, 28, 40, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1080px;
  --header-h: 60px;
}

html[data-theme="dark"] {
  --bg: #0f1016;
  --surface: #1a1b24;
  --surface-2: #23242f;
  --text: #ececf3;
  --text-muted: #9a9aac;
  --border: #2c2d3a;
  --primary: #818cf8;
  --primary-strong: #a5b0ff;
  --primary-soft: #23254a;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
  min-height: 100dvh;
}

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

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

code {
  background: var(--surface-2);
  padding: 0.15em 0.4em;
  border-radius: 6px;
  font-size: 0.9em;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: 720px; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex; align-items: center;
}
.header-inner { display: flex; align-items: center; gap: 16px; width: 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; font-size: 16px; font-weight: 800;
}
.brand-text { font-size: 1.05rem; letter-spacing: 0.3px; }
.site-nav { margin-left: auto; display: flex; gap: 4px; }
.site-nav a {
  color: var(--text-muted); padding: 8px 12px; border-radius: 999px; font-size: 0.95rem;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-nav a.active { color: var(--primary); background: var(--primary-soft); }

.theme-toggle {
  margin-left: 8px;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 18px; line-height: 1; display: grid; place-items: center;
  transition: background 0.2s ease, transform 0.1s ease;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Hero ---------- */
.hero { padding: 64px 0 40px; }
.hero-eyebrow {
  display: inline-block; color: var(--primary); background: var(--primary-soft);
  padding: 4px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; margin: 0 0 14px;
}
.hero-title { font-size: clamp(1.9rem, 6vw, 3rem); line-height: 1.2; margin: 0 0 14px; letter-spacing: -0.5px; }
.hero-sub { font-size: clamp(1rem, 2.5vw, 1.15rem); color: var(--text-muted); max-width: 620px; margin: 0 0 24px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; font-size: 0.98rem;
  border: 1px solid transparent; cursor: pointer; transition: transform 0.1s ease, background 0.2s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

/* ---------- Posts ---------- */
.posts { padding: 24px 0 56px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.5rem; margin: 0; }
.muted { color: var(--text-muted); }

.post-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.post-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(28,28,40,0.12); border-color: var(--primary); }
.post-card:focus-within { border-color: var(--primary); }
.post-cover {
  height: 140px; border-radius: var(--radius-sm); display: grid; place-items: center;
  font-size: 2.4rem; color: #fff; background: linear-gradient(135deg, var(--primary), #8b5cf6);
}
.post-card h3 { margin: 4px 0 0; font-size: 1.15rem; line-height: 1.4; }
.post-card h3 a { color: var(--text); }
.post-card h3 a:hover { color: var(--primary); }
.post-excerpt { color: var(--text-muted); font-size: 0.95rem; margin: 0; flex: 1; }
.post-meta { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--text-muted); flex-wrap: wrap; }
.tag { background: var(--surface-2); color: var(--text-muted); padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; }
.loading { color: var(--text-muted); }

/* ---------- Hub 卡片（外宣链接汇总，整卡可点跳外部原文） ---------- */
.hub-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.hub-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(28,28,40,0.12); border-color: var(--primary); text-decoration: none; }
.hub-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-color: var(--primary); }
.hub-cover {
  height: 128px; border-radius: var(--radius-sm); display: grid; place-items: center;
  font-size: 2.2rem; color: #fff; background: linear-gradient(135deg, var(--primary), #8b5cf6);
}
.hub-card h3 { margin: 2px 0 0; font-size: 1.1rem; line-height: 1.4; color: var(--text); }
.hub-desc { color: var(--text-muted); font-size: 0.92rem; margin: 0; flex: 1; }
.hub-meta { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); flex-wrap: wrap; }
.hub-go { align-self: flex-start; margin-top: 2px; font-size: 0.85rem; color: var(--primary); font-weight: 600; }

/* ---------- About ---------- */
.about { padding: 48px 0; border-top: 1px solid var(--border); background: var(--surface); }
.about-inner { display: grid; gap: 28px; grid-template-columns: 1fr; }
.about-text h2 { font-size: 1.5rem; margin: 0 0 12px; }
.about-text p { color: var(--text-muted); margin: 0 0 12px; }
.about-text ol { margin: 0; padding-left: 1.3em; color: var(--text-muted); }
.about-text li { margin-bottom: 8px; }
.about-text strong { color: var(--text); }
.about-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.about-card h3 { margin: 0 0 10px; }
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }

/* ---------- Article ---------- */
.article { padding: 32px 0 64px; }
.back-link { display: inline-block; margin-bottom: 18px; color: var(--text-muted); font-size: 0.92rem; }
.article-header { margin-bottom: 24px; }
.article-header h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.3; margin: 0 0 12px; letter-spacing: -0.4px; }
.article-cover {
  height: 200px; border-radius: var(--radius); display: grid; place-items: center;
  font-size: 3rem; color: #fff; background: linear-gradient(135deg, var(--primary), #8b5cf6); margin: 18px 0;
}
.article-content { font-size: 1.05rem; }
.article-content h2 { font-size: 1.4rem; margin: 1.6em 0 0.6em; }
.article-content h3 { font-size: 1.15rem; margin: 1.4em 0 0.5em; }
.article-content p { margin: 0 0 1em; }
.article-content ul, .article-content ol { margin: 0 0 1em; padding-left: 1.4em; }
.article-content blockquote {
  margin: 1.2em 0; padding: 12px 18px; border-left: 4px solid var(--primary);
  background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-muted);
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; background: var(--surface); }
.footer-inner { display: flex; flex-direction: column; gap: 4px; }
.footer-inner p { margin: 0; font-size: 0.9rem; }

/* ---------- 响应式 ---------- */
@media (min-width: 720px) {
  .about-inner { grid-template-columns: 1.6fr 1fr; align-items: start; }
}
@media (max-width: 560px) {
  .hero { padding: 44px 0 28px; }
  .site-nav { display: none; }            /* 移动端精简导航，保留品牌与主题切换 */
  .brand-text { font-size: 1rem; }
  .post-grid { grid-template-columns: 1fr; }
}
