/**
 * 共用回复条 · 收起 / 展开
 *
 * 知识库章节 / 工具箱条目与合集：.myt-reply-composer
 * 社区话题页：同一套收起行 class（.myt-reply-collapsed-row 等），卡壳仍由
 * community/features/reply-dual.css 的 #wpforo 选择器压 wpForo。
 *
 * Token 对齐 CONTEXT §9 / DESIGN.md §7（白底 + #dedede + 14px 圆角）。
 */

.myt-reply-composer {
  --myt-reply-ink: #222222;
  --myt-reply-ink-secondary: #666666;
  --myt-reply-ink-tertiary: #999999;
  --myt-reply-ink-disabled: #cccccc;
  --myt-reply-line: #dedede;
  --myt-reply-line-soft: #ededed;
  --myt-reply-surface: #ffffff;
  --myt-reply-muted: #f5f5f5;
  --myt-reply-focus: #111111;
  --myt-reply-radius-card: 14px;
  --myt-reply-radius-control: 8px;
  box-sizing: border-box;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--myt-reply-line);
  border-radius: var(--myt-reply-radius-card);
  background: var(--myt-reply-surface);
  transition: border-color 0.2s ease;
}

.myt-reply-composer.is-expanded {
  padding: 16px;
  border-color: var(--myt-reply-ink-disabled);
}

.myt-reply-composer--guest {
  padding: 16px;
}

.myt-reply-collapsed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.myt-reply-composer .myt-reply-collapsed-row {
  cursor: text;
  display: none;
}

.myt-reply-composer .myt-reply-collapsed-row:focus-visible {
  outline: 2px solid var(--myt-reply-focus);
  outline-offset: 2px;
  border-radius: var(--myt-reply-radius-control);
}

.myt-reply-collapsed-row img,
.myt-reply-collapsed-row .avatar,
.myt-reply-collapsed-row .myt-reply-avatar,
.myt-reply-composer img.myt-reply-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  object-fit: cover;
  flex: none;
}

