/**
 * HoplaCollect Comments Section Styles
 * Aligned with FAQ, Contributions & Milestones design
 * Uses --hc-c1 palette variable from admin Colors tab
 */

/* ══════════════════════════════════════
   SCOPED RESETS
   ══════════════════════════════════════ */
/* Scoped resets — !important needed to override theme globals */
.hc-comments,
.hc-comments *,
.hc-comments *::before,
.hc-comments *::after {
  box-sizing: border-box !important;
}

.hc-comments button,
.hc-comments input,
.hc-comments textarea {
  font-family: inherit !important;
  line-height: inherit !important;
}

/* ── Section container ── */
.hc-comments {
  margin: var(--hc-space-10, 2.5rem) 0;
}

/* ══════════════════════════════════════
   HEADER — Icon + title + count
   ══════════════════════════════════════ */
.hc-comments-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0 0 1.25rem;
}

.hc-comments-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--hc-c1, var(--hc-primary, #6366f1)) 12%, transparent);
  color: var(--hc-c1, var(--hc-primary, #6366f1));
  flex-shrink: 0;
}

.hc-comments-header-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--hc-c1, var(--hc-primary, #6366f1));
  fill: none;
}

.hc-comments-header-text {
  flex: 1;
  min-width: 0;
}

.hc-comments-header-text h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 0.25rem;
  padding: 0;
  line-height: 1.3;
  border: none;
  background: none;
  letter-spacing: -0.01em;
}

.hc-comments-header-text p {
  font-size: 0.8125rem;
  color: #9ca3af;
  margin: 0;
  padding: 0;
  line-height: 1.5;
  font-weight: 400;
}

/* ══════════════════════════════════════
   LAYOUT — 2 columns (matches FAQ layout)
   ══════════════════════════════════════ */
.hc-comments-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.hc-comments-main {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.hc-comments-sidebar {
  position: sticky;
  top: 20px;
}

/* ══════════════════════════════════════
   COMMENT LIST
   ══════════════════════════════════════ */
.hc-comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

/* ── Single comment card ── */
.hc-comments-item {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 0;
  padding: 0.875rem 1rem;
  transition: none;
}

/* Slide-in animation */
.hc-comments-item--will-animate {
  opacity: 0;
  transform: translateY(8px);
}

.hc-comments-item--animate {
  animation: hc-comment-slide-in 0.3s ease forwards;
  animation-delay: var(--hc-anim-delay, 0ms);
}

@keyframes hc-comment-slide-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Comment top row: avatar + author + date */
.hc-comments-item-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}

.hc-comments-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.hc-comments-author {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e293b;
}

.hc-comments-date {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-left: auto;
  white-space: nowrap;
}

/* Comment body text */
.hc-comments-text {
  font-size: 0.875rem;
  line-height: 1.6;
  color: #374151;
  padding-left: calc(34px + 0.625rem); /* align with text after avatar */
  word-break: break-word;
}

/* ══════════════════════════════════════
   LOAD MORE BUTTON
   ══════════════════════════════════════ */
.hc-comments-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 1rem;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--hc-c1, var(--hc-primary, #6366f1));
  background: transparent;
  border: 1px dashed #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.hc-comments-load-more:hover {
  background: #f8fafc;
  border-color: var(--hc-c1, var(--hc-primary, #6366f1));
}

.hc-comments-load-more:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hc-comments-load-more svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
}

/* ══════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════ */
.hc-comments-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: #fafbfc;
  border: 1px dashed #e2e8f0;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.hc-comments-empty svg {
  color: #cbd5e1;
  stroke: #cbd5e1;
}

.hc-comments-empty-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #475569;
  margin: 0;
}

.hc-comments-empty-subtitle {
  font-size: 0.8125rem;
  color: #94a3b8;
  margin: 0;
  max-width: 320px;
  line-height: 1.5;
}

/* ══════════════════════════════════════
   FORM — Matches FAQ sidebar card style
   ══════════════════════════════════════ */
