/* community.css v10 */

/* ── Keyframes ───────────────────────────────────────────────────────────────*/
@keyframes commFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes commFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes commSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes commModalIn {
  from { opacity: 0; transform: scale(0.97) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes likePop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.45); }
  65%  { transform: scale(0.88); }
  100% { transform: scale(1); }
}
@keyframes commToastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Layout ──────────────────────────────────────────────────────────────────*/
body {
  margin: 0;
}

.community-layout {
  box-sizing: border-box;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 80px;
  min-height: calc(100dvh - 84px);
}
.community-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.community-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* ── Write button ─────────────────────────────────────────────────────────────*/
.community-write-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--on-gold);
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.community-write-btn:hover { opacity: 0.85; }
.community-write-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Login prompt ─────────────────────────────────────────────────────────────*/
.community-login-prompt {
  background: var(--bg-card, #151515);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--radius, 8px);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-3);
}
.community-login-prompt button {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.community-login-prompt button:hover { border-color: var(--gold); }

/* ── Post list ────────────────────────────────────────────────────────────────*/
.community-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 400px;
}
.comm-post-new { animation: commFadeIn 0.3s ease; }

/* ── Post card ────────────────────────────────────────────────────────────────*/
.comm-post {
  background: var(--bg-card, #151515);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--radius, 8px);
  box-sizing: border-box;
  padding: 16px;
  transition: border-color 0.15s;
  width: 100%;
}
.comm-post:hover { border-color: var(--gold); }

.comm-post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.comm-avatar-clip {
  width: 34px; height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--bg-3, #1f1f1f);
  flex-shrink: 0;
}
.comm-avatar-clip img {
  width: 100%; height: 100%;
  object-fit: contain;
}
.comm-post-meta {
  flex: 1;
  min-width: 0;
}
.comm-post-nickname {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comm-post-time {
  font-size: 11px;
  color: var(--text-3);
}

.comm-post-delete {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.comm-post-delete:hover {
  color: var(--danger, #e05);
  background: rgba(220,0,50,0.08);
  border-color: rgba(220,0,50,0.28);
}

.comm-post-content {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
}

/* ── Post image ───────────────────────────────────────────────────────────────*/
.comm-post-img-wrap {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-3);
  cursor: zoom-in;
  max-height: 400px;
  min-height: 0;
  width: 100%;
}
.comm-post-img-wrap img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  display: block;
}

/* ── Quoted post ──────────────────────────────────────────────────────────────*/
.comm-quote {
  border-left: 3px solid var(--gold);
  background: var(--bg-3);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.comm-quote-author {
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 2px;
  font-size: 11px;
}
.comm-quote-content {
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.comm-quote-img {
  margin-top: 4px;
  border-radius: 4px;
  max-height: 60px;
  object-fit: contain;
}

/* ── Post actions ─────────────────────────────────────────────────────────────*/
.comm-post-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.comm-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.comm-action-btn:hover { background: var(--bg-3); color: var(--text); }
.comm-action-btn.is-liked { color: var(--gold); }
.comm-like-pop svg { animation: likePop 0.35s cubic-bezier(0.34,1.56,0.64,1); }
.comm-action-btn svg { width: 15px; height: 15px; }
.comm-action-sep { flex: 1; }
.comm-action-quote {
  margin-left: auto;
}

/* ── Comments section ─────────────────────────────────────────────────────────*/
.comm-comments {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
  border-top: 1px solid transparent;
}
.comm-comments.is-open {
  grid-template-rows: 1fr;
  margin-top: 10px;
  padding-top: 10px;
  border-top-color: var(--border);
}
.comm-comments-inner { overflow: hidden; }

.comm-comment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.comm-comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.comm-comment-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-3);
  flex-shrink: 0;
}
.comm-comment-avatar img { width: 100%; height: 100%; object-fit: contain; }
.comm-comment-body {
  flex: 1;
  min-width: 0;
}
.comm-comment-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.comm-comment-nick {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.comm-comment-time {
  font-size: 10px;
  color: var(--text-3);
}
.comm-comment-del {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 10px;
  padding: 0 2px;
  margin-left: auto;
  transition: color 0.15s;
}
.comm-comment-del:hover { color: var(--danger, #e05); }
.comm-comment-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Comment input ────────────────────────────────────────────────────────────*/
.comm-comment-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.comm-comment-input {
  flex: 1;
  resize: none;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  line-height: 1.5;
  min-height: 38px;
  max-height: 100px;
  transition: border-color 0.15s;
  font-family: inherit;
}
.comm-comment-input:focus { outline: none; border-color: var(--gold); }
.comm-comment-submit {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--on-gold);
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.comm-comment-submit:hover { opacity: 0.85; }
.comm-comment-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Load more ────────────────────────────────────────────────────────────────*/
.community-load-more {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.community-load-more:hover { border-color: var(--gold); }
.community-load-more:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Write modal ──────────────────────────────────────────────────────────────*/
.comm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
  backdrop-filter: blur(2px);
}
@media (min-width: 600px) {
  .comm-modal-overlay { align-items: center; padding: 20px; }
}
.comm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: commSlideUp 0.26s cubic-bezier(0.22,1,0.36,1);
}
@media (min-width: 600px) {
  .comm-modal { border-radius: 16px; animation: commModalIn 0.22s ease; }
}
.comm-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.comm-modal-title {
  font-size: 15px;
  font-weight: 700;
}
.comm-modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.comm-modal-close:hover { color: var(--text); background: var(--bg-3); }
.comm-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Quote preview in modal ──────────────────────────────────────────────────*/
.comm-modal-quote {
  border-left: 3px solid var(--gold);
  background: var(--bg-3);
  border-radius: 0 6px 6px 0;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.comm-modal-quote-content {
  flex: 1;
  min-width: 0;
}
.comm-modal-quote-author { font-weight: 700; color: var(--gold); margin-bottom: 2px; }
.comm-modal-quote-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.comm-modal-quote-remove {
  background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 14px; padding: 0; flex-shrink: 0;
}
.comm-modal-quote-remove:hover { color: var(--text); }

.comm-modal-textarea {
  width: 100%;
  min-height: 120px;
  max-height: 240px;
  resize: vertical;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  line-height: 1.6;
  font-family: inherit;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.comm-modal-textarea:focus { outline: none; border-color: var(--gold); }

/* ── Image upload area ────────────────────────────────────────────────────────*/
.comm-upload-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comm-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
  align-self: flex-start;
}
.comm-upload-btn:hover { border-color: var(--gold); color: var(--text); }
.comm-upload-progress {
  font-size: 11px;
  color: var(--text-3);
  display: none;
}
.comm-upload-preview {
  position: relative;
  display: inline-block;
}
.comm-upload-preview img {
  max-height: 160px;
  max-width: 100%;
  border-radius: 8px;
  object-fit: contain;
  display: block;
}
.comm-upload-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.comm-upload-hint {
  font-size: 11px;
  color: var(--text-3);
}

/* ── Char counter ────────────────────────────────────────────────────────────*/
.comm-char-count {
  font-size: 11px;
  color: var(--text-3);
  text-align: right;
}
.comm-char-count.is-over { color: #e05; }

.comm-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.comm-modal-error {
  flex: 1;
  font-size: 12px;
  color: #e05;
}
.comm-submit-btn {
  padding: 9px 20px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--on-gold);
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.comm-submit-btn:hover { opacity: 0.85; }
.comm-submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Image lightbox ──────────────────────────────────────────────────────────*/
.comm-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.comm-lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
}

/* ── Empty / loading states ──────────────────────────────────────────────────*/
.community-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 14px;
}

/* Skeleton mirrors .comm-post exactly */
.comm-post-skeleton {
  background: var(--bg-card, #151515);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--radius, 8px);
  box-sizing: border-box;
  padding: 16px;
  width: 100%;
}
.comm-sk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;  /* matches .comm-post-head */
}
.comm-sk-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
}
.comm-sk-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.comm-sk-nick {
  height: 13px;
  width: min(34vw, 116px);
  border-radius: 4px;
}
.comm-sk-nick--compact { width: min(28vw, 92px); }
.comm-sk-time {
  height: 11px;
  width: 54px;
  border-radius: 4px;
}
.comm-sk-time--compact { width: 44px; }
.comm-sk-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.comm-sk-icon-btn,
.comm-sk-delete-btn {
  height: 28px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 6px;
  box-sizing: border-box;
}
.comm-sk-icon-btn { width: 32px; }
.comm-sk-delete-btn { width: 51px; }
.comm-sk-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;  /* matches .comm-post-content */
}
.comm-sk-text {
  height: 23px;
  width: 100%;
  border-radius: 4px;
}
.comm-sk-text--short { width: 68%; }
.comm-sk-text--mid { width: 65%; }
.comm-sk-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.12));
}
.comm-sk-action {
  width: 44px;
  height: 23px;
  border-radius: 6px;
}
.comm-sk-quote {
  width: 54px;
  height: 23px;
  border-radius: 6px;
}
.comm-sk-foot .comm-sk-quote { margin-left: auto; }
.comm-sk-img {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
  max-height: 400px;
  border-radius: 8px;
}

