/* A hero's card in a map's details (heroRow in templates/_match_details_script.html),
   finished or live (static/live-map.js updateHero), on the dashboard and the stream.
   The hero's portrait with its name at the left; the player and the role over net
   worth, KDA and the level; the buyback's square; the items in two rows of three at
   the card's right, up to its edges as the portrait. One grid:
   portrait | pad | net worth | gap | KDA | gap | level | gap | buyback | gap | items.
   The number columns are as wide as the map's widest values (--card-*-ch, in
   characters, setHeroCardColumns; JetBrains Mono: every character .6em, a KDA slash
   .12em more), the buyback's as its square; the gaps share what is left equally. So
   the values stand in the same place in every card, evenly spaced; a card without a
   buyback keeps its column empty. */
.hero-card-list { display: flex; flex-direction: column; gap: calc(8px * var(--s)); }
.hero-card {
    --card-font: 15px;
    /* The coin before net worth; «KDA» and «LVL» (three characters, 4 px after them). */
    --card-coin: 17px;
    --card-label: 10px;
    --card-art: calc(128px * var(--s));
    --card-pad: calc(10px * var(--s));
    --card-net: calc((var(--card-coin) + 5px + var(--card-net-ch, 5) * .6 * var(--card-font)) * var(--s));
    --card-kda: calc((1.8 * var(--card-label) + 4px + (var(--card-kda-ch, 6) * .6 + .24) * var(--card-font)) * var(--s));
    --card-lvl: calc((1.8 * var(--card-label) + 4px + var(--card-lvl-ch, 2) * .6 * var(--card-font)) * var(--s));
    /* The buyback's square: its time is 8:00 to 0:00, four characters, three quarters of its width. */
    --card-bb: calc(44px * var(--s));
    --card-gap: minmax(calc(6px * var(--s)), 1fr);
    /* Two rows of items and their gap fill the card's 64 units less its borders; the
       tiles are a little wider than the icons' 88:64 (the card is lower than they are). */
    --card-tile: calc(31px * var(--s) - 1px);
    --card-tile-ratio: 1.45;
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) var(--card-bb) var(--card-gap) auto;
    /* The player's line and the numbers' in the middle, the rest the card's full height. */
    grid-template-rows: 1fr auto auto 1fr;
    align-items: center;
    min-height: calc(64px * var(--s));
    overflow: hidden;
    border: 1px solid rgba(51, 65, 85, .55);
    border-radius: calc(10px * var(--s));
    background: linear-gradient(90deg, #131c2e, #0f1626 70%);
    /* UI, not text: an arrow cursor and no text selection. */
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
}

/* The portrait, fading into the card at its right, the name on it. */
.hero-card-art { position: relative; grid-column: 1; grid-row: 1 / -1; align-self: stretch; overflow: hidden; }
.hero-card-portrait {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    -webkit-mask-image: linear-gradient(90deg, #000 64%, transparent);
    mask-image: linear-gradient(90deg, #000 64%, transparent);
}
.hero-card-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 42%, rgba(5, 9, 17, .9)); }
/* No pick yet: an empty portrait, fading as a portrait does. */
.hero-card.blank .hero-card-art { background: linear-gradient(90deg, #0b1220 64%, transparent); }
.hero-card-name {
    position: absolute;
    z-index: 2;
    right: calc(6px * var(--s));
    bottom: calc(6px * var(--s));
    left: calc(10px * var(--s));
    overflow: hidden;
    color: #fff;
    font-size: calc(13.5px * var(--s));
    font-weight: 700;
    line-height: 1.1;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
    white-space: nowrap;
}
/* The respawn time above a name on two lines (fitHeroName). */
.hero-card-art:has(.hero-card-name.two-lines) .hero-card-respawn { bottom: calc(34px * var(--s)); }
.hero-card-aegis {
    position: absolute;
    z-index: 3;
    top: calc(3px * var(--s));
    right: calc(6px * var(--s));
    width: calc(34px * var(--s));
    height: calc(34px * var(--s));
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .85));
}

/* The player's line over the numbers, from net worth's column to the level's: the
   nick and the role in one size on one baseline, the role fainter. */
