/* =====================================================================
   Feed Layout & Timeline Sorting
   ===================================================================== */

:root {
  --avatar-size: 40px;
  --thread-line: var(--border-subtle, #edebe6);
  --accent: #4f46e5;                            /* Modern indigo accent */
}

@media (prefers-color-scheme: dark) {
  :root { --thread-line: #2a2e35; }
}

/* Two-column post layout: avatar gutter | main content */
feed-post,
feed-reply {
  display: flex;
  gap: 14px;
}

/* Left column: avatar gutter */
feed-gutter {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 var(--avatar-size);
}

feed-avatar {
  display: block;
  cursor: pointer;
}

feed-avatar img {
  display: block;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--thread-line);
  background: var(--thread-line);
}

/* Right column: content */
feed-post-main {
  display: block;
  flex: 1;
  min-width: 0;
}

/* Thread line: connecting ancestor avatars in conversations */
feed-thread-origin feed-gutter::after {
  content: '';
  flex: 1;
  width: 2px;
  margin-top: 6px;
  background: var(--thread-line);
}

/* Post created timestamp */
feed-created a {
  color: var(--text-muted, #656f77);
  text-decoration: none;
  font-weight: 400;
}

feed-created a:hover {
  text-decoration: underline;
}

/* "View replies" CTA */
.view-replies {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.view-replies:hover {
  text-decoration: underline;
}

feed-thread-origin feed-post-main .view-replies,
.view-replies[hidden],
dialog#replyDialog .view-replies,
feed-thread-root .view-replies {
  display: none;
}

/* Composer integration */
composer-section:has(> feed-gutter) {
  display: flex;
  gap: 14px;
}

composer-section:has(> feed-gutter) > form {
  flex: 1;
  min-width: 0;
}

composer-section feed-gutter::after {
  content: none;
}

/* =====================================================================
   Infinite Scroll Sentinel & Spinner
   ===================================================================== */

feed-load-more {
  display: block;
  min-height: 1px;
  text-align: center;
}

/* Spinner tinted in brand indigo */
feed-load-more.loading {
  min-height: 48px;
  background: no-repeat center / 24px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%234f46e5' stroke-width='3' stroke-dasharray='42 15'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='0.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
}

feed-load-more.failed {
  padding: 16px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* =====================================================================
   Reply Sort Segmented Control
   ===================================================================== */

reply-sort {
  display: flex;
  gap: 6px;
  padding: 8px 0;
}

reply-sort button {
  padding: 5px 14px;
  border: 1px solid var(--thread-line);
  border-radius: 8px;                           /* Refined pill */
  background: transparent;
  color: var(--text-muted, #656f77);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

reply-sort button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

/* =====================================================================
   Timeline Sort: Latest / Popular
   ===================================================================== */

timeline-sort {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--thread-line);
  background: transparent;
}

timeline-sort button {
  min-height: 34px;
  padding: 4px 14px;
  border: 1px solid var(--thread-line);
  border-radius: 10px;                          /* Modern subtle chip */
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-muted, #656f77);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

timeline-sort button:hover {
  background: #ffffff;
  color: #16181b;
}

timeline-sort button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

timeline-sort button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Feed dimming during network sort switch */
feed-timeline[aria-busy="true"] {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s;
}

@media (max-width: 799px) {
  timeline-sort button { min-height: 38px; }
}