/* Comments — themed with the site token layer (theme.css), not raw Bootstrap,
   so the section reads consistently on every host page (edition, issue,
   reading-order, search). */
.comments-section { border-top: 1px solid var(--border); padding-top: 1.5rem; color: var(--text); }
.comments-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.comments-heading { font-size: 1.25rem; margin: 0; color: var(--text); }
.comments-heading .text-muted { color: var(--text-muted) !important; font-weight: 600; }
.comment-sort { display: inline-flex; gap: .5rem; }

.comment-compose { position: relative; margin-bottom: 1.5rem; }
.comment-compose-actions { margin-top: .5rem; display: flex; gap: .75rem; align-items: center; justify-content: flex-end; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* One comment = avatar gutter + aligned content column. Head, body and
   actions all share the left edge of the content column. */
.comment-node { padding: .85rem 0; border-bottom: 1px solid var(--border); }
.comment-node:last-child { border-bottom: 0; }
.comment-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: .75rem; align-items: start; }
.comment-avatar { flex: none; display: block; line-height: 0; text-decoration: none; }
.comment-main { min-width: 0; }

.comment-head { font-size: .85rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .4rem .55rem; align-items: baseline; }
.comment-author { font-weight: 700; color: var(--text); text-decoration: none; }
.comment-author-link:hover { color: var(--brand); text-decoration: underline; }
.comment-time, .comment-edited { color: var(--text-muted); font-size: .8rem; }
.comment-body { margin: .4rem 0 .55rem; color: var(--text); line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; }
.comment-body > :last-child { margin-bottom: 0; }
.comment-body a { word-break: break-all; color: var(--brand); }

.comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.comment-action { font-size: .82rem; }
.comment-action.active { color: var(--brand); font-weight: 700; }
.comment-actions .comment-action { min-height: 36px; }
.comment-votes { color: var(--text-muted); font-size: .82rem; font-weight: 600; padding: .2rem .35rem; }
.comment-action.is-voted { font-weight: 700; color: var(--brand); }

.comment-node.is-deleted .comment-body { font-style: italic; color: var(--text-muted); }

/* Flat thread rows: indent + reply rail come from each row's --comment-depth
   (capped in JS at REPLY_INDENT_CAP), replacing the old nested .comment-replies
   wrappers. Same-depth rows share a continuous left rail. */
/* Row-enter fade: expanding a thread inserts its replies into the x-for, and
   each new row fades in. Opacity only -- a transform kept by fill-mode would
   make every row a containing block for its fixed-position menus. */
.comment-flat-row {
  margin-left: calc(var(--comment-depth, 0) * 1.05rem);
  animation: cc-fade-in var(--motion-med) var(--ease-enter) both;
}
.comment-flat-row.has-rail { border-left: 2px solid var(--border); padding-left: 1rem; }
@media (max-width: 575.98px) {
  .comment-row { gap: .6rem; }
  .comment-flat-row { margin-left: calc(var(--comment-depth, 0) * .5rem); }
  .comment-flat-row.has-rail { padding-left: .6rem; }
}

/* Skip layout/paint for off-screen rows in long expanded threads (the shelf-wall
   mitigation). The row-enter fade is on .comment-flat-row; this is on the inner
   node so animation and content-visibility never contend. */
.comment-node { content-visibility: auto; contain-intrinsic-size: auto 96px; }

/* Collapse chevron: ▸ points right when collapsed, rotates to point down (▼) when
   open. The shared .cc-chev.is-open rotates -90deg; the thread toggle wants
   right→down, so correct the angle here (transition still comes from .cc-chev). */
.comment-collapse .cc-chev.is-open { transform: rotate(90deg); }

