/* Player card modal (static/js/playerCard.js, templates/partials/player_card.html) */
[data-player-id] {
    cursor: pointer;
}

/* Above the roster / Top 5 modals it can be opened from */
#playerCardPopUp {
    z-index: 200;
}

.player-card-popup-content {
    position: relative;
    align-self: baseline;
    max-height: 90vh;
    overflow-y: auto;
}

.player-card-popup-content .close {
    position: absolute;
    top: 14px;
    right: 18px;
    z-index: 2;
    color: white;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.player-card-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    width: min(400px, 94vw);
    height: 300px;
    background: white;
    border-radius: 14px;
}

.hockey-card {
    width: min(400px, 94vw);
    box-sizing: border-box;
    background: #fefefe;
    border: 8px solid var(--card-primary);
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    text-align: left;
}

.hockey-card-image {
    position: relative;
    aspect-ratio: 16 / 10;
    background: linear-gradient(160deg, #f2f2f2, #d1d1d1);
}

.hockey-card-hero {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hockey-card-logo {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 52px;
    height: 52px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
}

.hockey-card-flag {
    position: absolute;
    bottom: 22px;
    right: 10px;
    width: 40px;
    border: 2px solid white;
    border-radius: 3px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Name banner with a slanted top edge */
.hockey-card-banner {
    position: relative;
    margin-top: -16px;
    padding: 20px 14px 10px;
    background: var(--card-primary);
    color: white;
    clip-path: polygon(0 16px, 100% 0, 100% 100%, 0 100%);
    border-bottom: 5px solid var(--card-accent);
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    align-items: baseline;
}

.hockey-card-number {
    grid-row: 1 / span 2;
    font-size: 2.2rem;
    font-weight: bold;
    line-height: 1;
}

.hockey-card-name {
    font-size: 1.25rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.hockey-card-team {
    font-size: 0.85rem;
    opacity: 0.9;
}

.hockey-card-bio {
    width: calc(100% - 20px);
    margin: 10px;
    white-space: normal;
}

/* Stats can scroll sideways if a long row still doesn't fit */
.hockey-card-stats-wrap {
    margin: 10px 8px;
    overflow-x: auto;
}

.hockey-card-bio th {
    text-align: left;
    font-size: 0.8rem;
    font-weight: normal;
    color: #666;
    text-transform: uppercase;
    width: 30%;
    vertical-align: top;
    background: transparent;
}

.hockey-card-bio td {
    text-align: left;
    font-size: 0.95rem;
}

.hockey-card-bio tr,
.hockey-card-stats tr {
    background: transparent;
}

.hockey-card-flag-inline {
    width: 18px;
    vertical-align: middle;
    border: 1px solid #ddd;
}

.hockey-card-stats {
    width: 100%;
    margin: 0;
    place-self: start;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* tables.css sets tr to 1.1rem globally; keep the card's own sizes */
.hockey-card-stats tr,
.hockey-card-bio tr {
    font-size: inherit;
}

.hockey-card-stats td,
.hockey-card-stats th {
    padding: 3px 3px;
}

.hockey-card-stats thead th {
    background: var(--card-primary);
    color: white;
    font-size: 0.7rem;
}

.hockey-card-teams {
    white-space: nowrap;
    font-size: 0.7rem;
}

.hockey-card-teams img {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

.hockey-card-teams img + img {
    margin-left: 2px;
}

.hockey-card-stats tr.hockey-card-career th,
.hockey-card-stats tr.hockey-card-career td {
    border-top: 2px solid var(--card-primary);
    font-weight: bold;
}

.hockey-card-stats tbody th {
    background: transparent;
    text-align: left;
    font-size: 0.85rem;
    white-space: nowrap;
}

.hockey-card-stats tbody tr:nth-child(odd) {
    background: #f2f2f2;
}

.hockey-card-empty {
    margin: 10px;
    color: #666;
    background: white;
}

/* Flip card: front (bio, career) and back (percentiles) share one grid cell. The hidden face
   has the `hidden` attribute; playerCard.js shows both while turning and toggles .flipped */
.hockey-card-flip {
    position: relative;
    width: min(400px, 94vw);
    perspective: 1400px;
}

.hockey-card-flipper {
    display: grid;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.hockey-card-flip.flipped .hockey-card-flipper {
    transform: rotateY(180deg);
}

.hockey-card-flipper > .hockey-card {
    grid-area: 1 / 1;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.hockey-card-flipper > .hockey-card[hidden] {
    display: none;
}

.hockey-card-back {
    transform: rotateY(180deg);
}

@media (prefers-reduced-motion: reduce) {
    .hockey-card-flipper {
        transition: none;
    }
}

/* Plain white icons left of the modal's close cross, styled like it */
.hockey-card-icons {
    position: absolute;
    top: 14px;
    right: 48px;
    z-index: 3;
    display: flex;
    gap: 10px;
}

/* Icon with a small caption underneath (Compare, Flip) */
.hockey-card-icons .card-icon-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    user-select: none;
}

.card-icon-caption {
    margin-top: -3px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.card-icon-button:hover,
.card-icon-button:focus-visible,
.card-icon-button:hover .card-icon,
.card-icon-button:focus-visible .card-icon {
    color: var(--card-accent);
    outline: none;
}

.hockey-card-flip:has(.hockey-card-back) .hockey-card-flipper {
    cursor: pointer;
}

.card-icon {
    font-size: 26px;
    line-height: 32px;
    color: white;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    user-select: none;
}

.card-icon:hover,
.card-icon:focus-visible {
    color: var(--card-accent);
    outline: none;
}

/* Back: headshot, name, team and nationality on the team color */
.hockey-card-back {
    display: flex;
    flex-direction: column;
}

.hockey-card-back-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    padding-top: 60px; /* room for the captioned icons */
    background: var(--card-primary);
    border-bottom: 5px solid var(--card-accent);
    color: white;
}

.hockey-card-headshot {
    width: 84px;
    height: 84px;
    flex: none;
    border-radius: 50%;
    border: 3px solid var(--card-accent);
    background: #f2f2f2;
    object-fit: cover;
}

.hockey-card-back-id {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.hockey-card-back-number {
    font-size: 1.4rem;
}

.hockey-card-back-id .hockey-card-team {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hockey-card-back-id .hockey-card-team img {
    width: 22px;
    height: 22px;
    padding: 1px;
    background: white;
    border-radius: 50%;
}

.hockey-card-back-id .hockey-card-team img.hockey-card-flag-small {
    width: 22px;
    height: auto;
    padding: 0;
    border-radius: 2px;
}

.hockey-card-pct {
    padding: 14px 14px 0;
}

.hockey-card-source {
    margin: auto 12px 10px;
    padding-top: 10px;
    font-size: 0.7rem;
    color: #666;
}

@media (max-width: 500px) {
    .hockey-card-stats {
        font-size: 0.72rem;
    }
    .hockey-card-stats td,
    .hockey-card-stats th {
        padding: 2px 2px;
    }
    .hockey-card-teams img {
        width: 16px;
        height: 16px;
    }
}

/* Player comparison in the card modal (playerCard.js): a card-sized panel with a team-color
   header, so the white close cross and icons stay visible */
.player-compare {
    display: flex;
    flex-direction: column;
    min-height: 420px;
}

.player-compare-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 84px 10px 12px;
    background: var(--card-primary);
    border-bottom: 5px solid var(--card-accent, #d1d1d1);
    color: white;
}

.player-compare-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: bold;
}

.player-compare-picker {
    padding: 12px;
}

.player-compare-search {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font: inherit;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.player-compare-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 6px;
}

.picker-tab,
.picker-team-select {
    padding: 4px 10px;
    font: inherit;
    font-size: 0.85rem;
    border: 1px solid #ccc;
    border-radius: 999px;
    background: white;
    color: #333;
    cursor: pointer;
}

.picker-tab.active {
    background: var(--card-primary);
    border-color: var(--card-primary);
    color: white;
}

.player-compare-results {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
}

.player-compare-option {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 4px 6px;
    font: inherit;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.player-compare-option:hover,
.player-compare-option:focus-visible {
    background: #f2f2f2;
    outline: none;
}

.player-compare-option img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f2f2f2;
    object-fit: cover;
}

.option-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.option-meta {
    font-size: 0.75rem;
    color: #666;
    white-space: nowrap;
}

.player-compare-note {
    display: flex;
    justify-content: center;
    padding: 16px;
    color: #666;
    font-size: 0.85rem;
}

.player-compare-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 12px 0;
}

.player-compare-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
    min-width: 0;
}

.player-compare-headshot {
    width: 90px;
    height: 90px;
    margin-bottom: 4px;
    border-radius: 50%;
    border: 3px solid var(--team-color);
    background: #f2f2f2;
    object-fit: cover;
}

.player-compare-side .option-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.player-compare-flag {
    width: 18px;
    border: 1px solid #ddd;
}

.player-compare-mount {
    padding: 4px 14px 0;
    box-sizing: border-box;
}

/* Same compare icon as on the card, in the player's team color */
.player-compare-change {
    margin-top: 4px;
    font-size: 26px;
    color: var(--team-color);
    cursor: pointer;
    user-select: none;
}

.player-compare-change:hover,
.player-compare-change:focus-visible {
    opacity: 0.7;
    outline: none;
}

/* "· 6th in NHL" / "· 82nd pctl" after a card-back stat label */
.hockey-card-rank {
    margin-left: 0.2em;
}
