/* ============================================================
   KeyCMS · 内容互动组件（点赞 / 收藏 / 反馈）
   独立样式表，不依赖 /css/site.css，可在任意前台模板包中使用。

   设计要点：
   - 操作条使用半透明中性表面 + 继承文字色，浅色与深色主题都能直接嵌入；
   - 点赞 / 收藏的激活态只用彩色图标与轻微色块强调，文字保持继承色以保证对比度；
   - 反馈弹窗需要有实色背景，页面明暗由 JS 探测后写入
     <html data-engage-tone="light|dark">，避免弹窗与页面出现阅读反差；
   - 轻提示统一使用深色胶囊，在任意背景上都可读。
   ============================================================ */

/* ---------- 操作条 ---------- */
.article-engage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  margin: 28px 0;
  padding: 12px 16px;
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 14px;
  background: rgba(128, 128, 128, 0.08);
  color: inherit;
}

.engage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.engage-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding-inline: 14px;
  border: 1px solid rgba(128, 128, 128, 0.42);
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.06);
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  opacity: 0.86;
  cursor: pointer;
  transition: opacity 0.18s, background 0.18s, border-color 0.18s, transform 0.18s;
}
.engage-btn:hover { opacity: 1; background: rgba(128, 128, 128, 0.16); }
.engage-btn:active { transform: scale(0.97); }
.engage-btn:focus-visible { outline: 2px solid rgba(128, 128, 128, 0.7); outline-offset: 2px; }
.engage-btn:disabled { opacity: 0.45; cursor: progress; }

.engage-icon { flex: none; }
.engage-count { font-size: 12px; font-weight: 700; opacity: 0.66; font-variant-numeric: tabular-nums; }

.engage-btn.is-active { opacity: 1; }
.engage-btn.is-active .engage-count { opacity: 0.86; }

.engage-btn--like.is-active {
  background: rgba(226, 89, 78, 0.14);
  border-color: rgba(226, 89, 78, 0.5);
}
.engage-btn--like.is-active .engage-icon { color: #e2594e; fill: #e2594e; }

.engage-btn--favorite.is-active {
  background: rgba(222, 163, 44, 0.16);
  border-color: rgba(222, 163, 44, 0.55);
}
.engage-btn--favorite.is-active .engage-icon { color: #dfa32c; fill: #dfa32c; }

.engage-hint { margin: 0; font-size: 12.5px; line-height: 1.55; opacity: 0.66; }
.engage-hint a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 反馈弹窗 ---------- */
.feedback-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: min(88vh, 760px);
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 20px;
  background: #ffffff;
  color: #16181b;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: 0 32px 72px -32px rgba(12, 15, 18, 0.5);
  overflow: auto;
  overscroll-behavior: contain;
}
.feedback-dialog:not([open]) { display: none; }
.feedback-dialog::backdrop { background: rgba(12, 15, 18, 0.55); }

[data-engage-tone="dark"] .feedback-dialog {
  border-color: rgba(255, 255, 255, 0.12);
  background: #171c23;
  color: #e9eef5;
}

.feedback-form { display: block; padding: 22px 22px 18px; }
.feedback-form[hidden], .feedback-done[hidden] { display: none; }

.feedback-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.feedback-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.feedback-sub { margin: 6px 0 0; font-size: 12.5px; line-height: 1.6; opacity: 0.64; }

.feedback-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  transition: opacity 0.18s, background 0.18s;
}
.feedback-close:hover { opacity: 1; background: rgba(128, 128, 128, 0.14); }
.feedback-close:focus-visible { outline: 2px solid rgba(128, 128, 128, 0.7); outline-offset: 2px; }

