/* =============================================================================
   character_comment_modal.css
   キャラへのコメント機能・モーダル専用スタイル。
   既存 style10.css の :root 変数（--color-primary 等）をそのまま前提にする。
   style10.css より後に読み込むこと（hero_select.css / ranking.css と同じ方針）。
   ============================================================================= */

.comment-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: comment-modal-overlay-in 0.2s ease;
}

.comment-modal-overlay.closing {
  animation: comment-modal-overlay-out 0.2s ease forwards;
}

@keyframes comment-modal-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes comment-modal-overlay-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.comment-modal {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  width: 600px;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.comment-modal-overlay.closing .comment-modal {
  animation: comment-modal-out 0.2s ease forwards;
}

@keyframes comment-modal-out {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(12px); opacity: 0; }
}

/* --- ヘッダー --- */

.comment-modal__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.comment-modal__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--color-text-muted);
}

.comment-modal__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment-modal__title-wrap {
  flex: 1;
  min-width: 0;
}

.comment-modal__title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comment-modal__count {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 2px 0 0;
}

.comment-modal__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.comment-modal__close:hover {
  background: var(--color-border);
}

/* --- 本体（一覧） --- */

.comment-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comment-modal__loading,
.comment-modal__empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 24px 0;
}

.comment-item {
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.comment-item:first-child {
  padding-top: 0;
  border-top: none;
}

.comment-item.is-highlighted {
  animation: comment-item-highlight 1.6s ease;
  border-radius: 8px;
}

@keyframes comment-item-highlight {
  0%   { background: rgba(255, 214, 0, 0.25); }
  100% { background: transparent; }
}

.comment-item__reply-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--color-bg);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.comment-item__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.comment-item__author {
  font-size: 0.82rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-item__author-name {
  font-weight: 700;
  color: var(--color-text);
}

.comment-item__author-hash {
  color: var(--color-text-muted);
  margin-left: 4px;
}

.comment-item__time {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.comment-item__body {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-item__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.comment-item__action-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.76rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.comment-item__action-btn:hover {
  color: var(--color-text);
}

.comment-item__action-btn--delete:hover {
  color: var(--color-danger);
}

/* --- フッター（投稿フォーム） --- */

.comment-modal__footer {
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
  flex-shrink: 0;
}

.comment-modal__reply-chip {
  display: none;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.comment-modal__reply-chip.is-active {
  display: flex;
}

.comment-modal__reply-chip-cancel {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.comment-modal__textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  margin-bottom: 6px;
  box-sizing: border-box;
}

.comment-modal__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.comment-modal__footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-modal__name-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  margin-bottom: 6px;
}

.comment-modal__name-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.comment-modal__char-count {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.comment-modal__submit {
  margin-left: auto;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.comment-modal__submit:hover {
  background: var(--color-primary-dark);
}

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

.comment-modal__error {
  color: var(--color-danger);
  font-size: 0.78rem;
  margin: 6px 0 0;
}

.comment-modal__login-required {
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  padding: 6px 0;
}

.comment-modal__login-required a {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

/* --- カード側の💬ボタン（character-card__body内） --- */

.character-card__comment-btn {
  align-self: flex-start;
  margin: 0;
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

/* --- スマホ幅：ボトムシート表示 --- */

@media (max-width: 640px) {
  .comment-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .comment-modal {
    width: 100%;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
  }

  .comment-modal-overlay.closing .comment-modal {
    animation: comment-modal-out-mobile 0.2s ease forwards;
  }
}

@keyframes comment-modal-out-mobile {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(40px); opacity: 0; }
}
