/* The feed page (feeds/index, _batch, _card, the post partials, _rate and
   feed_controller.js), laid out like X's timeline: one column between two
   hairlines, each post a row with an avatar on the left and its name line,
   text, picture and action bar on the right, posts split by a hairline
   instead of boxed. Cards sit in one grid whatever batch frame they arrived
   in: every batch frame is display: contents, so Turbo can nest them freely
   while the grid only ever sees cards. Every animation is a one-shot entrance
   with the reduced-motion fallback at the bottom. */

#feed {
  /* The post grid: side padding, avatar, and the gap after it. */
  --feed-gutter: 1rem;
  --feed-avatar: 2.5rem;
  --feed-gap: 0.75rem;
  --feed-indent: calc(var(--feed-avatar) + var(--feed-gap));
  min-height: 100vh;
  border-inline: 1px solid var(--border);
}

/* One column at every width, so the stream reads top to bottom. */
.feed-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.feed-batch { display: contents; }
/* A frame still waiting to load needs a box of its own, or Turbo's
   IntersectionObserver never sees it scroll into view. Once complete it
   becomes display: contents like the rest and its cards join the grid. */
.feed-batch[loading="lazy"]:not([complete]) {
  display: block;
  grid-column: 1 / -1;
}

/* ---- the post ------------------------------------------------------------ */

.feed-card,
.feed-slot {
  min-width: 0;
  border-bottom: 1px solid var(--border);
  animation: fade-up-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.feed-card {
  position: relative;
  padding: 0.75rem var(--feed-gutter);
  /* What an excerpt's "See more" fades into: whatever is behind the post. */
  --excerpt-fade: var(--page-bg);
  transition: background-color 0.2s ease;
}
/* The action bar brings its own space under it. */
.feed-card:has(.feed-rate) { padding-bottom: 0.25rem; }
/* A post that opens somewhere tints on hover (and on a press on a phone),
   the whole row, like X. A star-only review opens nothing, so it stays put. */
.feed-card:has(.feed-post__cover):hover,
.feed-card:has(.feed-post__cover):active {
  background: var(--feed-hover);
  --excerpt-fade: var(--feed-hover);
}
/* Keyboard focus on any link in the post rings the whole row. */
.feed-card:has(.feed-post__link:focus-visible) {
  outline: 2px solid var(--feed-accent);
  outline-offset: -2px;
}
/* A gentle stagger as a batch lands, capped so a late card never waits long. */
.feed-card:nth-child(2) { animation-delay: 0.05s; }
.feed-card:nth-child(3) { animation-delay: 0.1s; }
.feed-card:nth-child(4) { animation-delay: 0.15s; }
.feed-card:nth-child(n + 5) { animation-delay: 0.2s; }

.feed-post {
  display: grid;
  grid-template-columns: var(--feed-avatar) minmax(0, 1fr);
  column-gap: var(--feed-gap);
  font-size: 0.9375rem;
  line-height: 1.25rem;
}

/* The post's own link, empty and spanning the whole card, so a click
   anywhere opens it. Everything else that is clickable sits above it. */
.feed-post__cover {
  position: absolute;
  inset: 0;
}
.feed-post__link,
.feed-post [data-controller="excerpt"] a,
.feed-rate,
.feed-quote {
  position: relative;
  z-index: 1;
}

.feed-post__avatar {
  display: grid;
  place-items: center;
  width: var(--feed-avatar);
  height: var(--feed-avatar);
  overflow: hidden;
  border-radius: 9999px;
  background: var(--surface);
}
/* A listing's logo: a rounded square, like a company account on X, with a
   hairline so a white logo still has an edge on a white page. */
.feed-post__avatar--logo {
  border-radius: 0.625rem;
  box-shadow: inset 0 0 0 1px var(--border);
}
.feed-post__avatar--logo img { border-radius: inherit; }
.feed-post__avatar--brand { background: var(--pill-amber-bg); }
/* Our mark sits still here: one per article would be a lot of motion. */
.feed-post__avatar--brand .brand-logo g { animation: none; }
.feed-post__avatar--letter {
  background: var(--pill-blue-bg);
  color: var(--pill-blue-text);
  font-size: 1.0625rem;
  font-weight: 700;
}

.feed-post__main { min-width: 0; }

/* The name line: bold name, then muted bits split by a middle dot. */
.feed-post__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.25rem;
  min-width: 0;
  color: var(--text-muted);
}
.feed-post__name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: inherit;
  font-weight: 700;
  color: var(--page-text);
}
.feed-post__subject {
  font-weight: 700;
  color: var(--page-text);
}
.feed-post__meta { white-space: nowrap; }
.feed-post__meta:not(.feed-post__meta--plain)::before {
  content: "·";
  margin-right: 0.25rem;
}
.feed-post__rating {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
}
.feed-post__rating svg { align-self: center; }
/* shared/_patron_mark after a featured name: inline, sitting on the cap
   height of the bold name rather than below the baseline. */
