/* ============================================================
   СТРАНИЦА ПОСТОВ
   ============================================================ */

.controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.posts-feed {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 80px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}

/* ---------- Карточка ---------- */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: rgba(20, 12, 35, 0.6);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  animation: riseIn 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1),
    border-color 0.35s ease,
    box-shadow 0.35s ease,
    background 0.35s ease;
}
.post-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at top right,
    color-mix(in srgb, var(--accent, #8b5cf6) 18%, transparent),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.post-card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent, #8b5cf6) 50%, transparent);
  background: rgba(28, 17, 48, 0.75);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 30px color-mix(in srgb, var(--accent, #8b5cf6) 22%, transparent);
}
.post-card:hover::before {
  opacity: 1;
}

.post-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
}
.author {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.author-avatar-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.author-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.author-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-date {
  font-size: 12px;
  color: var(--muted);
}

.post-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #a78bfa);
  background: color-mix(in srgb, var(--accent, #a78bfa) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #a78bfa) 30%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
}
.post-category .c-icon {
  font-size: 12px;
  line-height: 1;
}

.post-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  position: relative;
}
.post-image {
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: rgba(0, 0, 0, 0.3);
  position: relative;
}
.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.post-card:hover .post-image img {
  transform: scale(1.05);
}
.post-excerpt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  position: relative;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  position: relative;
}
.post-tags .tag {
  font-family: inherit;
  font-size: 12px;
  color: var(--purple-bright);
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.2);
  padding: 3px 10px;
  border-radius: 100px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}
.post-tags .tag:hover {
  background: rgba(139, 92, 246, 0.22);
  color: #fff;
  border-color: rgba(167, 139, 250, 0.5);
}

.post-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(167, 139, 250, 0.1);
  position: relative;
  flex-wrap: wrap;
}
.post-foot-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.reactions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.react-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 100px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.25s ease,
    background 0.25s ease,
    border-color 0.25s ease,
    transform 0.2s ease;
}
.react-btn:hover {
  color: var(--text);
  background: rgba(139, 92, 246, 0.1);
  transform: translateY(-1px);
}
.react-btn.like.active {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.3);
}
.react-btn.dislike.active {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
}
.react-btn svg {
  transition: transform 0.25s ease;
}
.react-btn:hover svg {
  transform: scale(1.15);
}

.post-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.post-meta-item svg {
  opacity: 0.7;
}
.post-meta-item-lg {
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: rgba(20, 12, 35, 0.5);
  border-radius: 100px;
}

.post-report-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.25s ease,
    background 0.25s ease,
    border-color 0.25s ease,
    transform 0.2s ease;
}
.post-report-btn:hover {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
  transform: translateY(-1px);
}
.post-report-btn-lg {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: rgba(20, 12, 35, 0.5);
}

/* ---------- Кнопка закладки ---------- */
.post-bookmark-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.25s ease,
    background 0.25s ease,
    border-color 0.25s ease,
    transform 0.2s ease;
}
.post-bookmark-btn:hover {
  color: var(--purple-bright);
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateY(-1px);
}
.post-bookmark-btn.active {
  color: var(--purple-bright);
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
}

/* ---------- Модалка ---------- */
.modal-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 18px;
  margin-top: 4px;
  border-top: 1px solid rgba(167, 139, 250, 0.12);
}
.modal-meta-row .react-btn {
  padding: 9px 16px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: rgba(20, 12, 35, 0.5);
}

/* Кнопка удаления поста */
.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 100px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #f87171;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
  margin-left: auto;
}
.btn-delete:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: #f87171;
  transform: translateY(-1px);
}

/* ============================================================
   Формы в модалках (создание / редактирование поста)
   ============================================================ */

.modal-form-select {
  padding: 13px 16px;
  border-radius: 12px;
  background: rgba(10, 7, 16, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    background-color 0.25s ease;
}
.modal-form-select:focus {
  border-color: rgba(167, 139, 250, 0.6);
  background-color: rgba(10, 7, 16, 0.85);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
}
.modal-form-select option {
  background: #1a1029;
  color: #ece9f5;
}

.modal-form-textarea {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  background: rgba(10, 7, 16, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 140px;
  line-height: 1.55;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    background-color 0.25s ease;
}
.modal-form-textarea:focus {
  border-color: rgba(167, 139, 250, 0.6);
  background-color: rgba(10, 7, 16, 0.85);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
}
.modal-form-textarea::placeholder {
  color: rgba(162, 155, 184, 0.5);
}

/* Действия в модалке редактирования */
.edit-post-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.edit-post-actions .auth-submit {
  flex: 1;
  margin-top: 0;
}
.edit-post-actions .btn-cancel {
  padding: 14px 24px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}
.edit-post-actions .btn-cancel:hover {
  color: var(--text);
  border-color: var(--purple-bright);
}

/* ============================================================
   КОММЕНТАРИИ
   ============================================================ */

.comments-container {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(167, 139, 250, 0.12);
}

.comments-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.comments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.comments-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.comments-count {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 100px;
  background: rgba(139, 92, 246, 0.15);
  color: var(--purple-bright);
}

/* ---------- Форма добавления ---------- */
.comment-login-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(139, 92, 246, 0.06);
  border: 1px dashed rgba(167, 139, 250, 0.3);
  color: var(--muted);
  font-size: 14px;
}
.comment-login-hint svg {
  color: var(--purple-bright);
  flex-shrink: 0;
}

.comment-form,
.comment-reply-form {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: flex-start;
}

.comment-form-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid rgba(167, 139, 250, 0.3);
}
.comment-form-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment-form-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.comment-form textarea,
.comment-reply-form textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(10, 7, 16, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}
.comment-form textarea:focus,
.comment-reply-form textarea:focus {
  border-color: rgba(167, 139, 250, 0.6);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
}
.comment-form textarea::placeholder,
.comment-reply-form textarea::placeholder {
  color: rgba(162, 155, 184, 0.55);
}