.myt-reply-placeholder {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 330;
  color: var(--myt-wpf-color-ink-tertiary, var(--myt-reply-ink-tertiary, #999999));
}

.myt-reply-composer .myt-reply-fake-btn,
.myt-reply-fake-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 64px;
  height: 36px;
  margin: 0;
  padding: 0 16px;
  border: none;
  border-radius: 8px;
  background: var(--myt-wpf-color-line-soft, var(--myt-reply-line-soft, #ededed));
  color: var(--myt-wpf-color-ink, var(--myt-reply-ink, #222222));
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-sizing: border-box;
}

/* 有 JS：默认收起；无 JS：只出示表单，保证能发 */
.myt-reply-js .myt-reply-composer:not(.is-expanded) .myt-reply-collapsed-row {
  display: flex;
}

.myt-reply-js .myt-reply-composer:not(.is-expanded) .myt-reply-composer__form {
  display: none;
}

.myt-reply-js .myt-reply-composer.is-expanded .myt-reply-collapsed-row {
  display: none;
}

.myt-reply-composer__title,
.myt-reply-composer__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.myt-reply-composer__form {
  position: relative;
  margin: 0;
  min-width: 0;
}

.myt-reply-composer__input {
  display: block;
  width: 100%;
  min-height: 64px;
  max-height: 400px;
  margin: 0;
  padding: 8px 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  font-size: 16px;
  font-weight: 330;
  line-height: 1.6;
  color: var(--myt-reply-ink);
  resize: none;
  overflow-y: auto;
}

.myt-reply-composer__input::placeholder {
  color: var(--myt-reply-ink-disabled);
}

.myt-reply-composer__input:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

.myt-reply-composer__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--myt-wpf-color-line-soft, var(--myt-reply-line-soft, #ededed));
}

.myt-reply-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.myt-reply-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--myt-wpf-color-ink-secondary, var(--myt-reply-ink-secondary, #666666));
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.myt-reply-icon-btn:hover {
  background: var(--myt-wpf-color-surface-muted, var(--myt-reply-muted, #f5f5f5));
  color: var(--myt-wpf-color-ink, var(--myt-reply-ink, #222222));
}

.myt-reply-icon-btn:focus-visible {
  outline: 2px solid var(--myt-reply-focus, #111111);
  outline-offset: 2px;
}

.myt-reply-icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.myt-emoji-pop {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 30;
  display: none;
  width: 296px;
  max-width: calc(100vw - 48px);
  padding: 10px;
  border: 1px solid var(--myt-wpf-color-line-soft, var(--myt-reply-line-soft, #ededed));
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(17, 17, 17, 0.1);
}

.myt-emoji-pop.is-open {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.myt-emoji-pop button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 33px;
  height: 33px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.myt-emoji-pop button:hover {
  background: var(--myt-wpf-color-surface-muted, var(--myt-reply-muted, #f5f5f5));
}

.myt-reply-image-preview {
  position: relative;
  display: inline-block;
  max-width: 180px;
  margin-top: 8px;
}

.myt-reply-image-preview[hidden] {
  display: none;
}

.myt-reply-image-preview__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 140px;
  object-fit: cover;
  border-radius: 12px;
  background: #f5f5f5;
}

.myt-reply-image-preview__remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 9999px;
  background: rgba(17, 17, 17, 0.72);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.myt-reply-composer__toolbar,
.myt-reply-composer .myt-reply-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: none;
  margin-left: auto;
  flex: none;
}

.myt-reply-composer .myt-reply-cancel,
.myt-reply-composer .myt-reply-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 64px;
  height: 36px;
  margin: 0;
  padding: 0 16px;
  border: none;
  border-radius: var(--myt-reply-radius-control);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.myt-reply-composer .myt-reply-cancel {
  background: var(--myt-reply-line-soft);
  color: var(--myt-reply-ink);
}

.myt-reply-composer .myt-reply-cancel:hover {
  background: var(--myt-reply-muted);
}

.myt-reply-composer .myt-reply-submit {
  background: var(--myt-reply-ink);
  color: #ffffff;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.myt-reply-composer .myt-reply-submit:hover:not(:disabled) {
  background: var(--myt-reply-focus);
}

.myt-reply-composer .myt-reply-submit:disabled {
  opacity: 0.4;
  cursor: default;
}

.myt-reply-composer .myt-reply-cancel:focus-visible,
.myt-reply-composer .myt-reply-submit:focus-visible {
  outline: 2px solid var(--myt-reply-focus);
  outline-offset: 2px;
}

.myt-reply-composer__login {
  margin: 0;
  font-size: 15px;
  font-weight: 330;
  color: var(--myt-reply-ink-secondary);
  text-align: left;
}

.myt-reply-composer__login a {
  color: var(--myt-reply-ink);
  font-weight: 500;
  text-decoration: none;
}

.myt-reply-composer__login a:hover,
.myt-reply-composer__login a:focus-visible {
  text-decoration: underline;
}

.myt-reply-composer__login a:focus-visible {
  outline: 2px solid var(--myt-reply-focus);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .myt-reply-composer {
    padding: 10px 12px;
  }

  .myt-reply-composer .myt-reply-fake-btn,
  .myt-reply-composer .myt-reply-cancel,
  .myt-reply-composer .myt-reply-submit,
  .myt-reply-icon-btn {
    min-height: 44px;
    height: 44px;
  }

  .myt-reply-icon-btn {
    width: 44px;
  }
}

.comments-area .mytb-comment-img,
.myt-reply-js .mytb-comment-img {
  margin: 0.5rem 0 0;
}

.comments-area article img,
.comments-area .mytb-comment-img img,
.myt-reply-js .mytb-comment-img img {
  display: block;
  max-width: min(100%, 420px);
  height: auto;
  margin-top: 0.5rem;
  border-radius: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .myt-reply-composer,
  .myt-reply-composer .myt-reply-submit {
    transition: none;
  }
}
