/*
 * The team builder's own page: the kept teams, the bar over the stage, the sheets. The stage itself — fighters,
 * ring, sockets, kit, pickers — is teamDesigner.css, loaded before this.
 *
 * One column on a phone; the kept teams beside the stage from 1024px; the sheets beside both from 1500px, so a
 * wide screen shows the whole team and what is read off it without scrolling.
 */

.tb-wrap {
    max-width: 1720px;
    margin-inline: auto;
}

.tb-head {
    margin-bottom: 1rem;
}

.tb-head .title {
    margin-bottom: .2rem;
}

.tb-head .subtitle {
    margin: 0;
    color: var(--bulma-text-weak);
}

.tb-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.tb-box.box {
    margin-bottom: 0;
    padding: 1rem;
}

.tb-box > .title {
    margin-bottom: .5rem;
}

/* ── the kept teams ─────────────────────────────────────────────────────────────────────────── */

.tb-rail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .6rem;
}

.tb-rail__head .title {
    margin-bottom: 0;
}

.tb-teams {
    display: flex;
    gap: .4rem;
    margin: 0;
    padding: 0 0 .15rem;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.tb-team {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-width: 9.5rem;
    max-width: 14rem;
    border: 1px solid var(--bulma-border-weak);
    border-radius: 8px;
    background: var(--bulma-scheme-main-bis);
}

.tb-team.is-open {
    border-color: var(--bulma-link);
    box-shadow: inset 3px 0 0 var(--bulma-link);
}

.tb-team__open {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    width: 100%;
    padding: .45rem .6rem .25rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.tb-team__open:hover .tb-team__name,
.tb-team__open:focus-visible .tb-team__name {
    text-decoration: underline;
}

.tb-team__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tb-team__meta {
    min-height: 1.2em;
    font-size: .75rem;
    color: var(--bulma-text-weak);
}

.tb-team__acts {
    display: flex;
    gap: .25rem;
    padding: 0 .35rem .3rem;
}

.tb-team__act {
    padding: .1rem .3rem;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--bulma-text-weak);
    font: inherit;
    font-size: .75rem;
    cursor: pointer;
}

.tb-team__act:hover,
.tb-team__act:focus-visible {
    background: var(--bulma-scheme-main-ter);
    color: var(--bulma-text-strong);
}

.tb-team__act.is-delete:hover,
.tb-team__act.is-delete:focus-visible {
    color: var(--bulma-danger);
}

.tb-note {
    margin-top: .5rem;
    font-size: .8rem;
    color: var(--bulma-text-weak);
}

.tb-note:empty {
    display: none;
}

/* ── the team on the stage ──────────────────────────────────────────────────────────────────── */

.tb-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.tb-bar .input {
    flex: 1 1 12rem;
    min-width: 0;
    font-weight: 600;
}

.tb-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.tb-start {
    display: flex;
    max-width: 30rem;
    margin-top: .5rem;
}

/* The picker's panel hangs from its input's left edge here (the simulator hangs it from the right), and on a
   narrow screen is no wider than the input, so it never pushes the page sideways. */
.tb-start .bsim-picker__panel {
    left: 0;
    right: auto;
}

@media (max-width: 768px) {
    .tb-start .bsim-picker__panel {
        width: 100%;
        max-width: 100%;
    }
}

.tb-status {
    min-height: 1.5em;
    margin: .4rem 0 0;
    font-size: .85rem;
    color: var(--bulma-text-weak);
}

.tb-status.is-bad {
    color: var(--bulma-danger);
}

/* An action offered in the status line itself: a link's weight, a button's behaviour. */
.tb-status__act {
    padding: 0;
    border: 0;
    background: none;
    color: var(--bulma-link);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.tb-pending {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin: .5rem 0;
    padding: .6rem .7rem;
    border: 1px solid var(--bulma-link);
    border-radius: 10px;
    background: color-mix(in srgb, var(--bulma-link) 8%, transparent);
}

.tb-pending.is-hidden {
    display: none;
}

.tb-pending__q {
    flex: 1 0 100%;
    font-size: .9rem;
    font-weight: 600;
}

/* The stage is three fighters across whatever it is given: held to a width a fighter still reads at. */
.tb-main .bsim-team {
    max-width: 56rem;
    margin-inline: auto;
}

.tb-note-label {
    display: block;
    margin-bottom: .2rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--bulma-text-weak);
}

/* ── the sheets ─────────────────────────────────────────────────────────────────────────────── */

.tb-sheets {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    align-content: start;
    align-items: start;
}

.tb-lead {
    font-size: .9rem;
    color: var(--bulma-text);
}

#tb-legal.is-wrong {
    border-top: 2px solid var(--bulma-danger);
}

.tb-rows {
    margin: .45rem 0 0;
    padding: 0;
    list-style: none;
}

.tb-rows:empty {
    display: none;
}

.tb-row {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: .5rem;
    padding: .35rem 0;
    border-top: 1px solid var(--bulma-border-weak);
    font-size: .85rem;
}

.tb-row__where {
    font-weight: 600;
    color: var(--bulma-text-weak);
    text-transform: capitalize;
}

/* ── on the ladder ──────────────────────────────────────────────────────────────────────────── */

