/* ============================================================
   资料共享广场（模块2）— 延续编辑式扁平设计语言
   base 结构层；圆角 / 投影 / 玻璃由 glass.css 覆盖。
   悬停 = 微变底 + 竖条擦入 / 方向性底色擦除（与全站母题同源）
   ============================================================ */

/* ---------- 工具条：白底面板，间距走 --s3 令牌 ---------- */
.posts-toolbar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--s3);
  padding: var(--s3) 14px;
  margin-bottom: 16px;
  position: relative; z-index: 1; /* 下拉面板提升：glass isolation 把面板 z-index 困在祖先内，祖先 z-index:auto 被下方卡片盖住 */
}
input.posts-search {
  flex: 1 1 220px; min-width: 0; width: auto;
  padding: calc(9px * var(--ui-scale, 1)) calc(12px * var(--ui-scale, 1)); font-size: .84rem; /* 需求六·item5：广场搜索框随滑块 */
}
select.posts-sort {
  flex: 0 0 auto; width: auto; min-width: 112px;
  padding: calc(9px * var(--ui-scale, 1)) calc(30px * var(--ui-scale, 1)) calc(9px * var(--ui-scale, 1)) calc(12px * var(--ui-scale, 1)); font-size: .8rem; /* 需求六·item5：广场排序下拉随滑块 */
}

/* ---------- 帖子卡 ---------- */
/* #161：卡片可点击查看全文——交互卡，悬停走引擎 hover 洗 + cursor 指针（原「统一静态」对交互卡放开）；
   入场动效统一走全站 .reveal 浮入管线 */
.post-card {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 18px 20px 14px;
  cursor: pointer;
  --g-hover: var(--g-hover-wash); /* 引擎标准悬停白洗（glass.css），非新动效 */
}
.post-card + .post-card { margin-top: 12px; }

.post-card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.post-title {
  font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em;
  line-height: 1.35; color: var(--ink); overflow-wrap: anywhere;
  /* #161：标题转 button 承载键盘焦点/Enter 激活，样式还原为文本外观 */
  border: none; background: none; padding: 0; margin: 0; font-family: inherit;
  text-align: left; cursor: pointer; width: auto;
}

/* 作者 + 时间：时间走等宽字，em-dash 分隔呼应全站横线母题 */
.post-meta {
  display: flex; align-items: baseline; gap: 0; margin-top: 6px;
  font-size: .74rem; font-weight: 500; color: var(--muted);
}
.post-meta .post-author { font-weight: 700; color: var(--ink-3); }
.post-meta .post-time {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .02em; color: var(--muted);
}
.post-meta .post-time::before { content: '—'; margin: 0 10px; color: var(--faint); }

