/* =========================================================
   css/community.css — Reddit-style community forum
   ========================================================= */

/* ── Auth form (modal) ── */
.community-auth__toggle {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 12px; font-family: 'Outfit', sans-serif; font-size: 12.5px; color: var(--text-muted);
}
.community-auth__toggle-btn {
  background: none; border: none; cursor: pointer; font-family: 'Outfit', sans-serif;
  font-size: 12.5px; font-weight: 600; color: var(--accent); transition: opacity 0.3s;
}
.community-auth__toggle-btn:hover { opacity: 0.7; }

/* ── Topics ── */
.community-topics {
  display: flex; gap: 8px; padding: 0 24px 16px;
  overflow-x: auto; scrollbar-width: none;
}
.community-topics::-webkit-scrollbar { display: none; }
.community-topic {
  flex-shrink: 0; padding: 7px 15px; border-radius: 100px;
  font-family: 'Outfit', sans-serif; font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--divider); background: var(--card); color: var(--text-secondary);
  cursor: pointer; transition: all 0.35s var(--ease-out); white-space: nowrap;
  text-decoration: none; box-shadow: var(--shadow-xs);
}
.community-topic:hover { border-color: var(--accent-soft); color: var(--text-primary); }
.community-topic:active { transform: scale(0.96); }
.community-topic.active {
  background: var(--text-primary); border-color: var(--text-primary);
  color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(28,25,23,0.12);
}

/* ── Sort controls ── */
.community-sort {
  display: flex; gap: 4px; padding: 0 24px 16px;
}
.community-sort__btn {
  padding: 6px 14px; border-radius: 100px; font-family: 'Outfit', sans-serif;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  background: none; border: none; cursor: pointer; transition: all 0.3s var(--ease-out);
}
.community-sort__btn:hover { color: var(--text-primary); background: var(--bg-subtle); }
.community-sort__btn.active { color: var(--text-primary); background: var(--bg-subtle); font-weight: 600; }

/* ── Post card — Reddit-style ── */
.community-post {
  padding: 16px 24px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.community-post:hover { background: rgba(28,25,23,0.012); }

/* Post header: avatar + username + time */
.community-post__header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.community-post__avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif; font-size: 12px; font-weight: 600; color: var(--accent);
  flex-shrink: 0; overflow: hidden;
}
.community-post__avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.community-post__author {
  font-family: 'Outfit', sans-serif; font-size: 13px; font-weight: 600; color: var(--text-primary);
}
.community-post__dot { color: var(--text-muted); font-size: 10px; }
.community-post__time {
  font-family: 'Outfit', sans-serif; font-size: 12px; color: var(--text-muted);
}

/* Topic badge */
.community-post__topic {
  display: inline-block; font-family: 'Outfit', sans-serif; font-size: 10px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 100px;
  margin-bottom: 6px; background: var(--bg-subtle); color: var(--text-secondary);
}

/* Title */
.community-post__title {
  font-family: 'Outfit', sans-serif; font-size: 16px; font-weight: 600;
  color: var(--text-primary); line-height: 1.35; margin-bottom: 6px; letter-spacing: -0.01em;
}

