/* Gramtopia 语法社 · 博客样式 */
:root {
  --paper: #F0EEEB;
  --paper-deep: #E7E4DF;
  --ink: #161616;
  --ink-2: rgba(0, 0, 0, .55);
  --ink-3: rgba(0, 0, 0, .38);
  --line: rgba(0, 0, 0, .28);
  --accent: #6756bd;
  --cat-grammar: #6756bd;
  --cat-method: #41674e;
  --cat-news: #dd2727;
  --footer: #0E0E0E;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

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

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(103, 86, 189, .22); }

a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 28px; }
.wrap--reading { max-width: 720px; }

/* ---------- 头部导航 ---------- */
.site-header {
  border-bottom: 1px dotted var(--line);
}
.site-header .wrap {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding-top: 22px; padding-bottom: 18px; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 10px; }
.brand-logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; display: block; }
.brand .brand-sub { color: var(--ink-3); font-weight: 500; font-size: 13px; margin-left: 4px; }
.nav { display: flex; gap: 22px; font-family: var(--mono); font-size: 12.5px; }
.nav a { color: var(--ink-2); }
.nav a::before { content: "["; color: var(--ink-3); }
.nav a::after { content: "]"; color: var(--ink-3); }
.nav a:hover { color: var(--accent); }

/* 下划线滑动动画（从右向左展开） */
.u-link {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 100% 100%;
  transition: background-size .3s ease, color .2s ease;
  padding-bottom: 2px;
}
.u-link:hover { background-size: 100% 1px; background-position: 0 100%; }

