/* ══════════════════════════════════════════════════════════
   HCI Engagement — Self-contained plugin styles
   ══════════════════════════════════════════════════════════ */

:root {
  --hci-gold: #c9a84c;
  --hci-gold-dim: #b8963e;
  --hci-brown-dark: #2d1810;
  --hci-brown-mid: #4a2c1a;
  --hci-text: #2d1810;
  --hci-text-secondary: #6b5a4a;
  --hci-text-muted: #a08060;
  --hci-border: #e8ddd0;
  --hci-border-dark: #c4b8a8;
  --hci-bg: #faf6f0;
  --hci-bg-white: #ffffff;
  --hci-bg-sidebar: #f5efe6;
  --hci-radius: 20px;
  --hci-radius-sm: 8px;
  --hci-radius-full: 50px;
  --hci-transition: 0.2s ease;
}

/* ──── Engagement Bar ──── */
.hci-story-card-engagement {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--hci-border);
  padding-top: 12px;
  margin-block-start: 0;
}
.hci-story-card-engagement p { margin: 0 !important; }

/* ──── Emotions Group ──── */
.hci-emotions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.hci-emotion-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--hci-radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--hci-transition);
  user-select: none;
  font-size: 13px;
  color: var(--hci-text-muted);
  position: relative;
}
.hci-emotion-btn:hover {
  background: rgba(201, 168, 76, 0.08);
  border-color: var(--hci-border);
}
.hci-emotion-btn.active {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--hci-gold);
  color: var(--hci-text);
}
.hci-like-btn.active {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
}
.hci-emotion-btn.active .hci-emotion-count {
  color: var(--hci-gold);
  font-weight: 600;
}
.hci-like-btn.active .hci-emotion-count {
  color: #e74c3c;
}

.hci-emotion-btn .hci-emotion-emoji {
  font-size: 20px;
  line-height: 1;
  transition: transform var(--hci-transition);
}
.hci-emotion-btn:hover .hci-emotion-emoji { transform: scale(1.25); }
.hci-emotion-btn:active .hci-emotion-emoji { transform: scale(0.9); }

.hci-emotion-count {
  font-size: 12px;
  font-weight: 500;
  min-width: 8px;
}

/* ──── CSS Tooltips ──── */
.hci-emotion-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--hci-brown-dark);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hci-transition), transform var(--hci-transition);
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.hci-emotion-btn::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--hci-brown-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hci-transition);
  z-index: 10;
}
.hci-emotion-btn:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.hci-emotion-btn:hover::before { opacity: 1; }

/* ──── Actions Group ──── */
.hci-actions {
  display: flex;
  gap: 12px;
  position: relative;
}
.hci-engagement-item {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: color var(--hci-transition);
}
.hci-engagement-item:hover { color: var(--hci-gold); }
.hci-engagement-item.active { color: #e74c3c; }

/* ──── Comment Count Badge ──── */
.hci-comment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(201, 168, 76, 0.12);
  color: var(--hci-brown-mid);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  transition: all var(--hci-transition);
}
.hci-comment-btn:hover .hci-comment-count {
  background: rgba(201, 168, 76, 0.2);
  color: var(--hci-gold);
}
.hci-comment-count:empty,
.hci-comment-count[data-count="0"] {
  display: none;
}

/* ──── Responsive: Engagement Bar ──── */
@media (max-width: 782px) {
  .hci-story-card-engagement {
    flex-wrap: wrap;
    gap: 8px;
  }
  .hci-emotions { gap: 4px; }
  .hci-emotion-btn { padding: 4px 8px; }
  .hci-emotion-btn .hci-emotion-emoji { font-size: 18px; }
  .hci-actions { gap: 8px; }
}

/* ══════════════════════════════════════════════════════════
   COMMENT BLOCK
   ══════════════════════════════════════════════════════════ */

.hci-comment-block {
  border-top: 1px solid var(--hci-border);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.3s ease;
  padding: 0 16px;
  margin-block-start: 0;
}
.hci-comment-block.open {
  max-height: 800px;
  opacity: 1;
  padding: 16px 0;
  overflow-y: auto;
}

/* ──── Comment List ──── */
.hci-comments-list {
  padding-bottom: 12px;
}
.hci-comments-list:empty {
  display: none;
}
.hci-comments-list:not(:empty) {
  border-top: 1px solid var(--hci-border);
  margin: 16px 0;
}

.hci-comment-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
}
.hci-comment-item + .hci-comment-item {
  border-top: 1px solid rgba(232, 221, 208, 0.5);
}

/* ──── Comment Avatar ──── */
.hci-comment-avatar {
  width: 39px;
  height: 39px;
  border-radius: var(--hci-radius-full);
  flex-shrink: 0;
  background: var(--hci-border);
  object-fit: cover;
}

/* ──── Comment Body ──── */
.hci-comment-body {
  flex: 1;
  min-width: 0;
}
.hci-comment-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.hci-comment-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--hci-text);
  line-height: 1.4;
}
.hci-comment-date {
  font-size: 12px;
  color: var(--hci-text-muted);
  line-height: 1.4;
}
.hci-comment-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--hci-text);
  margin: 0;
}

