/* Forum — the post gallery renders inside the normal room shell (#main-content),
   in place of the message stream. Uses the shared OKLCH tokens so it tracks
   light/dark automatically. */

/* Fill the main content column and scroll internally, top-aligned (the chat
   message area pins to the bottom; the gallery reads top-down). */
.forum {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  align-self: stretch;
}

/* Left-aligned like the message list — share the app's content gutter. A wide
   cap keeps line lengths sane on ultrawide without leaving a right void on
   normal screens. Everything below shares this same left edge. */
.forum__inner {
  width: 100%;
  max-inline-size: 80rem;
  padding: 1rem calc(var(--inline-space) + 1vw) 2.5rem;
}

/* --- inline "New post" compose (native <details> disclosure) --------- */
/* The <summary> is the "New post" trigger; <details> handles open/close and the
   ✕ affordance with no JS. Closed, it's just the pill. Open, the card frames the
   form and the ＋ glyph rotates into a ✕. */
.forum-compose > summary {
  list-style: none;
  display: inline-flex;
  width: fit-content;
  cursor: pointer;
}

.forum-compose > summary::-webkit-details-marker {
  display: none;
}

.forum-compose[open] {
  border: 1px solid var(--color-selected-dark);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: var(--color-selected);
}

.forum-compose[open] > summary {
  margin-block-end: 0.75rem;
}

.forum-compose[open] .forum-compose__toggle-icon {
  transform: rotate(45deg);
}

.forum-compose__title {
  font-size: 1.15rem;
  font-weight: 600;
}

/* The body reuses the composer's rich input shell; give it room to read as a
   post body rather than a one-line chat message. */
.forum-compose__body lexxy-editor {
  min-block-size: 6em;
}

/* --- toolbar: filters (left) + New post (right) ---------------------- */
/* Filters lead on the left; the composer pins to the right edge and expands to a
   full-width row below them when opened. On an empty forum (no filters) it sits
   left. Everything wraps on narrow screens. */
.forum__toolbar .forum-compose {
  margin-inline-start: auto;
}

.forum__toolbar .forum-compose:only-child {
  margin-inline-start: 0;
}

.forum__toolbar .forum-compose[open] {
  flex: 1 1 100%;
  margin-inline-start: 0;
}

/* A smaller, lighter "New post" pill so it doesn't outweigh the content or echo
   the heavy room-name pill in the nav. */
.forum-compose__toggle {
  --btn-padding: 0.65em 1.3em;

  font-size: 0.84375rem;
}

/* --- post cards (full-width list rows, hairline-divided) ------------- */
.forum-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 15px 20px 15px 4px;
  border-block-end: 1px solid var(--color-border);
  color: inherit;
  text-decoration: none;
  transition: background 120ms ease;
}

.forum-card:hover {
  background: var(--color-bg-hover);
}

.forum-card__status {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-dark);
  color: var(--color-text-subtle);
}

.forum-card__status .icon { width: 13px; height: 13px; }

/* Solved flips to a solid positive disc with a white check (white holds on
   the mid-lightness green in both themes) */
.forum-card__status--solved {
  color: white;
  border-color: var(--color-positive);
  background: var(--color-positive);
}

.forum-card__title {
  font-size: 0.96875rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.35;
  color: var(--color-text);
}

.forum-card__byline {
  font-size: 0.84375rem;
  color: var(--color-text-lighter);
  margin-block-start: 2px;
}

/* --- chips: neutral (Following) and positive (Solved) ----------------- */
.forum-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 2px 9px;
  border-radius: var(--border-radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  background: var(--color-border);
  color: var(--color-text-muted);
}

.forum-tag--solved {
  background: color-mix(in srgb, var(--color-positive) 14%, transparent);
  color: var(--color-positive);
}

.forum-tag--solved .icon { width: 0.7em; height: 0.7em; }

/* "Following" mark — rendered server-side on the cards the viewer follows. */
.forum-tag--following .icon { width: 0.8em; height: 0.8em; }

/* --- byline (author) + right-aligned activity column ----------------- */
/* The activity column right-aligns replies + last-active so each row reads
   left→right: what the post is, then how much is happening in it. */
.forum-card__activity {
  text-align: end;
  min-inline-size: 0;
  padding-block-start: 2px;
  font-size: 0.78125rem;
  color: var(--color-text-subtle);
}

