﻿/* ============================================================================
 * blog.css — 博客页面：文章详情 / 归档时间轴 / 说说 / 相册
 * 依赖 tokens.css 的变量，所以放在 tokens 之后加载。
 * ========================================================================== */

/* ---------- 页脚导航行（导航栏只留两个切换，其余入口放这里）---------- */
.foot-links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px;
  margin-bottom: 14px;
}
.foot-links a {
  color: var(--w-muted); text-decoration: none;
  font-size: 13.5px;
  transition: color .2s var(--w-ease);
}
.foot-links a:hover { color: var(--w-ink); }

/* ---------- 通用容器 ---------- */
.page .wrap-narrow { max-width: 820px; margin: 0 auto; padding: 0 24px; }
.page > .wrap-narrow + .wrap-narrow { margin-top: clamp(40px, 6vw, 72px); }
.empty-tip {
  padding: 22px 0; color: var(--w-muted); font-size: 14px;
}
.empty-tip a { color: var(--w-accent-tx); }

/* ---------- 文章详情 ---------- */
.post-detail { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.back-link {
  display: inline-block; margin-bottom: 22px;
  color: var(--w-muted); text-decoration: none; font-size: 13.5px;
  transition: color .2s var(--w-ease);
}
.back-link:hover { color: var(--w-ink); }
.post-h1 {
  margin: 0 0 16px;
  font-size: clamp(26px, 4.2vw, 40px);
  line-height: 1.25;
  letter-spacing: -.02em;
  color: var(--w-ink);
}
.post-meta--detail {
  display: flex; flex-wrap: wrap; align-items: center; gap: 9px;
  padding-bottom: 22px; margin-bottom: 26px;
  border-bottom: 1px solid var(--w-hair);
  font-size: 13px; color: var(--w-faint);
}
.post-meta--detail .post-tag { text-decoration: none; }
.post-meta--detail .post-tag:hover { color: var(--w-ink); }
.post-meta--detail .post-views { color: var(--w-faint); }
.post-meta--detail #post-views { margin-left: auto; }

.post-body { color: var(--w-text); font-size: 16px; line-height: 1.95; }
.post-body p { margin: 0 0 20px; }
.post-body p:last-child { margin-bottom: 0; }
.post-body code {
  font-family: var(--w-font-mono);
  font-size: .88em;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  color: var(--w-accent-tx);
}
:root[data-theme="light"] .post-body code { background: rgba(24, 18, 30, .06); }

.post-nav {
  display: grid;
  /* minmax(0,1fr)：默认的 1fr 等于 minmax(auto,1fr)，长标题会把列撑破并挤出容器 */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 46px; padding-top: 26px;
  border-top: 1px solid var(--w-hair);

  /* ---- 以下四条是"防泄漏"保险，不是重复劳动 ----
     站点导航原本用的是裸元素选择器 nav { ... }，而本元素恰好是 <nav class="post-nav">，
     于是被整组命中，实测后果：
       · position:sticky + top:0 + z-index:30 → 滚动到文章底部时粘在视口顶部，
         与顶部导航抢同一位置，且因 DOM 靠后反而盖住它；
       · height:52px（pages.css 里 blog 页导航的折叠高度）→ 容器被锁死在 52px，
         而窄屏下两张卡片叠起来有 170px 以上，内容溢出容器直接压到页脚上；
       · background / border-bottom / box-shadow → 多出一层底色与投影，
         触摸设备上还会被 @media (hover:none) 染成不透明深色。
     根因已在各站内导航选择器上加 body > 限定修复；这里再钉一遍，
     保证今后新增任何 <nav> 都不会复现同一类问题。 */
  position: static; z-index: auto; height: auto;
  background: none; box-shadow: none; backdrop-filter: none; border-bottom: 0;
}
.post-nav-item {
  display: flex; flex-direction: column; gap: 6px;
  padding: 15px 18px;
  border-radius: 16px;
  border: 1px solid var(--w-hair);
  background: rgba(255, 255, 255, .04);
  text-decoration: none;
  transition: border-color .2s var(--w-ease), background-color .2s var(--w-ease), transform .2s var(--w-ease);
  min-width: 0;
}
.post-nav-item span { font-size: 12px; color: var(--w-faint); }
.post-nav-item b {
  font-size: 14.5px; font-weight: 600; color: var(--w-ink);
  line-height: 1.5;
  overflow-wrap: anywhere;    /* 超长英文标题不再撑破卡片 */
}
.post-nav-item:hover {
  border-color: color-mix(in srgb, var(--w-accent) 36%, var(--w-hair));
  background: color-mix(in srgb, var(--w-accent) 7%, transparent);
}
.post-nav-item--next { text-align: right; }
@media (max-width: 560px) {
  .post-nav { grid-template-columns: minmax(0, 1fr); }
  .post-nav-item--next { text-align: left; }
  /* 缺一篇时 JS 会补一个空的 <span> 占位（桌面端用它把"下一篇"顶到右列）。
     窄屏是单列，这个空占位会白占一整行、还多带一个 14px 的间隙，
     看起来就是"错位"——直接让它退出布局。 */
  .post-nav > span:empty { display: none; }
  .post-body { font-size: 15.5px; line-height: 1.9; }
}

/* ---------- 归档：搜索栏 + 标签 + 时间轴 ---------- */
.archive-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.archive-search { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.archive-search input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 16px;   /* 16px：iOS 聚焦不放大 */
  padding: 11px 15px;
  border-radius: 12px;
  border: 1px solid var(--w-hair);
  background: var(--w-sunken, rgba(255, 255, 255, .05));
  color: var(--w-ink);
}
.archive-search input::placeholder { color: var(--w-faint); }
.archive-search button {
  font: inherit; font-size: 13.5px; cursor: pointer;
  padding: 0 20px; min-height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--w-accent-hi), var(--w-accent));
  color: #fff;
  transition: transform .15s var(--w-ease), box-shadow .2s var(--w-ease);
}
.archive-search button:active { transform: scale(.97); }
.archive-count { font-size: 13px; color: var(--w-faint); font-variant-numeric: tabular-nums; }