.tb-pill {
    display: inline-block;
    padding: 0 .5rem;
    border: 1px solid color-mix(in srgb, var(--hue, var(--bulma-border)) 60%, var(--bulma-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--hue, transparent) 16%, transparent);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.tb-meta:empty {
    display: none;
}

.tb-meta__chance {
    margin-top: .6rem;
    font-size: .9rem;
}

.tb-meta__big {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}

.tb-meta__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: .75rem;
    margin-top: .7rem;
}

.tb-meta__k {
    margin-bottom: .25rem;
    font-size: .7rem;
    font-weight: 600;
    color: var(--bulma-text-weak);
}

.tb-meta__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: baseline;
    gap: .5rem;
    padding: .2rem 0;
    font-size: .85rem;
}

.tb-meta__row .tb-pill {
    justify-self: start;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-meta__pct {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tb-meta__n {
    min-width: 4.5rem;
    text-align: right;
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
    color: var(--bulma-text-weak);
}

.tb-meta__note {
    margin-top: .5rem;
    font-size: .78rem;
    color: var(--bulma-text-weak);
}

.tb-meta__near {
    margin-top: .8rem;
}

.tb-meta__team {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr) auto;
    align-items: center;
    gap: .5rem;
    padding: .3rem 0;
    border-top: 1px solid var(--bulma-border-weak);
    font-size: .85rem;
}

.tb-meta__rank {
    font-variant-numeric: tabular-nums;
    color: var(--bulma-text-weak);
}

.tb-meta__who {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tb-meta__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tb-meta__same {
    font-size: .75rem;
    color: var(--bulma-text-weak);
}

.tb-meta__take {
    padding: .15rem .5rem;
    border: 1px solid var(--bulma-border);
    border-radius: 6px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: .75rem;
    cursor: pointer;
}

.tb-meta__take:hover,
.tb-meta__take:focus-visible {
    border-color: var(--bulma-link);
    color: var(--bulma-link);
}

.tb-points {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: .6rem;
    font-size: .8rem;
}

.tb-points:empty {
    display: none;
}

.tb-points__k {
    flex: 1 0 100%;
    font-size: .7rem;
    color: var(--bulma-text-weak);
}

.tb-points__cell {
    display: inline-flex;
    align-items: baseline;
    gap: .35rem;
    padding: .15rem .55rem;
    border: 1px solid var(--bulma-border-weak);
    border-radius: 8px;
    background: var(--bulma-scheme-main-bis);
}

.tb-points__cell.is-over {
    border-color: var(--bulma-danger);
}

.tb-points__who {
    color: var(--bulma-text-weak);
}

.tb-points__n {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tb-curve {
    display: flex;
    align-items: flex-end;
    gap: .35rem;
    height: 6.5rem;
    margin: .6rem 0 .2rem;
}

.tb-curve.is-hidden {
    display: none;
}

.tb-curve__col {
    flex: 1 1 0;
    max-width: 3rem;
    height: 100%;
    display: grid;
    grid-template-rows: 1.1rem minmax(0, 1fr) 1.2rem;
    justify-items: center;
    align-items: end;
    font-size: .75rem;
}

.tb-curve__n {
    font-variant-numeric: tabular-nums;
    color: var(--bulma-text-strong);
}

.tb-curve__bar {
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: var(--bulma-link);
    opacity: .8;
}

.tb-curve__cost {
    color: var(--bulma-text-weak);
}

.tb-curve__cost::after {
    content: "⚡";
    margin-left: 1px;
    font-size: .7em;
}

.tb-totals {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .4rem;
    margin: .6rem 0;
}

.tb-totals:empty {
    display: none;
}

.tb-total {
    padding: .4rem .5rem;
    border: 1px solid var(--bulma-border-weak);
    border-radius: 8px;
    background: var(--bulma-scheme-main-bis);
}

.tb-total dt {
    font-size: .7rem;
    color: var(--bulma-text-weak);
}

.tb-total dd {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .4rem;
}

.tb-chips:empty {
    display: none;
}

.tb-chip {
    display: inline-flex;
    align-items: baseline;
    gap: .3rem;
    padding: .1rem .5rem;
    border: 1px solid var(--bulma-border-weak);
    border-radius: 999px;
    font-size: .78rem;
}

.tb-chip.is-class {
    font-weight: 600;
}

.tb-chip__n {
    font-variant-numeric: tabular-nums;
    color: var(--bulma-text-weak);
}

/* ── from 1024px: the kept teams stand beside the stage, as a list ───────────────────────────── */

@media (min-width: 1024px) {
    .tb-layout {
        grid-template-columns: 15rem minmax(0, 1fr);
    }

    .tb-rail {
        position: sticky;
        top: 4.5rem;
        grid-row: 1 / span 2;
    }

    .tb-teams {
        flex-direction: column;
        overflow: visible;
    }

    .tb-team {
        min-width: 0;
        max-width: none;
        flex-direction: row;
        align-items: center;
    }

    .tb-team__acts {
        flex-direction: column;
        gap: 0;
        padding: .2rem .25rem;
    }

    .tb-sheets {
        grid-column: 2;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── from 1500px: the sheets stand beside the stage ─────────────────────────────────────────── */

@media (min-width: 1500px) {
    .tb-layout {
        grid-template-columns: 15rem minmax(0, 1.55fr) minmax(19rem, 1fr);
    }

    .tb-rail {
        grid-row: auto;
    }

    .tb-sheets {
        grid-column: auto;
        grid-template-columns: minmax(0, 1fr);
        position: sticky;
        top: 4.5rem;
    }
}
