/* feed.css - blended infinite-scroll feed, social-feed styling */

/* ---- Feed intro (title + sub-header) ---- */

.feed-intro {
  padding: 0.5rem 0 0.25rem 0;
}

.feed-intro-title {
  font-weight: 800;
  font-size: 1.9rem;
  margin-bottom: 0.4rem;
}

.feed-intro-subtitle {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.95rem;
}

/* ---- Floating search button (site-wide, see base.html) ---- */

.search-fab {
  position: fixed;
  bottom: 60px;
  right: 76px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: #181818;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  cursor: pointer;
}

.search-fab:hover {
  background-color: #000;
}

.search-fab-popover {
  position: fixed;
  bottom: 116px;
  right: 20px;
  width: min(320px, calc(100vw - 40px));
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 0.75rem;
  z-index: 9999;
}

.dark-mode .search-fab-popover {
  background: #1e1e1e;
  border: 1px solid #333;
}

.dark-mode .feed-intro-subtitle {
  color: #999 !important;
}

.feed-page {
  max-width: 1200px;
  margin: 0 auto;
}

.feed-page .d-flex.justify-content-between {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.just-in-strip {
  max-width: 1200px;
  margin: 0 auto 1.5rem auto;
}

/* Multi-column grid on desktop: single card-per-row wastes width and makes
   low-resolution scraped thumbnails look worse (stretched) than they need to.
   minmax(300px, 1fr) auto-collapses to one column on narrow/mobile viewports
   without a manual breakpoint. This is also the fallback layout if the
   Masonry.js upgrade below never initializes (e.g. the async script fails
   to load) — cards still lay out sanely, just row-aligned instead of packed. */
#feed-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

#feed-items > .feed-card {
  margin-bottom: 0;
}

/* True Pinterest-style masonry, applied by feed.js once Masonry.js (already
   loaded site-wide via base.html) initializes on #feed-items. Uneven card
   heights (missing image, short excerpt) get packed tightly instead of
   leaving gaps in a row, which is the whole point over the plain grid above. */
#feed-items.masonry-active {
  display: block;
  position: relative;
}

#feed-items.masonry-active > .feed-card {
  width: 100%;
  margin-bottom: 20px;
}

@media (min-width: 600px) {
  #feed-items.masonry-active > .feed-card {
    width: 48%;
  }
}

@media (min-width: 900px) {
  #feed-items.masonry-active > .feed-card {
    width: 31.5%;
  }
}

/* ---- Card shell ---- */

.feed-card {
  position: relative;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: 1.25rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.feed-card:hover {
  box-shadow: 0 .75rem 1.5rem rgba(0, 0, 0, .08);
}

.feed-card-body {
  padding: 0.9rem 1rem 1rem 1rem;
}

.feed-card:not(.has-media) .feed-card-body {
  padding-top: 1rem;
}

/* ---- Media (thumbnail) ---- */

.feed-card-media {
  position: relative;
  line-height: 0;
  background: #f2f2f2;
}

.feed-card-thumb {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.feed-play-icon {
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.feed-type-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  backdrop-filter: blur(2px);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.feed-type-chip {
  font-weight: 500;
  margin-bottom: 0.4rem;
  display: inline-block;
}

/* ---- Text ---- */

.feed-card-title a {
  color: #14171a;
}

.feed-card-title a:hover {
  color: var(--primary-color, #0d6efd);
}

.feed-card-excerpt {
  line-height: 1.45;
  /* Not line-clamped: with masonry active, uneven card heights (short excerpt,
     no image) are the point - they let Pinterest-style packing actually pack.
     Length is already bounded server-side (attach_display_text truncates to
     200 chars), so this can't run away unbounded. */
}

/* ---- Action bar (Twitter-style icon row) ---- */

.feed-card-actions {
  position: relative;
  z-index: 2;
  gap: 0.25rem;
}

.feed-card-actions .share-buttons,
.feed-card-actions .vote-btn,
.feed-card-actions .save-btn {
  position: relative;
}

.vote-btn,
.save-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: #657786;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.vote-btn:hover {
  background-color: rgba(224, 36, 94, 0.1);
  color: #e0245e;
}

.vote-btn.voted {
  color: #e0245e;
}

.save-btn:hover {
  background-color: rgba(13, 110, 253, 0.1);
  color: var(--primary-color, #0d6efd);
}

.save-btn.saved i {
  color: var(--primary-color, #0d6efd);
}

.feed-card-actions .share-btn {
  color: #657786;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
}

/* ---- Just In strip ---- */

.just-in-row {
  scrollbar-width: thin;
}

.just-in-item {
  flex: 0 0 170px;
}

.just-in-item .feed-card {
  height: 100%;
  margin-bottom: 0;
  border-radius: 0.75rem;
}

.just-in-item .feed-card-body {
  padding: 0.6rem 0.65rem;
}

.just-in-item .feed-card-thumb {
  aspect-ratio: 16 / 10;
}

.just-in-item .feed-card-title {
  font-size: 0.8rem;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.just-in-item .feed-card-meta {
  font-size: 0.72rem;
}

/* ---- Sentinel ---- */

.feed-sentinel .feed-loading-msg,
.feed-sentinel .feed-end-msg {
  display: inline-block;
}

/* ---- Dark mode ---- */

.dark-mode .feed-card {
  background-color: #1e1e1e;
  border-color: #2c2c2c;
}

.dark-mode .feed-card-media {
  background: #151515;
}

.dark-mode .feed-card-title a {
  color: #e7e9ea;
}

.dark-mode .feed-card-meta,
.dark-mode .feed-card-excerpt {
  color: #999 !important;
}

.dark-mode .feed-type-chip {
  background-color: #333 !important;
  color: #ccc !important;
}

.dark-mode .vote-btn,
.dark-mode .save-btn,
.dark-mode .feed-card-actions .share-btn {
  color: #8899a6;
}
