/* components/trending-features.css — layout for sections/trending-features.hbs:
   numbered Trending beside Features (lead | side column). Columns are 1fr/3fr
   and 5fr/4fr, from the mockup. Stacks below --bp-lg; the side cards stack
   image over title from --bp-lg to --bp-xl.
   STICKY TRENDING: align-items: start shrinks every column to its content,
   so the Trending item re-stretches (align-self: stretch) to the row height,
   and position: sticky goes on its plain inner div — sticky on the grid item
   itself was inert in testing. */

/* A grid at every width so stacked columns keep the gap. */
.trending-features {
  display: grid;
  gap: var(--space-10);
  margin-block: var(--space-10);
}

@media (width >= 64rem) {
  .trending-features {
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
    gap: var(--space-8);
    align-items: start;
  }

  /* Column rule. */
  .trending-features__features {
    padding-inline-start: var(--space-8);
    border-inline-start: var(--border-width) solid var(--color-border-soft);
  }

  .trending-features__trending {
    align-self: stretch;
  }

  .trending-features__trending-inner {
    position: sticky;
    top: var(--space-8);
  }
}

/* Trending list: numbered by a CSS counter. Shared with trending-related.hbs.
   Headlines align to the top of their numerals — text-box trims both to cap
   height so the tops meet, not the line boxes. */
.trending-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: trending-rank;
}

.trending-list__item {
  counter-increment: trending-rank;
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding-block: var(--space-5);
  border-block-end: var(--border-width) solid var(--color-border-soft);
}

.trending-list__item:last-child {
  border-block-end: none;
}

.trending-list__item::before {
  content: counter(trending-rank);
  flex-shrink: 0;
  font-family: var(--font-ui);
  font-size: var(--text-4xl);
  line-height: 1;
  min-width: 2ch;
  text-box: trim-start cap alphabetic;
}

.trending-list__link {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  text-decoration: none;
  text-box: trim-start cap alphabetic;
}

/* HOVER — keyed off the link (the numeral isn't part of it). Shared with
   trending-related.hbs's list. */
.trending-list__item::before,
.trending-list__link {
  transition: opacity var(--transition);
}

@media (hover: hover) {
  .trending-list__item:has(.trending-list__link:hover)::before,
  .trending-list__link:hover {
    opacity: var(--card-hover-opacity);
  }
}

/* Features: lead | divided side column. */
.trending-features__grid {
  display: grid;
  gap: var(--space-8);
  padding-block-start: var(--space-6);
}

@media (width >= 64rem) {
  .trending-features__grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
    align-items: start;
  }

  .trending-features__side {
    padding-inline-start: var(--space-8);
    border-inline-start: var(--border-width) solid var(--color-border-soft);
  }
}

/* The lead's image is 3 / 2 at every width (the --media-ratio-lead exception). */
.trending-features__lead .post-card {
  --card-media-ratio: var(--media-ratio-lead);
}

/* Section-specific: no dek. */
.trending-features__lead .post-card__excerpt {
  display: none;
}

.trending-features__side {
  display: flex;
  flex-direction: column;
}

.trending-features__side .post-card {
  padding-block: var(--space-6);
  border-block-end: var(--border-width) solid var(--color-border-soft);
}

.trending-features__side .post-card:first-child {
  padding-block-start: 0;
}

.trending-features__side .post-card:last-child {
  padding-block-end: 0;
  border-block-end: none;
}

/* From --bp-lg to --bp-xl the side column is squeezed to ~255–340px, which
   leaves a title beside the image under 100px wide. So the cards stack image
   over title there. Selectors match post-card.css's horizontal rules and win
   on load order. Keep the range in step with the side cards' image_sizes. */
@media (64rem <= width < 80rem) {
  .trending-features__side .post-card {
    --card-media-ratio: var(--media-ratio-stacked);

    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .trending-features__side .post-card .post-card__body {
    grid-column: 1;
    grid-row: 2;
  }
}
