/* Discussion threads and inline replies. Shared post controls remain shared. */
.community-comments{
  margin-top: 20px;
  font-size: .9rem;
}

.community-comments .community-section-heading{
  margin-bottom: 10px;
}

.community-comments .community-section-heading h2{
  font-size: 1.12rem;
}

.community-comment{
  position: relative;
  min-width: 0;
  padding: 12px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.community-comment.has-comment-replies::after{
  content: "";
  position: absolute;
  z-index: 0;
  top: 14px;
  bottom: 0;
  left: 13px;
  width: 2px;
  border-radius: var(--rx-radius-pill);
  background: color-mix(in srgb, var(--rx-color-text-muted) 42%, var(--rx-color-border));
  pointer-events: none;
}

.community-comment > .community-post-byline,
.community-comment > .community-comment-body,
.community-comment > .community-post-actions,
.community-comment > .community-removal-reason,
.community-comment > .community-inline-reply-slot,
.community-comment > .community-comment-thread{
  position: relative;
  z-index: 1;
}

.community-comment-reply::before{
  content: "";
  position: absolute;
  z-index: 0;
  top: 13px;
  left: -20px;
  width: 32px;
  height: 2px;
  border-radius: var(--rx-radius-pill);
  background: color-mix(in srgb, var(--rx-color-text-muted) 42%, var(--rx-color-border));
  pointer-events: none;
}

.community-comment .community-post-byline .avatar-sm{
  position: relative;
  z-index: 2;
  background: var(--rx-color-page);
}

.community-comment-list > .community-comment-thread-root + .community-comment-thread-root{
  border-top: 1px solid var(--border);
}

.community-comment-body{
  color: var(--rx-color-text);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  margin-top: 7px;
  margin-left: 35px;
  font-size: .86rem;
  line-height: 1.5;
}

.community-comment-reply{
  padding: 10px 0;
  background: transparent;
}

.community-comment-actions{
  gap: 2px;
  margin: 9px -4px -4px 31px;
}

.community-comment > .community-removal-reason,
.community-comment > .community-inline-reply-slot{
  margin-left: 35px;
}

.community-comment-actions .community-post-action{
  min-height: 28px;
  padding: 4px 7px;
  border-radius: 7px;
  font-size: .75rem;
}

.community-comment-actions .community-vote-control{
  border-radius: 8px;
}

.community-comment-actions .community-vote-control .community-post-action{
  min-width: 28px;
}

.community-comment-actions .community-vote-control strong{
  font-size: .74rem;
}

.community-comment-thread{
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  min-width: 0;
  margin-top: 6px;
}

.community-comment-thread-line{
  position: relative;
  grid-row: 1;
  grid-column: 1;
  width: 32px;
  min-height: 42px;
  align-self: stretch;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--rx-color-text-muted);
  cursor: pointer;
}

.community-comment-thread-line::before,
.community-comment-thread-line::after{
  content: "";
  position: absolute;
  background: color-mix(in srgb, var(--rx-color-text-muted) 42%, var(--rx-color-border));
  transition: background 150ms ease, box-shadow 150ms ease;
}

.community-comment-thread-line::before{
  top: 0;
  bottom: 0;
  left: 13px;
  width: 2px;
  border-radius: 999px;
}

.community-comment-thread-line::after{
  display: none;
}

.community-comment-thread-line:hover::before,
.community-comment-thread-line:hover::after,
.community-comment-thread-line:focus-visible::before,
.community-comment-thread-line:focus-visible::after{
  background: var(--rx-color-accent);
  box-shadow: 0 0 8px rgba(var(--rx-color-accent-rgb), .36);
}

.community-comment-thread-line:focus-visible{
  border-radius: 8px;
  box-shadow: 0 0 0 3px var(--rx-color-focus);
}

.community-comment-thread-line-copy{
  display: none;
}

.community-comment-children{
  display: grid;
  grid-row: 1;
  grid-column: 2;
  gap: 6px;
  min-width: 0;
}

.community-comment-children.hidden{
  display: none;
}

.community-comment-thread.is-collapsed .community-comment-thread-line{
  grid-column: 1 / -1;
  width: max-content;
  min-height: 30px;
  padding: 0 10px 0 31px;
  color: var(--rx-color-text-muted);
  font: inherit;
  font-size: .75rem;
  font-weight: 800;
}

.community-comment-thread.is-collapsed .community-comment-thread-line::before{
  bottom: 12px;
}

.community-comment-thread.is-collapsed .community-comment-thread-line::after{
  top: 17px;
}

.community-comment-thread.is-collapsed .community-comment-thread-line-copy{
  display: inline;
}

.community-comment-branch-more-row{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 0 2px;
}

.community-comment-branch-more{
  color: var(--accent);
  font-weight: 700;
}

.community-comment:target,
.community-comment-target{
  background: linear-gradient(90deg, rgba(var(--accent-rgb), .09), transparent 72%);
  box-shadow: none;
}

.community-inline-reply-slot:empty{
  display: none;
}

.community-inline-reply-form{
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.community-inline-reply-form textarea{
  width: 100%;
  min-height: 68px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: .82rem;
  line-height: 1.45;
  resize: vertical;
}

.community-inline-reply-footer,
.community-inline-reply-actions{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.community-inline-reply-footer{
  justify-content: space-between;
}

.community-inline-reply-actions{
  justify-content: flex-end;
}

/* On narrow workspaces, indent the first reply level only. Deeper branches
   keep a labelled control above their replies instead of consuming more width. */
@media (max-width: 1180px){
  .community-comment-thread{
    grid-template-columns: var(--rx-size-tap-min) minmax(0, 1fr);
  }

  .community-comment-thread-line{
    width: var(--rx-size-tap-min);
    min-height: var(--rx-size-tap-min);
  }

  .community-comment-reply::before{
    left: calc(12px - var(--rx-size-tap-min));
    width: var(--rx-size-tap-min);
  }

  .community-comment-reply > .community-comment-thread{
    grid-template-columns: minmax(0, 1fr);
  }

  .community-comment-reply > .community-comment-thread > .community-comment-children{
    grid-column: 1;
    grid-row: 2;
  }

  .community-comment-reply > .community-comment-thread > .community-comment-thread-line,
  .community-comment-thread.is-collapsed .community-comment-thread-line{
    width: fit-content;
    max-width: 100%;
    min-width: var(--rx-size-tap-min);
    min-height: var(--rx-size-tap-min);
    padding: var(--rx-space-2) var(--rx-space-3);
    border-radius: var(--rx-radius-control);
    font: inherit;
    font-size: var(--rx-font-size-xs);
    font-weight: var(--rx-font-weight-strong);
    text-align: start;
    overflow-wrap: anywhere;
  }

  .community-comment-reply > .community-comment-thread .community-comment-thread-line-copy{
    display: inline;
  }

  .community-comment-reply.has-comment-replies::after,
  .community-comment-reply .community-comment-reply::before,
  .community-comment-reply > .community-comment-thread > .community-comment-thread-line::before,
  .community-comment-thread.is-collapsed .community-comment-thread-line::before{
    content: none;
  }
}
