/* comments.css —— 评论区新样式、详情页底栏、帖子图片自适应、标题
   必须放在 theme.css 之后加载（index.html 里已经排好），同权重的规则靠加载顺序覆盖旧样式 */

/* ====================== 帖子：标题 / 正文限行（列表里的卡片） ====================== */
.post-title { word-break: break-all; }
.post-card.in-feed .post-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 列表里正文最多 5 行，有标题时当作副标题只留 3 行；详情页不限 */
.post-card.in-feed .post-content {
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card.in-feed.has-title .post-content { -webkit-line-clamp: 3; }
.user-post-title {
  font-size: 15px; font-weight: 700; color: var(--text-title); margin-bottom: 4px;
  font-family: var(--font-display); word-break: break-all;
}

/* ====================== 帖子：单图按比例自适应 ====================== */
/* 外框的形状由 JS 在图片加载完后写入：--ar（宽高比）和 data-shape（wide / square / tall） */
.post-img-wrap {
  position: relative; width: 100%; aspect-ratio: var(--ar, 4 / 3);
  border-radius: 12px; overflow: hidden; background: var(--bg-page); margin-bottom: 8px;
}
.post-img-wrap[data-shape="square"] { width: 72%; }
.post-img-wrap[data-shape="tall"] { width: 62%; }
.post-img-wrap .post-img {
  width: 100%; height: 100%; max-height: none; object-fit: cover; border-radius: 0; display: block;
}
.post-img-long {
  position: absolute; right: 6px; bottom: 6px; font-size: 11px; color: #fff;
  background: rgba(20,25,32,0.55); padding: 2px 7px; border-radius: 8px;
}
.post-img-grid { border-radius: 12px; }
/* 详情页：图片看全貌，不裁切，最高 480px */
#detail-post-card .post-img-wrap { width: 100% !important; aspect-ratio: auto; }
#detail-post-card .post-img-wrap .post-img { height: auto; max-height: 480px; object-fit: contain; }
#detail-post-card .post-img-long { display: none; }

/* ====================== 详情页容器 ====================== */
#page-post-detail .page-content { padding: 0; bottom: 56px; }
/* 帖子自带的操作栏在详情页隐藏：它仍在 DOM 里，底栏的按钮会去触发它（见 post-detail.js） */
#detail-post-card .post-footer { display: none; }

/* ====================== 评论区标题栏（吸顶）：全部 N 条评论 ········ 热门 ▾ ====================== */
.detail-comments-title {
  position: sticky; top: 0; z-index: 20;
  margin-top: 8px; border-top: none; border-bottom: 1px solid var(--border-light);
  background: #fff; padding: 13px 16px 11px;
  display: flex; align-items: center; justify-content: space-between;
}
.detail-comments-label { font-size: 15px; font-weight: 700; color: var(--text-title); }
.detail-sort-btn {
  display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none;
  font-size: 13px; font-weight: 600; color: var(--text-body); padding: 2px 0 2px 10px;
}
.detail-sort-caret {
  width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--text-tip);
}
.detail-sort-menu {
  display: none; position: absolute; right: 12px; top: calc(100% - 4px); min-width: 88px;
  background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 6px 22px rgba(20,40,70,0.18);
}
.detail-sort-menu.show { display: block; }
.detail-sort-opt { padding: 11px 18px; font-size: 14px; color: var(--text-title); cursor: pointer; }
.detail-sort-opt:active { background: var(--bg-page); }
.detail-sort-opt.active { color: var(--accent); font-weight: 700; }

