/* ═══════════════════════════════════════════════
   Feed — Layout (custom: no Campfire equivalent)
   ═══════════════════════════════════════════════ */
body.feed-page #main-content {
  justify-content: start;
}

.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Containing block for absolute descendants (.for-screen-reader spans,
     closed popups). Without this they anchor to #main-content and inflate
     its scrollHeight — a phantom page-scroll below the feed. */
  position: relative;
  width: 100%;
  max-inline-size: 100%;
  padding: calc(var(--navbar-height) + var(--block-space)) var(--inline-space) var(--block-space-double);
}

@media (min-width: 100ch) {
  .feed {
    max-inline-size: 680px;
    margin-inline: auto;
    padding-block-start: var(--block-space);
  }
}

/* ─── Inline composer (Skool-style trigger row) ─── */
.feed-composer__trigger {
  --border-radius: 1.3rem;
  --border-color: var(--color-border-darker);
}

.feed-composer__prompt {
  --hover-size: 0;

  background: none;
  border: none;
  padding: 0;
  cursor: text;
  color: inherit;
  font: inherit;
}

.feed-composer__placeholder { font-size: 1rem; }

/* Dim the page behind an open composer (Skool focus treatment) */
.feed-composer__backdrop {
  position: fixed;
  inset: 0;
  background: oklch(var(--lch-always-black) / 0.35);
  z-index: 4;
}

.feed-composer .post-composer {
  position: relative;
  z-index: 5;
  box-shadow: 0 8px 32px oklch(var(--lch-always-black) / 0.18);
}

/* Focus ring follows the composer card's own radius — the inner inputs are
   bare (no outline), the container carries the state like .input--actor */
