/* ═══════════════════════════════════════════════════════════
   方块王国社区站 · 增量组件
   ── css/site.css ──

   只放「本站新增」的组件，凡是 style.css 已有的（.container/.section/
   .editor-btn/.news-item/.feature-card/.forum-cat/.badge/.news-detail-body 等）
   一律直接复用，不重复造轮子，也不在这里覆盖它们的原有属性。
   ═══════════════════════════════════════════════════════════ */

/* ── ① 导航里的用户态（layout.js 产出） ── */
.nav-user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  padding-left: 10px;
  border-left: 2px solid rgba(255, 255, 255, .22);
}
.nav-user { display: inline-flex; align-items: center; gap: 7px; }
.nav-avatar {
  width: 28px; height: 28px; flex: none;
  border: 2px solid var(--c-gold);
  border-radius: var(--radius);
  display: block;
}
.nav-user-name {
  font-size: 14px; font-weight: 700; color: #fff;
  max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-logout {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, .45);
  color: #e4f2df;
  font-size: 13px;
  min-height: 32px;
  padding: 2px 10px;
}
.nav-logout:hover { background: rgba(0, 0, 0, .22); color: #fff; }
/* 「注册」在窄屏也要是金色，但比「发布新帖」弱一级，避免两个主按钮对撞 */
.nav-cta-sm { min-height: 32px; padding: 4px 14px; font-size: 13.5px; }

/* 管理员后台入口（layout.js 仅在 role === 'admin' 时产出）。
   用描边金而非实心金：它右边紧邻实心的「发布新帖」与「退出」，
   再给一个实心块会三连撞，视觉上抢走用户的落点。 */
.nav-admin {
  min-height: 32px; padding: 2px 12px;
  font-size: 13px; font-weight: 700;
  background: rgba(217, 180, 106, .14);
  border: 2px solid var(--c-gold);
  color: #ffe9b8;
}
.nav-admin:hover { background: rgba(217, 180, 106, .34); color: #fff; }
/* 后台可把徽章换成上传的 Logo 图片。用 object-fit 而非拉伸，
   否则管理员传一张横幅比例的图，页头徽章会被压成扁片。 */
.brand-logo-img { object-fit: contain; }

@media (max-width: 767px) {
  /* 移动端：用户态独占一行，不再挤在一条横排里 */
  .nav-user-cell {
    margin: 8px 0 0;
    padding: 10px 12px 4px;
    border-left: 0;
    border-top: 2px solid rgba(255, 255, 255, .18);
    flex-wrap: wrap;
  }
  .nav-user-name { max-width: none; }
  .nav-cta-sm { width: fit-content; }
}

/* ── ② 页头：标题 + 面包屑 ── */
.page-head {
  background: linear-gradient(color-mix(in srgb, var(--c-brand-dark) 55%, var(--c-grass) 45%), color-mix(in srgb, var(--c-brand-dark) 80%, #000 20%));
  border-bottom: 4px solid color-mix(in srgb, var(--c-brand-dark) 75%, #000 25%);
  padding-block: 26px 22px;
  color: #fff;
}
.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 12.5px; color: #cfe8c8; margin-bottom: 8px;
}
.crumbs li { display: inline-flex; align-items: center; gap: 6px; }
.crumbs li + li::before { content: "›"; color: var(--c-gold); }
.crumbs a:hover { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.crumbs [aria-current] { color: #fff; font-weight: 600; }
.page-title {
  font-size: clamp(24px, 4vw, 34px); font-weight: 800; letter-spacing: .05em;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, .28); margin: 0;
}
.page-sub { margin-top: 6px; font-size: 14px; color: #d8ecd2; max-width: 62ch; }
/* 版块页头右侧的统计 */
.page-head-extra {
  margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px;
}
.mini-stat {
  background: rgba(0, 0, 0, .22);
  border: 2px solid rgba(255, 255, 255, .28);
  border-radius: var(--radius);
  padding: 4px 12px; font-size: 12.5px; color: #e6f4e2;
}
.mini-stat b { color: var(--c-gold); }

/* ── ③ 工具条（排序说明 / 发帖按钮） ── */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.toolbar-note { font-size: 13px; color: var(--c-ink-soft); }

/* ── ④ 帖子列表 ── */
.thread-list { display: flex; flex-direction: column; gap: 12px; }
.thread-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: start;
  background: #fff;
  border: var(--border-px) var(--border-style) var(--c-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
  padding: 14px 16px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.thread-row:hover {
  transform: translate(-1px, -2px);
  box-shadow: var(--shadow-hard);
  border-color: var(--c-brand);
}
.thread-row.is-pinned { background: #fffdf4; border-color: var(--c-parchment-d); }
.thread-ava {
  width: 40px; height: 40px; flex: none;
  border: 2px solid var(--c-line); border-radius: var(--radius);
  display: block;
}
.thread-main { min-width: 0; }
.thread-title {
  font-size: 16px; font-weight: 700; line-height: 1.45; margin: 0 0 4px;
  /* 标题不换行会顶破栅格，这里必须允许换行并保留 min-width:0 的收窄能力 */
  overflow-wrap: anywhere;
}
.thread-title a:hover { color: var(--c-brand-deep); }
.thread-excerpt {
  font-size: 13px; color: var(--c-ink-soft); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 列表展示的是服务端生成的 120 字摘要 —— 直接用，不要前端二次截断 */
.thread-meta {
  margin-top: 6px; font-size: 12px; color: #7d8580;
  display: flex; flex-wrap: wrap; gap: 4px 10px;
}
.thread-meta .who { font-weight: 600; color: var(--c-ink-soft); }
.thread-stats {
  display: flex; flex-direction: column; gap: 2px;
  text-align: right; font-size: 12px; color: var(--c-ink-soft);
  white-space: nowrap;
}
.thread-stats b { color: var(--c-brand-dark); font-variant-numeric: tabular-nums; }
/* 列表内的点赞按钮：与统计数右对齐成第二列尾部 */
.like-btn-row { align-self: center; }
.like-btn-row .like-count { font-variant-numeric: tabular-nums; }

/* 状态标签 */
.tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  padding: 1px 7px; margin-right: 6px; border-radius: var(--radius);
  vertical-align: 2px;
}
.tag.pin { background: #fdeaea; color: #a3251c; border: 1px solid #e08b84; }
.tag.lock { background: #efe9dd; color: #6a5a3a; border: 1px solid #c3b18c; }

/* ── ⑤ 帖子详情 ── */
.post-card {
  background: #fff;
  border: var(--border-px) var(--border-style) var(--c-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.post-card.is-op { border-color: var(--c-brand); box-shadow: var(--shadow-hard); }
.post-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(#eaf3e5, #dcebd4);
  border-bottom: 3px solid var(--c-brand);
  flex-wrap: wrap;
}
.post-card.is-op .post-head { background: var(--c-brand-soft); }
.post-ava {
  width: 38px; height: 38px; flex: none;
  border: 2px solid var(--c-brand-deep); border-radius: var(--radius);
}
.post-who { font-size: 14.5px; font-weight: 700; color: var(--c-brand-dark); }
.post-time { font-size: 12px; color: var(--c-ink-soft); }
.post-floor {
  margin-left: auto; font-size: 12px; font-weight: 700;
  color: #6a5a3a; background: var(--c-parchment);
  border: 2px solid var(--c-parchment-d); border-radius: var(--radius);
  padding: 1px 8px;
}
.post-body { padding: 16px 18px; }
/* 正文排版直接复用 style.css 的 .news-detail-body —— 服务端渲染的 HTML 标签集合一致 */
.post-actions {
  padding: 10px 18px 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.reply-box { margin-top: 26px; }

.section-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 28px 0 16px;
  font-size: 14px; font-weight: 700; color: var(--c-ink-soft);
}
.section-divider::after {
  content: ""; flex: 1; height: 3px;
  background: repeating-linear-gradient(90deg, var(--c-line) 0 10px, transparent 10px 18px);
}

/* ── ⑥ 分页 ── */
.pager {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 22px; padding-top: 16px;
  border-top: 2px dashed var(--c-line);
}
.pager-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: 38px; padding: 4px 12px;
  font-size: 13.5px; font-weight: 700;
  color: var(--c-ink); background: #fff;
  border: 2px solid var(--c-line); border-radius: var(--radius);
}
.pager-btn:hover:not([disabled]) { border-color: var(--c-brand); color: var(--c-brand-deep); }
.pager-btn.is-current {
  background: var(--c-brand-deep); color: #fff; border-color: var(--c-brand-dark);
  box-shadow: var(--shadow-hard-sm);
}
.pager-btn[disabled] { opacity: .45; cursor: not-allowed; }
.pager-gap { padding: 0 4px; color: var(--c-ink-soft); }
.pager-info { margin-left: auto; font-size: 13px; color: var(--c-ink-soft); }

/* ── ⑦ 加载 / 空态 ── */
.loading, .empty {
  padding: 40px 20px; text-align: center;
  background: #fff;
  border: var(--border-px) var(--border-style) var(--c-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
  color: var(--c-ink-soft); font-size: 14px;
}
.loading::before {
  content: ""; display: block; width: 26px; height: 26px; margin: 0 auto 12px;
  border: 4px solid var(--c-line); border-top-color: var(--c-brand-deep);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading::before { animation-duration: 2.4s; } }
.empty-title { font-size: 16px; font-weight: 700; color: var(--c-ink); margin-bottom: 8px; }
.empty-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ── ⑧ Markdown 预览框 ── */
.preview-box {
  margin-top: 8px;
  padding: 14px 16px;
  min-height: 120px;
  background: var(--c-brand-soft);
  border: 3px solid var(--c-line);
  border-radius: var(--radius);
  font-size: 14px; line-height: 1.8; color: var(--c-ink);
}
.preview-box.is-empty { color: #8b9490; font-style: normal; }
.preview-note { font-size: 12px; color: var(--c-ink-soft); margin-top: 6px; }
/* 预览区里的富文本排版同样复用 .news-detail-body 的规则 */
.preview-body > :first-child { margin-top: 0; }
.preview-body > :last-child { margin-bottom: 0; }
.preview-body p { margin: 0 0 10px; }
.preview-body h1, .preview-body h2, .preview-body h3 { margin: 14px 0 8px; font-size: 16px; }
.preview-body ul, .preview-body ol { margin: 0 0 10px; padding-left: 22px; list-style: disc; }
.preview-body ol { list-style: decimal; }
.preview-body a { color: var(--c-brand-deep); text-decoration: underline; text-underline-offset: 2px; }
.preview-body blockquote {
  margin: 10px 0; padding: 8px 14px;
  border-left: 4px solid var(--c-gold);
  background: rgba(217, 180, 106, .15);
  color: var(--c-ink-soft);
}
.preview-body strong { font-weight: 800; }

/* ── ⑨ 未登录引导卡 ── */
.gate-card {
  background: var(--c-parchment);
  border: 3px solid var(--c-parchment-d);
  box-shadow: inset 0 0 0 1px rgba(120, 90, 30, .16), var(--shadow-hard);
  border-radius: 2px;
  padding: 24px 22px;
  text-align: center;
}
.gate-title { font-size: 19px; font-weight: 800; color: #4a3414; margin-bottom: 8px; }
.gate-desc { font-size: 14px; color: #6b5430; max-width: 46ch; margin: 0 auto 18px; }
.gate-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* 版块卡片由 render.js 产出：这里补足原样式缺少的纵向堆叠行为 */
.forum-cat-head > span > .forum-cat-name,
.forum-cat-head > span > .forum-cat-meta { display: block; }
.forum-cat-body .news-item-excerpt {
  margin: 0;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  min-height: 3em;
}

/* ── ⑩ 首页：论坛区的最新帖摘要行 ── */
.home-latest { margin-top: 26px; }
.home-latest-head {
  font-size: 14px; font-weight: 800; color: var(--c-brand-dark);
  letter-spacing: .06em; margin-bottom: 10px;
}

/* ── ⑪ 通用卡片式容器（列表页/表单页外壳） ── */
.panel {
  background: #fff;
  border: var(--border-px) var(--border-style) var(--c-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
  padding: clamp(18px, 3.5vw, 28px);
}

/* ═══════════ 响应式 ═══════════ */
@media (max-width: 767px) {
  /* 两列：头像 + 主体；统计块与点赞按钮换行到第二列，不再和标题抢宽度 */
  .thread-row { grid-template-columns: 36px minmax(0, 1fr); gap: 10px 12px; }
  .thread-ava { width: 32px; height: 32px; }
  .thread-stats {
    grid-column: 2;
    flex-direction: row; flex-wrap: wrap; gap: 4px 14px;
    text-align: left; white-space: normal;
  }
  .like-btn-row { grid-column: 2; justify-self: start; align-self: start; }
  .thread-title { font-size: 15.5px; }
  /* 触控友好：分页按钮抬到 44px */
  .pager-btn { min-height: 44px; min-width: 44px; }
  .pager-info { margin-left: 0; width: 100%; text-align: center; }
  .post-floor { margin-left: 0; }
  .post-head { gap: 8px; }
}

@media (max-width: 420px) {
  /* 极窄屏：单列 + 隐藏头像，标题独占整行 */
  .thread-row { grid-template-columns: 1fr; }
  .thread-ava { display: none; }
  .thread-stats { grid-column: 1; }
  .like-btn-row { grid-column: 1; }
  .crumbs li { font-size: 12px; }
  .mini-stat { padding: 3px 9px; font-size: 12px; }
}

/* ═══════════ ⑧ 互动：点赞 / 行内编辑 / 确认框 / 用户主页 ═══════════ */

/* ── 作者名链接（render.js authorLink 产出） ── */
.who-link {
  color: var(--c-brand-deep); font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 2px;
  text-underline-offset: 2px; text-decoration-color: var(--c-line);
}
.who-link:hover { color: var(--c-brand-dark); text-decoration-color: var(--c-brand); }
.who-static { color: var(--c-ink-soft); }
.post-who-link { font-size: 14.5px; font-weight: 700; }

/* ── 点赞按钮：可切换的像素按钮 ── */
.like-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 3px 12px;
  font-size: 13.5px; font-weight: 700; font-family: inherit;
  color: var(--c-ink); background: #fff;
  border: 2px solid var(--c-line); border-radius: var(--radius);
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.like-btn:hover:not(:disabled) { border-color: var(--c-brand); color: var(--c-brand-deep); }
.like-btn:disabled { opacity: .6; cursor: progress; }
.like-btn .like-icon { font-size: 11px; line-height: 1; }
.like-btn.is-on {
  color: #fff; background: var(--c-brand-deep); border-color: var(--c-brand-dark);
  box-shadow: var(--shadow-hard-sm);
}
.like-btn.is-on:hover { background: var(--c-brand-dark); color: #fff; }
.like-btn.is-on .like-icon { color: var(--c-gold); }

/* ── 帖子操作条上的次级按钮 ── */
.post-act {
  min-height: 34px; padding: 3px 12px;
  font-size: 13.5px; font-weight: 700; font-family: inherit;
  color: var(--c-ink-soft); background: #fff;
  border: 2px solid var(--c-line); border-radius: var(--radius);
  cursor: pointer; transition: border-color .12s, color .12s;
}
.post-act:hover:not(:disabled) { border-color: var(--c-brand); color: var(--c-brand-deep); }
.post-act:disabled { opacity: .45; cursor: not-allowed; }
.post-act.is-danger:hover:not(:disabled) { border-color: #c62828; color: #a3251c; }

/* ── 行内编辑器（替换正文区） ── */
.inline-editor {
  padding: 14px 18px 16px;
  background: var(--c-bg-page);
  border-bottom: 2px dashed var(--c-line);
}
.inline-editor .field-label { display: block; margin: 0 0 6px; }
.inline-editor .field-control { margin-bottom: 10px; }
.inline-editor .field-msg { margin: 0 0 8px; }
.inline-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ── 危险按钮 ── */
.editor-btn.is-danger {
  color: #fff; background: #c62828; border-color: #8e1b1b;
}
.editor-btn.is-danger:hover { background: #a3251c; }

/* ── 确认框（BK.confirmDialog） ── */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(35, 39, 42, .55);
}
.modal-box {
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  background: #fff;
  border: 3px solid var(--c-charcoal); border-radius: var(--radius);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, .3);
}
.modal-title { font-size: 18px; font-weight: 800; color: var(--c-ink); margin-bottom: 10px; }
.modal-desc { font-size: 14px; line-height: 1.7; color: var(--c-ink-soft); margin-bottom: 18px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* ── 用户公开主页 ── */
.profile-card {
  display: grid; grid-template-columns: 96px 1fr; gap: 20px; align-items: start;
  padding: 22px; background: #fff;
  border: 3px solid var(--c-line); border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
}
.profile-ava {
  width: 96px; height: 96px; object-fit: cover;
  border: 3px solid var(--c-parchment-d); border-radius: var(--radius);
  background: var(--c-bg-page);
}
.profile-name { font-size: 22px; font-weight: 800; color: var(--c-ink); }
.profile-handle { font-size: 13.5px; color: var(--c-ink-soft); margin-top: 2px; }
.profile-bio { font-size: 14.5px; line-height: 1.75; color: var(--c-ink); margin-top: 12px; }
.profile-bio-empty { color: var(--c-ink-soft); font-style: italic; }
.profile-stats {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px;
}
.profile-stats > div {
  padding: 8px 14px; text-align: center;
  background: var(--c-bg-page);
  border: 2px solid var(--c-line); border-radius: var(--radius);
}
.profile-stats dt { font-size: 12px; color: var(--c-ink-soft); }
.profile-stats dd { font-size: 17px; font-weight: 800; color: var(--c-brand-dark); margin-top: 2px; }
.thread-list-empty { list-style: none; }

@media (max-width: 520px) {
  .profile-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .profile-stats { justify-content: center; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .editor-btn { flex: 1; }
}
