/* ============================================================
   前台样式 —— 无外部依赖，自带深色模式
   ============================================================ */

:root {
  --bg:        #faf9f7;
  --surface:   #ffffff;
  --text:      #1f1d1a;
  --muted:     #7c766e;
  --line:      #e7e3dd;
  --accent:    #2f6f4e;
  --accent-bg: #eaf2ed;
  --pin:       #b45309;
  --pin-bg:    #fdf2e4;
  --maxw:      720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #161917;
    --surface:   #1d211f;
    --text:      #e8e6e2;
    --muted:     #98928a;
    --line:      #2c3230;
    --accent:    #7cc4a0;
    --accent-bg: #1e2b25;
    --pin:       #e0a458;
    --pin-bg:    #2e2418;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 22px; position: relative; z-index: 1; }

/* ---------- 首页左侧背景图 ----------
   固定贴在视口左边、贴着底部，缩放到满屏高度；
   文字层（.wrap）z-index 更高，所有内容都压在图上。
   原图直接铺，不叠加任何渐变 / 遮罩。 */
.page-bg {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(36vw, 470px);
  background: url("/assets/pony-bg.png") left bottom / contain no-repeat;
  pointer-events: none;
  z-index: 0;
}

/* 窄屏没有「左边」，背景图会直接压住正文，干脆不显示 */
@media (max-width: 700px) {
  .page-bg { display: none; }
}

a { color: var(--accent); text-decoration: none; transition: opacity .15s ease; }
a:hover { opacity: .75; }

/* ---------- 顶部 ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 62px;
}
.brand { font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: .02em; }
.brand:hover { opacity: 1; color: var(--accent); }
.nav { display: flex; gap: 20px; font-size: 15px; }
.nav a { color: var(--muted); }
.nav a:hover, .nav a.active { color: var(--accent); opacity: 1; }

/* ---------- 首页引导 ---------- */
.intro { padding: 52px 0 34px; border-bottom: 1px solid var(--line); }
.intro h1 { margin: 0 0 12px; font-size: 27px; font-weight: 650; line-height: 1.4; letter-spacing: -.01em; }
.intro p { margin: 0; color: var(--muted); font-size: 15.5px; max-width: 34em; }

/* ---------- 文章列表 ---------- */
.posts { padding: 8px 0 30px; }

.post-item { padding: 26px 0; border-bottom: 1px solid var(--line); }
.post-item:last-child { border-bottom: none; }

.post-meta {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.post-meta time {
  color: var(--muted); font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.pin {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--pin);
  background: var(--pin-bg);
  border-radius: 4px;
  font-weight: 500;
}

.post-item h2 { margin: 0 0 8px; font-size: 19.5px; font-weight: 600; line-height: 1.5; }
.post-item h2 a { color: var(--text); }
.post-item h2 a:hover { color: var(--accent); opacity: 1; }

.excerpt { margin: 0; color: var(--muted); font-size: 15px; }

.empty { padding: 70px 0; text-align: center; color: var(--muted); }
.empty .hint { font-size: 14px; }

/* ---------- 分页 ---------- */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.pager .disabled { color: var(--line); }
.pager-info { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- 文章页 ---------- */
.article { padding: 46px 0 30px; }
.article-head { margin-bottom: 34px; }
.article-head h1 {
  margin: 0 0 12px; font-size: 28px; font-weight: 650;
  line-height: 1.42; letter-spacing: -.01em;
}
.article-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  color: var(--muted); font-size: 14px; margin: 0;
}
.article-meta .updated { font-size: 13px; }

.article-body { font-size: 16.5px; display: flow-root; }
.article-body > *:first-child { margin-top: 0; }

.article-body h2 {
  margin: 2.2em 0 .7em; font-size: 20px; font-weight: 600;
  padding-left: 11px; border-left: 3px solid var(--accent); line-height: 1.5;
}
.article-body h3 { margin: 1.8em 0 .6em; font-size: 17px; font-weight: 600; }
.article-body h4 { margin: 1.6em 0 .5em; font-size: 16px; font-weight: 600; }

.article-body p { margin: 0 0 1.15em; }
.article-body ul, .article-body ol { margin: 0 0 1.15em; padding-left: 1.4em; }
.article-body li { margin-bottom: .45em; }

.article-body blockquote {
  margin: 1.4em 0; padding: 4px 18px;
  border-left: 3px solid var(--line); color: var(--muted);
}

.article-body code {
  background: var(--accent-bg); color: var(--accent);
  padding: 2px 6px; border-radius: 4px; font-size: .88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.article-body pre {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; overflow-x: auto;
  line-height: 1.65; margin: 0 0 1.3em;
}
.article-body pre code {
  background: none; color: var(--text); padding: 0; font-size: 13.5px;
}

.article-body hr { border: none; border-top: 1px solid var(--line); margin: 2.4em 0; }

/* ---------- 正文图片（插入图片功能的表现） ---------- */
.article-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6em auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

/* 图片版式：在地址后面加 {left} / {right} / {center} / {full}
   {left} 左浮动、文字绕排；高度用视口宽度控制，窄屏不会顶满整屏 */
.article-body img.md-img-left,
.article-body img.md-img-right {
  display: block;
  height: clamp(230px, 26vw, 400px);
  width: auto;
  max-width: 46%;
  margin: .45em 0 1em;
  border: 0;
  border-radius: 0;
  background: none;
}
.article-body img.md-img-left  { float: left;  margin-right: 1.6em; }
.article-body img.md-img-right { float: right; margin-left: 1.6em; }
.article-body img.md-img-center { display: block; margin: 1.6em auto; }
.article-body img.md-img-full   { display: block; width: 100%; max-width: 100%; margin: 1.6em auto; }

.back-link {
  display: inline-block; margin-top: 42px; padding-top: 22px;
  border-top: 1px solid var(--line); width: 100%;
  font-size: 15px; color: var(--muted);
}
.back-link:hover { color: var(--accent); }

/* ---------- 404 ---------- */
.placeholder {
  min-height: 55vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 10px;
}
.placeholder h1 { font-size: 22px; font-weight: 600; margin: 0; }
.placeholder p { color: var(--muted); margin: 0; font-size: 15px; }

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 30px; border-top: 1px solid var(--line);
  background: var(--surface); padding: 30px 0 38px; text-align: center;
}
.site-footer p { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer .legal a { color: var(--muted); }
.site-footer .legal a:hover { color: var(--accent); }
/* 备案号之间的分隔点 + 网安备案图标（图标缺失时自动不渲染） */
.site-footer .legal .sep { color: var(--muted); margin: 0 6px; }
.site-footer .legal .beian-icon {
  width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px;
}

/* ---------- 移动端 ---------- */
@media (max-width: 600px) {
  body { font-size: 15.5px; }
  .intro { padding: 38px 0 26px; }
  .intro h1 { font-size: 23px; }
  .article-head h1 { font-size: 23px; }
  .article-body { font-size: 16px; }
  .header-inner { height: 56px; }

  /* 窄屏上浮动图容易把文字挤成一条，改成居中的小图 */
  .article-body img.md-img-left,
  .article-body img.md-img-right {
    float: none;
    height: auto;
    width: 58%;
    max-width: 58%;
    margin: 1.4em auto;
  }
}
