/* A cup played, as a row that opens its games: the team's page and a
   player's Career (js/teams/cup-run.js). The 42rem query asks the page's
   own container: the team's cups band, the profile's panel.

   Its name and days, its W D L, where it finished, and the chevron at the
   row's right edge. The row is a button; pressing it opens the cup's games
   under it, closed until then (Sergio, 3 October 2026).

   The rows share the list's columns, so the finish column is as wide as
   its longest word in this list and no wider: 24px from the W D L to the
   word, 16px from the word to the chevron (Sergio, 3 October 2026: the
   word stood 84px off the W D L in a column kept for "Under way"). */
.runs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto 14px;
    column-gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.run {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    border-bottom: 1px solid var(--border);
}

.run__row {
    position: relative;
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    grid-template-areas: "id wdl end chev";
    align-items: center;
    width: 100%;
    min-height: 72px;
    padding: var(--space-3) 0;
    border: 0;
    background: none;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.run__row::after {
    content: '';
    position: absolute;
    inset: auto 0 -1px;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s var(--ease-out);
}

.run__row:hover::after,
.run__row:focus-visible::after {
    transform: scaleX(1);
}

.run__row:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.run__id {
    grid-area: id;
    min-width: 0;
}

.run__name {
    display: block;
    font-family: var(--font-display);
    font-size: var(--text-xl);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.run__when {
    display: block;
    margin-top: var(--space-1);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.run__row .wdl {
    grid-area: wdl;
}

.run__row .cup-end {
    grid-area: end;
    min-width: 0;
    padding-left: var(--space-2);
    text-align: left;
}

.run__chev {
    grid-area: chev;
    justify-self: end;
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.6;
}

.run__row[aria-expanded="true"] .run__chev {
    transform: rotate(180deg);
}

.run__road {
    grid-column: 1 / -1;
    padding: var(--space-2) 0 var(--space-8);
}

/* The stages side by side, each as wide as its games need, a stage of
   three beside a knockout of four; on a narrow list each takes the row. */
.run__stages {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6) var(--space-8);
}

.run__stage {
    flex: var(--games) 1 0%;
    min-width: min(100%, calc(var(--games) * 6rem));
}

.run__stage-name {
    margin: 0 0 var(--space-3);
}

.run__games {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
    gap: var(--space-4) var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.run__game {
    display: grid;
    align-content: start;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-strong);
}

.run__game.is-final {
    padding-top: calc(var(--space-3) - 1px);
    border-top: 2px solid var(--led);
}

.run__game p {
    margin: 0;
}

.run__round {
    display: flex;
    justify-content: space-between;
    gap: var(--space-2);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.run__game.is-final .run__round {
    color: var(--led-pale);
}

.run__short {
    display: none;
}

.run__mark {
    color: var(--text-secondary);
    font-size: var(--text-base);
}

.run__game.is-w .run__mark {
    color: var(--text-primary);
}

.run__line {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.run__line img {
    flex: none;
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.run__score {
    display: inline-flex;
    align-items: baseline;
    gap: 0.12em;
    color: var(--text-secondary);
}

.run__game.is-w .run__score {
    color: var(--text-primary);
}

.run__score .t-figure {
    font-size: var(--text-3xl);
}

.run__v {
    font-size: var(--text-sm);
}

.run__team {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: var(--text-base);
    line-height: 1.25;
    overflow-wrap: anywhere;
}

/* A line of fact, then the way to the cup's page. */
.run__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 var(--space-6);
    margin: var(--space-6) 0 0;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.run__door {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-left: auto;
    color: var(--accent-hover);
    font-weight: var(--weight-medium);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color var(--duration) var(--ease-out);
}

.run__door:hover {
    color: #fff;
}

/* A narrow list: the W D L under the name, the round's short name, and
   smaller figures, so a knockout of four fits a phone. */
@container (max-width: 42rem) {
    .runs,
    .run {
        display: block;
    }
    .run__row {
        grid-template-columns: minmax(0, 1fr) auto 14px;
        grid-template-areas:
            "id  end chev"
            "wdl wdl chev";
        row-gap: var(--space-2);
        column-gap: var(--space-3);
    }
    .run__row .cup-end {
        padding-left: 0;
    }
    .run__long {
        display: none;
    }
    .run__short {
        display: inline;
    }
    .run__round {
        font-size: var(--text-xs);
    }
    .run__line img {
        width: 24px;
        height: 24px;
    }
    .run__score .t-figure {
        font-size: var(--text-xl);
    }
    .run__team {
        font-size: var(--text-sm);
    }
    .run__games {
        grid-template-columns: repeat(auto-fit, minmax(4.25rem, 1fr));
        gap: var(--space-4) var(--space-2);
    }
}