/* ── Share button ────────────────────────────────────────────────────────────*/
.comm-share-btn {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  color: var(--text-3);
  cursor: pointer;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  position: relative;
}
.comm-share-btn:hover {
  color: var(--text);
  background: var(--bg-3);
  border-color: rgba(200,146,26,0.42);
}
.comm-share-btn svg { width: 14px; height: 14px; }
.comm-share-btn + .comm-post-delete {
  margin-left: -4px;
}
.comm-share-btn + .comm-post-delete::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 14px;
  margin: 0 8px 0 0;
  background: var(--border, rgba(255,255,255,0.12));
  vertical-align: middle;
}

/* ── Toast ───────────────────────────────────────────────────────────────────*/
.comm-toast-stack {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.comm-toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.28);
  animation: commToastIn 0.22s ease;
  pointer-events: auto;
  white-space: nowrap;
  text-align: center;
}
.comm-toast.is-error { border-color: #e05; color: #e05; }
.comm-toast.is-out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

/* ── Inline confirm (delete) ─────────────────────────────────────────────────*/
.comm-confirm-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.comm-confirm-yes {
  color: #e05 !important;
  font-weight: 700;
}

/* ── Light mode overrides ────────────────────────────────────────────────────*/
[data-theme="light"] .comm-avatar-clip { border-color: var(--border); }
[data-theme="light"] .comm-comment-avatar { border-color: var(--border); }
