/* =====================================================================
   Public Feed Feature Styles
   ===================================================================== */

:root {
  --avatar-size: 40px;
  --thread-line: var(--border-subtle, #edebe6);
  --feed-border: var(--border-subtle, #edebe6);
  --feed-surface: #ffffff;
  --feed-surface-hover: #f7f6f2;                /* Warm tactile hover */
  --feed-accent: var(--accent, #4f46e5);         /* Brand indigo */
  --feed-text: #16181b;
  --feed-muted: #656f77;
  --chip-bg: #f2f0eb;
}

feed-section {
  display: block;
  width: 100%;
  position: static;          
  height: auto;             
  font-size: 1rem;
}

feed-panel {
  display: none;
  position: static;         
}

feed-section[data-active-view="timeline"] > feed-panel[data-view="timeline"],
feed-section[data-active-view="post"]     > feed-panel[data-view="post"],
feed-section[data-active-view="search"]  > feed-panel[data-view="search"] {
  display: block;
}

feed-panel[inert] { visibility: hidden; }

feed-panel emoji-picker-container {
  position: absolute;
  top: 151px;
  background-color: var(--feed-surface);
  border: 1px solid var(--feed-border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

/* =====================================================================
   Shared Header Chrome
   ===================================================================== */

feed-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--feed-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

div.feed-post-actions {
  margin-top: 10px;
}

feed-text {
  margin-top: 8px;
  display: block;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--feed-text);
  word-break: break-word;
}

feed-header-close {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--feed-muted);
}

feed-header-label {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =====================================================================
   Timeline & Post Structure
   ===================================================================== */

feed-timeline {
  display: block;
  margin: 0 auto;
  padding-bottom: 6rem;  
}

feed-post,
feed-reply {
  display: flex;
  gap: 12px;
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid var(--feed-border);
  width: 100%;
  transition: background-color 0.12s ease;
}

feed-post:hover,
feed-reply:hover {
  background-color: var(--feed-surface-hover);
}

feed-post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  font-weight: 600;
  font-size: 0.98rem;
  padding-right: 36px;                          /* Space for the ⋯ button */
}

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(--feed-border);
  background: var(--chip-bg);
}

feed-post-main {
  display: block;
  flex: 1;
  min-width: 0;
}

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

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

/* Time & Links */
feed-created a {
  color: var(--feed-muted);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.9rem;
}

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

feed-thread-root feed-created a {
  cursor: text;
}

feed-thread-root feed-created a:hover {
  text-decoration: none;
}

/* "· edited" after the time, when the text or tags were edited */
feed-edited {
  color: var(--feed-muted);
  font-weight: 400;
  font-size: 0.9rem;
  white-space: nowrap;
}

feed-edited::before {
  content: ' · ';
}

/* Hashtags */
feed-tag {
  display: inline-block;
  color: var(--feed-accent);
  font-weight: 500;
  font-size: 0.92rem;
  margin-right: 6px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

feed-tag:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* "View replies" */
.view-replies {
  display: inline-block;
  margin-top: 6px;
  color: var(--feed-accent);
  text-decoration: none;
  font-size: 0.88rem;
  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 Section inside Feed */
composer-section:has(> feed-gutter) {
  display: flex;
  gap: 12px;
}

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

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

/* =====================================================================
   Feed List & Feed Controls Modules
   ===================================================================== */

feed-list-module {
  display: block;
  inset: 0;
  background: var(--feed-surface);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

feed-create-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--feed-border);
}

feed-create-bar input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--feed-border);
  border-radius: 10px;
  outline: none;
}

feed-create-bar input:focus {
  border-color: var(--feed-accent);
}

feed-create-bar button {
  padding: 0.5rem 1.1rem;
  border-radius: 10px;
  border: none;
  background: var(--feed-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}

feed-create-bar button:hover {
  filter: brightness(1.05);
}

feed-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--feed-border);
  cursor: pointer;
  transition: background 0.12s ease;
}

feed-item:hover {
  background: var(--feed-surface-hover);
}

feed-item-title {
  font-weight: 600;
  display: block;
}

feed-item-meta {
  font-size: 0.8rem;
  color: var(--feed-muted);
  display: block;
}

/* Feed Posts Module */
feed-posts-module {
  display: block;
  position: absolute;
  inset: 0;
  background: var(--feed-surface);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

feed-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--feed-border);
  position: sticky;
  top: 48px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  z-index: 4;
}

feed-controls select,
feed-controls input[type="text"] {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--feed-border);
  font: inherit;
  outline: none;
}