/* ---------- 首页 Hero ---------- */
.hero { padding: 72px 0 40px; }
.hero h1 {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 800; line-height: 1.15; letter-spacing: .01em;
}
.hero .hero-desc { margin-top: 16px; color: var(--ink-2); font-size: 15.5px; max-width: 34em; }
.hero .hero-count { margin-top: 22px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* ---------- 首页搜索 ---------- */
.search-section { padding: 56px 0 28px; }
.search-box { position: relative; }
.search-box input {
  width: 100%; padding: 16px 20px; padding-right: 110px;
  font-size: 16px; font-family: var(--sans);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  outline: none; transition: border-color .2s ease, box-shadow .2s ease;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 4px 16px rgba(103,86,189,.12); }
.search-count {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 12px; color: var(--ink-3); pointer-events: none;
}
mark {
  background: rgba(103, 86, 189, .18);
  color: inherit; padding: 1px 2px; border-radius: 3px;
}

/* ---------- 文章索引列表 ---------- */
.post-list { border-top: 1px dotted var(--line); }
.post-row { display: block; padding: 30px 0 32px; border-bottom: 1px dotted var(--line); }
.post-meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}
.post-meta .date::before { content: "["; color: var(--ink-3); }
.post-meta .date::after { content: "]"; color: var(--ink-3); }
.cat { display: inline-flex; align-items: center; gap: 7px; }
.cat::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.cat--grammar::before { background: var(--cat-grammar); }
.cat--method::before { background: var(--cat-method); }
.cat--news::before { background: var(--cat-news); }
.post-title {
  margin-top: 12px;
  font-size: clamp(20px, 2.8vw, 29px);
  font-weight: 700; line-height: 1.4;
  transition: color .2s ease, transform .3s ease;
}
.post-row:hover .post-title { color: var(--accent); transform: translateX(6px); }
.post-excerpt {
  margin-top: 10px; color: var(--ink-2); font-size: 15px; line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.list-foot { padding: 34px 0 70px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* ---------- 文章页 ---------- */
.post-head { padding: 56px 0 30px; }
.back-link {
  display: inline-block; font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 16px;
  transition: color .2s ease, border-color .2s ease;
}
.back-link:hover { color: var(--accent); border-color: var(--accent); }
.post-head h1 {
  margin-top: 26px;
  font-size: clamp(28px, 4.6vw, 42px);
  font-weight: 800; line-height: 1.35;
}
.post-head .post-meta { margin-top: 18px; }

.post-body { padding: 8px 0 70px; font-size: 16.5px; line-height: 1.9; }
.post-source { margin: -50px 0 60px; }
.post-source a {
  display: inline-block; padding: 10px 22px; border-radius: 999px;
  background: #6756bd; color: #fff; font-size: 15px; text-decoration: none;
}
.post-body > p { margin: 1.1em 0; }
.post-body h2 {
  margin: 2.4em 0 .9em; font-size: 23px; font-weight: 700; line-height: 1.45;
  padding-top: 1.2em; border-top: 1px dotted var(--line);
}
.post-body h3 { margin: 2em 0 .7em; font-size: 18.5px; font-weight: 700; }
.post-body strong { font-weight: 700; }
.post-body ul, .post-body ol { margin: 1.1em 0; padding-left: 1.6em; }
.post-body li { margin: .45em 0; }
.post-body li::marker { color: var(--accent); font-family: var(--mono); }
.post-body a { color: var(--accent); }
.post-body blockquote {
  margin: 1.6em 0; padding: 18px 22px;
  background: var(--paper-deep); border-radius: 10px;
  color: rgba(0, 0, 0, .68); font-size: 15.5px;
}
.post-body blockquote p { margin: .4em 0; }
.post-body code {
  font-family: var(--mono); font-size: .86em;
  background: rgba(0, 0, 0, .06); border-radius: 5px; padding: 2px 6px;
}
.post-body pre {
  margin: 1.6em 0; padding: 18px 20px; overflow-x: auto;
  background: var(--footer); color: #eaeaea; border-radius: 10px;
  font-size: 13.5px; line-height: 1.7;
}
.post-body pre code { background: none; padding: 0; color: inherit; }
.post-body hr { border: none; border-top: 1px dotted var(--line); margin: 2.6em 0; }
.post-body img { max-width: 100%; border-radius: 10px; display: block; margin: 1.6em auto; }
.post-body table {
  width: 100%; border-collapse: collapse; margin: 1.6em 0; font-size: 15px;
}
.post-body th, .post-body td {
  padding: 10px 12px; border-bottom: 1px dotted var(--line); text-align: left;
}
.post-body th { font-weight: 700; font-size: 14px; color: var(--ink-2); }

.post-nav { padding: 0 0 80px; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* ---------- 页脚（与主站首页一致） ---------- */
.home-footer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
  min-height: 0;
  overflow: hidden;
  background: var(--footer);
}
.home-footer .disclaimer {
  margin-top: 0;
  margin-bottom: 2px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
}
.site-footer {
  background: var(--footer);
  color: rgba(255, 255, 255, 0.88);
  text-align: center;
  padding: 2px 0;
  font-size: 10px;
  line-height: 1.4;
}
.site-footer p { margin: 1px 0; line-height: 1.4; }
.site-footer a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: underline;
}
.site-footer a:hover { color: #fff; }
.home-footer a {
  -webkit-tap-highlight-color: transparent;
}
.home-footer a:active {
  transform: scale(0.97);
  opacity: 0.9;
  transition: transform 0.15s, opacity 0.15s;
}
.hp-help {
  padding: 0;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.95);
  font-size: inherit;
  line-height: 1;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s ease;
}
.hp-help:hover { color: #fff; }
.hp-help:active { color: rgba(255, 255, 255, 1); }

/* 保留旧类名兼容（如有其他页面引用） */
.footer-pills { display: flex; gap: 12px; flex-wrap: wrap; }
.footer-pills a {
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px;
  padding: 7px 20px; font-size: 13.5px; font-weight: 600; color: #fff;
  transition: background .25s ease, color .25s ease, border-color .25s ease;
}
.footer-pills a:hover { background: #fff; color: var(--footer); border-color: #fff; }
.footer-colophon {
  margin-top: 26px; font-family: var(--mono); font-size: 11.5px;
  color: rgba(255, 255, 255, .38); line-height: 1.9;
}

@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  .hero { padding: 52px 0 32px; }
  .search-section { padding: 40px 0 22px; }
  .search-box input { padding: 14px 16px; padding-right: 100px; font-size: 15px; }
  .brand-logo { width: 24px; height: 24px; }
  .brand { font-size: 15px; gap: 8px; }
  .nav { gap: 14px; font-size: 11.5px; }
  .post-row { padding: 24px 0 26px; }
  .post-head { padding: 40px 0 24px; }
  .post-body { font-size: 16px; }
}

/* ---------- 标签 chips ---------- */
.tag {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
}
.tag--link { color: var(--ink-2); transition: color .2s ease; }
.tag--link:hover { color: var(--accent); }
.post-tags { margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- 紧凑 Hero（标签页 / 图谱页） ---------- */
.hero--compact { padding: 48px 0 30px; }
.hero--compact h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 800; line-height: 1.2; }
.hero--compact .tag-title { margin-top: 22px; }
.hero--compact .back-link + h1 { margin-top: 22px; }
.hero--compact .hero-count { margin-top: 14px; }
.hero--compact .hero-count a { color: var(--accent); }

/* ---------- 标签索引 ---------- */
.tag-list {
  border-top: 1px dotted var(--line);
  padding: 10px 0 70px;
}
.tag-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 18px 0; border-bottom: 1px dotted var(--line);
  transition: transform .3s ease;
}
.tag-item:hover { transform: translateX(6px); }
.tag-item-name { font-size: 19px; font-weight: 700; transition: color .2s ease; }
.tag-item:hover .tag-item-name { color: var(--accent); }
.tag-item-count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* ---------- 分类聚合 ---------- */
.cat-section { padding: 0 0 50px; }
.cat-section-title { margin-bottom: 18px; font-size: 24px; font-weight: 800; }
.cat-section-title .cat { font-family: var(--sans); font-size: inherit; font-weight: inherit; }

/* ---------- 关系图谱 ---------- */
.graph-legend { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
.graph-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.graph-box {
  border-top: 1px dotted var(--line); border-bottom: 1px dotted var(--line);
  margin: 10px 0 70px;
}
#graphCanvas {
  display: block; width: 100%; height: 68vh; min-height: 420px;
  cursor: grab; touch-action: none;
}
#graphCanvas.dragging { cursor: grabbing; }

/* ---------- 草稿徽标（仅 dev 构建出现） ---------- */
.draft-badge {
  font-family: var(--mono); font-size: 11px; color: #b7791f;
  border: 1px dashed #b7791f; border-radius: 4px; padding: 1px 7px;
  white-space: nowrap;
}