.hc-comments-form-wrapper {
  background: var(--hc-surface, #ffffff);
  border: 1px solid var(--hc-border, #e5e7eb);
  border-top: 3px solid var(--hc-c1, var(--hc-primary, #6366f1));
  border-radius: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
  padding: 20px;
}

.hc-comments-form-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--hc-text, #1f2937);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.hc-comments-form-title svg {
  width: 18px;
  height: 18px;
  color: var(--hc-c1, var(--hc-primary, #6366f1));
  stroke: var(--hc-c1, var(--hc-primary, #6366f1));
  fill: none;
  flex-shrink: 0;
  opacity: .65;
}

/* Logged-in notice */
.hc-comments-logged-in {
  font-size: 0.8125rem;
  color: #64748b;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
}

.hc-comments-logged-in strong {
  color: #1e293b;
  font-weight: 600;
}

/* Fields — Matches FAQ sidebar form fields */
.hc-comments-field {
  margin-bottom: 14px;
}

.hc-comments-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--hc-text, #1f2937);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.hc-comments-field .hc-required {
  color: #dc2626;
}

.hc-comments-field input[type="text"],
.hc-comments-field input[type="email"],
.hc-comments-field textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: .875rem;
  font-weight: 500;
  color: #1e293b;
  background-color: #fff;
  border: 1.5px solid var(--hc-border, #d1d5db);
  border-radius: 0 !important;
  transition: border-color .15s ease, box-shadow .15s ease;
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.hc-comments-field input:focus,
.hc-comments-field textarea:focus {
  border-color: var(--hc-c1, var(--hc-primary, #6366f1));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hc-c1, var(--hc-primary, #6366f1)) 12%, transparent);
}

.hc-comments-field textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* Char counter */
.hc-comments-char-counter {
  display: flex;
  justify-content: flex-end;
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 0.25rem;
  transition: color 0.2s ease;
}

.hc-comments-char-counter--warn {
  color: #f59e0b;
}

.hc-comments-char-counter--limit {
  color: #ef4444;
  font-weight: 600;
}

/* Inline fields row (name + email) */
.hc-comments-fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Anonymous toggle */
.hc-comments-anon-check {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1.5px solid var(--hc-border, #e2e8f0);
  border-radius: 0;
  transition: border-color .2s ease, background .2s ease;
}

.hc-comments-anon-check:has(input:checked) {
  background: color-mix(in srgb, var(--hc-c1, var(--hc-primary, #6366f1)) 6%, #fff);
  border-color: color-mix(in srgb, var(--hc-c1, var(--hc-primary, #6366f1)) 35%, transparent);
}

.hc-comments-anon-check label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--hc-text, #1f2937);
  text-transform: none;
  margin: 0;
  line-height: 1;
}

/* Custom toggle track */
.hc-comments-anon-check input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  background: #cbd5e1;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  transition: background .2s ease;
  outline: none;
}

.hc-comments-anon-check input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .2s ease;
}

.hc-comments-anon-check input[type="checkbox"]:checked {
  background: var(--hc-c1, var(--hc-primary, #6366f1));
}

.hc-comments-anon-check input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

.hc-comments-anon-check input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hc-c1, var(--hc-primary, #6366f1)) 20%, transparent);
}

.hc-comments-anon-label {
  user-select: none;
}

.hc-comments-anon-hint {
  display: block;
  font-size: .72rem;
  color: var(--hc-muted, #9ca3af);
  margin-top: 6px;
  padding-left: 46px;
  line-height: 1.4;
}

/* Honeypot — visually hidden (!important needed to guarantee hiding) */
.hc-comments-hp {
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  height: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Submit — Matches FAQ sidebar submit button */
.hc-comments-submit {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-size: .92rem;
  font-weight: 700;
  color: #fff !important;
  background: var(--hc-c1, var(--hc-primary, #6366f1)) !important;
  border: none !important;
  border-radius: 0 !important;
  cursor: pointer;
  min-height: 44px;
  text-align: center;
  text-decoration: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  outline: none !important;
  transition: filter .15s ease, box-shadow .15s ease, transform .1s ease;
}

.hc-comments-submit:hover:not(:disabled) {
  filter: brightness(0.92);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
}

.hc-comments-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.hc-comments-submit:disabled {
  opacity: .5;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

.hc-comments-submit svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

/* Status feedback */
.hc-comments-status {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 0;
  line-height: 1.4;
}

.hc-comments-status--visible {
  display: flex;
}

.hc-comments-status--success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.hc-comments-status--error {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  color: #991b1b;
  border: 1px solid #fecaca;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 4px 12px rgba(0, 0, 0, .04);
}

.hc-comments-status svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 968px) {
  .hc-comments-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hc-comments-sidebar {
    position: static;
    order: -1;
  }
}

@media (max-width: 576px) {
  .hc-comments-text {
    padding-left: 0;
    margin-top: 0.375rem;
  }

  .hc-comments-item-header {
    flex-wrap: wrap;
  }

  .hc-comments-date {
    margin-left: 0;
    width: 100%;
    margin-top: 0.125rem;
  }
}
