/* ============================================================
   community.css — 社区页：分区导航 / 文献与帖子列表 / 详情模态框
   本页只负责「看」；发布内容请到 publish.html
   ============================================================ */

/* ============ 页头 ============ */
.page-head {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--line);
}

.page-head-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 40px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.page-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-label::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--ink-mute);
}

.page-head h1 {
  font-size: 2.2rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.page-head-meta {
  font-size: 0.8rem;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}

/* ============ 主体布局：单列内容流 ============ */
.community-layout {
  max-width: 840px;
  padding: 44px 0 80px;
}

/* ---- 内容流 ---- */
.community-main { min-width: 0; }

.community-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

/* 文献库 / 帖子广场已拆为独立页面，栏内只剩发布按钮，统一靠右 */
.community-bar > .btn-ghost {
  margin-left: auto;
}

/* ---- 池子切换：文献库 / 帖子广场（两个互不混用的池子） ---- */
.pool-seg {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.pool-btn {
  min-width: 118px;
  background: none;
  border: none;
  border-right: 1px solid var(--line);
  padding: 12px 22px;
  font-family: inherit;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}

.pool-btn:last-child { border-right: none; }
.pool-btn:hover { background: #f5f5f2; color: var(--ink); }

.pool-btn.active {
  background: var(--ink);
  color: #fff;
  font-weight: 550;
}

/* ---- 标签筛选 ---- */
.tag-filter {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.tag-filter-label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
  flex-shrink: 0;
}

.tag-chips { flex: 1; min-width: 0; }

.tag-chips:empty::after {
  content: "该池子还没有标签";
  font-size: 0.78rem;
  color: var(--ink-mute);
}

.browse-filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 18px;
}

/* 筛选胶囊 */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.filter-chip {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
}

.filter-chip:hover { border-color: var(--ink); color: var(--ink); }

.filter-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(26, 43, 60, 0.06);
  font-weight: 500;
}

.filters-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mini-search { display: flex; }

.mini-search input {
  width: 230px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-right: none;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0 12px;
}

.mini-search input:focus { outline: none; border-color: var(--ink); }

.mini-search button {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background-color .15s;
}

.mini-search button:hover { background: var(--accent); }

/* ============ 列表 ============ */
.post-list { display: flex; flex-direction: column; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 22px 24px 18px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color .2s;
}

.post-card:hover { border-color: var(--ink-mute); }
.post-card:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

/* 文献库 / 帖子广场：两个栏目的定位说明与卡片标识 */
.pool-intro {
  margin-bottom: 18px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  font-size: 0.78rem;
  line-height: 1.75;
  color: var(--ink-soft);
}
.pool-intro[data-pool="post"] { border-left-color: #d92d20; }
.pool-panel[data-pool="literature"] .post-card { border-left: 3px solid var(--accent); }
.pool-panel[data-pool="post"] .post-card { border-left: 3px solid #d92d20; }

.post-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.post-type {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
}

.post-type.literature { border-color: var(--accent); color: var(--accent); }

.post-card-cat {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.post-card h3 {
  font-size: 1.06rem;
  font-weight: 550;
  line-height: 1.4;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin-bottom: 8px;
}

.post-card-summary {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

/* 卡片上的自定义标签 */
.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.post-tag {
  font-size: 0.68rem;
  color: var(--accent);
  background: rgba(26, 43, 60, 0.06);
  border: 1px solid var(--line);
  padding: 3px 8px;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--ink-mute);
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.post-card-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.post-like,
.post-fav,
.post-delete {
  background: none;
  border: none;
  color: var(--ink-mute);
  font-family: inherit;
  font-size: 0.74rem;
  cursor: pointer;
  padding: 0;
  transition: color .15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.post-like:hover { color: var(--ink); }
.post-like.on { color: var(--accent); font-weight: 550; }
.post-fav:hover { color: var(--ink); }
.post-fav.on { color: var(--accent); font-weight: 550; }
.post-delete:hover { color: #c0392b; }
.post-delete:disabled { opacity: .6; cursor: default; }

.post-empty {
  font-size: 0.85rem;
  color: var(--ink-mute);
  padding: 40px 0;
  text-align: center;
}

.list-status {
  font-size: 0.78rem;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  padding: 4px 0 12px;
  display: none;
}

.list-status.show { display: block; }

.list-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 0;
}

.load-status {
  font-size: 0.75rem;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
  min-height: 1em;
}

/* ============ 详情模态框 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--surface);
  max-width: 720px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  transform: translateY(12px);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  display: flex;
  flex-direction: column;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-head {
  padding: 28px 36px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.modal-head-text { flex: 1; min-width: 0; }

.modal-cat {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal h2 {
  font-size: 1.5rem;
  font-weight: 550;
  line-height: 1.3;
  letter-spacing: -0.018em;
  color: var(--ink);
}

.modal-close {
  background: none;
  border: 1px solid var(--line-strong);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink-soft);
  flex-shrink: 0;
  transition: border-color .15s, color .15s, background-color .15s;
  font-family: inherit;
}

.modal-close:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: #f5f5f2;
}

.modal-close svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}

.modal-body { padding: 26px 36px 30px; flex: 1; }

.modal-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-content p {
  font-size: 0.94rem;
  color: var(--ink-soft);
  line-height: 1.85;
  margin-bottom: 14px;
}

.modal-content p:last-child { margin-bottom: 0; }

/* ---- 完整 Markdown 正文（标题 / 列表 / 引用 / 表格 / 代码 / 图片） ---- */
.modal-content h1,
.modal-content h2,
.modal-content h3,
.modal-content h4,
.modal-content h5,
.modal-content h6 {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.modal-content h1 { font-size: 1.42rem; margin: 26px 0 14px; }
.modal-content h2 {
  font-size: 1.22rem;
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.modal-content h3 { font-size: 1.06rem; margin: 22px 0 10px; }
.modal-content h4,
.modal-content h5,
.modal-content h6 { font-size: 0.96rem; margin: 18px 0 8px; }

.modal-content ul,
.modal-content ol {
  margin: 0 0 14px;
  padding-left: 22px;
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.8;
}

.modal-content li { margin-bottom: 5px; }
.modal-content li::marker { color: var(--ink-mute); }

.modal-content blockquote {
  margin: 18px 0;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--accent);
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.75;
}

.modal-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

.modal-content a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink-mute);
  overflow-wrap: anywhere;
}

.modal-content a:hover { border-bottom-color: var(--ink); }

.modal-content strong { color: var(--ink); font-weight: 600; }
.modal-content del { color: var(--ink-mute); }
.modal-content mark { background: #f3e6b8; color: var(--ink); }

.modal-content code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.84em;
  background: #f0f0ec;
  border: 1px solid var(--line);
  color: var(--accent);
  padding: 1px 5px;
}

.modal-content pre {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  background: #f7f7f4;
  overflow-x: auto;
}

.modal-content pre code {
  display: block;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre;
}

.modal-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 0.86rem;
  line-height: 1.6;
}

.modal-content th,
.modal-content td {
  border: 1px solid var(--line);
  padding: 7px 11px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
}

.modal-content th {
  background: var(--line);
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

.modal-content td { color: var(--ink-soft); }

.modal-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px 0;
  border: 1px solid var(--line);
}

.modal-content .task-list { list-style: none; padding-left: 2px; }
.modal-content .task-list li { display: flex; align-items: flex-start; gap: 8px; }
.modal-content .task-list input { margin-top: 5px; }

/* ---- 文献 PDF 预览 ---- */
.pdf-panel {
  margin: 22px 0 4px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.pdf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f7f7f4;
}

.pdf-label {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-soft);
}

.pdf-open {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--ink);
  border-bottom: 1px solid var(--ink-mute);
  text-decoration: none;
}

.pdf-open:hover { border-bottom-color: var(--ink); }

.pdf-frame {
  display: block;
  width: 100%;
  height: 560px;
  border: none;
  background: #f0f0ec;
}

.pdf-hint {
  padding: 8px 14px 10px;
  font-size: 0.7rem;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}

:root[data-theme="dark"] .pdf-head,
:root[data-theme="dark"] .modal-content pre { background: #1a1e1b; }

:root[data-theme="dark"] .modal-content code { background: #222824; }
:root[data-theme="dark"] .modal-content mark { background: #4a4526; color: var(--ink); }
:root[data-theme="dark"] .pdf-frame { background: #222824; }

@media (max-width: 760px) {
  .pdf-frame { height: 62vh; }
}

.post-modal-foot { margin-top: 20px; }

.card-read {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  padding: 8px 16px;
  transition: border-color .15s, background-color .15s, color .15s;
}

.card-read svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.card-read:hover { border-color: var(--ink); background: var(--ink); color: #fff; }

.modal-actions {
  display: flex;
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.action-btn {
  flex: 1;
  background: var(--surface);
  border: none;
  padding: 18px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  transition: background-color .15s, color .15s;
}

.action-btn:hover { background: #f5f5f2; color: var(--ink); }

.action-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.action-btn.active { color: var(--accent); }
.action-btn.active svg { fill: var(--accent); stroke: var(--accent); }

/* ============ 评论区（详情内） ============ */
.post-comments {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.comments-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.comments-title {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}

.comments-count {
  font-size: 0.78rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.comment-editor { margin-bottom: 20px; }

.comment-editor textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 11px 13px;
  resize: vertical;
}

.comment-editor textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.comment-editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.comment-hint {
  font-size: 0.72rem;
  color: var(--ink-mute);
}

.comment-list {
  display: flex;
  flex-direction: column;
}

.comment-item {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.comment-item:first-child { border-top: none; }

.comment-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.comment-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.comment-time {
  font-size: 0.7rem;
  color: var(--ink-mute);
}

.comment-text {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.comment-like,
.comment-delete {
  background: none;
  border: none;
  color: var(--ink-mute);
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}

.comment-like:hover { color: var(--ink); }
.comment-like.on { color: var(--accent); font-weight: 550; }
.comment-delete:hover { color: #c0392b; }

.comment-empty {
  font-size: 0.8rem;
  color: var(--ink-mute);
  padding: 12px 0;
}

/* ============ 通用按钮 / 分段控件 ============ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 22px;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 20px;
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
}

.btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: #f5f5f2;
}

.btn-sm { height: 36px; padding: 0 16px; font-size: 0.74rem; }

.seg {
  display: flex;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.seg-item {
  flex: 1 1 auto;
  min-width: 88px;
  background: none;
  border: none;
  border-right: 1px solid var(--line);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}

.seg-item:last-child { border-right: none; }
.seg-item:hover { background: #f5f5f2; color: var(--ink); }

.seg-item.active {
  background: var(--ink);
  color: #fff;
  font-weight: 550;
}

.seg-item:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .community-layout { padding: 32px 0 64px; }
}

@media (max-width: 760px) {
  .page-head { padding: 40px 0 32px; }
  .page-head h1 { font-size: 1.7rem; }
  .page-head-inner { gap: 16px; }

  .community-layout { padding: 28px 0 64px; }

  .community-bar { flex-direction: column; align-items: stretch; }
  .pool-seg { width: 100%; }
  .pool-btn { flex: 1; min-width: 0; }

  .tag-filter { flex-direction: column; align-items: stretch; gap: 8px; }

  .browse-filters { flex-direction: column; align-items: stretch; }
  .mini-search input { width: 100%; flex: 1; }

  .post-card { padding: 18px 20px 16px; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-height: 92vh;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(100%);
  }
  .modal-overlay.open .modal { transform: translateY(0); }
  .modal-head { padding: 22px 22px 18px; }
  .modal h2 { font-size: 1.28rem; }
  .modal-body { padding: 20px 22px 24px; }
}
