/* «Что почитать» на главной и в шторке: подборки сверху, карточки — горизонтальная лента. */
html.home-responsive #home-sheet .home-reads-links {
  display: none !important;
}

@media (max-width: 1366px) {
  html.home-responsive .home-reads-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
  }

  html.home-responsive .home-collections-rail,
  html.home-responsive .home-reads-side {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    contain: inline-size;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    min-width: 0;
    height: auto;
    grid-template-columns: unset;
    grid-template-rows: unset;
  }

  html.home-responsive .home-collections-rail::-webkit-scrollbar,
  html.home-responsive .home-reads-side::-webkit-scrollbar {
    display: none;
  }

  html.home-responsive .home-collections-rail > :not(:first-child) {
    display: grid;
  }

  html.home-responsive .home-collections-rail > .home-reads-card {
    display: grid;
    flex: 0 0 max(var(--home-reads-featured-min-w, 300px), calc((100% - 12px) / 2));
    min-width: var(--home-reads-featured-min-w, 300px);
    max-width: max(var(--home-reads-featured-min-w, 300px), calc((100% - 12px) / 2));
    scroll-snap-align: start;
    align-self: flex-start;
    box-sizing: border-box;
    height: var(--home-reads-collection-card-h);
    min-height: var(--home-reads-collection-card-h);
    max-height: var(--home-reads-collection-card-h);
    overflow: hidden;
  }

  html.home-responsive .home-collections-rail > .home-reads-card.is-featured {
    flex: 0 0 max(var(--home-reads-featured-min-w, 300px), 45%);
    min-width: var(--home-reads-featured-min-w, 300px);
    max-width: max(var(--home-reads-featured-min-w, 300px), 45%);
  }

  html.home-responsive .home-reads-side > .home-reads-card.is-compact {
    flex: 0 0 max(var(--home-reads-compact-min-w, 300px), calc((100% - 12px) / 2));
    min-width: var(--home-reads-compact-min-w, 300px);
    max-width: max(var(--home-reads-compact-min-w, 300px), calc((100% - 12px) / 2));
    scroll-snap-align: start;
    align-self: stretch;
    height: auto;
    min-height: 100%;
    grid-template-columns: minmax(0, 1fr) 72px;
    grid-template-rows: auto;
    grid-template-areas: "copy cover";
    align-items: start;
    padding: 14px 16px;
    background: var(--home-reads-compact-bg, #fafaf8);
    box-shadow: none;
  }

  html.home-responsive .home-reads-side > .home-reads-card.is-compact .home-reads-cover {
    box-shadow: none;
  }

  html.home-responsive .home-reads-side > .home-reads-card.is-compact[data-tone] {
    background: var(--home-reads-compact-bg, #fafaf8);
  }

  html.home-responsive .home-collections-rail > .home-reads-card.is-featured,
  html.home-responsive .home-collections-rail > .home-reads-card.is-featured[data-tone] {
    background: var(--home-reads-collection-bg, #ecf3f9);
  }

  html.home-responsive .home-reads-panel:not(.is-in-home-sheet) {
    --home-reads-rail-edge: 20px;
    --edge-bleed-inset: var(--home-reads-rail-edge);
  }

  @media (max-width: 767px) {
    html.home-responsive .home-reads-panel:not(.is-in-home-sheet) {
      --home-reads-rail-edge: 16px;
      --edge-bleed-inset: 16px;
    }
  }

  html.home-responsive .home-collections-rail .home-reads-card.has-illustration .home-reads-copy,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail .home-reads-card.has-illustration .home-reads-copy {
    max-width: 48%;
  }

  html.home-responsive .home-collections-rail .home-reads-art,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail .home-reads-art {
    left: auto;
    right: 10px;
    top: auto;
    bottom: 0;
    width: 54%;
    max-width: 54%;
    height: calc(100% - 8px);
    object-fit: contain;
    object-position: bottom right;
  }
}

@media (min-width: 768px) and (max-width: 1366px) {
  html.home-responsive .home-collections-rail > .home-reads-card {
    flex: 0 0 max(var(--home-reads-featured-min-w, 300px), calc((100% - 12px) / 2));
    min-width: var(--home-reads-featured-min-w, 300px);
    max-width: max(var(--home-reads-featured-min-w, 300px), calc((100% - 12px) / 2));
    align-self: flex-start;
  }

  html.home-responsive .home-collections-rail > .home-reads-card.is-featured {
    flex: 0 0 max(var(--home-reads-featured-min-w, 300px), 45%);
    min-width: var(--home-reads-featured-min-w, 300px);
    max-width: max(var(--home-reads-featured-min-w, 300px), 45%);
  }

  html.home-responsive .home-reads-side > .home-reads-card.is-compact {
    flex: 0 0 max(var(--home-reads-compact-min-w, 300px), calc((100% - 12px) / 2));
    min-width: var(--home-reads-compact-min-w, 300px);
    max-width: max(var(--home-reads-compact-min-w, 300px), calc((100% - 12px) / 2));
    grid-template-columns: minmax(0, 1fr) 88px;
    padding: 16px;
    column-gap: 16px;
  }

  html.home-responsive .home-reads-side > .home-reads-card.is-compact .home-reads-cover {
    width: 88px;
    height: 132px;
  }
}


.home-reads-card .home-reads-badge { background: var(--color-surface, #fff); }
html.home-responsive #home-sheet .home-reads-side > .home-reads-card.is-compact,
html.home-responsive #home-sheet .home-reads-side > .home-reads-card.is-compact[data-tone] {
  background: var(--home-reads-compact-bg, #fafaf8);
}

@media (max-width: 1199px) {
  html.home-responsive #home-sheet .home-reads-panel {
    --home-reads-collection-badge-gap: 0px;
  }
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail .home-reads-card.has-illustration .home-reads-art {
    top: var(--home-reads-collection-pad-block);
    bottom: auto;
    height: var(--home-reads-collection-cover-h);
    object-position: top right;
  }
}

/* Desktop collection books follow the illustration layout: copy left, cover right. */
@media (min-width: 1200px) {
  #moment-view .home-collections-rail > .home-reads-card.is-featured:not(.has-illustration) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 40%);
    grid-template-areas: "copy cover";
    column-gap: 14px;
  }
  #moment-view .home-collections-rail > .home-reads-card.is-featured:not(.has-illustration) .home-reads-cover {
    width: 100%;
    max-width: calc(var(--home-reads-collection-cover-h) * 0.55);
    height: auto;
    aspect-ratio: 2 / 3;
    align-self: start;
    justify-self: end;
  }
}

@media (min-width: 1200px) {
  #moment-view .home-collections-rail > .home-reads-card.is-featured:not(.has-illustration) {
    align-content: stretch;
  }
  #moment-view .home-collections-rail > .home-reads-card.is-featured:not(.has-illustration) .home-reads-copy {
    align-self: start;
  }
  #moment-view .home-collections-rail > .home-reads-card.is-featured:not(.has-illustration) .home-reads-cover {
    align-self: center;
  }
  #moment-view .home-collections-rail > .home-reads-card.is-featured.has-illustration .home-reads-art {
    transform: scale(1.15);
    transform-origin: bottom right;
  }
}
/* The side-by-side desktop mosaic begins at 1367px. */
@media (min-width: 1367px) {
  html.home-responsive #moment-view .home-reads-grid {
    grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
    width: 100%;
  }
  html.home-responsive #moment-view .home-collections-rail,
  html.home-responsive #moment-view .home-reads-side {
    width: 100%;
    max-width: none;
  }
  html.home-responsive #moment-view .home-collections-rail > .home-reads-card,
  html.home-responsive #moment-view .home-collections-rail > .home-reads-card.is-featured,
  html.home-responsive #moment-view .home-reads-side > .home-reads-card.is-compact {
    flex: none;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  #moment-view .home-collections-rail > .home-reads-card.is-featured {
    height: 100%;
    min-height: var(--home-reads-collection-card-h);
    max-height: none;
    align-self: stretch;
  }
}