/* ====================== 评论列表 ====================== */
.detail-comments-list { background: #fff; padding: 4px 16px 28px; min-height: 220px; }
.comment-empty { padding: 36px 0; }

.cm-item { display: flex; gap: 10px; padding: 10px 0; }
.cm-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: #e1f5fe; color: var(--accent); font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.cm-avatar.mine { background: var(--primary); color: var(--ink-on-primary); }
.cm-item.is-reply { padding: 8px 0 2px; }
.cm-item.is-reply .cm-avatar { width: 26px; height: 26px; font-size: 11px; }
.cm-main { flex: 1; min-width: 0; }

.cm-content.clickable { border-radius: 8px; }
.cm-content.clickable:active { background: var(--bg-page); }
.cm-head { display: flex; align-items: center; gap: 6px; line-height: 1.3; }
.cm-nick { font-size: 13px; font-weight: 600; color: #868e96; }
.cm-tag {
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  color: var(--accent); background: rgba(79,195,247,0.16);
}
.cm-text { font-size: 15px; color: var(--text-title); line-height: 1.55; margin-top: 3px; word-break: break-all; }
.cm-reply-to { color: #868e96; font-weight: 400; }
.cm-reply-name { color: var(--accent); }

.cm-meta { display: flex; align-items: center; gap: 14px; margin-top: 6px; font-size: 12px; color: var(--text-tip); }
.cm-act { cursor: pointer; user-select: none; color: #495057; font-weight: 600; }
.cm-act:active { opacity: .5; }
.cm-more { color: var(--text-tip); font-weight: 700; letter-spacing: 1px; }
.cm-like {
  margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  min-width: 40px; padding: 2px 0 2px 8px; font-size: 12.5px; color: #868e96;
  cursor: pointer; user-select: none;
}
.cm-like svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.cm-like:active { opacity: .6; }
.cm-like.liked { color: var(--accent); }
.cm-like.liked svg { fill: currentColor; }

/* 楼中楼：先露出第 1 条回复，其余折叠成"查看 N 条回复 ›" */
.cm-replies { margin-top: 4px; }
.cm-replies-toggle {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; user-select: none;
}
.cm-replies-toggle::before { content: ''; width: 22px; height: 1px; background: var(--border-light); }
.cm-replies-toggle::after { content: '›'; font-size: 17px; line-height: 1; display: inline-block; }
.cm-replies-toggle.open::after { transform: rotate(-90deg); }
.cm-replies-toggle:active { opacity: .6; }

/* ====================== 回复提示条（在底栏上方） ====================== */
.reply-target-bar {
  position: absolute; left: 0; right: 0; bottom: 56px; z-index: 101;
  align-items: center; justify-content: space-between;
  padding: 8px 16px; font-size: 12.5px; color: var(--text-body);
  background: #f4faff; border-top: 1px solid var(--border-light);
}
.reply-target-cancel { color: var(--text-tip); cursor: pointer; padding: 2px 4px; }

/* ====================== 详情页底栏：输入框 + 评论 / 点赞 / 收藏 / 转发 ====================== */
.detail-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 56px; z-index: 100;
  display: flex; align-items: center; gap: 10px; padding: 0 10px 0 12px;
  background: rgba(255,255,255,0.96); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-light);
}
.detail-bar-input {
  flex: 1; min-width: 0; height: 38px; border-radius: 19px; padding: 0 14px;
  background: #f1f4f8; display: flex; align-items: center;
  transition: background .15s, box-shadow .15s;
}
.detail-bar-input:focus-within { background: #fff; box-shadow: 0 0 0 2px rgba(79,195,247,0.55); }
.detail-bar-field { width: 100%; font-size: 14px; color: var(--text-title); }
.detail-bar-field::placeholder { color: var(--text-tip); }

.detail-bar-actions { display: flex; flex-shrink: 0; }
.dbar-btn {
  min-width: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: #6c757d; cursor: pointer; user-select: none; transition: transform .1s, color .15s;
}
.dbar-btn:active { transform: scale(0.9); }
.dbar-btn svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.dbar-num { font-size: 10.5px; line-height: 1; color: #868e96; }
#dbar-like.on { color: var(--accent); }
#dbar-like.on svg { fill: currentColor; }
#dbar-fav.on { color: var(--stamp); }
#dbar-fav.on svg { fill: currentColor; }

.detail-bar-send {
  display: none; flex-shrink: 0; height: 36px; padding: 0 18px; border-radius: 18px;
  align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff;
  background: var(--grad-primary); box-shadow: 0 3px 10px rgba(63,182,243,0.4); cursor: pointer;
}
.detail-bar-send:active { transform: scale(0.92); }
/* 输入中：收起四个图标，露出"发送" */
.detail-bar.typing .detail-bar-actions { display: none; }
.detail-bar.typing .detail-bar-send { display: flex; }