feed-controls button.new-post-btn {
  margin-left: auto;
  padding: 0.45rem 1rem;
  border-radius: 10px;
  border: none;
  background: var(--feed-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

feed-active-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  background: var(--chip-bg);
  font-size: 0.85rem;
  color: var(--feed-text);
}

feed-post-list {
  display: block;
  padding-bottom: 6rem;
}

feed-post-item {
  display: block;
  padding: 1rem;
  border-bottom: 1px solid var(--feed-border);
  cursor: pointer;
  transition: background 0.12s ease;
}

feed-post-item:hover {
  background: var(--feed-surface-hover);
}

feed-post-title {
  display: block;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 0.25rem;
}

feed-post-snippet {
  color: var(--feed-muted);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

feed-post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--feed-muted);
}

feed-post-meta .tag {
  background: var(--chip-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 500;
}

feed-post-meta .score::before { content: "▲ "; }
feed-post-meta .replies::before { content: "💬 "; }

/* =====================================================================
   Thread Module & Replies
   ===================================================================== */

feed-thread-module {
  display: block;
  position: absolute;
  inset: 0;
  background: var(--feed-surface);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 5.5rem;
}

feed-post-detail {
  display: block;
  padding: 1rem;
  border-bottom: 1px solid var(--feed-border);
}

feed-post-detail feed-post-title {
  font-size: 1.25rem;
}

feed-reply-list {
  display: block;
  padding: 0 1rem;
}

feed-reply-item {
  display: block;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--feed-border);
}

feed-reply-item.level-2 {
  margin-left: 1.75rem;
  border-left: 2px solid var(--thread-line);
  padding-left: 0.85rem;
}

reply-to-tag {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--feed-accent);
  margin-right: 0.35rem;
}

reply-author {
  font-weight: 700;
  margin-right: 0.5rem;
}

reply-time {
  font-size: 0.8rem;
  color: var(--feed-muted);
}

reply-text {
  display: block;
  margin-top: 0.25rem;
}

reply-actions {
  display: flex;
  gap: 0.85rem;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--feed-muted);
}

reply-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
}

reply-actions button.reacted {
  color: var(--feed-accent);
  font-weight: 600;
}

/* =====================================================================
   Fixed Thread Composer
   ===================================================================== */

feed-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--feed-border);
  padding: 0.6rem 0.9rem;
  z-index: 6;
  transition: padding 0.15s ease;
}

feed-composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--feed-border);
  border-radius: 12px;
  background: var(--chip-bg);
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  height: 2.5rem;
  outline: none;
  transition: all 0.15s ease;
}

feed-composer textarea:focus {
  background: #ffffff;
  border-color: var(--feed-accent);
}

feed-composer.collapsed textarea { height: 2.5rem; }
feed-composer:not(.collapsed) textarea { height: 5.5rem; }

feed-composer .composer-actions {
  display: none;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

feed-composer:not(.collapsed) .composer-actions {
  display: flex;
}

feed-composer .composer-actions button {
  padding: 0.45rem 1.1rem;
  border-radius: 10px;
  border: none;
  background: var(--feed-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

reply-preview-strip {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.4rem;
  background: var(--chip-bg);
  border-radius: 8px;
  font-size: 0.82rem;
}

reply-preview-strip.is-visible { display: flex; }

/* =====================================================================
   Modals & Dialogs (New Post, Reply, Report)
   ===================================================================== */

.reply-dialog {
  width: min(600px, 100vw - 32px);
  border: 1px solid var(--feed-border);
  border-radius: 16px;
  padding: 18px;
  background: var(--feed-surface);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

.reply-dialog::backdrop {
  background: rgba(10, 12, 16, 0.4);
  backdrop-filter: blur(4px);
}

@media (max-width: 599px) {
  .reply-dialog {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }
}

#newPostModal,
feed-report-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 16, 0.4);
  backdrop-filter: blur(4px);
}

#newPostModal.hidden,
feed-report-modal:not(.is-open) {
  display: none;
}

#newPostModal .new-post-dialog,
feed-report-modal .report-dialog {
  background: var(--feed-surface);
  border-radius: 16px;
  border: 1px solid var(--feed-border);
  padding: 1.5rem;
  width: min(480px, 92vw);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#newPostModal input,
#newPostModal textarea,
feed-report-modal select,
feed-report-modal textarea {
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--feed-border);
  background: var(--chip-bg);
  font: inherit;
  outline: none;
}

#newPostModal input:focus,
#newPostModal textarea:focus,
feed-report-modal select:focus,
feed-report-modal textarea:focus {
  background: #ffffff;
  border-color: var(--feed-accent);
}

#newPostModal .new-post-actions,
feed-report-modal .report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#newPostModal .new-post-actions button,
feed-report-modal .report-actions button {
  padding: 0.5rem 1.1rem;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

#newPostModal #submitNewPost {
  background: var(--feed-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

/* Toast Notifications */
feed-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  border-radius: 12px;
  background: #16181b;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

feed-toast button {
  background: none;
  border: none;
  color: var(--feed-accent);
  font-weight: 600;
  cursor: pointer;
}

feed-via {
    display: block;
    font-size: 0.8rem;
    color: var(--your-muted-color);
}