/* The Home lead keeps its own crop. Supporting images share one 16:9 frame. */
body.tsp-home-v3 #tsp-stories.v3-page :is(
    .v3-story-secondary, .v3-history-card, .v3-fantasy-story,
    .tsp-home-business-story, .tsp-home-reading-grid > li
) {
    container: tsp-home-story / inline-size;
}

body.tsp-home-v3 #tsp-stories.v3-page :is(
    .v3-story-secondary, .v3-history-card, .v3-fantasy-story,
    .tsp-home-business-support, #home-more-business, .tsp-home-video-grid
) .v3-story-cover {
    --v3-cover-ratio: 16 / 9;
    aspect-ratio: 16 / 9;
    align-self: start;
    min-height: 0;
}

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

/* A related story runs as a headline where the layout gives it only a small slot. */
body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-mlb-support .v3-story-secondary > a:has(> .v3-story-cover) {
    grid-template-columns: minmax(0, 1fr);
}

body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-mlb-support .v3-story-cover {
    display: none !important;
}

body.tsp-home-v3 #tsp-stories.v3-page :is(.v3-band-related, .tsp-home-spread-support) .v3-story-secondary > a:has(> .v3-story-cover) {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto;
    height: auto;
}

body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-spread-support .v3-story-secondary > a > .v3-story-cover {
    align-self: start !important;
}

@container tsp-home-story (min-width: 620px) {
    body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-spread-support:only-child .v3-story-secondary > a:has(> .v3-story-cover) {
        grid-template-columns: max(240px, 38%) minmax(0, 1fr) !important;
    }
}

body.tsp-home-v3 #tsp-stories.v3-page :is(.v3-featured-grid, .v3-history-rail, .v3-fantasy-stories) {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 264px), 1fr)) !important;
    grid-auto-flow: row;
}

body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-video-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-business-support .tsp-home-business-story:has(> .tsp-home-business-cover) {
    grid-template-columns: minmax(0, 1fr);
}

@container tsp-home-story (width < 240px) {
    body.tsp-home-v3 #tsp-stories.v3-page :is(.v3-story-secondary, .v3-history-card, .v3-fantasy-story, .tsp-home-business-support, .tsp-home-reading-grid) .v3-story-cover {
        display: none !important;
    }

    body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-video-time {
        margin: 0;
        white-space: nowrap;
    }
}

@media (max-width: 760px) {
    body.tsp-home-v3 #tsp-stories.v3-page .v3-fantasy-stories {
        grid-template-columns: minmax(0, 1fr) !important;
        grid-auto-rows: auto !important;
    }
}

/* The scoreboard action and status should stay legible next to compact totals. */
body.tsp-home-v3 #tsp-stories .tsp-home-scoreboard :is(
    .tsp-home-scoreboard-complete, .tsp-home-scoreboard-complete-label,
    .tsp-home-scoreboard-status
) {
    font-size: 12px;
    line-height: 1.25;
}

@media (max-width: 760px) {
    body.tsp-home-v3 #tsp-mobile-league-shortcuts a span {
        font-size: 12px;
    }

    body.tsp-home-v3 #tsp-stories #home-tv-guide-heading {
        font-size: clamp(22px, 6.2vw, 26px);
        line-height: 1.1;
    }
}

/* These two grids also have layout rules tied to their section IDs. */
body.tsp-home-v3 #tsp-stories #home-history .v3-history-rail,
body.tsp-home-v3 #tsp-stories #home-fantasy-desk .v3-fantasy-stories {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 264px), 1fr)) !important;
    grid-auto-flow: row;
    grid-auto-rows: auto;
}

@media (min-width: 761px) and (max-width: 1023px) {
    body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-story-spread:has(> .tsp-home-spread-lead + .tsp-home-spread-support),
    body.tsp-home-v3 #tsp-stories #home-business-ratings .tsp-home-business-content:has(> .tsp-home-business-story--lead + .tsp-home-business-support) {
        grid-template-columns: minmax(0, 1fr);
    }

    body.tsp-home-v3 #tsp-stories.v3-page .tsp-home-spread-lead + .tsp-home-spread-support,
    body.tsp-home-v3 #tsp-stories #home-business-ratings .tsp-home-business-story--lead + .tsp-home-business-support {
        border-inline-start: 0;
        padding-inline-start: 0;
    }
}

@media (max-width: 760px) {
    body.tsp-home-v3 #tsp-stories.v3-page #home-history .v3-history-rail {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

@media (min-width: 761px) and (max-width: 1023px) {
    body.tsp-home-v3 #tsp-stories.v3-page .v3-band.v3-league-band:has(> :is(
        [data-hs-league-section], [data-cf-surface="home-band"],
        .v3-league-stories + [data-score-home-band]
    )) {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    body.tsp-home-v3 #tsp-stories.v3-page .v3-history-promotion {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    body.tsp-home-v3 #tsp-stories.v3-page #home-history {
        width: 100%;
    }
}