.archive-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--w-hair);
  background: rgba(255, 255, 255, .05);
  color: var(--w-muted); font-size: 12.5px; text-decoration: none;
}
.chip--clear { color: var(--w-accent-tx); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; }
.tag-cloud .tag {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 44px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--w-hair);
  background: rgba(255, 255, 255, .04);
  color: var(--w-muted); font-size: 12.5px; text-decoration: none;
  transition: color .2s var(--w-ease), border-color .2s var(--w-ease), background-color .2s var(--w-ease);
}
.tag-cloud .tag i { font-style: normal; color: var(--w-faint); font-size: 11px; }
.tag-cloud .tag:hover, .tag-cloud .tag.is-on {
  color: var(--w-ink);
  border-color: color-mix(in srgb, var(--w-accent) 40%, transparent);
  background: color-mix(in srgb, var(--w-accent) 12%, transparent);
}

.timeline { position: relative; }
.tl-year { display: grid; grid-template-columns: 62px 1fr; gap: 14px; margin-bottom: 10px; }
.tl-year-label {
  padding-top: 14px;
  font-family: var(--w-font-mono); font-size: 13px;
  color: var(--w-faint); letter-spacing: .04em;
}
.tl-items { position: relative; padding-left: 18px; border-left: 1px solid var(--w-hair); }
.tl-item {
  position: relative;
  display: grid; grid-template-columns: 52px 1fr auto; align-items: baseline; gap: 12px;
  padding: 13px 4px;
  text-decoration: none;
  border-bottom: 1px solid var(--w-hair-soft);
  transition: background-color .2s var(--w-ease);
}
.tl-item:last-child { border-bottom: 0; }
.tl-item:hover { background: rgba(255, 255, 255, .035); }
.tl-dot {
  position: absolute; left: -23px; top: 20px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--w-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--w-accent) 18%, transparent);
}
.tl-date { font-size: 12.5px; color: var(--w-faint); font-variant-numeric: tabular-nums; }
.tl-title { font-size: 15.5px; color: var(--w-ink); font-weight: 600; line-height: 1.5; }
.tl-tags { font-size: 12px; color: var(--w-faint); }
.tl-item:hover .tl-title { color: var(--w-accent-tx); }
@media (max-width: 620px) {
  .tl-year { grid-template-columns: 1fr; gap: 4px; }
  .tl-year-label { padding-top: 8px; }
  .tl-item { grid-template-columns: 48px 1fr; }
  .tl-tags { grid-column: 2; }
}