/* Collection book stacks share the illustration card's copy-left composition. */
html.home-responsive :is(#moment-view, #home-sheet) .home-collections-rail > .home-reads-card.is-featured:not(.has-illustration) {
  grid-template-columns: minmax(0, 1fr) minmax(0, 40%);
  grid-template-areas: "copy cover";
  column-gap: 14px;
}
html.home-responsive :is(#moment-view, #home-sheet) .home-collections-rail .home-reads-cover-stack {
  grid-area: cover;
  position: relative;
  display: block;
  align-self: center;
  justify-self: end;
  width: 100%;
  aspect-ratio: 0.8;
  max-height: var(--home-reads-collection-cover-h, 165px);
}
html.home-responsive :is(#moment-view, #home-sheet) .home-collections-rail .home-reads-cover-stack .home-reads-cover {
  position: absolute;
  inset: auto 0 0 auto;
  width: 82%;
  max-width: none;
  height: auto;
  max-height: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}
html.home-responsive :is(#moment-view, #home-sheet) .home-collections-rail .home-reads-cover-stack.has-two-covers .home-reads-cover:first-child {
  inset: 0 auto auto 0;
  transform: rotate(-7deg);
}
html.home-responsive :is(#moment-view, #home-sheet) .home-collections-rail .home-reads-cover-stack.has-two-covers .home-reads-cover:last-child {
  transform: rotate(4deg);
}

@media (min-width: 1200px) {
  html.home-responsive #moment-view .home-collections-rail .home-reads-cover-stack {
    right: 8px;
  }
}