/* @mention links inside rendered comment bodies */
.comment-body a.mention {
  font-weight: 600; text-decoration: none;
  color: var(--brand, #7c5cbf);
  background: color-mix(in srgb, var(--brand, #7c5cbf) 14%, transparent);
  padding: 0 .25em; border-radius: .25em; word-break: normal;
}
.comment-body a.mention:hover { text-decoration: underline; }

.recommendations-widget {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin: 1rem 0;
}

.recommendations-copy {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  color: var(--text, inherit);
}

.recommendations-followed {
  color: var(--text-muted, #6c757d);
  font-size: .9rem;
}

.recommendations-button {
  --rec-accent: var(--recommendation-accent, var(--brand));
  --rec-fg: var(--recommendation-fg, var(--rec-accent));
  width: var(--recommendation-width, auto);
  min-height: var(--recommendation-min-height, 2.25rem);
  padding: var(--recommendation-padding, .45rem .85rem);
  border-radius: var(--recommendation-radius, var(--radius-sm));
  border-color: var(--recommendation-border, color-mix(in srgb, var(--rec-accent) 45%, var(--border)));
  background: var(--recommendation-bg, transparent);
  color: var(--rec-fg);
  font-family: var(--recommendation-font-family, var(--font-body));
  font-size: var(--recommendation-font-size, .9rem);
  letter-spacing: var(--recommendation-letter-spacing, normal);
  text-transform: var(--recommendation-text-transform, none);
  transition: var(--recommendation-transition, border-color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard), transform var(--motion-instant) var(--ease-standard));
}

.recommendations-button:hover,
.recommendations-button:focus,
.recommendations-button.active {
  border-color: var(--recommendation-hover-border, var(--rec-accent));
  background: var(--recommendation-hover-bg, color-mix(in srgb, var(--rec-accent) 12%, var(--surface)));
  color: var(--recommendation-hover-fg, var(--rec-fg));
  font-weight: 700;
}

.recommendations-button:hover,
.recommendations-button:focus {
  transform: var(--recommendation-hover-transform, translateY(-1px));
}

.recommendations-button:focus-visible {
  outline-color: var(--recommendation-focus-outline, color-mix(in srgb, var(--rec-accent) 55%, transparent));
  box-shadow: none;
}

.recommendations-button:active {
  transform: translateY(0);
}

/* Inline reply composer rendered under the comment being answered. */
.comment-reply-box { margin: .5rem 0 .25rem; }
.comment-reply-box .form-control { width: 100%; resize: vertical; }
.comment-reply-actions { margin-top: .4rem; display: flex; gap: .5rem; align-items: center; justify-content: flex-end; }

/* Inline comment editor. Mirrors compose/reply behavior while staying inside
   the existing avatar + content column. */
.comment-edit-box {
  position: relative;
  display: grid;
  gap: .45rem;
  margin: .45rem 0 .6rem;
}

.comment-edit-input {
  width: 100%;
  min-height: 6.5rem;
  resize: vertical;
}

.comment-edit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .75rem;
  color: var(--text-muted);
  font-size: .8rem;
}

.comment-edit-error {
  color: var(--danger, #dc3545);
  font-weight: 650;
}

.comment-edit-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .5rem;
}

.comment-edit-actions .btn,
.comment-edit-actions .comment-action {
  min-height: 34px;
}

.comment-edit-mentions.uta-results {
  position: static;
  width: 100%;
  max-width: 100%;
  max-height: 14rem;
  overflow: auto;
  margin: .25rem 0 0;
  padding: .35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.comment-edit-mentions .uta-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: .5rem;
  align-items: center;
  padding: .35rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.comment-edit-mentions .uta-row:hover,
.comment-edit-mentions .uta-row[aria-selected="true"] {
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}

@media (max-width: 575.98px) {
  .comment-edit-actions {
    justify-content: stretch;
  }

  .comment-edit-actions .btn,
  .comment-edit-actions .comment-action {
    flex: 1 1 auto;
  }
}

.comment-collapse {
  display: inline-block; margin: 0 0 .4rem; padding: .1rem .35rem;
  background: none; border: 0; cursor: pointer;
  color: var(--text-muted); font-size: .78rem; font-weight: 600;
  border-radius: var(--radius-sm);
}
.comment-collapse:hover { color: var(--text); background: color-mix(in srgb, var(--surface-2) 70%, transparent); }

.comment-show-more {
  display: inline-block; margin: .35rem 0; padding: .2rem .5rem;
  background: none; border: 0; cursor: pointer;
  color: var(--brand); font-size: .8rem; font-weight: 700;
  border-radius: var(--radius-sm);
}
.comment-show-more:hover { text-decoration: underline; }

/* Brief flash on a freshly posted comment so it's easy to find in a long thread. */
@keyframes cc-comment-flash {
  from { background: color-mix(in srgb, var(--brand) 22%, transparent); }
  to   { background: transparent; }
}
.comment-node.just-posted { animation: cc-comment-flash 2.2s var(--ease-standard); border-radius: var(--radius-sm); }

/* Unread comments (GH-161): an edge and a label, never a fill behind text. */
.comment-node.is-unread { box-shadow: inset 3px 0 0 var(--brand); padding-left: .6rem; }
.comment-new {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 0 .4rem;
  text-transform: uppercase;
}
.comment-jump-unread { margin-left: auto; }