/* Body preview */
.community-post__preview {
  font-family: 'Outfit', sans-serif; font-size: 14px; color: var(--text-secondary);
  line-height: 1.55; margin-bottom: 12px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* Bottom action bar — pill-shaped buttons in a row */
.community-post__actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.community-action {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 100px;
  font-family: 'Outfit', sans-serif; font-size: 12px; font-weight: 500;
  color: var(--text-muted); background: var(--bg-subtle);
  border: none; cursor: pointer; transition: all 0.3s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.community-action:hover { background: var(--divider); color: var(--text-secondary); }
.community-action:active { transform: scale(0.95); }
.community-action svg {
  width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8;
}
.community-action.voted { color: var(--accent); background: var(--accent-bg); }
.community-action.voted svg { stroke: var(--accent); }

/* ── FAB ── */
.community-fab {
  position: fixed;
  bottom: calc(var(--tab-bar-h, 82px) + 16px);
  right: max(16px, calc((100vw - 430px) / 2 + 16px));
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(181,137,46,0.3);
  transition: all 0.4s var(--ease-out); z-index: 100;
}
.community-fab:hover { transform: scale(1.08); box-shadow: 0 8px 28px rgba(181,137,46,0.35); }
.community-fab:active { transform: scale(0.95); }
.community-fab svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 2.2; }
.community-fab.hidden { display: none; }
@media (min-width: 768px) {
  .community-fab { right: calc((100vw - 1100px) / 2 + 24px); bottom: 32px; }
}

/* ── Bottom sheet (new post / auth modal) ── */
.community-sheet-overlay {
  position: fixed; inset: 0; background: rgba(28,25,23,0.4); z-index: 10000;
  opacity: 0; transition: opacity 0.3s var(--ease-out); pointer-events: none;
}
.community-sheet-overlay.show { opacity: 1; pointer-events: auto; }

.community-sheet {
  position: fixed; bottom: 0; left: 50%; transform: translate(-50%, 100%);
  width: 100%; max-width: 430px; background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 24px 32px; z-index: 10001;
  transition: transform 0.45s var(--ease-out);
  box-shadow: 0 -8px 40px rgba(28,25,23,0.12); max-height: 85vh; overflow-y: auto;
}
.community-sheet.show { transform: translate(-50%, 0); }
@media (min-width: 768px) {
  .community-sheet {
    max-width: 480px; border-radius: var(--radius-xl);
    bottom: auto; top: 50%; transform: translate(-50%, -50%) scale(0.95); opacity: 0;
  }
  .community-sheet.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.community-sheet__header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.community-sheet__title {
  font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 600;
  color: var(--text-primary); letter-spacing: -0.02em;
}
.community-sheet__close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--bg-subtle); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all 0.3s var(--ease-out);
}
.community-sheet__close:hover { background: var(--divider); }

.community-sheet__field { margin-bottom: 16px; }
.community-sheet__label {
  display: block; font-family: 'Outfit', sans-serif; font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}
.community-sheet__input,
.community-sheet__select,
.community-sheet__textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--divider);
  border-radius: var(--radius-sm); font-family: 'Outfit', sans-serif; font-size: 14px;
  color: var(--text-primary); background: var(--bg); outline: none;
  transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
  -webkit-appearance: none;
}
.community-sheet__input:focus,
.community-sheet__select:focus,
.community-sheet__textarea:focus {
  border-color: var(--accent-soft); box-shadow: 0 0 0 3px rgba(181,137,46,0.08);
}
.community-sheet__textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.community-sheet__submit {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-md);
  font-family: 'Outfit', sans-serif; font-size: 14.5px; font-weight: 600;
  cursor: pointer; background: var(--accent); color: #fff;
  box-shadow: 0 4px 20px rgba(181,137,46,0.25); transition: all 0.4s var(--ease-out); margin-top: 8px;
}
.community-sheet__submit:hover { box-shadow: 0 8px 28px rgba(181,137,46,0.3); transform: translateY(-1px); }
.community-sheet__submit:active { transform: scale(0.98); }
.community-sheet__submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Post detail view ── */
.community-detail { display: none; padding: 0 24px; padding-bottom: 40px; }
.community-detail.show { display: block; animation: fadeUp 0.35s var(--ease-out); }
.community-feed.hidden { display: none; }

.community-detail__back {
  display: flex; align-items: center; gap: 8px; background: none; border: none;
  cursor: pointer; font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 500;
  color: var(--text-secondary); padding: 12px 0;
}
.community-detail__back svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.community-detail__post-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.community-detail__topic {
  display: inline-block; font-family: 'Outfit', sans-serif; font-size: 10px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 100px;
  margin-bottom: 10px; background: var(--bg-subtle); color: var(--text-secondary);
}
.community-detail__title {
  font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 600;
  color: var(--text-primary); line-height: 1.2; letter-spacing: -0.02em; margin-bottom: 8px;
}
.community-detail__meta {
  font-family: 'Outfit', sans-serif; font-size: 13px; color: var(--text-muted); margin-bottom: 12px;
}
.community-detail__body {
  font-family: 'Source Serif 4', serif; font-size: 15.5px; line-height: 1.85;
  color: var(--text-body); padding-bottom: 16px; white-space: pre-wrap;
}

/* Post action bar in detail view */
.community-detail__actions {
  display: flex; align-items: center; gap: 8px; padding: 0 0 20px;
  border-bottom: 1px solid var(--divider);
}

/* ── Comments — threaded with indent lines ── */
.community-comments__header {
  font-family: 'Outfit', sans-serif; font-size: 10.5px; font-weight: 600;
  letter-spacing: 2.5px; text-transform: uppercase; color: var(--text-muted); padding: 20px 0 14px;
}