/* ---------- 说说 ---------- */
.moment-list { display: flex; flex-direction: column; gap: 12px; }
.moment {
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--w-hair);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015) 60%, rgba(255, 255, 255, .03)),
    color-mix(in srgb, var(--w-surface) 68%, transparent);
  box-shadow: var(--w-bevel), var(--w-e1);
}
:root[data-theme="light"] .moment { background: linear-gradient(180deg, #fff, #fbfafc); }
.moment-text { color: var(--w-text); font-size: 15px; line-height: 1.85; }
.moment-meta {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; font-size: 12px; color: var(--w-faint);
}
.moment-mood { font-size: 15px; line-height: 1; }

/* ---------- 相册 ---------- */
/* 瀑布流（CSS 多列）：每张图按**原图比例**展示，不裁切。
   之前用 grid + aspect-ratio:1/1 + object-fit:cover，正方形是整齐了，
   但你看到的就不是原图了 —— 比例这件事不该由版式决定。 */
.album-grid {
  columns: 3 220px;
  column-gap: 12px;
}
.photo {
  position: relative;
  display: block;
  margin: 0 0 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--w-hair);
  background: rgba(255, 255, 255, .04);
  text-decoration: none;
  break-inside: avoid;          /* 一张图不被拆到两列 */
  -webkit-column-break-inside: avoid;
  /* 手机点击时浏览器会盖一层灰蓝色高亮（大约 100ms）—— 点开图片的瞬间看起来就是"闪一下"。
     全站只有 .btn/button 关掉了它，图片链接漏了；这里补上。
     touch-action: manipulation 顺带去掉双击缩放的等待，点开更跟手。 */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.photo img {
  width: 100%;
  height: auto;                 /* 关键：按原图比例 */
  display: block;
  transition: transform .5s var(--w-ease-out), opacity .4s var(--w-ease);
}
.photo:hover img { transform: scale(1.02); }
.photo-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 22px 12px 10px;
  font-size: 12.5px; color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .62));
  opacity: 0;
  transition: opacity .25s var(--w-ease);
}
.photo:hover .photo-cap, .photo:focus-visible .photo-cap { opacity: 1; }
@media (hover: none) { .photo-cap { opacity: 1; } }

/* ---------- 首页文章列表（改成链接到详情页）---------- */
.post-list { display: flex; flex-direction: column; gap: 12px; }
a.post {
  display: flex; align-items: center; gap: 14px;
  padding: 17px 20px;
  border-radius: 18px;
  border: 1px solid var(--w-hair);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015) 60%, rgba(255, 255, 255, .035)),
    color-mix(in srgb, var(--w-surface) 70%, transparent);
  box-shadow: var(--w-bevel), var(--w-e1);
  text-decoration: none;
  transition: border-color .25s var(--w-ease), box-shadow .25s var(--w-ease), transform .25s var(--w-ease);
}
:root[data-theme="light"] a.post { background: linear-gradient(180deg, #fff, #fbfafc); }
a.post:hover {
  border-color: color-mix(in srgb, var(--w-accent) 34%, var(--w-hair));
  box-shadow: var(--w-bevel), var(--w-e2);
  transform: translateY(-1px);
}
a.post .post-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
a.post .post-title { font-size: 16px; font-weight: 700; color: var(--w-ink); letter-spacing: -.01em; line-height: 1.4; }
a.post .post-summary { font-size: 13.5px; color: var(--w-muted); line-height: 1.7; }
a.post .post-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 12px; color: var(--w-faint); }
a.post .post-meta time { font-variant-numeric: tabular-nums; }
a.post .post-tag {
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--w-hair-soft);
  background: rgba(255, 255, 255, .045);
  color: var(--w-muted); font-size: 11.5px;
}
a.post .post-views { margin-left: auto; font-variant-numeric: tabular-nums; }
a.post .post-more {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--w-hair);
  display: grid; place-items: center;
}
a.post .post-more::before {
  content: ''; width: 6px; height: 6px;
  border-right: 1.6px solid var(--w-muted);
  border-bottom: 1.6px solid var(--w-muted);
  transform: rotate(-45deg);
}
@media (max-width: 600px) {
  a.post { padding: 15px 16px; gap: 10px; }
  a.post .post-title { font-size: 15px; }
  a.post .post-summary { display: none; }   /* 手机上只留标题与元信息，列表更紧凑 */
}

