/* Story art uses the lead frame or a supporting 16:9 frame. The section
   marks, score logos and link icons are outside these editorial selectors. */
body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page :is(
  .v3-story-secondary:not(:where(#home-featured *)) > a,
  .tsp-home-business-support .tsp-home-business-story,
  .v3-history-card > a,
  .v3-fantasy-story > a,
  .tsp-home-reading-grid > li > a,
  .tsp-home-big3-secondary > a,
  #home-nba-throwback > a
):has(> :is(.v3-story-cover, img)) {
  container: supporting-story / inline-size;
  display: flex !important;
  flex-wrap: wrap;
  align-items: center !important;
  height: auto !important;
}

body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page :is(
  .v3-story-secondary:not(:where(#home-featured *)) > a,
  .tsp-home-business-support .tsp-home-business-story,
  .v3-history-card > a,
  .v3-fantasy-story > a,
  .tsp-home-reading-grid > li > a,
  .tsp-home-big3-secondary > a,
  #home-nba-throwback > a
) > :is(.v3-story-cover, img) {
  --v3-cover-ratio: 16 / 9;
  --supporting-photo-width: 100cqw;
  flex: 0 0 var(--supporting-photo-width);
  width: var(--supporting-photo-width);
  --supporting-photo-height: calc(var(--supporting-photo-width) * 0.5625);
  height: var(--supporting-photo-height) !important;
  object-fit: cover;
  min-height: var(--supporting-photo-height) !important;
  max-height: var(--supporting-photo-height) !important;
  aspect-ratio: 16 / 9 !important;
  align-self: start;
  border-radius: 8px;
}

body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page .v3-story-cover img {
  object-fit: cover !important;
}

body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page :is(
  .v3-story-secondary:not(:where(#home-featured *)) > a,
  .tsp-home-business-support .tsp-home-business-story,
  .v3-history-card > a,
  .v3-fantasy-story > a,
  .tsp-home-reading-grid > li > a,
  .tsp-home-big3-secondary > a,
  #home-nba-throwback > a
):has(> :is(.v3-story-cover, img)) > :not(.v3-story-cover, img) {
  flex: 1 1 260px;
  min-width: 0;
}

/* Single-column cards use the image's full width. Larger cards can run a
   landscape image beside the headline without dipping below 240 x 135px. */
@media (min-width: 761px) {
  @container supporting-story (min-width: 540px) {
    body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page :is(
      .v3-story-secondary:not(:where(#home-featured *)) > a,
      .tsp-home-business-support .tsp-home-business-story,
      .v3-history-card > a,
      .tsp-home-big3-secondary > a,
      #home-nba-throwback > a
    ) > :is(.v3-story-cover, img) {
      --supporting-photo-width: clamp(240px, 38cqw, 320px);
    }
  }
}

/* A short card is a headline row whenever its content box cannot carry
   the supporting photo. The usual headline remains the accessible link. */
@container supporting-story (width < 240px) {
  body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page :is(.v3-story-cover, .tsp-home-big3-secondary > a > img) {
    display: none !important;
  }
}

/* Lead images in the phone feed use the full-width 16:9 frame. */
@media (max-width: 760px) {
  body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page :is(
    .tsp-home-mlb-lead .v3-story-cover,
    .tsp-home-big3-lead > a > img
  ) {
    --v3-cover-ratio: 16 / 9;
    aspect-ratio: 16 / 9 !important;
  }
}

/* Lead art spans the lead card, including shorter sports packages. */
body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page :is(
  .v3-lead-photo,
  .tsp-home-spread-lead > .v3-band-photo,
  .tsp-home-business-story--lead > .tsp-home-business-cover,
  .tsp-home-mlb-lead .v3-story-cover,
  .tsp-featured-game-image
) {
  flex: none !important;
  width: 100%;
  height: auto !important;
  max-height: none !important;
}

body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page .tsp-home-business-story--lead:has(> :is(.v3-story-cover, img)) {
  grid-template-columns: minmax(0, 1fr) !important;
}

body.tsp-home-v3[data-preview-home-style] #tsp-stories.v3-page .tsp-home-business-story--lead > .v3-story-cover {
  --v3-cover-ratio: 16 / 9;
  aspect-ratio: 16 / 9 !important;
}