.post-composer {
  --border-radius: 0.75em;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.post-composer:focus-within {
  --border-color: var(--color-selected-dark);
  box-shadow: 0 0 0 2px var(--color-selected-dark);
}

/* Focus tint stays on the card edge, not the internal dividers */
.post-composer form > * { --border-color: var(--color-border); }

.feed-composer .post-composer:focus-within {
  box-shadow: 0 0 0 2px var(--color-selected-dark), 0 8px 32px oklch(var(--lch-always-black) / 0.18);
}

/* The composer ring is the single focus affordance — inner inputs stay bare */
.post-composer :is(.post-form__title-input, trix-editor):is(:focus, :focus-visible) {
  outline: none;
  box-shadow: none;
}

/* Drag-and-drop affordance while files are over the form */
.post-form--dragging {
  outline: 2px dashed oklch(var(--lch-blue) / 0.6);
  outline-offset: -0.5em;
  border-radius: inherit;
}

/* ─── Category filter chips ─── */
.feed__filters {
  overflow-x: auto;
  scrollbar-width: none;
  margin-block-end: var(--block-space);
  padding-block: 2px; /* room for focus rings */
}

.feed__filters::-webkit-scrollbar { display: none; }

.feed__filters .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Category label in the card byline */
.post-card__category:hover { text-decoration: underline; }

/* Choice chips — radios or checkboxes styled as buttons, active via :has(:checked).
   Used by the composer category picker and the event reminder offsets. */
.post-form__category-chip,
.choice-chip { cursor: pointer; }

.post-form__category-chip:has(:checked),
.choice-chip:has(:checked) {
  background-color: var(--color-text);
  color: var(--color-bg);
  --btn-border-color: var(--color-text);
}

/* Announce-in-a-room: the select only appears once the switch is on */
.post-form__announce-select {
  display: none;
  max-inline-size: 16rem;
}

.post-form__announce:has(.switch__input:checked) .post-form__announce-select {
  display: block;
}

/* ─── Feed sections ─── */
.feed__pinned,
.feed__posts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.feed__pinned { margin-block-end: 0.75rem; }

.feed__loading { display: flex; justify-content: center; padding: var(--block-space-double) 0; }

/* ═══════════════════════════════════════════════
   Post Card
   ═══════════════════════════════════════════════ */
.post-card {
  --border-radius: 0.75em;
  --border-color: var(--color-border-dark);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

/* Card-level border tints (pinned, hover) must not bleed into internal dividers */
.post-card > * { --border-color: var(--color-border); }

.post-card--feed { cursor: pointer; }

.post-card--feed:hover {
  --border-color: var(--color-border-darker);
  box-shadow: 0 2px 10px oklch(var(--lch-always-black) / 0.07);
}

/* Pinned cards read at a glance: warm border, faint wash, soft lift */
.post-card--pinned {
  --border-color: oklch(var(--lch-orange) / 0.55);
  background-color: oklch(var(--lch-orange) / 0.045);
  box-shadow: 0 1px 6px oklch(var(--lch-orange) / 0.12);
}

.post-card--pinned.post-card--feed:hover {
  --border-color: oklch(var(--lch-orange) / 0.8);
  box-shadow: 0 2px 10px oklch(var(--lch-orange) / 0.2);
}

/* Options button — hidden until hover (matches message__options-btn pattern) */
.post-card__options-btn {
  @media (hover: hover) and (pointer: fine) {
    opacity: 0;
    transition: opacity 150ms ease-in-out;
    transition-delay: 150ms;
  }
  @media (hover: none) and (pointer: coarse) {
    opacity: 0.5;
  }
}

:is(.post-card, .comment, .comment--reply):hover .post-card__options-btn,
:is(.post-card, .comment, .comment--reply):has([open]) .post-card__options-btn {
  opacity: 1;
}

/* Actions dropdown menu (replaces inline positioning) */
.post-card__actions-menu {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: 100%;
  z-index: 10;
  min-inline-size: 10rem;
}

/* Two-line byline: name over timestamp (Skool header) */
.post-card__byline { line-height: 1.35; }

.post-card__byline strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Post title carries the card — everything else recedes behind it */
.post-card__title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

/* Unread marker — blue dot before the title of posts newer than your last visit */
.post-card--unread .post-card__title::before {
  content: "";
  display: inline-block;
  inline-size: 0.5em;
  block-size: 0.5em;
  border-radius: 50%;
  background: oklch(var(--lch-blue));
  margin-inline-end: 0.45em;
  vertical-align: 0.1em;
}

/* Fresh comment activity since your last visit */
.post-card__new-activity {
  color: oklch(var(--lch-blue));
  font-weight: 500;
}

/* Pinned badge: warm chip in the header (Skool's label, Campfire's tokens) */
.post-card__pinned-badge {
  font-weight: 600;
  background-color: oklch(var(--lch-orange) / 0.15);
  border-radius: 2em;
  padding: 0.2em 0.7em;
}

/* Pinned comment label (show page) */
.post-card__pinned-label {
  color: oklch(var(--lch-blue));
  font-weight: 600;
}

/* Show page: the post reads like a chat page — an open document with the
   room composer at the bottom — not a card floating inside a page */
.feed--show { padding-block-end: 0; }

.feed--show > .post-card {
  border: none;
  box-shadow: none;
  background: transparent;
  padding-inline: 0;
}

.feed--show > .post-card:hover { box-shadow: none; }

.feed--show .post-card__title { font-size: 1.5rem; }

.feed--show .post-card__footer { border-block-start: none; }

/* Section heading */
.feed__section-heading { margin-block-end: var(--block-space-half); }

/* Body truncation in feed */
.post-card__preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Right-side media thumbnail on feed cards (Skool layout) */
.post-card__thumb {
  position: relative;
  inline-size: 84px;
  block-size: 84px;
  border-radius: 0.5em;
  overflow: clip;
  background: var(--color-message-bg);
}

.post-card__thumb--video-file { background: oklch(var(--lch-always-black) / 0.85); }

.post-card__thumb img:not(.post-card__thumb-play),
.post-card__thumb video {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

.post-card__thumb-play {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 1px 4px oklch(var(--lch-always-black) / 0.45));
}

/* "+N" corner badge when more media hides behind the thumb */
.post-card__thumb[data-thumb-overflow]::after {
  content: attr(data-thumb-overflow);
  position: absolute;
  inset-block-end: 0.25em;
  inset-inline-end: 0.25em;
  background: oklch(var(--lch-always-black) / 0.65);
  color: oklch(var(--lch-always-white));
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 0.35em;
  padding: 0.1em 0.35em;
}

/* Long bodies clamp behind "See more" so media and comments stay above the
   fold; the expandable controller unclamps short posts on connect */
.post-card__body--clamped {
  max-block-size: 24rem;
  overflow: clip;
  position: relative;
}

.post-card__body--clamped::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  block-size: 2.25rem;
  background: linear-gradient(to bottom, transparent, var(--color-bg) 85%);
}

/* Snapped to a block boundary: nothing ragged to mask */
.expandable--snapped .post-card__body--clamped::after { content: none; }

.post-card__see-more {
  display: block;
  border: none;
  background: none;
  padding: 0.35em 0;
  margin-block-end: 0.65em;
  cursor: pointer;
  color: var(--color-link);
  font-weight: 600;
  font-size: 0.9rem;
}

.post-card__see-more:hover { text-decoration: underline; }

.expandable--open .post-card__body--clamped { max-block-size: none; }
.expandable--open .post-card__body--clamped::after { content: none; }
.expandable--open .post-card__see-more { display: none; }

/* Full body — social-feed reading rhythm: every Trix line block breathes
   like a paragraph (Skool's cadence for punchy line-break-heavy posts) */
.post-card__body .trix-content { line-height: 1.55; }
.post-card__body .trix-content > div { margin-block-end: 0.85em; }
.post-card__body .trix-content > :first-child { margin-block-start: 0; }
.post-card__body .trix-content > :last-child { margin-block-end: 0; }
.post-card__body .trix-content img { max-width: 100%; border-radius: 0.5em; margin-block: var(--block-space-half); }

/* Video embed — scaled down on the page like the rest of the media */
.post-card__video-embed {
  aspect-ratio: 16 / 9;
  border-radius: 0.5em;
  overflow: clip;
  margin-block: var(--block-space-half);
  max-inline-size: 480px;
}

.post-card__video-embed iframe,
.post-card__video-embed video { width: 100%; height: 100%; border: 0; }

/* Media gallery on the post page — 2-up grid, single image full width */
.post-card__media-gallery {
  margin-block-start: var(--block-space-half);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.375em;
}

.post-card__media-gallery--single { grid-template-columns: 1fr; }

.post-card__media-tile {
  position: relative;
  display: block;
  border-radius: 0.5em;
  overflow: clip;
  aspect-ratio: 3 / 2;
}

/* Scaled down on the page — the lightbox is where media goes full size */
.post-card__media-gallery--single .post-card__media-tile { aspect-ratio: auto; max-block-size: 360px; }

/* A lone third tile stretches across both columns */
.post-card__media-tile:nth-child(3):last-child { grid-column: 1 / -1; }

.post-card__media-tile img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

.post-card__media-gallery--single .post-card__media-tile img { object-fit: contain; object-position: left; }

/* "+N" overlay on the last visible tile when more images exist */
.post-card__media-tile[data-post-card-overflow]::after {
  content: "+" attr(data-post-card-overflow);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: oklch(var(--lch-always-black) / 0.5);
  color: oklch(var(--lch-always-white));
  font-size: 1.5rem;
  font-weight: 700;
}

/* Engagement stats: icon + count pills — opt out of the circle-button
   convention (.btn:has(.for-screen-reader):has(img)) so counts sit beside
   the icon instead of stacking underneath it */
.post-card__stat {
  --btn-border-radius: 2em;
  --btn-padding: 0.35em 0.75em;
  aspect-ratio: auto;
  block-size: auto;
  inline-size: auto;
  display: inline-flex;
  gap: 0.35em;
  font-weight: 500;
}

.post-card__stat-count { font-size: 0.85rem; }

.post-card__stat--active {
  background-color: var(--color-selected);
  border-radius: 2em;
}

.post-card__stat--active .post-card__stat-count { font-weight: 700; }

/* ─── Polls ─── */
.poll-option__form { inline-size: 100%; }

.poll-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5em;
  inline-size: 100%;
  border: 1px solid var(--color-border-darker);
  border-radius: 0.5em;
  padding: 0.5em 0.8em;
  cursor: pointer;
  overflow: clip;
  text-align: start;
  transition: border-color 150ms ease;
}