/* ──── Comment Actions ──── */
.hci-comment-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.hci-comment-actions button {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--hci-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--hci-transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hci-comment-actions button:hover {
  color: var(--hci-text-secondary);
  background: rgba(232, 221, 208, 0.4);
}

.hci-comment-vote-up.active {
  color: var(--hci-gold) !important;
}
.hci-comment-vote-down.active {
  color: var(--hci-text-secondary) !important;
}

.hci-comment-divider {
  width: 1px;
  height: 14px;
  background: var(--hci-border);
  margin: 0 2px;
}

.hci-comment-report-btn:hover {
  color: #c0392b !important;
}
.hci-comment-report-btn:disabled {
  color: #27ae60 !important;
  cursor: default;
  background: none !important;
}

/* ──── Reply Nesting ──── */
.hci-comment-replies {
  margin-top: 4px;
  padding-left: 12px;
  border-left: 2px solid var(--hci-border);
}
.hci-comment-replies:empty { display: none; }
.hci-comment-reply .hci-comment-avatar {
  width: 24px;
  height: 24px;
}
.hci-comment-reply .hci-comment-author { font-size: 12px; }
.hci-comment-reply .hci-comment-date { font-size: 11px; }
.hci-comment-reply .hci-comment-text { font-size: 13px; }

/* ══════════════════════════════════════════════════════════
   COMMENT FORM
   ══════════════════════════════════════════════════════════ */

.hci-comment-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.hci-comment-login-required {
  background: var(--hci-bg-white);
  border: 1px solid var(--hci-border);
  border-radius: var(--hci-radius);
  padding: 16px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--hci-text-secondary);
  width: 100%;
}
.hci-comment-login-link {
  color: var(--hci-gold);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--hci-transition);
}
.hci-comment-login-link:hover {
  color: var(--hci-brown-mid);
}
.hci-comment-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--hci-border);
  border-radius: var(--hci-radius);
  background: var(--hci-bg-white);
  padding: 4px 4px 4px 14px;
  transition: border-color var(--hci-transition);
}
.hci-comment-input-wrap:focus-within {
  border-color: var(--hci-border-dark);
}

.hci-comment-input {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 6px 0;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  background: transparent;
  color: var(--hci-text);
  line-height: 1.5;
  outline: none;
}
.hci-comment-input::placeholder {
  color: var(--hci-text-muted);
}

.hci-comment-submit {
  flex-shrink: 0;
  background: var(--hci-brown-dark);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--hci-transition);
}
.hci-comment-submit:hover {
  background: var(--hci-brown-mid);
}
.hci-comment-submit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ──── Guest Name Input ──── */
.hci-comment-name-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--hci-border);
  padding: 4px 0;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: var(--hci-text);
  outline: none;
  margin-bottom: 4px;
}
.hci-comment-name-input::placeholder {
  color: var(--hci-text-muted);
}
.hci-comment-name-input:focus-visible { outline: none; }
.hci-comment-input:focus-visible { outline: none; }

/* ──── Reply Form ──── */
.hci-comment-reply-form {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(232, 221, 208, 0.5);
}
.hci-comment-reply-form .hci-comment-avatar {
  width: 24px;
  height: 24px;
}
.hci-comment-reply-form .hci-comment-submit {
  padding: 5px 14px;
  font-size: 12px;
}

/* ──── Success State ──── */
.hci-comment-success {
  text-align: center;
  color: #27ae60;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 0;
}

/* ══════════════════════════════════════════════════════════
   SHARE POPOVER
   ══════════════════════════════════════════════════════════ */

.hci-share-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--hci-bg-white);
  border: 1px solid var(--hci-border);
  border-radius: var(--hci-radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 6px;
  display: flex;
  gap: 2px;
  z-index: 100;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity var(--hci-transition), transform var(--hci-transition);
}
.hci-share-popover.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.hci-share-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  padding: 0;
  color: var(--hci-text-secondary);
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--hci-transition);
}
.hci-share-option:hover {
  background: var(--hci-bg);
  color: var(--hci-text);
}
.hci-share-option.hci-copied { color: #27ae60; }
.hci-share-native {
  border-right: 1px solid var(--hci-border);
  margin-right: 4px;
  padding-right: 8px;
  border-radius: 0;
}

/* ──── Share Tooltips (same as emotions) ──── */
.hci-share-option::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--hci-brown-dark);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hci-transition), transform var(--hci-transition);
  z-index: 110;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.hci-share-option::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--hci-brown-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hci-transition);
  z-index: 110;
}
.hci-share-option:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.hci-share-option:hover::before { opacity: 1; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */

/* ──── Load More Buttons ──── */
.hci-load-more-comments,
.hci-load-more-replies {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--hci-text-muted);
  cursor: pointer;
  text-align: center;
  border-radius: var(--hci-radius-sm);
  transition: all var(--hci-transition);
}
.hci-load-more-comments:hover,
.hci-load-more-replies:hover {
  color: var(--hci-text);
  background: rgba(232, 221, 208, 0.3);
}
.hci-load-more-comments:disabled,
.hci-load-more-replies:disabled {
  opacity: 0.5;
  cursor: wait;
}
.hci-load-more-replies {
  font-size: 12px;
  padding: 6px 0;
}

@media (max-width: 768px) {
  .hci-comment-block { padding: 0 12px; }
  .hci-comment-block.open { padding: 12px; }
  .hci-comment-avatar { width: 28px; height: 28px; }
  .hci-comment-reply .hci-comment-avatar { width: 22px; height: 22px; }
  .hci-share-popover { right: auto; left: 0; }
  .hci-comment-actions { gap: 2px; }
  .hci-comment-actions button { padding: 4px 6px; font-size: 11px; }
}