.comment-form-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.comment-char-count {
  font-size: 12px;
  color: var(--muted);
  margin-right: auto;
  opacity: 0.7;
}

.comment-form-foot .btn-save {
  padding: 8px 20px;
  border-radius: 100px;
  border: none;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.comment-form-foot .btn-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.5);
}
.comment-form-foot .btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.comment-reply-form .btn-cancel {
  padding: 8px 20px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}
.comment-reply-form .btn-cancel:hover {
  color: var(--text);
  border-color: var(--purple-bright);
}

/* ---------- Список ---------- */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comments-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: rgba(20, 12, 35, 0.4);
  border: 1px dashed rgba(167, 139, 250, 0.2);
  border-radius: 16px;
}

/* ---------- Комментарий ---------- */
.comment {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: flex-start;
  padding: 4px 0;
  animation: riseIn 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.comment.is-deleted {
  opacity: 0.7;
}

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid rgba(167, 139, 250, 0.3);
}
.comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.comment-author {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.comment-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 100px;
  background: rgba(139, 92, 246, 0.14);
  color: var(--purple-bright);
  text-transform: uppercase;
}
.comment-role.admin,
.comment-role.owner {
  background: linear-gradient(
    135deg,
    rgba(232, 121, 249, 0.18),
    rgba(139, 92, 246, 0.18)
  );
  color: #e879f9;
}
.comment-role.moderator {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}
.comment-time {
  font-size: 12px;
  color: var(--muted);
}

.comment-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.comment-text.deleted {
  color: var(--muted);
  font-style: italic;
}

.comment-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 2px;
}
.comment-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 100px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease;
}
.comment-action:hover {
  color: var(--text);
  background: rgba(139, 92, 246, 0.1);
}
.comment-action.active.like {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.3);
}
.comment-action.active.dislike {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
}
.comment-action.danger:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

/* ---------- Форма ответа ---------- */
.comment-reply-form {
  margin-top: 10px;
  grid-template-columns: 1fr;
}
.comment-reply-form textarea {
  min-height: 60px;
  font-size: 13px;
}

/* ---------- Вложенные ответы ---------- */
.comment-replies {
  margin-top: 14px;
  padding-left: 14px;
  border-left: 2px solid rgba(167, 139, 250, 0.2);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.comment-replies .comment-avatar {
  width: 32px;
  height: 32px;
  font-size: 13px;
}
.comment-replies .comment {
  grid-template-columns: 32px 1fr;
  gap: 10px;
}
.comment-replies .comment-author {
  font-size: 13px;
}
.comment-replies .comment-text {
  font-size: 13px;
}

/* ============================================================
   Кликабельные теги + баннер активного тега
   ============================================================ */

.tag-filter-banner {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto 16px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 14px;
  font-size: 14px;
  color: var(--text);
}
.tag-filter-banner[hidden] {
  display: none;
}
.tag-filter-banner b {
  color: var(--purple-bright);
}
.tag-filter-banner button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.tag-filter-banner button:hover {
  background: rgba(139, 92, 246, 0.3);
}

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
  .posts-feed {
    padding-left: 48px;
    padding-right: 48px;
  }
}
@media (max-width: 900px) {
  .controls-right {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .sort {
    align-self: flex-start;
  }
}
@media (max-width: 720px) {
  .posts-feed {
    padding: 0 24px 40px;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .post-card {
    padding: 18px;
  }
  .post-title {
    font-size: 17px;
  }

  .tag-filter-banner {
    margin: 0 20px 16px;
  }

  .comment-form,
  .comment {
    grid-template-columns: 32px 1fr;
    gap: 10px;
  }
  .comment-form-avatar,
  .comment-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
  .comment-replies {
    padding-left: 10px;
    margin-top: 12px;
  }
  .comment-action {
    padding: 4px 8px;
    font-size: 11px;
  }

  .edit-post-actions {
    flex-direction: column-reverse;
  }
  .edit-post-actions .btn-cancel,
  .edit-post-actions .auth-submit {
    width: 100%;
  }
}