.forum-card__replies {
  font-size: 0.84375rem;
  color: var(--color-text-lighter);
}

.forum-avatar { border-radius: 25%; object-fit: cover; flex: none; }
.forum-card__stack {
  align-items: center;

  /* Participant faces are a desktop affordance; below tablet-landscape the row
     keeps just the reply count, which never leaves. */
  @media (max-width: 1023.9px) {
    display: none;
  }
}
.forum-card__stack .forum-card__stack-avatar { box-shadow: 0 0 0 2px var(--color-bg); }
.forum-card__stack .forum-card__stack-avatar + .forum-card__stack-avatar { margin-inline-start: -6px; }

/* --- filter bar (uses the shared .segmented-control from patterns.css) --- */
.forum-filter { row-gap: 0.5rem; }

/* The sort control drops on phones; the Solved filter stays. */
.forum-filter__sort {
  @media (max-width: 499.9px) {
    display: none;
  }
}

/* --- post header (shared by panel + standalone page) ----------------- */
/* A muted glyph anchors the question as a hero above the title. */
.forum-post-header__glyph {
  display: inline-flex;
  color: var(--color-border-darkest);
}

.forum-post-header__glyph .icon {
  --icon-size: 1.9rem;
}

/* The forum hero sits inline (glyph · title · ⋯) in the thread panel's header,
   which is otherwise a fixed-height single-line bar — let it grow so a wrapping
   title doesn't overflow the bar. */
.thread-panel__header:has(.forum-post-header) {
  block-size: auto;
  padding-block: 0.6rem;
}

.thread-panel__header .forum-post-header {
  flex: 1;
  min-inline-size: 0;
}

.forum-post-header__title {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--color-text);

  /* Tighter title on phones. */
  @media (max-width: 499.9px) {
    font-size: 1.3125rem;
  }
}

/* The title frame hugs the title in display mode (so the Solved badge stays
   alongside), but takes the row when it holds the inline edit form. */
.forum-post-header__title-frame:has(.forum-post-title-edit) { flex: 1; }

/* --- opening post (the question): read it like a post, not a chat line --- */
/* The opening message carries the post body (message--forum-opening); give it
   larger, roomier type. The message partial emits a "N replies" separator below
   it (only on the post's own page), which serves as the divider before the
   discussion. */
.message--forum-opening .message__body-content {
  font-size: 1.0625rem;
  line-height: 1.6;
  padding-block-end: 0.5rem;
}

/* "OP" tag next to the original poster's name (opening message + their replies). */
.message__op-badge {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.5;
  color: var(--color-link);
  background: var(--color-selected);
}

/* Post options menu: the shared .popup-menu (same bordered, arrowed dropdown as
   the sidebar room menu), but anchored to the right of the header's ⋯ trigger so
   it opens down-and-left instead of spilling off-panel. */
.forum-post-menu {
  --btn-size: 2.8em;
  --arrow-size: 1.5em;
  inset: var(--btn-size) 0 auto auto;
  transform-origin: top right;
  z-index: 100;
  min-inline-size: 11ch;
}

.forum-post-menu::before,
.forum-post-menu::after {
  inset-inline-start: auto;
  inset-inline-end: calc(var(--btn-size) / 2);
  transform: translateX(0);
}

/* Match the sidebar dropdown items exactly (.actions-menu .action-btn, which is
   scoped under #sidebar so it can't be shared): same small font, item padding,
   and hover-pill radius — so the button interactions read identically. */
.forum-post-menu .action-btn {
  font-size: var(--font-size-small);
  --width: 100%;
  --btn-padding: calc(var(--inline-space) * 2 / 3) var(--inline-space);
  --btn-border-radius: calc(var(--arrow-size) / 2 - var(--inline-space-half));
  --busy-inset: calc(var(--inline-space) * 1.5);
  white-space: nowrap;
  justify-content: start;
  font-weight: 400;
}

/* --- empty state ----------------------------------------------------- */
.forum__empty {
  padding: 3rem 1.5rem;
  border: 1px dashed var(--color-border-darker);
  border-radius: 0.75rem;
  margin-top: 0.5rem;
}

.forum__empty-glyph { color: var(--color-border-darkest); }
.forum__empty-glyph .icon { width: 1.75rem; height: 1.75rem; }
