/* ============================================================
   合成大苏轼 — 评论区页面样式
   评论组件样式复用自 sushiNxuan64（urthreads），配色与首页一致
   ============================================================ */

/* 首页底部评论区入口：一行字，两侧各一条线（与首页标题装饰线同风格）
   margin-top:auto 在首页 flex 列布局下吸收剩余空间：屏高足够时贴底；
   屏高不足时 auto 为 0，间距由 footer-quote 的 padding-bottom 保证 */
.comments-entry {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
}

.comments-entry::before,
.comments-entry::after {
    content: "";
    width: 48px;
    height: 1px;
    background: #b8cdb8;
    transition: background 0.2s ease;
}

.comments-entry:hover::before,
.comments-entry:hover::after {
    background: #6b866b;
}

.comments-entry-title {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e2c;
    letter-spacing: 4px;
    margin: 0;
    text-decoration: underline;
    text-underline-offset: 5px;
    text-decoration-color: #b8cdb8;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.comments-entry:hover .comments-entry-title {
    color: #4a7a52;
    text-decoration-color: #4a7a52;
}

.comments-entry-sub {
    display: none;
}

/* 评论内容允许选中复制（游戏全局 div 设了 user-select:none，这里对评论区所有元素恢复），
   移动端长按正文即可弹出系统复制菜单 */
#commentsPage,
#commentsPage * {
    user-select: text;
    -moz-user-select: text;
    -webkit-user-select: text;
    -ms-user-select: text;
}

/* ========== 评论区页面 ========== */
#commentsPage {
    /* fixed 全屏 + 内部滚动：body overflow:hidden（Cocos 需要），长内容时评论区自己滚 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    display: none;
    box-sizing: border-box;
    padding: 32px 20px 48px;
    background: #f5f3ef;
    font-family: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
    text-align: left;
    z-index: 10001;
}

.comments-page-inner {
    max-width: 560px;
    margin: 0 auto;
}

.comments-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.comments-back-btn {
    /* 对齐 sushiNxuan64 的 back-link：一行字，hover 时才出现下划线 */
    border: none;
    background: transparent;
    color: #4a7a52;
    font-family: inherit;
    font-size: 14px;
    letter-spacing: 1px;
    padding: 0;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.comments-back-btn:hover {
    color: #2c3e2c;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.comments-page-title-wrap {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.comments-page-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e2c;
    letter-spacing: 2px;
    margin: 0;
}

.comments-page-like-bar {
    text-align: center;
    margin-bottom: 14px;
}

.page-like-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 22px;
    border: 1px solid #4a7a52;
    border-radius: 0;
    background: #ffffff;
    color: #4a7a52;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-like-btn:hover:not(:disabled) {
    background: #4a7a52;
    color: #fff;
}

.page-like-btn.is-liked {
    background: #4a7a52;
    color: #fff;
    cursor: default;
}

.page-like-btn:disabled {
    opacity: 0.85;
}

.rank-comments {
    background: #faf9f6;
    border: 1px dashed #b8cdb8;
    padding: 18px 20px;
}

.comments-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

/* 「留言评论」左侧矩形竖条（同 sushiNxuan64） */
.comments-section-header .title-deco-bar {
    width: 4px;
    height: 18px;
    background: #2c3e2c;
    flex-shrink: 0;
}

.comments-section-title {
    font-size: 15px;
    font-weight: 700;
    color: #2c3e2c;
    letter-spacing: 2px;
    margin: 0;
}