/* Join the conversation input (top of comments) */
.community-comment-join {
  padding: 0 0 16px;
}
.community-comment-join__input {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--divider);
  border-radius: var(--radius-md); font-family: 'Outfit', sans-serif; font-size: 14px;
  color: var(--text-muted); background: var(--bg); cursor: pointer;
  transition: border-color 0.3s var(--ease-out); outline: none;
}
.community-comment-join__input:hover { border-color: var(--accent-soft); }

/* Comment thread */
.community-comment {
  position: relative; padding: 12px 0 12px 20px; margin-left: 14px;
}
/* Vertical thread line */
.community-comment::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--divider); border-radius: 1px;
}
.community-comment:last-child::before { bottom: 12px; }

/* Nested replies — deeper indent */
.community-comment .community-comment { margin-left: 10px; }

.community-comment__header {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
}
.community-comment__avatar {
  width: 22px; height: 22px; border-radius: 50%; background: var(--bg-subtle);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif; font-size: 10px; font-weight: 600; color: var(--text-secondary);
  flex-shrink: 0; overflow: hidden;
}
.community-comment__avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.community-comment__author {
  font-family: 'Outfit', sans-serif; font-size: 12.5px; font-weight: 600; color: var(--text-primary);
}
.community-comment__time {
  font-family: 'Outfit', sans-serif; font-size: 11px; color: var(--text-muted);
}
.community-comment__body {
  font-family: 'Outfit', sans-serif; font-size: 14px; color: var(--text-body);
  line-height: 1.6; margin: 4px 0 6px;
}
/* Comment actions */
.community-comment__actions {
  display: flex; align-items: center; gap: 6px;
}
.community-comment__action {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: 'Outfit', sans-serif; font-size: 11px; font-weight: 500;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  padding: 3px 8px; border-radius: 100px; transition: all 0.3s var(--ease-out);
}
.community-comment__action:hover { background: var(--bg-subtle); color: var(--text-secondary); }
.community-comment__action svg {
  width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8;
}

/* Comment input (bottom) */
.community-comment-input {
  display: flex; gap: 10px; padding: 16px 0 8px; align-items: flex-end;
}
.community-comment-input__field {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--divider);
  border-radius: var(--radius-sm); font-family: 'Outfit', sans-serif; font-size: 13.5px;
  color: var(--text-primary); background: var(--bg); outline: none; resize: none;
  min-height: 42px; max-height: 100px; line-height: 1.5;
  transition: border-color 0.3s var(--ease-out);
}
.community-comment-input__field:focus { border-color: var(--accent-soft); }
.community-comment-input__field::placeholder { color: var(--text-muted); }
.community-comment-input__send {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.4s var(--ease-out);
}
.community-comment-input__send:hover { background: var(--accent-soft); }
.community-comment-input__send:active { transform: scale(0.95); }
.community-comment-input__send svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; }

/* ── Empty state ── */
.community-empty { text-align: center; padding: 48px 24px; }
.community-empty__icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.community-empty__title {
  font-family: 'Outfit', sans-serif; font-size: 16px; font-weight: 600;
  color: var(--text-primary); margin-bottom: 6px;
}
.community-empty__desc {
  font-family: 'Outfit', sans-serif; font-size: 13px; color: var(--text-muted); line-height: 1.5;
}

/* ── Loading skeleton ── */
.community-skeleton { padding: 18px 24px; border-bottom: 1px solid var(--divider); }
.community-skeleton__row {
  height: 14px; border-radius: 6px; margin-bottom: 10px;
  background: linear-gradient(90deg, var(--bg-subtle) 25%, #efe9df 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%; animation: shimmer 1.8s ease infinite;
}
.community-skeleton__row:first-child { width: 40%; }
.community-skeleton__row:nth-child(2) { width: 80%; height: 16px; }
.community-skeleton__row:nth-child(3) { width: 60%; }

/* ── Toast ── */
.community-toast {
  position: fixed; bottom: calc(var(--tab-bar-h, 82px) + 20px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary); color: #fff;
  font-family: 'Outfit', sans-serif; font-size: 13px; font-weight: 500;
  padding: 10px 20px; border-radius: 100px; z-index: 700;
  opacity: 0; transition: all 0.4s var(--ease-out); pointer-events: none; white-space: nowrap;
}
.community-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
