/* ============================================================
   MainStreet Comments System — scoped to #comments-section
   Editorial palette: #fafaf5, #003366, #6b7280, #e5e5e0
   ============================================================ */

/* Auth prompt */
#comments-section .comments-auth-prompt {
  text-align: center;
  border: 1px dashed #e5e5e0;
  border-radius: 0.375rem;
  padding: 1.5rem;
  color: #6b7280;
  font-size: 0.875rem;
}

#comments-section .comments-auth-prompt p {
  margin-bottom: 0.75rem;
}

#comments-section .comments-auth-email {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

#comments-section .comments-auth-email input[type="email"] {
  border: 1px solid #e5e5e0;
  border-radius: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-family: Inter, sans-serif;
  font-size: 0.875rem;
  color: #1a1a1a;
  outline: none;
  min-width: 200px;
}

#comments-section .comments-auth-email input[type="email"]:focus {
  border-color: #003366;
}

/* Signed-in user info */
#comments-section .comments-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

#comments-section .comments-user-info .user-name {
  font-weight: 600;
  color: #003366;
}

#comments-section .comments-user-info a {
  color: #6b7280;
  text-decoration: underline;
  cursor: pointer;
}

#comments-section .comments-user-info a:hover {
  color: #003366;
}

/* Display name setup form */
#comments-section .comments-display-name-form {
  border: 1px solid #e5e5e0;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #fafaf5;
}

#comments-section .comments-display-name-form p {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

/* Comment form */
#comments-section .comment-form-wrapper {
  margin-bottom: 1rem;
}

#comments-section .comment-textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid #e5e5e0;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-family: Inter, sans-serif;
  font-size: 0.875rem;
  color: #1a1a1a;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  outline: none;
}

#comments-section .comment-textarea:focus {
  border-color: #003366;
}

#comments-section .comment-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#comments-section .char-count {
  font-size: 0.75rem;
  color: #9ca3af;
}

#comments-section .char-count.over-limit {
  color: #dc2626;
}

/* Buttons */
#comments-section .btn-primary {
  background-color: #003366;
  color: #ffffff;
  padding: 0.375rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-family: Inter, sans-serif;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

#comments-section .btn-primary:hover {
  opacity: 0.85;
}

#comments-section .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#comments-section .btn-secondary {
  background-color: transparent;
  color: #003366;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-family: Inter, sans-serif;
  border: 1px solid #e5e5e0;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

#comments-section .btn-secondary:hover {
  border-color: #003366;
}

/* Article reactions */
#comments-section .reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

#comments-section .reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  color: #6b7280;
  background: #f9fafb;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
  font-family: Inter, sans-serif;
  line-height: 1.4;
  filter: grayscale(0.6);
  opacity: 0.8;
}

#comments-section .reaction-badge span {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
}

#comments-section .reaction-badge:hover {
  border-color: #003366;
  background: #f0f4f8;
  filter: grayscale(0);
  opacity: 1;
}

#comments-section .reaction-badge.active {
  background: #e8eef5;
  border-color: #003366;
  color: #003366;
  font-weight: 600;
  filter: grayscale(0);
  opacity: 1;
}

#comments-section .reaction-badge.active span {
  color: #003366;
}

/* Comment list */
#comments-section .comment-item {
  border-left: 3px solid #003366;
  padding: 0.75rem 0.75rem 0.5rem 0.75rem;
  margin-bottom: 1rem;
  background: transparent;
}

#comments-section .comment-item.deleted {
  border-left-color: #e5e5e0;
}

#comments-section .comment-item .comment-author {
  font-weight: 600;
  color: #003366;
  font-size: 0.875rem;
}

#comments-section .comment-item .comment-timestamp {
  font-size: 0.75rem;
  color: #6b7280;
  margin-left: 0.5rem;
}

#comments-section .comment-item .comment-body {
  font-size: 0.875rem;
  color: #1a1a1a;
  line-height: 1.6;
  margin-top: 0.25rem;
  word-break: break-word;
}

#comments-section .comment-item .comment-body.deleted-body {
  font-style: italic;
  color: #9ca3af;
}

#comments-section .comment-item .comment-body a {
  color: #003366;
  text-decoration: underline;
}

#comments-section .comment-item .comment-body a:hover {
  opacity: 0.75;
}

/* Comment action buttons */
#comments-section .comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.375rem;
  align-items: center;
}

#comments-section .comment-action-btn {
  font-size: 0.75rem;
  color: #6b7280;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: Inter, sans-serif;
  transition: color 0.15s ease;
}

#comments-section .comment-action-btn:hover {
  color: #003366;
}

#comments-section .comment-action-btn.danger:hover {
  color: #dc2626;
}

/* Replies */
#comments-section .replies-list {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
}

#comments-section .reply-item {
  border-left: 2px solid #e5e5e0;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

#comments-section .reply-item .comment-author {
  font-weight: 600;
  color: #003366;
  font-size: 0.8125rem;
}

#comments-section .reply-item .comment-timestamp {
  font-size: 0.6875rem;
  color: #6b7280;
  margin-left: 0.375rem;
}

#comments-section .reply-item .comment-body {
  font-size: 0.8125rem;
  color: #1a1a1a;
  line-height: 1.6;
  margin-top: 0.2rem;
  word-break: break-word;
}

#comments-section .reply-item .comment-body.deleted-body {
  font-style: italic;
  color: #9ca3af;
}

#comments-section .reply-item .comment-body a {
  color: #003366;
  text-decoration: underline;
}

#comments-section .reply-item .comment-body a:hover {
  opacity: 0.75;
}

/* Reply form */
#comments-section .reply-form-wrapper {
  margin-left: 1.5rem;
  margin-top: 0.375rem;
  margin-bottom: 0.5rem;
}

#comments-section .reply-form-wrapper .comment-textarea {
  min-height: 56px;
  font-size: 0.8125rem;
}

/* Edit mode */
#comments-section .comment-edit-wrapper {
  margin-top: 0.25rem;
}

#comments-section .comment-edit-wrapper .comment-textarea {
  min-height: 60px;
}

/* Error / status messages */
#comments-section .comments-message {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
}

#comments-section .comments-message.error {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

#comments-section .comments-message.success {
  background: rgba(0, 51, 102, 0.06);
  color: #003366;
  border: 1px solid rgba(0, 51, 102, 0.15);
}

#comments-section .comments-message.info {
  background: #fafaf5;
  color: #6b7280;
  border: 1px solid #e5e5e0;
}

/* Loading spinner */
#comments-section .comments-loading {
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
  padding: 1rem;
}

/* Empty state */
#comments-section .comments-empty {
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
  padding: 1rem 0;
}

/* Reaction tooltip */
#comments-section .reaction-tooltip {
  position: absolute;
  background: #1a1a1a;
  color: #fafaf5;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
  max-width: 220px;
  white-space: normal;
  word-break: break-word;
}

/* Responsive: no horizontal overflow */
@media (max-width: 640px) {
  #comments-section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  #comments-section .comment-item,
  #comments-section .reply-item {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  #comments-section .replies-list,
  #comments-section .reply-form-wrapper {
    margin-left: 0.75rem;
  }

  #comments-section .comments-auth-email {
    flex-direction: column;
    align-items: stretch;
  }

  #comments-section .comments-auth-email input[type="email"] {
    min-width: unset;
    width: 100%;
  }
}