.post-snippet {
  margin-top: 10px;
  font-size: .84rem; line-height: 1.66; color: var(--ink-3);
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* R24：帖子预览卡正文与操作按钮之间去分割线、收紧间距（预览紧贴动作，视觉一体的反馈） */
.post-actions {
  margin-top: 10px; padding-top: 0;
  display: flex; align-items: center; gap: 10px;
}

/* ---------- 点赞按钮：线框拇指 → 已赞红色填充（计数随动） ---------- */
/* 文字色双源收敛——base/hover/liked 的 color 直写删净，统一走引擎 --g-fg
   （glass.css .post-like 设 --g-fg: var(--muted) / :has(input:checked) 设 --g-fg: var(--danger)）。 */
/* #160：点赞接复选框逻辑——label+隐藏原生 checkbox，checked 驱动 :has 视觉（同 .checkbox-item）。
   隐藏用 sr-only 画法：保可聚焦可切换，键盘焦点视觉由 :has(input:focus-visible) 移到 pill 上。 */
.post-like {
  display: inline-flex; align-items: center; gap: calc(7px * var(--ui-scale, 1));
  padding: calc(5px * var(--ui-scale, 1)) calc(14px * var(--ui-scale, 1));
  font-size: .78rem; font-weight: 700; letter-spacing: .02em;
  cursor: pointer; user-select: none; /* label 需指针光标（原 button 原生有） */
  transition: color var(--t-base) var(--ease-out),
              border-color var(--t-base) var(--ease-out),
              transform var(--t-fast) var(--ease-out); /* G28：background-color 死 */
}
.post-like input[type="checkbox"] {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.post-like:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; } /* 键盘焦点环（checkbox-item 同款） */
.post-like .like-icon, .post-fav .fav-icon {
  flex-shrink: 0;
  width: calc(15px * var(--ui-scale, 1)); height: calc(15px * var(--ui-scale, 1)); /* K1 图标随滑块 */
  transition: fill var(--t-base) var(--ease-out), stroke var(--t-base) var(--ease-out);
}
.post-like .like-count { font-family: var(--mono); font-size: .74rem; }
.post-like:hover { --g-fg: var(--ink-3); }
.post-like:active { transform: scale(.94); transition-duration: 80ms; }
.post-like:has(input:checked) .like-icon { fill: var(--danger); stroke: var(--danger); } /* 文字色单源 glass.css（--g-fg: var(--danger)） */

/* ---------- 收藏按钮（R23）：线框书签 → 已收藏主题色实心（收藏即保存，私人无计数） ----------
   同 .post-like 复选逻辑与 sr-only 隐藏 checkbox；主题色区分于点赞红（--g-fg 单源 glass.css） */
.post-fav {
  display: inline-flex; align-items: center; gap: calc(7px * var(--ui-scale, 1));
  padding: calc(5px * var(--ui-scale, 1)) calc(14px * var(--ui-scale, 1));
  font-size: .78rem; font-weight: 700; letter-spacing: .02em;
  cursor: pointer; user-select: none;
  transition: color var(--t-base) var(--ease-out),
              border-color var(--t-base) var(--ease-out),
              transform var(--t-fast) var(--ease-out);
}
.post-fav input[type="checkbox"] {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.post-fav:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.post-fav .fav-label { font-size: .76rem; }
.post-fav:hover { --g-fg: var(--ink-3); }
.post-fav:active { transform: scale(.94); transition-duration: 80ms; }
.post-fav:has(input:checked) .fav-icon { fill: var(--accent); stroke: var(--accent); }
.post-fav:has(input:checked) .fav-label { color: var(--accent); }

/* #161：详情浮窗 footer——点赞 pill 与删除分居两侧 */
.post-detail-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-light); }
.post-detail-body { margin-top: 10px; }

/* 作者自删：低调文字按钮，悬停转危险红 + 细下划线 */
.post-del {
  flex-shrink: 0; padding: 2px 4px;
  font-size: .72rem; font-weight: 600; color: var(--faint);
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.post-del:hover { color: var(--danger-deep); border-bottom-color: var(--danger); }

/* ---------- 发布弹窗：Markdown 小按钮工具条 ---------- */
.md-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.md-btn {
  padding: 5px 12px;
  font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  transition: color var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out); /* G28：background-color 死 */
}
.md-btn:active { transform: translateY(1px); }
label.md-btn { display: inline-block; cursor: pointer; } /* 插图按钮是原生 label（唤起文件框），补内联块与指针 */

/* 标题字数计数：输入行最右，灰色小字 n/60，超 55 变红 */
.title-count { flex-shrink: 0; font-family: var(--mono); font-size: .68rem; color: var(--muted); letter-spacing: .02em; transition: color var(--t-fast) var(--ease-out); }
.title-count.over { color: var(--danger); }

textarea.post-body-input { min-height: calc(200px * var(--ui-scale, 1)); font-size: .86rem; line-height: 1.6; } /* 需求六·item5：帖子正文输入随滑块 */

/* ---------- 实时预览：虚线围合区分「编辑 / 所见」，图片限宽 ---------- */
.md-preview {
  min-height: 64px; max-height: 240px; overflow-y: auto;
  padding: 12px 14px;
}
/* R21④：标题紧缩小阶梯——1/2 级不再巨大（少用 1/2 级、优先 3/5 级），各级递增幅度 ~.04rem
   v0.25.94：选择器扩展 .post-detail-body——帖子详情浮窗同口径（此前仅 .md-preview 有排版，
   详情里标题吃浏览器巨大默认、列表编号因全局 *{padding:0} 重置从左边戳出正文）。 */