.hero-card-top { display: flex; grid-column: 3 / 8; grid-row: 2; align-items: center; gap: calc(8px * var(--s)); min-width: 0; margin-bottom: calc(8px * var(--s)); }
.hero-card-who { display: flex; flex: 0 1 auto; align-items: baseline; gap: calc(8px * var(--s)); min-width: 0; }
.hero-card-player { flex: 0 1 auto; min-width: 0; overflow: hidden; color: #e2e8f0; font-size: calc(14px * var(--s)); font-weight: 600; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.hero-card-role { flex: none; color: #64748b; font-size: calc(14px * var(--s)); font-weight: 500; line-height: 1.1; opacity: .75; white-space: nowrap; }
.hero-card-role-number { display: none; }

/* Net worth, KDA and the level, each at its column's start: the coin next to its
   number, KDA and the level after their small labels. */
.hero-card-net,
.hero-card-stat {
    display: inline-flex;
    grid-row: 3;
    align-items: center;
    color: #f8fafc;
    font-family: 'JetBrains Mono', monospace;
    font-size: calc(var(--card-font) * var(--s));
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}
.hero-card-net { grid-column: 3; gap: calc(5px * var(--s)); }
.hero-card-gold { flex: none; width: calc(var(--card-coin) * var(--s)); height: calc(var(--card-coin) * var(--s)); object-fit: contain; }
.hero-card-kda { grid-column: 5; }
.hero-card-lvl { grid-column: 7; }
/* The level's digits right-aligned in its column: a one-digit level ends where a
   two-digit one does, so the buyback's square stands as far from it as from the items. */
.hero-card-lvl-value { min-width: calc(var(--card-lvl-ch, 2) * .6em); text-align: right; }
.hero-card-stat b { margin-right: calc(4px * var(--s)); color: #64748b; font-size: calc(var(--card-label) * var(--s)); font-weight: 600; }
.hero-card-kda i { margin: 0 .06em; color: #475569; font-style: normal; font-weight: 500; }
.hero-card-deaths { color: #fca5a5; }

/* A live map's buyback on cooldown (live-map.js): a square in its column, «BB» over
   its time, both one size. */
.hero-card-bb {
    display: flex;
    flex-direction: column;
    grid-column: 9;
    grid-row: 1 / -1;
    align-items: center;
    justify-content: center;
    justify-self: center;
    gap: calc(3px * var(--s));
    width: var(--card-bb);
    height: var(--card-bb);
    /* The font's letters and digits sit .08em above their line's middle: the padding
       moves them down by that, so they stand in the square's middle. */
    padding: .16em 0 0;
    border: 1px solid rgba(245, 158, 11, .4);
    border-radius: calc(7px * var(--s));
    background: rgba(245, 158, 11, .12);
    color: #fbbf24;
    font: 700 calc(14px * var(--s))/1 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.hero-card-bb b { color: #fcd34d; font-weight: 800; }
/* The buyback by the player's nick (tablets): a flat chip, «BB» and its time in one line. */
.hero-card-bb-chip {
    display: none;
    flex: none;
    align-items: center;
    gap: .35em;
    height: calc(20px * var(--s));
    /* In the chip's middle, as in the square's. */
    padding: .16em calc(6px * var(--s)) 0;
    border: 1px solid rgba(245, 158, 11, .4);
    border-radius: calc(4px * var(--s));
    background: rgba(245, 158, 11, .12);
    color: #fbbf24;
    font: 700 calc(11.5px * var(--s))/1 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.hero-card-bb-chip b { color: #fcd34d; font-weight: 700; }

/* The items: two rows of three up to the card's top, bottom and right edges; the
   card's rounded corners clip the outer tiles. */
.hero-card-items {
    display: grid;
    grid-column: 11;
    grid-row: 1 / -1;
    grid-template-columns: repeat(3, calc(var(--card-tile) * var(--card-tile-ratio)));
    /* A taller card (two lines of numbers): the rows grow with it. */
    grid-template-rows: repeat(2, minmax(var(--card-tile), 1fr));
    align-self: stretch;
    gap: calc(2px * var(--s));
}
.hero-card-items .hero-item-slot { position: relative; width: 100%; height: 100%; aspect-ratio: auto; border: 0; border-radius: 0; }
/* The icon fills its tile without giving the row its own height. */
.hero-card-items .hero-item { position: absolute; inset: 0; }
.hero-card-items .hero-item-slot.empty { background: #0d1420; box-shadow: inset 0 0 0 1px #1e293b; }

/* A finished map (no buyback): the items after the level, flush to the card's top
   and bottom; the neutral item a circle at the card's right. */
.hero-card.finished { grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) auto calc(10px * var(--s)) calc(30px * var(--s)) calc(12px * var(--s)); }
.hero-card.finished .hero-card-items { grid-column: 9; }
.hero-card-neutral { display: grid; grid-column: 11; grid-row: 1 / -1; justify-self: center; place-items: center; width: calc(30px * var(--s)); }
.hero-card-neutral .hero-item-slot.neutral { width: 100%; margin: 0; aspect-ratio: 1; border-color: rgba(158, 143, 239, .5); border-radius: 50%; }
.hero-card-neutral .hero-item-slot.empty { background: #0d1420; }

/* A hero without statistics (a map without its archive): the player's line alone. */
.hero-card.no-stats .hero-card-top { grid-column: 3 / -1; margin: 0 calc(10px * var(--s)) 0 0; }

/* Dead: one shade over the whole card, so the portrait (grey under it), the name, the
   numbers, the buyback and the items dim alike; only the respawn time stays bright. */
.hero-card.dead { border-color: rgba(51, 65, 85, .25); }
.hero-card.dead::before { content: ''; position: absolute; z-index: 4; inset: 0; border-radius: inherit; background: rgba(2, 6, 13, .59); pointer-events: none; }
.hero-card.dead .hero-card-portrait { filter: grayscale(1); }
.hero-card-respawn {
    position: absolute;
    z-index: 6;
    inset: 0 0 calc(14px * var(--s));
    display: grid;
    place-items: center;
    color: #fff;
    font: 800 calc(28px * var(--s))/1 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .9);
    pointer-events: none;
}
/* The aegis holder: a gold outline. Its inner half-pixel ring is a layer over the
   card's content: as an inset shadow it lay under the portrait at the card's edge. */
.hero-card.aegis {
    border-color: rgba(251, 191, 36, .6);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, .12), 0 0 14px rgba(251, 191, 36, .14);
}
.hero-card.aegis::before { content: ''; position: absolute; z-index: 5; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 .5px rgba(251, 191, 36, .55); pointer-events: none; }
/* Flashes over the card: a death's red wash (or one seen only in K/D/A), a buyback's gold. */
.hero-card::after { content: ''; position: absolute; z-index: 4; inset: 0; border-radius: inherit; opacity: 0; pointer-events: none; }
.hero-card.death-flash::after,
.hero-card.death-blink::after { background: rgba(185, 28, 28, .38); animation: hero-card-flash 1.4s ease-out both; }
.hero-card.buyback-flash::after { background: rgba(245, 158, 11, .26); animation: hero-card-flash 1.4s ease-out both; }
@keyframes hero-card-flash {
    0% { opacity: 0; }
    26% { opacity: 1; }
    100% { opacity: 0; }
}

/* A live map in its draft (live-map.js): the pick's number in the numbers' place,
   which keep their room; picks to come dimmed, the pick being made lit. */
/* The number a step above the card's figures, «ПИК» a label on its baseline:
   right of the portrait, which carries it, in the card's middle. */
.hero-card.draft-view .hero-card-art { overflow: visible; }
.hero-card-pick {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: calc(100% + var(--card-pad));
    display: flex;
    align-items: baseline;
    transform: translateY(-50%);
    color: #f8fafc;
    font: 700 calc(18px * var(--s))/1 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.hero-card-pick b { margin-right: calc(7px * var(--s)); color: #64748b; font-size: calc(12px * var(--s)); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.hero-card.draft-view :is(.hero-card-top, .hero-card-net, .hero-card-stat, .hero-card-items, .hero-card-bb) { visibility: hidden; }
.hero-card.draft-view.blank:not(.draft-next) { opacity: .7; }
.hero-card.draft-next { border-color: rgba(99, 102, 241, .45); }
.hero-card.draft-next .hero-card-art { background: linear-gradient(90deg, rgba(99, 102, 241, .14) 64%, transparent); animation: hero-card-pulse 3.2s ease-in-out infinite; }
.hero-card.draft-next .hero-card-pick { color: #a5b4fc; }
.hero-card.draft-next .hero-card-pick b { color: #818cf8; }
@keyframes hero-card-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
    .hero-card.death-flash::after,
    .hero-card.death-blink::after,
    .hero-card.buyback-flash::after,
    .hero-card.draft-next .hero-card-art { animation: none; }
}

/* Narrower hero columns: the containers are .hero-column (match-details.css). */
@media (min-width: 640px) {
    /* The stream's four matches, screens about 1050-1150 px: a narrower portrait,
       smaller numbers and square, the tiles nearer the icons' shape; no role. */
    @container (max-width: 470px) {
        .hero-card {
            --card-font: 14px;
            --card-art: calc(104px * var(--s));
            --card-pad: calc(8px * var(--s));
            --card-bb: calc(38px * var(--s));
            --card-gap: minmax(calc(4px * var(--s)), 1fr);
            --card-tile-ratio: 1.375;
        }
        .hero-card-role { display: none; }
        .hero-card-bb { gap: calc(2.5px * var(--s)); padding-top: .12em; font-size: calc(12px * var(--s)); }
        .hero-card.finished { grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) auto calc(8px * var(--s)) calc(30px * var(--s)) calc(8px * var(--s)); }
    }
    /* Tablets (screens about 640-1050 px, two columns as on desktops): the desktop
       card a step smaller as the column narrows — numbers, portrait, the buyback's
       square and the tiles. Each step takes the widest values a game brings
       (45 100, 12/10/25, level 30). The labels stay: without «KDA» a net worth's
       thousands («38 100») would run into KDA. */
    @container (max-width: 424px) {
        .hero-card {
            --card-font: 13px;
            --card-art: calc(88px * var(--s));
            --card-pad: calc(6px * var(--s));
            --card-bb: calc(34px * var(--s));
            --card-gap: minmax(calc(3px * var(--s)), 1fr);
            --card-tile-ratio: 1.25;
        }
        .hero-card-name { right: calc(6px * var(--s)); left: calc(8px * var(--s)); font-size: calc(12.5px * var(--s)); }
        .hero-card-bb { font-size: calc(11px * var(--s)); }
        .hero-card-neutral { width: calc(26px * var(--s)); }
        .hero-card.finished { grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) auto calc(6px * var(--s)) calc(26px * var(--s)) calc(6px * var(--s)); }
    }
    @container (max-width: 384px) {
        .hero-card {
            --card-font: 12.5px;
            --card-art: calc(72px * var(--s));
            --card-bb: calc(30px * var(--s));
            --card-tile-ratio: 1.15;
        }
        .hero-card-name { right: calc(4px * var(--s)); left: calc(6px * var(--s)); font-size: calc(11.5px * var(--s)); }
        .hero-card-bb { gap: calc(2px * var(--s)); font-size: calc(10px * var(--s)); }
        .hero-card-neutral { width: calc(24px * var(--s)); }
        .hero-card.finished { grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) auto calc(6px * var(--s)) calc(24px * var(--s)) calc(6px * var(--s)); }
    }
    /* Portrait iPads (768-834 px). */
    @container (max-width: 354px) {
        .hero-card {
            --card-font: 12px;
            --card-coin: 15px;
            --card-label: 9px;
            --card-art: calc(64px * var(--s));
            --card-pad: calc(5px * var(--s));
            --card-bb: calc(28px * var(--s));
            --card-gap: minmax(calc(2.5px * var(--s)), 1fr);
            --card-tile-ratio: 1.05;
        }
        .hero-card-player { font-size: calc(13px * var(--s)); }
        .hero-card-name { font-size: calc(11px * var(--s)); }
        .hero-card-bb { font-size: calc(9.5px * var(--s)); }
        .hero-card-neutral { width: calc(22px * var(--s)); }
        .hero-card.finished { grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) auto calc(5px * var(--s)) calc(22px * var(--s)) calc(5px * var(--s)); }
    }
    @container (max-width: 322px) {
        .hero-card {
            --card-font: 11.5px;
            --card-coin: 14px;
            --card-label: 8.5px;
            --card-art: calc(56px * var(--s));
            --card-pad: calc(4px * var(--s));
            --card-bb: calc(26px * var(--s));
            --card-gap: minmax(calc(2px * var(--s)), 1fr);
            --card-tile-ratio: 1;
        }
        .hero-card-player { font-size: calc(12.5px * var(--s)); }
        .hero-card-name { right: calc(3px * var(--s)); left: calc(5px * var(--s)); font-size: calc(10.5px * var(--s)); }
        .hero-card-bb { gap: calc(1.5px * var(--s)); font-size: calc(9px * var(--s)); }
        .hero-card-neutral { width: calc(20px * var(--s)); }
        .hero-card.finished { grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) auto calc(4px * var(--s)) calc(20px * var(--s)) calc(4px * var(--s)); }
    }
    /* The narrowest (phones on their side, 640-700 px): the buyback a flat chip by the
       player's nick, its square's column left to the numbers. */
    @container (max-width: 301px) {
        .hero-card {
            --card-art: calc(52px * var(--s));
            --card-tile-ratio: .96;
            grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) 0 0 auto;
        }
        .hero-card-name { right: calc(2px * var(--s)); left: calc(4px * var(--s)); font-size: calc(10px * var(--s)); }
        .hero-card-bb { display: none; }
        .hero-card-bb-chip { display: inline-flex; height: calc(16px * var(--s)); padding-right: calc(4px * var(--s)); padding-left: calc(4px * var(--s)); font-size: calc(9.5px * var(--s)); }
    }
}
/* Tablets (screens 640-1050 px): the buyback a flat chip by the player's nick, not a
   square in its column; a live card's portrait takes that column's room (a finished
   card has none to give: its neutral item is there). The chip is no taller than the
   nick's line, so a card with one keeps its rows where the others have theirs. */
@media (min-width: 640px) and (max-width: 1050px) {
    .hero-card { grid-template-columns: var(--card-art) var(--card-pad) var(--card-net) var(--card-gap) var(--card-kda) var(--card-gap) var(--card-lvl) var(--card-gap) 0 0 auto; }
    .hero-card-bb { display: none; }
    .hero-card-bb-chip { display: inline-flex; align-self: center; height: calc(15px * var(--s)); padding-right: calc(5px * var(--s)); padding-left: calc(5px * var(--s)); font-size: calc(10.5px * var(--s)); }
    @container (max-width: 470px) {
        .hero-card:not(.finished) { --card-art: calc(128px * var(--s)); }
    }
    @container (max-width: 424px) {
        .hero-card:not(.finished) { --card-art: calc(122px * var(--s)); }
    }
    @container (max-width: 384px) {
        .hero-card:not(.finished) { --card-art: calc(102px * var(--s)); }
    }
    /* The nick's line lower in the narrower steps: the chip with it. */
    @container (max-width: 354px) {
        .hero-card:not(.finished) { --card-art: calc(92px * var(--s)); }
        .hero-card-bb-chip { height: calc(14px * var(--s)); font-size: calc(10px * var(--s)); }
    }
    @container (max-width: 322px) {
        .hero-card:not(.finished) { --card-art: calc(82px * var(--s)); }
        .hero-card-bb-chip { height: calc(13px * var(--s)); padding-right: calc(4px * var(--s)); padding-left: calc(4px * var(--s)); font-size: calc(9.5px * var(--s)); }
    }
    @container (max-width: 301px) {
        .hero-card:not(.finished) { --card-art: calc(52px * var(--s)); }
    }
}

/* Phones (finished maps; a live map has its own roster, live-map.css): the portrait
   with the hero's name, KDA and the role's number. */
@media (max-width: 639px) {
    .hero-card,
    .hero-card.finished {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-rows: auto;
        min-height: 44px;
        border-radius: 8px;
    }
    .hero-card-art { grid-row: 1; }
    .hero-card-portrait {
        object-position: center 30%;
        -webkit-mask-image: linear-gradient(90deg, #000 55%, transparent);
        mask-image: linear-gradient(90deg, #000 55%, transparent);
    }
    /* The name on one line: the card is too low for two (fitHeroName). */
    .hero-card { --card-name-lines: 1; }
    .hero-card-name { right: 2px; bottom: 5px; left: 5px; font-size: 11px; }
    /* KDA in a column as wide as the map's widest, so it starts at one place in every card. */
    .hero-card-kda {
        grid-column: 2;
        grid-row: 1;
        width: calc((var(--card-kda-ch, 6) * .6 + .24) * 10px);
        margin-left: 4px;
        font-size: 10px;
    }
    .hero-card-kda b { display: none; }
    .hero-card-top,
    .hero-card.no-stats .hero-card-top { grid-column: 3; grid-row: 1; margin: 0 4px 0 5px; }
    .hero-card-player,
    .hero-card-role-name,
    .hero-card-net,
    .hero-card-lvl,
    .hero-card-bb,
    .hero-card-items,
    .hero-card-neutral,
    .hero-card-pick { display: none; }
    .hero-card-role { opacity: 1; }
    .hero-card-role-number {
        display: grid;
        place-items: center;
        width: 18px;
        height: 18px;
        border: 1px solid #334155;
        border-radius: 4px;
        background: #1e293b;
        color: #64748b;
        font: 700 10px/1 Inter, sans-serif;
    }
}
