/* Factologist · Horizons · homepage equal-height editorial rows (2026-11-08)
   Restricted to the two existing homepage blocks. No layout shifts based on title length.
   The full article titles remain in HTML for search engines and assistive technology. */

.horizons .hz-reading-now > div {
  align-items: stretch;
  grid-auto-flow: row;
  min-width: 0;
}

/* "Что читают сейчас": same image, title zone and bottom metadata baseline. */
.horizons .hz-reading-now .story-card-compact {
  --hz-equal-row-height: 124px;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  grid-template-rows: var(--hz-equal-row-height);
  align-items: stretch;
  align-content: start;
  gap: 10px;
  height: var(--hz-equal-row-height);
  min-height: var(--hz-equal-row-height);
  max-height: var(--hz-equal-row-height);
  min-width: 0;
  overflow: hidden;
}

.horizons .hz-reading-now .story-card-compact > .story-card-media {
  display: block;
  width: 62px;
  height: 62px;
  max-height: 62px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  align-self: start;
}

.horizons .hz-reading-now .story-card-media img,
.horizons .hz-reading-now .story-card-media picture,
.horizons .hz-reading-now .story-card-media picture img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.horizons .hz-reading-now .story-card-compact > .story-card-copy {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 21px;
  align-items: stretch;
  height: var(--hz-equal-row-height);
  min-width: 0;
  min-height: 0;
  max-height: var(--hz-equal-row-height);
  padding: 0;
  overflow: hidden;
}

.horizons .hz-reading-now .story-card-compact h3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  align-self: start;
  margin: 0;
  max-height: calc(4 * 1.38em);
  min-width: 0;
  overflow: hidden;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.38;
}

.horizons .hz-reading-now .story-card-compact h3 a {
  color: inherit;
}

.horizons .hz-reading-now .story-card-compact .hz-card-meta {
  display: flex;
  flex-wrap: nowrap;
  align-self: end;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  height: 21px;
  min-height: 21px;
  min-width: 0;
  overflow: hidden;
}

.horizons .hz-reading-now .hz-card-meta > span:first-child {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.horizons .hz-reading-now .hz-card-meta .hz-views {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* "Популярное": fixed three-column geometry even if an image is missing.
   Rank, thumbnail, text and reading count retain their own stable slots. */
.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked {
  display: grid;
  gap: 12px;
  align-items: start;
}

.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked > li {
  --hz-rank-row-height: 116px;
  display: grid;
  grid-template-columns: 28px 46px minmax(0, 1fr);
  grid-template-rows: var(--hz-rank-row-height);
  gap: 9px;
  align-items: start;
  width: 100%;
  height: var(--hz-rank-row-height);
  min-height: var(--hz-rank-row-height);
  max-height: var(--hz-rank-row-height);
  min-width: 0;
  margin: 0;
  overflow: hidden;
}

.horizons .hz-main-grid > .hz-sidebar #popular .hz-rank {
  grid-column: 1;
  grid-row: 1;
  width: 28px;
  height: 30px;
  margin: 0;
  align-self: start;
}

.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked-image {
  grid-column: 2;
  grid-row: 1;
  display: block;
  width: 46px;
  height: 46px;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  overflow: hidden;
}

.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked-image picture,
.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked li > div {
  display: grid;
  grid-column: 3;
  grid-row: 1;
  grid-template-rows: minmax(0, 1fr) 21px;
  align-items: stretch;
  width: 100%;
  height: var(--hz-rank-row-height);
  min-width: 0;
  min-height: 0;
  max-height: var(--hz-rank-row-height);
  overflow: hidden;
}

.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked li > div > a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  align-self: start;
  min-width: 0;
  max-height: calc(4 * 1.39em);
  margin: 0;
  overflow: hidden;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.39;
  text-decoration: none;
}

.horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked li > div > small {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 5px;
  height: 21px;
  min-height: 21px;
  margin: 0;
  line-height: 21px;
  white-space: nowrap;
}

/* Do not spill five tiny columns onto a phone.
   Existing 3-/2-column theme breakpoints remain untouched. */
@media (max-width: 900px) {
  .horizons .hz-reading-now .story-card-compact {
    --hz-equal-row-height: 116px;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 9px;
  }
  .horizons .hz-reading-now .story-card-compact > .story-card-media {
    width: 56px;
    height: 56px;
    max-height: 56px;
  }
}

@media (max-width: 560px) {
  .horizons .hz-reading-now > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
  }
  .horizons .hz-reading-now .story-card-compact {
    --hz-equal-row-height: 102px;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
  }
  .horizons .hz-reading-now .story-card-compact > .story-card-media {
    width: 64px;
    height: 64px;
    max-height: 64px;
  }
  .horizons .hz-main-grid > .hz-sidebar #popular .hz-ranked > li {
    --hz-rank-row-height: 106px;
    grid-template-columns: 28px 46px minmax(0, 1fr);
    gap: 9px;
  }
}

/* Keyboard focus remains visible without moving the grid's geometry. */
.horizons .hz-reading-now a:focus-visible,
.horizons .hz-main-grid > .hz-sidebar #popular a:focus-visible {
  outline: 2px solid #2867b1;
  outline-offset: 2px;
  border-radius: 3px;
}