.feedback-fields { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.feedback-field { display: flex; flex-direction: column; gap: 6px; }
.feedback-field label { font-size: 12.5px; font-weight: 650; opacity: 0.8; }

.feedback-field select,
.feedback-field input,
.feedback-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(128, 128, 128, 0.42);
  border-radius: 10px;
  background: rgba(128, 128, 128, 0.06);
  color: inherit;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.feedback-field textarea { min-height: 108px; resize: vertical; }
.feedback-field select option { background: #ffffff; color: #16181b; }
[data-engage-tone="dark"] .feedback-field select option { background: #171c23; color: #e9eef5; }

.feedback-field select:focus,
.feedback-field input:focus,
.feedback-field textarea:focus {
  outline: none;
  border-color: rgba(128, 128, 128, 0.8);
  box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.18);
  background: rgba(128, 128, 128, 0.1);
}
.feedback-field.is-invalid textarea { border-color: #e2594e; box-shadow: 0 0 0 3px rgba(226, 89, 78, 0.14); }

.feedback-counter { align-self: flex-end; font-size: 11.5px; opacity: 0.55; font-variant-numeric: tabular-nums; }
.feedback-req { margin-left: 3px; color: #e2594e; }
.feedback-optional { margin-left: 8px; font-size: 11.5px; font-weight: 500; opacity: 0.55; }

.feedback-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(226, 89, 78, 0.12);
  color: #c0342b;
  font-size: 12.5px;
  line-height: 1.55;
}
[data-engage-tone="dark"] .feedback-error { color: #ffb4ab; }

.feedback-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.feedback-done { padding: 34px 24px 28px; text-align: center; }
.feedback-done-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.feedback-done-desc { margin: 0 0 18px; font-size: 13px; line-height: 1.6; opacity: 0.72; }

/* 弹窗内的按钮：不依赖站内 .btn 体系，保证在任意模板包中都可见 */
.feedback-dialog .btn,
.feedback-dialog .kc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding-inline: 18px;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, opacity 0.18s;
}
.feedback-dialog .btn:hover,
.feedback-dialog .kc-btn:hover { background: rgba(128, 128, 128, 0.14); }
.feedback-dialog .btn--primary,
.feedback-dialog .kc-btn-primary {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}
.feedback-dialog .btn--primary:hover,
.feedback-dialog .kc-btn-primary:hover { background: #115e59; border-color: #115e59; }
.feedback-dialog .btn--primary:disabled { opacity: 0.6; cursor: progress; }
.feedback-dialog .btn:focus-visible,
.feedback-dialog .kc-btn:focus-visible { outline: 2px solid rgba(128, 128, 128, 0.7); outline-offset: 2px; }

/* ---------- 我的收藏 ---------- */
.favorites-grid { margin-top: 4px; }
.favorite-item { display: flex; flex-direction: column; }
.favorite-item .card { flex: 1; }
.favorite-item.is-removing { opacity: 0.4; pointer-events: none; transition: opacity 0.25s ease; }
.favorite-remove {
  align-self: flex-start;
  margin-top: 8px;
  height: 28px;
  padding-inline: 12px;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: opacity 0.18s, color 0.18s, border-color 0.18s, background 0.18s;
}
.favorite-remove:hover { opacity: 1; color: #c0342b; border-color: rgba(192, 52, 43, 0.6); background: rgba(192, 52, 43, 0.08); }
.favorite-remove:focus-visible { outline: 2px solid rgba(128, 128, 128, 0.7); outline-offset: 2px; }

/* ---------- 轻提示 ---------- */
.site-toast-stack {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.site-toast {
  max-width: min(90vw, 420px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 23, 27, 0.94);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.55);
  animation: siteToastIn 0.2s ease-out;
}
.site-toast--error { background: #b42318; }
@keyframes siteToastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .article-engage { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
  .engage-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .engage-btn { justify-content: center; padding-inline: 8px; }
  .engage-hint { text-align: center; }
  .feedback-form { padding: 18px 16px 16px; }
  .feedback-foot { flex-direction: column-reverse; }
  .feedback-foot .btn { width: 100%; }
}

@media print {
  .article-engage, .feedback-dialog, .site-toast-stack { display: none !important; }
}