/* ========== 评论列表（由 comments.js 动态生成，样式同 sushiNxuan64） ========== */
.comment-list-wrap { margin-bottom: 14px; }
/* 排序切换条 */
.comment-sort-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.comment-sort-label {
  font-size: 12px;
  color: #7a877a;
}
.comment-sort-divider {
  color: #c6d2c6;
}
.comment-sort-btn {
  border: none;
  background: transparent;
  color: #4a7a52;
  font-family: inherit;
  font-size: 12px;
  padding: 2px 0;
  cursor: pointer;
  transition: color 0.2s ease;
}
.comment-sort-btn:hover {
  color: #2c3e2c;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.comment-sort-btn.is-active {
  color: #2c3e2c;
  font-weight: 700;
}
.comment-item {
  padding: 10px 0;
  border-bottom: 1px solid #e8ede8;
}
.comment-item:last-child { border-bottom: none; }
.comment-reply { margin-left: 1.5rem; }
/* 对齐 n选64 观感：n选64 有全局 * { margin:0; padding:0 } reset，
   本站没有，需显式清掉 p 元素默认 margin，否则昵称/正文间距偏大 */
.comment-item p,
.comment-empty,
.comment-status,
.comment-identity-bar {
  margin: 0;
}
.comment-meta {
  font-size: 12px;
  color: #7a877a;
  margin-bottom: 4px;
}
.comment-body {
  font-size: 13px;
  color: #2c3e2c;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-actions {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}
.comment-like-button,
.comment-reply-button {
  border: none;
  background: transparent;
  color: #4a7a52;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.2s ease;
}
.comment-like-button:hover,
.comment-reply-button:hover { color: #2c3e2c; text-decoration: underline; }
.comment-like-button:disabled { cursor: default; opacity: 0.6; }
.comment-like-button.is-liked { color: #4a7a52; font-weight: 700; }
.comment-replies { margin-top: 8px; }
.comment-empty {
  color: #7a877a;
  font-size: 13px;
  padding: 12px 0;
  text-align: center;
}
.comment-list-wrap .comment-loading { font-size: 12px; }
.comment-identity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #7a877a;
}
.comment-identity-bar[hidden] { display: none; }
.comment-identity-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-identity-edit {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #4a7a52;
  font-family: inherit;
  font-size: 12px;
  padding: 2px 0;
  cursor: pointer;
}
.comment-identity-edit:hover { color: #2c3e2c; text-decoration: underline; }

/* 状态信息 */
.comment-status {
  font-size: 12px;
  color: #7a877a;
  margin-bottom: 10px;
  min-height: 16px;
}
.comment-status.is-error { color: #8b7373; }

/* 评论表单 */
.comment-draft-form { display: flex; flex-direction: column; gap: 10px; }
.comment-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid #b8cdb8;
  border-radius: 0;
  background: #fff;
  color: #2c3e2c;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  box-sizing: border-box;
}
.comment-textarea:focus { outline: none; border-color: #4a7a52; }
.comment-send-btn {
  align-self: flex-end;
  padding: 8px 24px;
  border: 1px solid #4a7a52;
  border-radius: 0;
  background: #4a7a52;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.comment-send-btn:hover { background: #2c3e2c; border-color: #2c3e2c; }
.comment-send-btn:disabled { background: #b8cdb8; border-color: #b8cdb8; cursor: default; }

/* 身份弹窗 */
.comment-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.comment-modal[hidden] { display: none; }
.comment-modal-box {
  background: #faf9f6;
  border: 1px solid #b8cdb8;
  border-radius: 0;
  padding: 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.comment-modal-title {
  font-size: 15px;
  color: #2c3e2c;
  margin: 0 0 16px;
  letter-spacing: 1px;
}
.comment-identity-form { display: flex; flex-direction: column; gap: 10px; }
.comment-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #b8cdb8;
  border-radius: 0;
  background: #fff;
  color: #2c3e2c;
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}
.comment-input:focus { outline: none; border-color: #4a7a52; }
.comment-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.comment-cancel-btn,
.comment-submit-btn {
  padding: 8px 18px;
  border: 1px solid #b8cdb8;
  border-radius: 0;
  background: #fff;
  color: #2c3e2c;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.comment-cancel-btn:hover { background: #f5f8f4; }
.comment-submit-btn {
  background: #4a7a52;
  color: #fff;
  border-color: #4a7a52;
}
.comment-submit-btn:hover { background: #2c3e2c; border-color: #2c3e2c; }

/* 移动端 */
@media (max-width: 800px) {
  #commentsPage { padding: 24px 14px 40px; }
  .comments-page-title { font-size: 14px; }
  .rank-comments { padding: 14px; }
  /* 评论相关字号整体再小一档 */
  .comments-section-title { font-size: 13px; }
  .page-like-btn { font-size: 11px; }
  .comment-meta { font-size: 10px; }
  .comment-body { font-size: 10px; }
  .comment-like-button,
  .comment-reply-button { font-size: 10px; }
  .comment-empty { font-size: 11px; }
  .comment-input,
  .comment-textarea { font-size: 10px; min-height: 56px; }
  .comment-send-btn,
  .comment-submit-btn,
  .comment-cancel-btn { font-size: 11px; }
  .comment-modal-title { font-size: 14px; }
  .comment-status { font-size: 10px; }
  .comment-identity-bar { font-size: 10px; }
  .comment-modal-box { padding: 18px; }
  .donate-box { padding: 18px 14px; }
  .donate-title { font-size: 14px; }
  .donate-text { font-size: 11px; }
  .donate-close-btn { font-size: 12px; }
  .donate-qr img { max-width: 200px; }
}

/* ========== 赞赏区（评论区页底部） ========== */
.donate-section {
  text-align: center;
  margin-top: 28px;
}

/* 短细线分隔 */
.donate-divider {
  width: 48px;
  height: 1px;
  background: #b8cdb8;
  margin: 0 auto 18px;
}

/* 字距用 HTML 中的 en space 实现：letter-spacing 会在末字后多出一段，
   导致下划线右侧多出一截（视觉上像多个空格） */
.donate-link {
  border: none;
  background: transparent;
  color: #4a7a52;
  font-family: inherit;
  font-size: 14px;
  padding: 0 0 2px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-color: #b8cdb8;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.donate-link:hover {
  color: #2c3e2c;
  text-decoration-color: #2c3e2c;
}

/* ========== 赞赏弹窗（参考 sushiNxuan64 design提示组件 Modal 规范） ========== */
.donate-modal {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 44, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  padding: 20px;
}

.donate-modal[hidden] { display: none; }

.donate-box {
  background: #faf9f6;
  border: 1px solid #b8cdb8;
  box-shadow: 0 12px 40px rgba(44, 62, 44, 0.2);
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 24px 26px;
}

.donate-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #2c3e2c;
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #b8cdb8;
}

.donate-text {
  font-size: 13px;
  line-height: 1.8;
  color: #2c3e2c;
  text-align: left;
}

.donate-text p {
  margin: 0 0 10px;
}

.donate-text p:last-child {
  margin-bottom: 0;
}

.donate-qr {
  text-align: center;
  margin-top: 16px;
}

.donate-qr img {
  display: block;
  margin: 0 auto;
  max-width: 260px;
  width: 70%;
  height: auto;
  border: 1px solid #b8cdb8;
  background: #fff;
  padding: 8px;
  box-sizing: border-box;
  cursor: zoom-in; /* 点击放大 */
}

/* 赞赏码大图查看器 */
.donate-qr-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10003; /* 高于赞赏弹窗 10002 */
  padding: 20px;
  cursor: zoom-out;
}

.donate-qr-viewer[hidden] { display: none; }

.donate-qr-viewer img {
  display: block;
  max-width: 86vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  background: #fff;
  padding: 10px;
  box-sizing: border-box;
}

.donate-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.donate-close-btn {
  padding: 6px 20px;
  border: 1px solid #b8cdb8;
  border-radius: 0;
  background: #fff;
  color: #2c3e2c;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.donate-close-btn:hover {
  background: #f5f8f4;
  border-color: #4a7a52;
}