.feed-post__badge {
  display: inline-flex;
  margin-left: 0.25rem;
  vertical-align: -0.2em;
}
.feed-post__link:hover { text-decoration: underline; }
.feed-post__link:focus-visible { outline: none; }

.feed-post__text {
  margin-top: 0.125rem;
  overflow-wrap: anywhere;
  color: var(--page-text);
}
/* An article's or story's title: the post's text, a step up. */
.feed-post__title {
  margin-top: 0.125rem;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.375rem;
  letter-spacing: -0.01em;
  text-wrap: pretty;
  color: var(--page-text);
}
.feed-post__excerpt {
  margin-top: 0.25rem;
  color: var(--text-muted);
}
/* Up to nine lines with the text's own breaks (feed_excerpt_lines), a little
   more open than the rest of the post. */
.feed-excerpt {
  white-space: pre-line;
  line-height: 1.375rem;
}
/* The line between two paragraphs: empty, and taller than a line of text. */
.feed-excerpt__gap {
  display: inline-block;
  height: 1.75rem;
  vertical-align: top;
}
/* A review's comment is the post itself, so it reads at full strength. */
.feed-post__excerpt--body { color: var(--page-text); }
.feed-post__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.625rem;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--pill-blue-text);
}
.feed-post__stars {
  display: flex;
  gap: 0.0625rem;
  margin-top: 0.25rem;
}
.feed-post__stars svg { width: 1rem; height: 1rem; }

/* The maker's reply under a review, boxed like a quoted post. */
.feed-quote {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.75rem;
}
.feed-quote__head {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 700;
  color: var(--page-text);
}
.feed-quote__logo {
  width: 1.25rem;
  height: 1.25rem;
  overflow: hidden;
  border-radius: 0.3125rem;
  background: var(--surface);
}
.feed-quote__body { margin-top: 0.25rem; color: var(--page-text); }

/* A blog cover or news picture: the post's centrepiece, the full width of
   the text column, rounded and outlined like media on X. */
.feed-media {
  margin-top: 0.75rem;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
}
.feed-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.feed-media__source {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1rem;
  color: var(--text-muted);
}

/* Admin-only: the kind and the time, above the name line like X's
   "reposted" line. */
.feed-card__label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.375rem var(--feed-indent);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.feed-card__time { margin-left: auto; }
.feed-card__kind {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  background: var(--surface);
  padding: 0.125rem 0.625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.feed-card__kind--new {
  background: var(--pill-green-bg);
  color: var(--pill-green-text);
}
.feed-card__kind--featured {
  background: var(--pill-amber-bg);
  color: var(--pill-amber-text);
}

/* ---- the action bar ------------------------------------------------------ */

/* Under the text column, pulled left by half a hit circle so the first
   icon's glyph lines up with the text above it. */
.feed-rate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1.5rem;
  margin: 0.25rem 0 0 calc(var(--feed-indent) - 0.5rem);
}

.feed-action {
  --action-color: var(--pill-blue-text);
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  line-height: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}
.feed-action__icon {
  display: grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 9999px;
  transition: background-color 0.2s ease;
}
.feed-action__icon svg { width: 1.125rem; height: 1.125rem; }
.feed-action__count { padding: 0 0.75rem 0 0.125rem; }
.feed-action:hover,
.feed-action:focus-visible { color: var(--action-color); }
.feed-action:hover .feed-action__icon,
.feed-action:focus-visible .feed-action__icon {
  background: color-mix(in srgb, var(--action-color) 12%, transparent);
}
.feed-action:focus-visible { outline: none; }
.feed-action:focus-visible .feed-action__icon { outline: 2px solid var(--action-color); }
.feed-action--share { margin-left: auto; }
/* display: inline-flex above would otherwise beat the hidden attribute that
   share-listing_controller.js sets where there is no share sheet. */
.feed-action[hidden] { display: none; }

/* The stars: one group that takes an amber tint on hover and fills up to
   the star under the pointer, the way a like heart turns pink on X. */
.feed-action--stars {
  --action-color: var(--pill-star-filled);
  height: 2.125rem;
  padding-inline: 0.25rem;
  border-radius: 9999px;
  transition: background-color 0.2s ease;
}
.feed-action--stars:hover { background: color-mix(in srgb, var(--action-color) 14%, transparent); }
.feed-star {
  display: grid;
  place-items: center;
  padding: 0.1875rem;
  border-radius: 9999px;
  cursor: pointer;
}
.feed-star .star-icon {
  display: block;
  width: 1.125rem;
  height: 1.125rem;
  color: var(--pill-star-empty);
  transition: color 0.15s ease, transform 0.15s ease;
}
.feed-star svg { width: 100%; height: 100%; }
.feed-action--stars:hover .star-icon { color: var(--pill-star-filled); }
.feed-action--stars .feed-star:hover ~ .feed-star .star-icon { color: var(--pill-star-empty); }
.feed-star:active .star-icon { transform: scale(0.85); }
.feed-star:has(input:focus-visible) {
  outline: 2px solid var(--feed-accent);
  outline-offset: -1px;
}

