.trending {
  --trending-gap: 16px;
  --trending-card-height: 147px;
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding-bottom: 30px;
  min-width: 0;
}
.trending-bar, .trending-controls, .trending-pager {
  display: flex;
  align-items: center;
}
.trending-bar { justify-content: space-between; gap: 14px; min-height: 42px; }
.trending h2 { font-size: 33px; font-weight: 800; line-height: 37px; letter-spacing: -1.1px; }
.trending-controls { gap: 15px; }
.trending-periods {
  display: grid;
  grid-template-columns: 109px 109px 115px;
  gap: 3px;
  padding: 3px;
  border-radius: 6px;
  background: var(--soft);
}
.trending-periods button { border: 0; border-radius: 4px; min-height: 32px; padding: 0 5px; }
.trending-periods button:hover { background: rgb(21 23 20 / .06); }
.trending-periods button[aria-pressed=true] { background: var(--ink); color: white; }
.trending-pager { gap: 6px; }
.trending [hidden] { display: none; }
.trending-pager output { white-space: nowrap; margin-right: 2px; }
.trending-pager button { padding: 0; width: 34px; min-height: 34px; }
.trending-pager button:disabled { opacity: .36; cursor: default; }
.trending-pager button:disabled:hover { background: transparent; }
.trending-rule { height: 1px; background: var(--line); }
.trending-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 2 * var(--trending-gap)) / 3);
  gap: var(--trending-gap);
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
}
.trending-track::-webkit-scrollbar { display: none; }
.trending-track:focus-visible, .trending-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -3px;
}
.trending-card {
  scroll-snap-align: start;
  --section-color: #007d76;
  color: var(--ink);
  background: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
  min-height: var(--trending-card-height);
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  animation: trending-appear 180ms ease both;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.trending-card[data-rubric=potok] { --section-color: #6b18e2; }
.trending-card:hover { background: #fcfcfa; border-color: #aeb1a7; }
.trending-card h3 {
  font-size: 17px;
  font-weight: 700;
  line-height: 23px;
  letter-spacing: -.28px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.trending-card-top, .trending-card-bottom, .trending-tag { display: flex; align-items: center; }
.trending-card-top, .trending-card-bottom { justify-content: space-between; gap: 4px 8px; }
.trending-card-bottom { flex-wrap: wrap; }
.trending-tag { color: var(--section-color); gap: 7px; font-size: 13px; font-weight: 500; line-height: 19px; }
.trending-meta { display: flex; align-items: baseline; gap: 8px; }
.trending-source-count { font-size: 13px; line-height: 19px; font-weight: 500; color: var(--muted); }
.trending-mono { font: 500 11px/16px "IBM Plex Mono", monospace; letter-spacing: .3px; color: var(--muted); }
.trending-score { color: var(--ink); font-weight: 700; white-space: nowrap; }
.trending-status { margin: 0; min-height: var(--trending-card-height); padding: 19px 0; color: var(--muted); }
.trending-retry { justify-self: start; }
@keyframes trending-appear { from { opacity: 0; } to { opacity: 1; } }

@media (width > 760px) {
  .trending { --trending-card-height: 248px; }
  .trending .trending-pager { display: none; }
  .trending-track {
    /* The spacer tracks keep the leader and the compact columns at different gaps. */
    grid-template-columns: minmax(0, 480fr) 16px minmax(0, 386fr) 12px minmax(0, 386fr);
    grid-auto-flow: row;
    grid-auto-rows: minmax(118px, auto);
    gap: 12px 0;
    overflow: visible;
    scroll-snap-type: none;
  }
  .trending-card { min-height: 118px; padding: 12px; }
  .trending-card h3 {
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0;
    -webkit-line-clamp: 2;
  }
  .trending-card:first-child {
    grid-column: 1;
    grid-row: 1 / span 2;
    min-height: var(--trending-card-height);
    padding: 16px;
    background: var(--soft);
  }
  .trending-card:first-child:hover {
    background: color-mix(in srgb, var(--soft), var(--ink) 3%);
  }
  .trending-card:first-child h3 {
    font-size: clamp(22px, 2.6vw, 34px);
    line-height: 1.118;
    letter-spacing: -.034em;
    -webkit-line-clamp: 4;
  }
  .trending-card:nth-child(even) { grid-column: 3; }
  .trending-card:nth-child(2n+3) { grid-column: 5; }
  .trending-card:not(:first-child) .trending-tag img { width: 15px; height: 15px; }
  .trending-card:not(:first-child) .trending-meta { gap: 6px; }
  .trending-card:not(:first-child) .trending-source-count {
    font: 500 11px/16px var(--mono, "IBM Plex Mono", monospace);
    letter-spacing: .3px;
  }

  /* Give the available cards the full width when a period has fewer than five. */
  .trending-card:only-child { grid-column: 1 / -1; grid-row: 1; }
  .trending-card:nth-child(2):last-child,
  .trending-card:nth-child(2):nth-last-child(2),
  .trending-card:nth-child(3):last-child,
  .trending-card:nth-child(4):last-child { grid-column: 3 / -1; }
  .trending-card:nth-child(2):last-child { grid-row: 1 / span 2; }
}

@media (max-width: 760px) {
  .trending { --trending-gap: 12px; --trending-card-height: 150px; padding-bottom: 24px; }
  .trending-bar { align-items: stretch; flex-direction: column; gap: 9px; }
  .trending h2 { font-size: 25px; line-height: 29px; letter-spacing: -.7px; }
  .trending-periods { width: min(342px, 100%); grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .trending-periods button { min-height: 36px; }
  .trending .trending-pager { display: none; }
  .trending-track { grid-auto-columns: calc(100% - 40px); }
  .trending-card { padding: 14px; }
}
@media (max-width: 650px) {
  .trending { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .trending-card { animation: none; transition: none; }
}

.page-home .trending + .home-grid { padding-top: 0; }
.trending-cms-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.trending-cms-heading h1 { overflow-wrap: anywhere; }
.trending-cms .cms-tabs, .trending-cms-pager { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 12px; }
.trending-cms .cms-tabs a {
  padding: 6px 10px; border-radius: 5px; color: var(--ink); text-decoration: none;
}
.trending-cms .cms-tabs a[aria-current], .trending-cms .cms-tabs a:hover { background: var(--soft); }
.trending-cms .subtle { color: var(--muted); font-size: 13px; }
.trending-cms .table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.trending-cms .cms-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.trending-cms .cms-table :is(th, td) { padding: 9px 11px; }
.trending-cms .cms-table thead { background: var(--soft); color: var(--muted); }
.trending-cms .cms-table tbody tr + tr { border-top: 1px solid var(--line); }
.trending-cms .trending-table { min-width: 900px; }
.trending-cms .trending-table th:first-child { min-width: 200px; width: 37%; }
.trending-table th a { display: block; color: var(--ink); }
.trending-table td { white-space: nowrap; }
.trending-cms .cms-card {
  background: white; padding: 18px; border: 1px solid var(--line); border-radius: 6px; min-width: 0;
}
.trending-cms .cms-card h2 { font-size: 19px; line-height: 1.3; margin: 0 0 8px; }
.trending-cms .cms-card + .cms-card { margin-top: 12px; }
.trending-cms .cms-card li { overflow-wrap: anywhere; }
.trending-cms details summary { cursor: pointer; }
.trending-carousel-review .table-scroll { margin-top: 9px; }
.trending-carousel-review table { min-width: 500px; }
.trending-cms .trending-rank-heading { margin: 21px 0 9px; font-size: 19px; line-height: 1.3; }
.trending-partial { display: block; color: var(--muted); }
.trending-diagnostics dl { display: grid; gap: 7px; margin: 0 0 9px; }
.trending-diagnostics dl div { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.trending-diagnostics dd { margin: 0; overflow-wrap: anywhere; }
.trending-badge {
  display: inline-block; padding: 2px 6px; border-radius: 4px; margin: 3px 4px 0 0; background: var(--soft);
}
.trending-badge.potok { color: #6b18e2; background: #eee8fc; }
.trending-badge.signal { color: #00685f; background: #ddf0e9; }
.trending-badge.bad { color: var(--error); }
.trending-badge.good { color: #304300; background: #e8eddb; }
.trending-event-meta { margin-bottom: 12px; }
.trending-detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 14px; margin-bottom: 14px; }
.trending-rating .table-scroll { margin-block: 9px; }
.trending-form { display: grid; gap: 8px; margin-top: 12px; }
.trending-form button { justify-self: start; }
.trending-form select {
  display: block; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: white;
}
.trending-members { display: grid; gap: 10px; margin: 9px 0; padding-left: 19px; }
.trending-members label { display: block; margin-top: 4px; }
@media (max-width: 760px) {
  .trending-cms-heading { flex-direction: column; align-items: flex-start; }
  .trending-detail { grid-template-columns: minmax(0, 1fr); }
}
