/* MoFlow Enhancement Layer — 质感与交互性升级 */

/* ---------- 后退 wipe 时跳过错峰入场，避免横扫与渐入动画叠影（no-reveal 在返回动画结束后继续保住列表静止） ---------- */
html:is(.is-wiping, .no-reveal) :is(.feed-item, .side-block, .post-head, .post-content, .post-foot) {
  opacity: 1 !important;
  animation: none !important;
}
html:is(.is-wiping, .no-reveal) :is(.feed-thumb img, .feed-gallery-item img) {
  opacity: 1 !important;
  transition: transform .8s var(--ease-out);
}

/* ---------- 现代平滑滚动条 ---------- */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 4px;
  transition: background var(--t-fast);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-3);
}

/* ---------- 键盘可达性跳过内容链接 ---------- */
.skip-to-content {
  position: fixed;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  padding: 10px 24px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: top .2s ease;
  text-decoration: none;
  box-shadow: var(--shadow-pop);
}
.skip-to-content:focus {
  top: 0;
  outline: none;
}

/* ---------- 信息流错峰渐入动画 ---------- */
@media (prefers-reduced-motion: no-preference) {
  .feed-item {
    opacity: 0;
    animation: feed-reveal .55s var(--ease-out) both;
  }
  .feed-item:nth-child(1) { animation-delay: 20ms; }
  .feed-item:nth-child(2) { animation-delay: 70ms; }
  .feed-item:nth-child(3) { animation-delay: 130ms; }
  .feed-item:nth-child(4) { animation-delay: 190ms; }
  .feed-item:nth-child(5) { animation-delay: 250ms; }
  .feed-item:nth-child(6) { animation-delay: 310ms; }
  .feed-item:nth-child(7) { animation-delay: 370ms; }
  .feed-item:nth-child(8) { animation-delay: 430ms; }
  .feed-item:nth-child(9) { animation-delay: 490ms; }
  .feed-item:nth-child(10) { animation-delay: 550ms; }
  .feed-item:nth-child(n+11) { animation-delay: 590ms; }
}
@keyframes feed-reveal {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 缩略图平滑加载显现（保留悬停缩放过度） ---------- */
.js .feed-thumb img,
.js .feed-gallery-item img {
  opacity: 0;
  transition: opacity .6s ease, transform .8s var(--ease-out);
}
.js .feed-thumb img.is-loaded,
.js .feed-gallery-item img.is-loaded {
  opacity: 1;
}

/* ---------- 文章页内容错峰入场 ---------- */
@media (prefers-reduced-motion: no-preference) {
  .post-head, .post-content, .post-foot {
    animation: content-rise .6s var(--ease-out) both;
  }
  .post-head { animation-delay: 0ms; }
  .post-content { animation-delay: 100ms; }
  .post-foot { animation-delay: 180ms; }
}
@keyframes content-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 侧栏模块错峰浮现 ---------- */
@media (prefers-reduced-motion: no-preference) {
  .side-block {
    opacity: 0;
    animation: side-appear .45s var(--ease-out) both;
  }
  .side-block:nth-child(1) { animation-delay: 80ms; }
  .side-block:nth-child(2) { animation-delay: 180ms; }
  .side-block:nth-child(3) { animation-delay: 280ms; }
  .side-block:nth-child(4) { animation-delay: 380ms; }
  .side-block:nth-child(5) { animation-delay: 480ms; }
}
@keyframes side-appear {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 侧栏作者卡片微浮效果（2.8.0 去卡片化后停用） ---------- */

/* ---------- 标签悬浮微胶囊反馈 ---------- */
.post-tag, .side-tag {
  padding: 3px 9px;
  border-radius: 4px;
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.post-tag:hover, .side-tag:hover {
  background: var(--accent-soft);
  color: var(--accent-hi);
  transform: translateY(-1px);
}

/* ---------- 顶部阅读进度条 ---------- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  z-index: 1200;
  pointer-events: none;
  transition: width 90ms cubic-bezier(.16, 1, .3, 1);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--accent-soft);
}

/* ---------- 首页头图缓慢 Ken Burns 动效 ---------- */
@media (prefers-reduced-motion: no-preference) {
  .banner-slide.is-active {
    animation: ken-burns 16s ease-in-out infinite alternate;
  }
}
@keyframes ken-burns {
  from { transform: scale(1); }
  to { transform: scale(1.035); }
}

/* ---------- 弹窗与悬浮播放器毛玻璃磨砂质感 ---------- */
/* .player-list 嵌套在已有 backdrop-filter / transform 的父容器（.player-float / .drawer）内，
   浏览器规范下会各自形成孤立 backdrop 根导致模糊失效；若设半透明反而会透出底层锐利文字造成重影，
   故列表浮层保持纯实底 var(--bg-elev)，只给外层独立面板做毛玻璃。 */
@supports ((backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px))) {
  .search-panel, .player-float, .to-top {
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
  }
  [data-scheme="dark"] :is(.player-float, .to-top) {
    background: rgba(34, 31, 26, 0.88);
  }
  [data-scheme="dark"] .search-panel {
    background: rgba(33, 30, 26, 0.95);
  }
  [data-scheme="light"] :is(.player-float, .to-top) {
    background: rgba(255, 253, 248, 0.90);
  }
  [data-scheme="light"] .search-panel {
    background: rgba(255, 253, 248, 0.96);
  }
}

/* ---------- 评论项悬浮过渡 ---------- */
.comment {
  transition: background var(--t-fast), border-radius var(--t-fast);
  margin-inline: -10px;
  padding-inline: 10px;
}
.comment:hover {
  background: var(--hover-wash);
  border-radius: var(--radius);
}

/* ---------- 最左栏展开统计栏 (方案 B) ---------- */
.rail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 10px 0;
  margin: 0 16px 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  opacity: 0;
  transition: opacity .18s ease;
  flex-shrink: 0;
}
@media (min-width: 900px) {
  .rail:hover .rail-stats,
  .rail:focus-within .rail-stats,
  .rail.is-open .rail-stats {
    opacity: 1;
  }
}
@media (min-width: 1400px) {
  .rail-stats {
    opacity: 1;
  }
}
.rail-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.rail-stat-num {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.2;
  color: var(--fg);
}
.rail-stat-name {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  margin-top: 2px;
  letter-spacing: .06em;
  color: var(--fg-3);
}

/* ---------- 分割线刻度点文章目录 (Dot Timeline TOC) ---------- */
.line-toc {
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 105;
  display: flex;
  align-items: center;
  transition: opacity .22s ease, visibility .22s;
}
/* 覆盖 display: flex，避免无章节文章（hidden 属性未移除）仍渲染隐形感应区与空面板 */
.line-toc[hidden] {
  display: none;
}
/* 滚到评论区时收起：轨道的悬停感应区会压住「提交评论」按钮，导致点击被吞 */
.line-toc.is-off {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
@media (max-width: 899px) {
  .line-toc { display: none !important; }
}

/* 刻度点垂直轨道（扩大感应区，灵敏展开） */
.line-toc-track {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  padding: 24px 10px;
  min-height: 240px;
  cursor: pointer;
}
/* 悬停感应区：向文章左侧延伸 28px、右侧 10px、上下各 28px——
   再大就会压到中栏里的评论表单等可点区域（曾吞掉「提交评论」的点击） */
.line-toc-track::before {
  content: "";
  position: absolute;
  top: -28px;
  bottom: -28px;
  left: -28px;
  right: -10px;
  z-index: 1;
}

/* 刻度小点：一级标题大点（12px），二级标题小点（8px） */
.line-toc-dot {
  position: relative;
  z-index: 2;
  display: block;
  padding: 0;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--fg-3);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.line-toc-dot.is-h2 {
  width: 12px;
  height: 12px;
  border-width: 2.5px;
  border-color: var(--fg-2);
}
.line-toc-dot.is-h3 {
  width: 8px;
  height: 8px;
  border-width: 2px;
  border-color: var(--line-2);
  background: var(--bg);
}
.line-toc-dot:hover,
.line-toc-dot:focus-visible,
.line-toc-dot.is-preview {
  border-color: var(--accent);
  transform: scale(var(--dot-scale, 1.3));
}
.line-toc-dot.is-near {
  border-color: var(--fg-2);
  transform: scale(var(--dot-scale, 1.15));
}
/* 活跃状态：简洁纯色放大 + 实体光晕，无呼吸动画 */
.line-toc-dot.is-active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.line-toc-dot.is-h3.is-active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 0 2.5px var(--accent-soft);
}

/* 向左展开的毛玻璃目录面板 */
.line-toc-panel {
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  width: 236px;
  max-width: 260px;
  max-height: 65vh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .2s ease .15s, transform .2s var(--ease-out) .15s, visibility .2s .15s;
  z-index: 3;
}
/* 鼠标在点与面板间微移时防抖桥接 */
.line-toc-panel::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 0;
  bottom: 0;
  width: 30px;
}
@supports ((backdrop-filter: blur(14px)) or (-webkit-backdrop-filter: blur(14px))) {
  .line-toc-panel {
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
  }
  [data-scheme="dark"] .line-toc-panel {
    background: rgba(33, 30, 26, 0.94);
  }
  [data-scheme="light"] .line-toc-panel {
    background: rgba(255, 253, 248, 0.95);
  }
}