.md-preview h1, .md-preview h2, .post-detail-body h1, .post-detail-body h2 { font-size: 1.02rem; font-weight: 900; letter-spacing: -.01em; color: var(--ink); margin: 12px 0 5px; }
.md-preview h3, .post-detail-body h3 { font-size: .96rem; font-weight: 800; letter-spacing: -.01em; color: var(--ink); margin: 10px 0 4px; }
.md-preview h4, .post-detail-body h4 { font-size: .92rem; font-weight: 800; color: var(--ink-2); margin: 8px 0 3px; }
.md-preview h5, .post-detail-body h5 { font-size: .9rem; font-weight: 700; color: var(--ink-2); margin: 7px 0 3px; }
.md-preview h6, .post-detail-body h6 { font-size: .88rem; font-weight: 700; color: var(--ink-3); margin: 6px 0 2px; }
.md-preview h1:first-child, .md-preview h2:first-child, .md-preview h3:first-child,
.md-preview h4:first-child, .md-preview h5:first-child, .md-preview h6:first-child,
.md-preview p:first-child, .post-detail-body h1:first-child, .post-detail-body h2:first-child,
.post-detail-body h3:first-child, .post-detail-body h4:first-child, .post-detail-body h5:first-child,
.post-detail-body h6:first-child, .post-detail-body p:first-child { margin-top: 0; }
/* R21①③：正文行距 1.8（原 1.7）+ 字号 .86rem（与平台普通文本一致，原 .84）+ 段距加大 */
.md-preview p, .post-detail-body p {
  font-size: .86rem; line-height: 1.8; color: var(--ink-3);
  margin: 4px 0 4px 12px; overflow-wrap: anywhere; /* R21②：正文比标题统一右缩进 12px */
}
.md-preview strong, .post-detail-body strong { color: var(--ink); font-weight: 800; }
.md-preview img, .post-detail-body img {
  display: block; max-width: 100%; margin: 8px 0;
  border: 1px solid var(--border-light);
}
.md-preview-empty { font-size: .78rem; color: var(--faint); }

/* #161：详情浮窗正文用 md-preview 排版但放开高度封顶（浮窗整体在 overlay 滚动，无需内滚） */
.md-preview--full { max-height: none; }

/* #162：markdown 列表/引用/行内代码排版（解析器新增块级+行内语法）
   R21②：列表容器比正文进一步右缩进（20px，编号在此），列表文字 20+16=36px——层级：标题0/正文12/编号20
   v0.25.94：扩展 .post-detail-body——详情正文同口径（全局 *{padding:0} 把 ol 默认缩进清零，
   无此规则的容器里编号画在负空间、从左边戳出正文）。padding-left 16px 是编号立足区，不可省。 */
.md-preview ul, .md-preview ol, .post-detail-body ul, .post-detail-body ol { margin: 4px 0 4px 20px; padding-left: 16px; }
.md-preview ul, .post-detail-body ul { list-style: disc; }
.md-preview ol, .post-detail-body ol { list-style: decimal; }
.md-preview li, .post-detail-body li { font-size: .86rem; line-height: 1.8; color: var(--ink-3); margin: 2px 0; overflow-wrap: anywhere; }
.md-preview li::marker, .post-detail-body li::marker { color: var(--muted); }
.md-preview blockquote, .post-detail-body blockquote {
  margin: 6px 0 6px 12px; padding: 4px 12px; /* R21②：引用随正文缩进线（比标题右缩进） */
  border-left: 3px solid var(--accent-tint, rgba(122,104,224,.3));
  color: var(--ink-3); font-size: .86rem; line-height: 1.8; /* R21①③：正文口径 */
}
.md-preview blockquote p, .post-detail-body blockquote p { margin: 2px 0; }
.md-preview code, .post-detail-body code {
  font-family: var(--mono); font-size: .78em;
  padding: 1px 5px; border-radius: 5px;
  background: var(--g-fill-weak, rgba(255,255,255,.5));
  color: var(--accent-deep, #4B3DB0);
  overflow-wrap: anywhere;
}

/* 未放行图片的占位标记 */
.md-img-blocked {
  display: inline-block; padding: 1px 8px; margin: 0 2px;
  color: var(--warn-deep);
  font-size: .72rem; font-weight: 600;
}

/* ---------- 窄屏：搜索框独占一行，卡片收紧 ---------- */
@media (max-width: 640px) {
  input.posts-search { flex-basis: 100%; }
  .post-card { padding: 14px 14px 12px; }
  .post-card-head { flex-direction: column; align-items: flex-start; gap: 2px; }
}
