/* Shared stat comparison (static/js/comparison.js): Top scorers, Goalies, Last meeting */

/* minmax(0, ...) lets the columns shrink below long names instead of squeezing the comparison */
.top_row_element.compare-card {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
}

/* Top scorers and Goalies: the photo's top lines up with the team tags above the stat rows,
   name/number/buttons underneath; both cards match since their headers are the same height. */
.top_row_element.compare-card {
    grid-template-rows: auto auto;
    align-content: start;
}

.compare-card .headshot-img,
.compare-card .headshot-img-opponent,
.compare-card .top-scorer-info-opponent {
    align-self: start;
}

.compare-card .headshot-img,
.compare-card .headshot-img-opponent {
    min-width: 0;
    width: 100%;
    white-space: normal;
    padding: 0 6px;
    box-sizing: border-box;
}

.compare-card .headshot-img > img,
.compare-card .headshot-img-opponent > img {
    display: block;
    width: 88%;
    max-width: 124px;
    margin: 0 auto;
}

.compare-card .headshot-caption > p:first-child {
    margin-block: 6px 0;
}

.compare-card .headshot-caption .primary_button {
    margin-top: 8px;
}

.compare-card .headshot-caption .arrow-button.team-arrows,
.compare-card .headshot-caption .arrow-button.opponent-arrows {
    justify-content: center;
    align-items: center;
    padding: 0;
    background: none;
}

/* Last meeting: use the card width (capped so it doesn't stretch too far) */
.previous-matchup {
    justify-self: stretch;
    width: 100%;
    box-sizing: border-box;
}

.previous-matchup .compare-mount {
    max-width: 320px;
    margin: 0 auto;
}

.compare-mount,
#goalie-compare {
    width: 100%;
    min-width: 0;
}

.compare {
    width: 100%;
    font-variant-numeric: tabular-nums;
}

/* Team tags above the value columns */
.compare-teams {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.compare-team {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    color: #333;
}

/* Team-color underline, rounded like the stat bars */
.compare-team::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    border-radius: 999px;
    background: var(--team-color);
}

.compare-team:empty::after {
    display: none;
}

.compare-team img {
    width: 32px;
    height: 32px;
}

/* Value | label | value, with the bar underneath across the full width */
.compare-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: baseline;
    column-gap: 8px;
    padding-top: 9px;
}

.compare-value {
    font-size: 1.05rem;
    font-weight: bold;
    color: #222;
}

.compare-value.left {
    text-align: left;
}

.compare-value.right {
    text-align: right;
}

.compare-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    white-space: nowrap;
}

/* Keeps the x of xGF/xGA lowercase */
.compare-label .compare-case {
    text-transform: none;
}

/* The one bar style for every comparison row. Only the colors (--left-color /
   --right-color on .compare) and the split (--split, set per row) vary. */
.compare-bar {
    --slant: 4px;
    --gap: 3px;
    grid-column: 1 / -1;
    position: relative;
    height: 6px;
    margin-top: 5px;
    /* Rounded ends on the bar itself, so both halves are clipped the same way */
    border-radius: 999px;
    overflow: hidden;
}

.compare-bar span {
    position: absolute;
    inset: 0;
}

.compare-bar .bar-left {
    background: var(--left-color);
    clip-path: polygon(0 0, calc(var(--split) + var(--slant) - var(--gap)) 0, calc(var(--split) - var(--slant) - var(--gap)) 100%, 0 100%);
}

.compare-bar .bar-right {
    background: var(--right-color);
    clip-path: polygon(calc(var(--split) + var(--slant) + var(--gap)) 0, 100% 0, 100% 100%, calc(var(--split) - var(--slant) + var(--gap)) 100%);
}

.compare-bar.even .bar-left,
.compare-bar.even .bar-right {
    background: #d1d1d1;
}

@media (max-width: 500px) {
    .compare-row {
        column-gap: 4px;
    }
    .compare-value {
        font-size: 0.95rem;
    }
    .compare-label {
        font-size: 0.6rem;
        letter-spacing: 0.04em;
    }
    .compare-team img {
        width: 26px;
        height: 26px;
    }
    .compare-card .primary_button {
        padding: 5px 8px;
        font-size: 12px;
    }
    /* Goalie arrows (< #31 >) must fit the narrow headshot column */
    .compare-card .arrow-button {
        padding: 0 2px;
    }
    .compare-card .arrow-button .material-symbols-outlined {
        font-size: 18px;
    }
}

/* Stat labels with a definition (statInfo.js): dotted underline, info box on hover/tap */
[data-stat-info] {
    cursor: help;
    text-decoration: underline dotted;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

[data-stat-info]:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 2px;
}

.stat-info-box {
    position: fixed;
    z-index: 300; /* above the player card modal */
    max-width: min(280px, calc(100vw - 16px));
    padding: 8px 10px;
    box-sizing: border-box;
    background: #222;
    color: #f2f2f2;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    font-size: 0.78rem;
    font-weight: normal;
    line-height: 1.4;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    pointer-events: none;
}

.stat-info-box[hidden] {
    display: none;
}