/* The rest of the form (text box or sign-in note) opens on its own line
   under the bar once a star is picked. */
.feed-rate__more {
  display: none;
  flex-basis: 100%;
  order: 1;
  margin: 0.25rem 0 0.75rem 0.5rem;
}
.feed-rate:has(input[type="radio"]:checked) .feed-rate__more { display: block; }
/* The thank-you that replaces the stars: a small pill in the bar's flow. */
.feed-rate > div.inline-flex {
  margin-block: 0.25rem;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}
.feed-rate > div.inline-flex svg { width: 1rem; height: 1rem; }

/* ---- house cards, loading and the end ----------------------------------- */

/* Review prompt, newsletter and "list your agent": full-width modules
   between hairlines, like X's "Who to follow". */
.feed-slot { padding: 1rem var(--feed-gutter); }
.feed-slot__heading {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.5rem;
  letter-spacing: -0.01em;
  color: var(--page-text);
}

/* Load more (no-JavaScript fallback inside the lazy frame) and the end note
   span the whole grid. */
.feed-load-more,
.feed-end {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.5rem var(--feed-gutter);
  color: var(--text-muted);
}
.feed-end { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
/* While Turbo fetches the next batch, a small spinner stands in for the
   fallback link. */
.feed-batch[busy] .feed-load-more { position: relative; }
.feed-batch[busy] .feed-load-more > * { visibility: hidden; }
.feed-batch[busy] .feed-load-more::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.5rem;
  height: 1.5rem;
  margin: -0.75rem 0 0 -0.75rem;
  border: 2.5px solid color-mix(in srgb, var(--feed-accent) 25%, transparent);
  border-top-color: var(--feed-accent);
  border-radius: 9999px;
  animation: feed-spin 0.7s linear infinite;
}
@keyframes feed-spin { to { transform: rotate(360deg); } }

/* The "N new items" pill: a small chip floating clear below the top of the
   screen (and below an iPhone's status bar), in the accent, with an arrow
   pointing up at where the new posts land. A hairline ring and a soft amber
   shadow lift it off the text it floats over. */
.feed-pill-holder {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
  z-index: 20;
  display: flex;
  justify-content: center;
  height: 0;
}
.feed-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  height: 2rem;
  border-radius: 9999px;
  background: var(--feed-pill-bg);
  color: var(--feed-pill-text);
  padding: 0 0.875rem 0 0.6875rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: var(--feed-pill-shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease, filter 0.2s ease;
  animation: feed-pill-in 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
.feed-pill.hidden { display: none; }
.feed-pill::before {
  content: "";
  width: 0.875rem;
  height: 0.875rem;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M5 12l7-7 7 7'/%3E%3C/svg%3E") center / contain no-repeat;
}
.feed-pill:hover { transform: translateY(-1px); filter: brightness(1.04); }
.feed-pill:active { transform: scale(0.97); }
.feed-pill:focus-visible { outline: 2px solid var(--feed-accent); outline-offset: 3px; }
@keyframes feed-pill-in {
  from { opacity: 0; transform: translateY(-0.75rem) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* ---- phones -------------------------------------------------------------- */

/* The column runs edge to edge with no side hairlines, and a blog cover or
   news picture breaks out of the text column to the full screen width, a
   touch taller, so it leads the post. The action bar gets thumb-sized hit
   circles. */
@media (max-width: 600px) {
  #feed { border-inline: 0; }

  .feed-media {
    margin-inline: calc(-1 * (var(--feed-gutter) + var(--feed-indent))) calc(-1 * var(--feed-gutter));
    aspect-ratio: 4 / 3;
    border-inline: 0;
    border-radius: 0;
  }

  .feed-rate { column-gap: 1rem; margin-left: calc(var(--feed-indent) - 0.625rem); }
  .feed-action__icon { width: 2.5rem; height: 2.5rem; }
  .feed-action--stars { height: 2.5rem; }
  .feed-star { padding: 0.25rem; }
  .feed-star .star-icon { width: 1.375rem; height: 1.375rem; }
}

@media (prefers-reduced-motion: reduce) {
  .feed-card,
  .feed-slot,
  .feed-pill { animation: none; }
  .feed-batch[busy] .feed-load-more::after { animation-duration: 2s; }
}