/* ---------- 文章正文里的图 ---------- */
.post-img {
  display: block;
  width: 100%;
  height: auto;                 /* 按原图比例，不裁切 */
  border-radius: 14px;
  border: 1px solid var(--w-hair);
  background: rgba(255, 255, 255, .03);
  margin: 4px 0 20px;
}
.post-figure { margin: 0 0 22px; }
.post-figure .post-img { margin-bottom: 8px; }
.post-figure figcaption {
  font-size: 12.5px; color: var(--w-faint); text-align: center; line-height: 1.7;
}

/* ---------- 相册灯箱 ---------- */
/* 为什么不用 display 切换 + 全屏 backdrop-filter（两者都会让开合"闪"）：
   ① display:none ⇄ flex 是硬切：关闭的瞬间整块消失、屏幕亮度骤变，观感就是闪一下。
      改动后元素常驻 DOM，用 visibility + opacity 过渡，进退场都有完整动画。
   ② 全屏 backdrop-filter 每次显示都要重建合成层，淡入过程中背景被逐帧重采样，
      在集显 / 移动 GPU 上会出现肉眼可见的闪烁；而遮罩本身接近不透明，
      那层模糊几乎看不出来，性能代价却是全页最贵的。改为纯色遮罩 + 暗角。 */
.dz-lb {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  padding: 56px 16px 64px;
  background: radial-gradient(120% 92% at 50% 42%, rgba(8, 8, 10, .88), rgba(0, 0, 0, .95));
  overscroll-behavior: contain;
  opacity: 0; visibility: hidden; pointer-events: none;
  /* 关闭时先淡出、过渡结束再隐藏；打开时立即可见 —— 顺序反了就会"闪" */
  transition: opacity .22s var(--w-ease-out), visibility 0s linear .22s;
  /* 手机上点遮罩关闭时，浏览器默认会盖一层高亮，也是一次可见的"闪" */
  -webkit-tap-highlight-color: transparent;
  /* 触摸设备靠这条阻断"背景页面跟着滚动"，**不去改 html 的 overflow**。
     理由：改根元素 overflow 会让手机浏览器重新计算可视视口（地址栏收放），
     整页跟着跳一下 —— 这正是"微信不闪、Edge 闪"的分野之一。
     触摸事件本身不受 touch-action 影响，所以滑动切图/下滑关闭照常工作。 */
  touch-action: none;
}
.dz-lb.is-open {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: opacity .22s var(--w-ease-out), visibility 0s;
}
.dz-lb-img {
  max-width: min(1100px, 100%);
  max-height: calc(100vh - 130px);     /* 老浏览器兜底 */
  /* 用 svh（小视口）而不是 dvh（动态视口）：
     手机上地址栏一伸一缩，dvh 就跟着变，图片高度被反复重算 —— 看起来就是"图片忽大忽小地闪"。
     svh 是"地址栏常驻时"的固定高度，全程稳定，代价只是图片比可用空间略小一点。 */
  max-height: calc(100svh - 130px);
  width: auto; height: auto;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  /* 遮罩整体是 touch-action:none（阻断背景滚动），但**图片上保留双指放大**，
     想看清细节时仍然可以捏合缩放。 */
  touch-action: pinch-zoom;
  opacity: 0; transform: scale(.965);
  transition: opacity .26s var(--w-ease-out), transform .3s var(--w-ease-out);
}
.dz-lb.is-open .dz-lb-img { opacity: 1; transform: none; }
.dz-lb-btn {
  position: absolute;
  display: grid; place-items: center;
  min-width: 44px; min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(20, 20, 24, .6);
  color: #fff; font: inherit; font-size: 18px; cursor: pointer;
  transition: background-color .2s var(--w-ease), border-color .2s var(--w-ease), transform .2s var(--w-ease);
}
.dz-lb-btn:hover { background: rgba(40, 40, 46, .8); border-color: rgba(255, 255, 255, .34); }
.dz-lb-btn:active { transform: scale(.94); }
.dz-lb-close { top: 14px; right: 14px; }
.dz-lb-prev { left: 14px; top: 50%; transform: translateY(-50%); font-size: 26px; }
.dz-lb-next { right: 14px; top: 50%; transform: translateY(-50%); font-size: 26px; }
.dz-lb-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, .86); font-size: 13px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .55));
}
.dz-lb-count { font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .6); }
@media (max-width: 560px) {
  .dz-lb { padding: 48px 8px 60px; }
  .dz-lb-prev, .dz-lb-next { min-width: 40px; min-height: 40px; font-size: 22px; }
  .dz-lb-prev { left: 6px; } .dz-lb-next { right: 6px; }
}
