/*
 * comments.css — стили секции комментариев eco-os.ru
 * Тема: Claude Dancer + Fluid Ocean. Все цвета из tokens-claude.css.
 * Mobile-first, WCAG AA контрасты.
 */

/* ------------------------------------------------------------------
   Секция комментариев
------------------------------------------------------------------ */
.comments-section {
  width: 100%;
  max-width: 720px;
  margin: 56px auto 0;
  padding: 0 16px 64px;
  box-sizing: border-box;
}

.comments-inner {
  position: relative;
}

/* Разделитель сверху */
.comments-section::before {
  content: '';
  display: block;
  width: 100%;
  height: 1px;
  background: rgba(44,110,123,0.18);
  margin-bottom: 40px;
}

.comments-eyebrow {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal, #2c6e7b);
  margin-bottom: 8px;
}

.comments-heading {
  font-family: var(--font-display, 'Newsreader', serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink, #2a2418);
  margin: 0 0 32px;
}

/* ------------------------------------------------------------------
   Auth bar
------------------------------------------------------------------ */
.comments-auth-bar {
  border-radius: var(--radius-md, 8px);
  padding: 20px;
  margin-bottom: 24px;
}

.auth-bar-anon {
  background: rgba(200, 227, 231, 0.30);
  border: 1px solid rgba(44, 110, 123, 0.20);
}

.auth-bar-anon .auth-bar-prompt {
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 15px;
  color: var(--ink, #2a2418);
  margin: 0 0 12px;
}

.auth-bar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-bar-hint {
  font-size: 13px;
  color: var(--ink-3, #7a6c5e);
  margin: 12px 0 0;
}

.auth-bar-hint a {
  color: var(--teal, #2c6e7b);
  text-decoration: none;
}

.auth-bar-unverified {
  background: rgba(184, 139, 26, 0.12);
  border: 1px solid rgba(184, 139, 26, 0.25);
}

.auth-bar-unverified p {
  margin: 0 0 12px;
  color: var(--ink, #2a2418);
  font-size: 15px;
}

.auth-bar-banned {
  background: rgba(184, 58, 58, 0.10);
  border: 1px solid rgba(184, 58, 58, 0.25);
}

.auth-bar-banned p {
  margin: 0;
  color: var(--ink, #2a2418);
  font-size: 15px;
}

.auth-bar-banned a {
  color: var(--teal, #2c6e7b);
}

/* ------------------------------------------------------------------
   Trust info banner
------------------------------------------------------------------ */
.comments-trust-info {
  background: rgba(200, 227, 231, 0.25);
  border: 1px solid rgba(44, 110, 123, 0.15);
  border-radius: var(--radius-md, 8px);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.comments-trust-info p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2, #4a3f33);
  line-height: 1.5;
}

/* ------------------------------------------------------------------
   Форма коммента
------------------------------------------------------------------ */
.comment-form {
  margin-bottom: 32px;
}

.comment-form-field {
  position: relative;
}

.comment-textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px 28px;
  border: 1.5px solid rgba(44, 110, 123, 0.28);
  border-radius: var(--radius-md, 8px);
  background: rgba(255, 252, 246, 0.85);
  color: var(--ink, #2a2418);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--teal, #2c6e7b);
  box-shadow: 0 0 0 3px rgba(44, 110, 123, 0.12);
}

.comment-textarea.error {
  border-color: var(--error, #b83a3a);
}

.comment-counter {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--ink-3, #7a6c5e);
  pointer-events: none;
  user-select: none;
}

.comment-counter.counter-warning { color: var(--warning, #b88b1a); }
.comment-counter.counter-error   { color: var(--error, #b83a3a); }
.comment-counter.counter-ok      { color: var(--teal, #2c6e7b); }

.comment-form-hint {
  margin: 8px 0 12px;
  font-size: 13px;
  color: var(--ink-3, #7a6c5e);
  line-height: 1.4;
}

.comment-form-hint a {
  color: var(--teal, #2c6e7b);
  text-decoration: none;
}

/* Error/success callouts */
.comment-form-error,
.comment-form-success {
  padding: 12px 16px;
  border-radius: var(--radius-md, 8px);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.comment-form-error {
  background: rgba(184, 58, 58, 0.10);
  border: 1px solid rgba(184, 58, 58, 0.25);
  color: var(--ink, #2a2418);
}

.comment-form-success {
  background: rgba(200, 227, 231, 0.35);
  border: 1px solid rgba(44, 110, 123, 0.20);
  color: var(--ink, #2a2418);
}

.comment-form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ------------------------------------------------------------------
   Кнопки
------------------------------------------------------------------ */
.btn-comment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: var(--radius-pill, 9999px);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  box-sizing: border-box;
}

.btn-comment:focus-visible {
  outline: 2px solid var(--teal, #2c6e7b);
  outline-offset: 2px;
}

.btn-comment-primary {
  background: var(--teal, #2c6e7b);
  color: var(--cream, #f5f1eb);
}

.btn-comment-primary:hover,
.btn-comment-primary:focus {
  background: var(--teal-deep, #1f525c);
}

.btn-comment-outline {
  background: transparent;
  color: var(--teal, #2c6e7b);
  border: 1.5px solid var(--teal, #2c6e7b);
}

.btn-comment-outline:hover {
  background: rgba(44, 110, 123, 0.08);
}

.btn-comment-ghost {
  background: transparent;
  color: var(--ink-2, #4a3f33);
}

.btn-comment-ghost:hover {
  background: rgba(42, 36, 24, 0.06);
}

.btn-comment:disabled,
.btn-comment[disabled] {
  opacity: 0.55;
  pointer-events: none;
}

/* Spinner анимация */
@keyframes comment-spin {
  to { transform: rotate(360deg); }
}

.spinner {
  animation: comment-spin 0.9s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

/* ------------------------------------------------------------------
   Список комментариев
------------------------------------------------------------------ */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ------------------------------------------------------------------
   Карточка коммента
------------------------------------------------------------------ */
.comment-card {
  background: rgba(255, 252, 246, 0.78);
  border: 1px solid rgba(44, 110, 123, 0.14);
  border-radius: var(--radius-md, 8px);
  padding: 16px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(42,36,24,0.08));
  transition: opacity 0.3s ease;
}

/* Fade-in для новых комментов */
@media (prefers-reduced-motion: no-preference) {
  .comment-card.comment-new {
    animation: comment-fadein 0.4s ease both;
  }
  @keyframes comment-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
  }
}

.comment-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.comment-avatar {
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  line-height: 0;
}

.comment-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.comment-author {
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink, #2a2418);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comment-date {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--ink-3, #7a6c5e);
  letter-spacing: 0.03em;
}

.comment-body {
  margin-bottom: 12px;
}

.comment-body p {
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink, #2a2418);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Like / Reply / Report кнопки */
.comment-like,
.comment-reply-btn,
.comment-report,
.comment-like-anon,
.comment-reply-anon,
.comment-report-anon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  min-height: 36px;
  min-width: 44px;
  border: none;
  background: transparent;
  color: var(--ink-2, #4a3f33);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.comment-like:hover,
.comment-reply-btn:hover,
.comment-report:hover {
  background: rgba(42, 36, 24, 0.06);
}

.comment-like:focus-visible,
.comment-reply-btn:focus-visible,
.comment-report:focus-visible {
  outline: 2px solid var(--teal, #2c6e7b);
  outline-offset: 2px;
}

.comment-like.liked .like-count,
.comment-like[aria-pressed="true"] .like-count {
  color: var(--terracotta, #d4845b);
}

.comment-report,
.comment-report-anon {
  color: var(--ink-3, #7a6c5e);
  margin-left: auto;
}

.comment-report:disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   Ответы (вложенность 1 уровень)
------------------------------------------------------------------ */
.comment-replies {
  margin-left: 24px;
  margin-top: 8px;
  padding-left: 16px;
  border-left: 1.5px solid rgba(44, 110, 123, 0.20);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-reply {
  padding: 12px 14px;
}

/* ------------------------------------------------------------------
   Inline-форма ответа
------------------------------------------------------------------ */
.comment-reply-form-container {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(44, 110, 123, 0.10);
}

.comment-reply-form-container .comment-form {
  margin-bottom: 0;
}

.comment-reply-form-container .comment-textarea {
  min-height: 80px;
}

/* ------------------------------------------------------------------
   Пустое состояние
------------------------------------------------------------------ */
.comments-empty {
  padding: 32px 0;
  text-align: center;
}

.comments-empty-text {
  font-family: var(--font-display, 'Newsreader', serif);
  font-size: 18px;
  font-style: italic;
  color: var(--ink-2, #4a3f33);
  margin: 0 0 16px;
}

/* ------------------------------------------------------------------
   Пагинация (Показать ещё)
------------------------------------------------------------------ */
.comments-pagination {
  margin-top: 24px;
  text-align: center;
}

.comments-load-more {
  width: 100%;
  max-width: 360px;
}

/* Skeleton cards при загрузке */
.comment-skeleton {
  background: rgba(255, 252, 246, 0.78);
  border: 1px solid rgba(44, 110, 123, 0.10);
  border-radius: var(--radius-md, 8px);
  padding: 16px;
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(42,36,24,0.06) 25%, rgba(42,36,24,0.12) 50%, rgba(42,36,24,0.06) 75%);
  background-size: 200% 100%;
  margin-bottom: 10px;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton-line {
    animation: skeleton-shimmer 1.5s infinite;
  }
  @keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
  }
}

/* ------------------------------------------------------------------
   Toast уведомления
------------------------------------------------------------------ */
.comments-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-pill, 9999px);
  background: var(--ink, #2a2418);
  color: var(--cream, #f5f1eb);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-md, 0 6px 18px rgba(42,36,24,0.12));
  white-space: nowrap;
  pointer-events: none;
}

.comments-toast.toast-error {
  background: var(--error, #b83a3a);
}

.comments-toast.toast-success {
  background: var(--success, #5a8c4a);
}

@media (prefers-reduced-motion: no-preference) {
  .comments-toast {
    animation: toast-in 0.25s ease both;
  }
  @keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 16px); }
    to   { opacity: 1; transform: translateX(-50%); }
  }
}

/* ------------------------------------------------------------------
   Tablet ≥768px
------------------------------------------------------------------ */
@media (min-width: 768px) {
  .comments-section {
    padding: 0 24px 72px;
  }

  .auth-bar-actions {
    flex-direction: row;
  }

  .comment-replies {
    margin-left: 40px;
    padding-left: 20px;
  }

  .comments-load-more {
    width: auto;
  }
}

/* ------------------------------------------------------------------
   Desktop ≥1280px
------------------------------------------------------------------ */
@media (min-width: 1280px) {
  .comment-replies {
    margin-left: 48px;
  }
}
