/* ─── Page détail V2 (handoff : screens/detail.html, reply-loading.html) ─── */

.comment-vote-btn { transition: color var(--ds-motion-fast); }
.comment-vote-btn:hover { color: var(--color-accent); }
.comment-vote-btn.active { color: var(--color-accent); }
.reply-toggle:hover { color: var(--color-accent); }

.post-detail-v2 {
  margin: 0 auto;
  max-width: var(--layout-reading-max);
  padding: 0 0 calc(var(--ds-space-16) + var(--space-8) + env(safe-area-inset-bottom)); /* place pour la barre de réponse */
}

.post-detail-v2__article {
  border-bottom: 1px solid var(--color-border-subtle);
  padding: var(--space-4);
}

.post-detail-v2__title {
  color: var(--color-text);
  font-size: var(--ds-font-size-xl);
  letter-spacing: var(--ds-letter-spacing-heading);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-heading);
  margin: var(--space-3) 0 0;
}

.post-detail-v2__body {
  margin-top: var(--space-4);
}

/* Actions : Vòt · Repons · Pataje · … (pas de pilules, icônes encre) */
.post-detail-v2__actions {
  margin-top: var(--space-4);
}

.post-detail-v2__actions .post-actions {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-4);
}

.post-detail-v2__actions .post-action {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--color-text-muted);
  display: inline-flex;
  font: inherit;
  font-size: var(--ds-font-size-sm);
  gap: var(--space-1);
  line-height: 1;
  min-height: var(--ds-size-target);
  padding: 0;
  text-decoration: none;
  white-space: nowrap;
}

.post-detail-v2__actions .post-action__icon {
  color: var(--color-accent);
}

.post-detail-v2__actions .post-action:hover,
.post-detail-v2__actions .vote-btn.active.post-action {
  color: var(--color-accent);
}

.post-detail-v2__actions .vote-btn.active.post-action {
  font-weight: var(--ds-font-weight-semibold);
}

.post-body {
  display: grid;
  gap: var(--space-4);
}

/* Image pleine largeur (bord à bord), 16:10 */
.post-detail-v2 .post-body__media {
  margin: 0 calc(var(--space-4) * -1);
}

.post-body__media {
  margin: 0;
}

.post-body__image {
  aspect-ratio: 16 / 10;
  background: var(--color-surface-soft);
  display: block;
  height: auto;
  object-fit: cover;
  width: 100%;
}

.post-body__content {
  color: var(--color-text);
  font-size: var(--ds-font-size-md);
  line-height: var(--ds-line-height-relaxed);
  overflow-wrap: anywhere;
}

.post-body__content p {
  margin: 0 0 var(--space-post-paragraph);
}

.post-body__content p:last-child {
  margin-bottom: 0;
}

/* ─── Repons : ouvertes, sans cadre ni filet, rythme régulier de 22px ─── */

.comment-thread {
  margin-bottom: var(--space-1);
  padding: var(--space-4) var(--space-4) 0;
}

.comment-thread__title {
  color: var(--color-text);
  font-size: var(--ds-font-size-md);
  font-weight: var(--ds-font-weight-semibold);
  margin: 0;
}

.comment-thread__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding-top: var(--space-4);
}

/* Un seul niveau : retrait de 14px, sans barre verticale */
.comment-thread__replies {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin: var(--space-5) 0 0 var(--space-4);
}

.comment-thread__replies:empty {
  display: none;
}

.comment-item {
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  transition: background-color var(--ds-motion-glide);
}

.comment-item__top {
  align-items: center;
  display: flex;
  gap: var(--space-2);
}

.comment-item__avatar {
  align-items: center;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-semibold);
  height: 28px;
  justify-content: center;
  overflow: hidden;
  text-decoration: none;
  width: 28px;
}

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

.comment-item__line {
  align-items: center;
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: var(--space-1);
  line-height: var(--ds-line-height-body);
  min-width: 0;
}

.comment-item__author {
  color: var(--color-text);
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-semibold);
  text-decoration: none;
}

.comment-item__dot,
.comment-item__time {
  color: var(--color-text-subtle);
  font-size: var(--ds-font-size-xs);
}

.comment-item__body {
  color: var(--color-text);
  font-size: var(--ds-font-size-md);
  line-height: var(--ds-line-height-prose);
  margin: var(--space-2) 0 0;
  overflow-wrap: anywhere;
}

/* Repons efase gardée pour ses réponses (TECH_DEBT §2) */
.comment-item__body--deleted {
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0;
}


.comment-item__mention {
  color: var(--color-accent);
  font-weight: var(--ds-font-weight-semibold);
}

.comment-item__actions {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-1);
}

.comment-item__action {
  align-items: center;
  background: none;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--ds-font-size-sm);
  gap: var(--space-1);
  min-height: var(--ds-size-target);
  padding: 0;
  text-decoration: none;
  white-space: nowrap;
}

