/* Public-facing blog-post comments UI.
 * Tokens: --primary-color, --secondary-color from common.css.
 * Surface tone matches the dark gradient body; spacing follows --blog-gap-*. */

.comments-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--secondary-color);
  font-family: "Rubik", sans-serif;
  min-width: 0;
}

/* Debug overlay: add `?debug` to the URL, or in DevTools run
   document.body.classList.add('debug-borders')
   to outline every element on the page in red. Uses outline (not border) so
   the layout itself is not disturbed by the inspection. */
body.debug-borders *,
body.debug-borders *::before,
body.debug-borders *::after {
  outline: 1px solid rgba(255, 0, 0, 0.7) !important;
}

.comments-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.comments-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--secondary-color);
  letter-spacing: 0.01em;
}

.comments-count {
  font-size: 1rem;
  font-weight: 500;
  margin-left: 0.4rem;
  color: rgba(255, 255, 255, 0.55);
}

.comments-status {
  margin: 1rem 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
}

.comments-status[hidden] {
  display: none;
}

/* ---------- Form ---------- */
.comment-form {
  display: block;
  margin-bottom: 2rem;
}

.comment-form-label {
  display: block;
}

.comment-form-textarea {
  width: 100%;
  min-height: 6rem;
  padding: 0.75rem 0.9rem;
  resize: vertical;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--secondary-color);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.comment-form-textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.comment-form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(16, 172, 132, 0.15);
}

.comment-form-textarea:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.comment-form-error {
  margin-top: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 0.88rem;
  line-height: 1.4;
}

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.comment-form-submit,
.comment-form-cancel,
.comments-load-more,
.comment-action {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease;
}

.comment-form-submit {
  background: var(--primary-color);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.comment-form-submit:hover:not(:disabled) {
  background: #0e8d6c;
}

.comment-form-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.comment-form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.comment-form-submit.is-busy {
  opacity: 0.7;
}

.comment-form-cancel {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.15);
  font-size: 0.9rem;
}

.comment-form-cancel:hover:not(:disabled) {
  color: var(--secondary-color);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Signed-out / unverified notices */
.comment-form--signed-out,
.comment-form--unverified {
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 2rem;
}

.comment-form-notice {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
}

.comment-form-signin-link,
.comment-form-verify-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.comment-form-signin-link:hover,
.comment-form-verify-link:hover {
  text-decoration: underline;
}

/* ---------- List ---------- */
.comment-list,
.comment-replies {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment-list > .comment-item + .comment-item {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 1.25rem;
  padding-top: 1.25rem;
}

.comment-replies {
  margin-top: 1rem;
  margin-left: 2rem;
  padding-left: 1rem;
  border-left: 2px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comments-empty {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 0.95rem;
}

/* ---------- Item ---------- */
.comment {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.85rem;
}

.comment-item--deleted .comment {
  opacity: 0.7;
}

.comment-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  user-select: none;
  overflow: hidden;
  flex-shrink: 0;
}

.comment-avatar--image {
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.comment-body-col {
  min-width: 0;
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.comment-author-name {
  font-weight: 600;
  color: var(--secondary-color);
  font-size: 0.95rem;
}

.comment-timestamp,
.comment-edited {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
}

.comment-edited::before {
  content: "·";
  margin-right: 0.4rem;
  color: rgba(255, 255, 255, 0.3);
}

.comment-badges {
  display: inline-flex;
  gap: 0.35rem;
}

.comment-badge {
  display: inline-flex;
  align-items: center;
  height: 1.3rem;
  padding: 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
}

.comment-badge--admin {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.comment-badge--author {
  background: rgba(16, 172, 132, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 172, 132, 0.4);
}

.comment-body {
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.88);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.comment-body p {
  margin: 0 0 0.6rem;
  font-weight: 400;
}

.comment-body p:last-child {
  margin-bottom: 0;
}

.comment-body--deleted {
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.55rem;
}

.comment-action {
  background: transparent;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.3rem 0.55rem;
}

.comment-action:hover:not(:disabled) {
  color: var(--primary-color);
  background: rgba(16, 172, 132, 0.08);
}

.comment-action--delete:hover:not(:disabled) {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

.comment-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.comment-inline-form {
  margin-top: 0.85rem;
}

.comment-inline-form[hidden] {
  display: none;
}

.comment-form--reply,
.comment-form--edit {
  margin-bottom: 0.5rem;
}

/* ---------- Load more ---------- */
.comments-load-more {
  display: block;
  width: 100%;
  margin: 1.5rem 0 0;
  background: transparent;
  color: var(--secondary-color);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.7rem 1rem;
}

.comments-load-more:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(16, 172, 132, 0.05);
}

.comments-load-more:disabled,
.comments-load-more.is-busy {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .comments-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
  }

  .comments-title {
    font-size: 1.25rem;
  }

  .comment {
    grid-template-columns: 32px 1fr;
    gap: 0.65rem;
  }

  .comment-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .comment-replies {
    margin-left: 1rem;
    padding-left: 0.65rem;
  }

  .comment-form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .comment-form-submit,
  .comment-form-cancel {
    width: 100%;
  }
}

@media (hover: none) {
  .comment-action:hover {
    color: rgba(255, 255, 255, 0.55);
    background: transparent;
  }

  .comments-load-more:hover {
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--secondary-color);
    background: transparent;
  }
}