/* 悬停展开向左平滑滑入，悬停时 0ms 瞬间响应 */
.line-toc:hover .line-toc-panel,
.line-toc:focus-within .line-toc-panel {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
  transition-delay: 0s;
}

.line-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.line-toc-title {
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg);
}
.line-toc-count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

.line-toc-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  gap: 2px;
  mask-image: linear-gradient(180deg, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
}
.line-toc-item {
  border-radius: 4px;
  transition: background var(--t-fast);
}
.line-toc-item a {
  display: block;
  padding: 4px 6px;
  border-left: 2px solid transparent;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--t-fast), border-color var(--t-fast), padding-left var(--t-fast);
}
.line-toc-item.is-h3 a {
  font-size: var(--fs-xs);
  padding-left: 16px;
  color: var(--fg-3);
}
.line-toc-item:hover,
.line-toc-item.is-preview {
  background: var(--hover-wash);
}
.line-toc-item:hover a,
.line-toc-item.is-preview a {
  color: var(--accent-hi);
}
.line-toc-item.is-active {
  background: var(--accent-soft);
}
.line-toc-item.is-active a {
  border-left-color: var(--accent);
  padding-left: 8px;
  color: var(--accent);
  font-weight: 600;
}
.line-toc-item.is-h3.is-active a {
  padding-left: 18px;
}