.comment-item__action .icon {
  color: var(--color-accent);
}

.comment-item__action.active {
  color: var(--color-accent);
  font-weight: var(--ds-font-weight-semibold);
}

/* Repons visée par « Reponn » */
.comment-item.is-reply-target {
  background: var(--color-accent-soft);
  margin: calc(var(--space-2) * -1) calc(var(--space-3) * -1);
  padding: var(--space-2) var(--space-3);
}

/* Repons tout juste publiée : bref fondu accent-soft. Durée longue assumée (le temps de la repérer,
   pas un mouvement d'interface) : aucun jeton de mouvement ne couvre ce cas. */
.comment-item.is-fresh {
  animation: comment-fresh 1.6s var(--ds-motion-ease);
}

@keyframes comment-fresh {
  0% { background: var(--color-accent-soft); }
  100% { background: transparent; }
}

.comment-edit-form {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.comment-edit-input {
  min-height: 88px;
}

.comment-edit-actions {
  margin-top: var(--space-2);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* ─── Barre de réponse : toujours visible, collée en bas ─── */

.reply-bar {
  background: var(--color-bg);
  border-top: 1px solid var(--color-border-subtle);
  bottom: 0;
  left: 0;
  padding-bottom: env(safe-area-inset-bottom);
  position: fixed;
  right: 0;
  z-index: var(--ds-z-sticky);
}

.reply-bar__context {
  align-items: center;
  color: var(--color-text-muted);
  display: flex;
  font-size: var(--ds-font-size-xs);
  gap: var(--space-2);
  margin: 0 auto;
  max-width: var(--layout-reading-max);
  padding: var(--space-2) var(--space-4) 0;
}

.reply-bar__context[hidden] {
  display: none;
}

.reply-bar__context .icon {
  color: var(--color-accent);
  height: var(--ds-size-icon-sm);
  width: var(--ds-size-icon-sm);
}

.reply-bar__context b {
  color: var(--color-text);
  font-weight: var(--ds-font-weight-semibold);
}

.reply-bar__cancel {
  align-items: center;
  background: none;
  border: 0;
  color: var(--color-text-subtle);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  margin-left: auto;
  min-height: var(--ds-size-target-min);
  min-width: var(--ds-size-target-min);
}

.reply-bar__row {
  align-items: flex-end;
  display: flex;
  gap: var(--space-2);
  margin: 0 auto;
  max-width: var(--layout-reading-max);
  padding: var(--space-2) var(--space-4);
}

.reply-bar__avatar {
  align-items: center;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-semibold);
  height: 28px;
  justify-content: center;
  margin-bottom: var(--space-2);
  overflow: hidden;
  width: 28px;
}

.reply-bar__avatar img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

/* Le champ du système (ds-input), qui grandit avec le texte ; une repons se lit et s'écrit en 16 px */
.reply-bar__input {
  font-size: var(--ds-font-size-md);
  height: auto;
  line-height: var(--ds-line-height-body);
  max-height: 120px;
  min-height: var(--ds-size-target);
  padding-block: var(--space-2);
  resize: none;
}

/* Envoyer : le bouton principal du système (ds-btn--primary ds-btn--icon) */
.reply-bar__send {
  flex: 0 0 auto;
}



/* Envoi en cours : spinner dans le bouton, jamais d'écran bloqué */
.reply-bar__spinner {
  animation: reply-spin 0.8s linear infinite; /* boucle de chargement : durée hors jetons assumée */
  border: 2px solid color-mix(in srgb, var(--ds-on-color) 35%, transparent);
  border-radius: var(--radius-full);
  border-top-color: var(--color-on-accent);
  display: none;
  height: 18px;
  width: 18px;
}

.reply-bar__row.htmx-request .reply-bar__send-icon {
  display: none;
}

.reply-bar__row.htmx-request .reply-bar__spinner {
  display: block;
}

.reply-bar__row.htmx-request .reply-bar__send:disabled {
  background: var(--ds-accent);
  color: var(--ds-on-color);
}

@keyframes reply-spin {
  to { transform: rotate(360deg); }
}

.reply-bar__login {
  align-items: center;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--ds-radius-pill);
  color: var(--color-accent);
  display: flex;
  flex: 1;
  font-weight: var(--ds-font-weight-semibold);
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .comment-item,
  .comment-item.is-fresh,
  .reply-bar__spinner {
    animation: none;
    transition: none;
  }
}

/* Desktop : la barre reste collée en bas de la colonne de lecture (R9) */
@media (min-width: 1024px) {
  .reply-bar {
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    left: 50%;
    max-width: var(--layout-reading-max);
    transform: translateX(-50%);
    width: 100%;
  }
}