/* Result bar fills behind the label */
.poll-option::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  inline-size: var(--poll-percent, 0%);
  background-color: var(--color-selected);
  transition: inline-size 300ms ease;
}

.poll-option > * { position: relative; }

.poll-option:hover,
.poll-option--mine { border-color: var(--color-selected-dark); }

.poll-option--mine .poll-option__label { font-weight: 600; }

/* Poll builder in the composer */
.post-form__poll {
  border: 1px solid var(--color-border);
  border-radius: 0.75em;
  margin-inline: var(--inline-space);
  margin-block-end: var(--block-space-half);
  padding: var(--block-space-half);
}

/* Commenter faces link through to the conversation */
.post-card__faces-link:hover .post-card__faces { filter: brightness(0.92); }

.post-card__faces { display: flex; }

.post-card__face {
  --avatar-size: 2.2ch;
  margin-inline-end: -0.3rem;
  border: 2px solid var(--color-bg);
  border-radius: 50%;
}

.post-card__face:last-child { margin-inline-end: 0; }

/* Like widget: toggle + who-liked count sit as one tight group */
.like-widget { display: inline-flex; align-items: center; gap: 0.1em; }
.like-widget form.button_to { display: inline; }
.like-widget .post-card__stat-count { --btn-padding: 0.35em 0.5em; }

