/* ==========================================================================
   yanger blog · post.css
   文章排版 / 代码块 / 表格 / 目录 / 上一篇·下一篇
   ========================================================================== */

.post { padding-top: 44px; }
.post-error { margin-top: 44px; }
.post-header { margin-bottom: 40px; }
.post-title {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: clamp(28px, 4.5vw, 42px);
  font-weight: 400; line-height: 1.35;
}
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; font-size: 13.5px; color: var(--faint); }
.post-meta time { font-variant-numeric: tabular-nums; }
.post-meta .tag-list { gap: 6px; }

/* ---------- 正文排版 ---------- */
.post-body { font-size: 16.5px; line-height: 1.9; }
.post-body > *:first-child { margin-top: 0; }
.post-body h2 { font-size: 1.35em; font-weight: 600; margin: 2.2em 0 .8em; }
.post-body h3 { font-size: 1.15em; font-weight: 600; margin: 1.8em 0 .6em; }
.post-body h4 { font-size: 1.02em; font-weight: 600; margin: 1.6em 0 .5em; }
.post-body h2, .post-body h3, .post-body h4 { scroll-margin-top: calc(var(--header-h) + 24px); }
.post-body p { margin: 1em 0; }
.post-body ul, .post-body ol { margin: 1em 0; padding-left: 1.5em; }
.post-body li { margin: .35em 0; }
.post-body li::marker { color: var(--faint); }
.post-body blockquote {
  margin: 1.4em 0; padding: .2em 0 .2em 1.2em;
  border-left: 2px solid var(--rule-strong);
  color: var(--muted);
}
.post-body blockquote p { margin: .5em 0; }
.post-body hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }
.post-body a {
  text-decoration: underline; text-decoration-thickness: 1px;
  text-decoration-color: var(--faint); text-underline-offset: .25em;
  transition: text-decoration-color .25s;
}
.post-body a:hover { text-decoration-color: var(--ink); }
.post-body strong { font-weight: 600; }
.post-body img { display: block; margin: 1.6em auto; border-radius: 10px; }

/* ---------- 代码 ---------- */
.post-body code {
  padding: .18em .42em; border-radius: 5px;
  background: var(--surface);
  font-family: var(--mono); font-size: .88em;
}
.post-body pre {
  margin: 1.5em 0; padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: 12px;
  overflow-x: auto; line-height: 1.7;
}
.post-body pre code { display: block; padding: 0; background: none; border-radius: 0; font-size: 13.5px; }

/* ---------- 表格 ---------- */
.post-body table { width: 100%; margin: 1.5em 0; border-collapse: collapse; font-size: 14.5px; }
.post-body th, .post-body td { padding: 10px 14px; border: 1px solid var(--rule); text-align: left; }
.post-body th { font-weight: 600; background: var(--surface); }

/* ---------- 目录 ---------- */
/* 侧栏目录可滚动但隐藏滚动条（与 base.css 里 html/body 的处理一致） */
.toc { font-size: 13.5px; scrollbar-width: none; -ms-overflow-style: none; }
.toc::-webkit-scrollbar { display: none; width: 0; height: 0; }
.toc-list { display: flex; flex-direction: column; gap: 2px; list-style: none; margin: 0; padding: 0; }
.toc-list a {
  display: block; padding: 5px 10px;
  border-left: 2px solid var(--rule);
  color: var(--muted); text-decoration: none; line-height: 1.5;
  transition: color .2s, border-color .2s;
}
.toc-list a:hover { color: var(--ink); }
.toc-list a[aria-current="true"] { color: var(--ink); border-left-color: var(--ink); }
.toc-list .toc-h3 a { padding-left: 24px; }

/* 移动端：折叠面板（置于文章上方） */
@media (max-width: 1099.98px) {
  .toc { order: -1; border: 1px solid var(--rule); border-radius: 12px; padding: 10px 14px 14px; }
  .toc-list { display: none; margin-top: 10px; }
  .toc.is-open .toc-list { display: flex; }
}
@media (min-width: 1100px) {
  .toc-toggle { display: none; }
}

/* ---------- 上一篇 / 下一篇 ---------- */
.post-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 64px; padding-top: 28px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
}
.post-nav a { display: block; text-decoration: none; color: var(--muted); line-height: 1.6; transition: color .25s; }
.post-nav a:hover { color: var(--ink); }
.post-nav .nav-next { text-align: right; }
.post-nav .nav-label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--faint); }

/* ---------- 正文图片查看器 ---------- */
.post-body img.is-zoomable { cursor: zoom-in; }
.post-body img.is-zoomable:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

/* 查看器始终使用深色底，避免浅色主题下黑底图片与页面融为一体 */
.image-viewer {
  position: fixed; inset: 0;
  width: auto; height: auto;
  max-width: none; max-height: none;
  margin: 0; padding: 0;
  border: 0;
  overflow: hidden;
  background: #0b0907f2;
  color: #f2ece1;
  overscroll-behavior: contain;
  transition: none;
}
.image-viewer[open] {
  display: flex; flex-direction: column;
  animation: image-viewer-in .2s ease-out;
}
.image-viewer::backdrop {
  background: #0b0907d9;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.image-viewer__bar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(14px, env(safe-area-inset-top, 0px)) clamp(16px, 3vw, 28px) 6px;
}
.image-viewer__title {
  margin: 0;
  font-size: 13px; letter-spacing: .12em;
  color: #f2ece19e;
}
.image-viewer__close {
  display: inline-flex; align-items: center; gap: 6px;
  flex: none;
  min-height: 40px;
  padding: 7px 14px 7px 11px;
  border: 1px solid #f2ece145; border-radius: 999px;
  background: #f2ece10f; color: #f2ece1;
  font-size: 13px; line-height: 1.2; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s, border-color .2s;
}
.image-viewer__close:hover { background: #f2ece126; border-color: #f2ece180; }
.image-viewer__close:focus-visible { outline: 2px solid #f2ece1; outline-offset: 3px; }
.image-viewer__close svg { width: 16px; height: 16px; }

.image-viewer__stage {
  flex: 1 1 auto;
  min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 10px clamp(16px, 3vw, 28px);
  overflow: hidden;
}
.image-viewer__img {
  display: block;
  width: auto; height: auto;
  max-width: 100%; max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 24px 80px #00000080;
  -webkit-user-drag: none;
  user-select: none;
  animation: image-viewer-pop .24s cubic-bezier(.22, 1, .36, 1);
}

.image-viewer__hint {
  flex: none;
  margin: 0;
  padding: 10px 16px max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  text-align: center;
  font-size: 12px;
  color: #f2ece17a;
}

/* 弹窗打开时锁住文章滚动容器；dialog 本身负责背景 inert */
html.image-viewer-open main { overflow: hidden; }

@media (max-width: 479px) {
  .image-viewer__title { display: none; }
  .image-viewer__bar { justify-content: flex-end; }
  .image-viewer__stage { padding-inline: 12px; }
}
@media (hover: none) {
  .image-viewer__hint-esc { display: none; }
}

@keyframes image-viewer-in { from { opacity: 0; } }
@keyframes image-viewer-pop {
  from { opacity: 0; transform: scale(.97); }
}