/* Likes popup */
.likes-popup {
  position: absolute;
  inset-block-end: 100%;
  inset-inline-start: 0;
  margin-block-end: var(--block-space-half);
  min-inline-size: 14rem;
  max-block-size: 16rem;
  overflow-y: auto;
  z-index: 10;
}

.likes-popup__heading {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* @mention highlight */
.trix-content .mention { color: var(--color-link); font-weight: 500; }

/* ═══════════════════════════════════════════════
   Post Composer
   ═══════════════════════════════════════════════ */
.post-form__title-input {
  --hover-size: 0;

  width: 100%;
  border: none;
  outline: none;
  font-size: 1.4rem;
  font-weight: 300;
  color: inherit;
  background: transparent;
  padding: var(--block-space) var(--inline-space) var(--block-space-half);
}

.post-form__title-input::placeholder { color: var(--color-border-darker); }

.post-form__editor { padding-inline: var(--inline-space); min-block-size: 6rem; }

/* Formatting toolbar hides until the text-options button toggles it —
   same interaction as the room composer's rich-text button */
.post-composer trix-toolbar { display: none !important; }

.post-form--rich-text trix-toolbar {
  display: block !important;
  padding-inline: var(--inline-space);
  border-block-end: 1px solid var(--color-border);
  padding-block-end: var(--block-space-half);
  margin-block-end: var(--block-space-half);
}

.post-form--rich-text trix-toolbar .trix-button-group { border: none !important; margin-inline-end: 0.25rem !important; }
.post-form--rich-text trix-toolbar .trix-button { border: none !important; border-radius: 0.25em; }

.post-form__editor trix-editor {
  border: none !important;
  padding: 0 !important;
  min-block-size: 5rem;
  line-height: 1.7;
  /* Long drafts scroll inside the editor so the composer card (and its Post
     button) never grows past the viewport */
  max-block-size: min(48vh, 26rem);
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.post-form__editor trix-editor:focus { outline: none; box-shadow: none; }
.post-form__editor trix-editor img { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 0.4em; }

/* Media area in composer */
.post-form__media-area { padding-inline: var(--inline-space); }

.post-form__media-files { display: flex; flex-wrap: wrap; gap: var(--block-space-half); }

.post-form__media-file { position: relative; }

.post-form__media-file-thumb {
  width: 80px; height: 80px; object-fit: cover; border-radius: 0.5em;
  border: 1px solid var(--color-border);
  display: block;
}

.post-form__media-file-remove {
  position: absolute;
  inset-block-start: -0.4em;
  inset-inline-end: -0.4em;
  inline-size: 1.4em;
  block-size: 1.4em;
  border: none;
  border-radius: 50%;
  background: oklch(var(--lch-always-black) / 0.75);
  color: oklch(var(--lch-always-white));
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.post-form__media-file-remove:hover { background: oklch(var(--lch-always-black)); }

.post-form__media-file-name {
  display: inline-flex; align-items: center;
  padding: 0.4em 0.6em;
  font-size: 0.8rem;
}

/* GIF picker grid */
.gif-picker__results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.25em;
  max-height: 220px;
  overflow-y: auto;
}

.gif-picker__results img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 0.4em;
  cursor: pointer;
}

.gif-picker__results img:hover { opacity: 0.75; }

/* Hide Trix captions */
.post-form__editor figcaption { display: none !important; }

/* ═══════════════════════════════════════════════
   Comments
   ═══════════════════════════════════════════════ */

/* Comment bubble — Skool shape: bordered soft rectangle, name + time inside */
.comment__bubble {
  background: var(--color-message-bg);
  border: 1px solid var(--color-border-dark);
  border-radius: 0.75em;
}

/* Landing on a comment anchor (mention card, copied link) flashes its bubble —
   the message search-highlight treatment, settling back to the normal border */
:is(.comment, .comment--reply):target .comment__bubble {
  border-color: var(--color-text);
  animation: comment-target-fade 0.5s 1.5s forwards;
}

@keyframes comment-target-fade {
  to { border-color: var(--color-border-dark); }
}

.comment__text .trix-content { font-size: inherit; line-height: inherit; }
.comment__text .trix-content > :first-child { margin-block-start: 0; }
.comment__text .trix-content > :last-child { margin-block-end: 0; }
.comment__text .trix-content p { margin-block: 0.2em; }
.comment__text .trix-content img { max-width: 100%; max-height: 200px; border-radius: 0.4em; }

/* Replies tuck under the parent bubble with a smaller avatar (Skool hierarchy) */
.comment--reply { margin-inline-start: calc(4ch + 0.75rem); }

/* Hide Trix toolbar in comment composers */
#new_comment_form trix-toolbar,
[data-comment-reply-target="form"] trix-toolbar { display: none !important; }

/* Hide figcaptions in comment composers */
#new_comment_form figcaption,
[data-comment-reply-target="form"] figcaption { display: none !important; }

/* Images inside comment Trix editors */
#new_comment_form trix-editor img,
[data-comment-reply-target="form"] trix-editor img {
  max-width: 100%;
  max-height: 150px;
  border-radius: 0.4em;
}

/* GIF picker inside comments — shorter than post composer */
#new_comment_form .gif-picker__results,
[data-comment-reply-target="form"] .gif-picker__results { max-height: 160px; }

/* Sticky comment composer at bottom */
.comment-composer-sticky {
  position: sticky;
  bottom: 0;
  background: var(--color-bg);
  z-index: 2;
}

/* Inline reply composer: indented under its parent, led by a reply glyph */
.comment-reply-composer { margin-inline-start: 1ch; }
.comment-reply-composer__glyph { opacity: 0.45; }

/* ═══════════════════════════════════════════════
   Mobile
   ═══════════════════════════════════════════════ */
@media (max-width: 50ch) {
  .comment--reply { margin-inline-start: 2ch; }
}
