/* ============================================================================
 * player-card.css — the player card, shared by every page that draws one.
 *
 * Extracted from dashboard.css and lines.html by tools/build-card-styles.js, so the two cannot
 * drift. dashboard.html still links dashboard.css for the shell; this file carries the card, and
 * every page that shows a player links BOTH.
 *
 * Six pages inlined their own copy of the card rules before this existed, which is how the line
 * editor and the dashboard ended up drawing the same player differently.
 *
 * Edit dashboard.css (for the shell's rules) or this file (for the card's), then re-run:
 *   node tools/build-card-styles.js
 * ========================================================================== */




.stat-chip .k {
  font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint);
}


.stat-chip .v {
  font-size: 0.82rem; font-weight: 700; color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}


.stat-chip.good .v { color: var(--good); }


.stat-chip.warn .v { color: var(--warn); }


.stat-chip.bad  .v { color: var(--bad); }



/*
 * A one-line "nothing here yet" note.
 *
 * Shares .empty-state's colour but not its box: the trades history sits inside a panel that
 * already has a border, so a second dashed box inside it reads as a nested error rather than a
 * placeholder.
 */
.empty-note {
  padding: 0.5rem 0;
  color: var(--text-faint);
  font-size: 0.78rem;
}


/* Hidden means hidden — the panels toggle this class rather than rebuilding their markup. */
.empty-note.hidden { display: none; }


/*
 * ─── A STAT-CHIP RULE WAS HERE, AND IT BELONGED TO ANOTHER FILE ───
 *
 *     .stat-chip { flex: 1; min-width: 0; }
 *
 * A stat chip is the OVR / cap / points / season box in the HEADER. This file styles player cards, and it
 * has no chips in it at all — so the rule did nothing here and everything in `dashboard.css`, which is
 * loaded alongside it.
 *
 * Which made the two headers differ, because they load the pair in OPPOSITE ORDER:
 *
 *     dashboard.html   dashboard.css, then player-card.css   ->  flex: 1 wins   ->  chips STRETCH
 *     lines.html       player-card.css, then dashboard.css   ->  the good rule wins
 *
 * So the season box fitted on the lines page and bled past its border on the dashboard, from the same
 * markup and (apparently) the same CSS. `tools/dbg-season-chip.js` is what found it, by measuring the two
 * pages and printing the differing computed properties — `flex: 1 0%` against `flex: 0 auto`.
 */


/* ─── Player detail ───
   The line editor's card, with the player's record beneath it. The card styles come from the
   same class names, so a player looks identical here and on the lines board. */
.player-detail { display: flex; flex-direction: column; gap: 1rem; }



.pd-top { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }



/* Fixed, so the head beside it starts at the same place for every player. */
.pd-card {
  position: relative;
  width: 132px;
  height: 176px;
  flex: none;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

/*
 * The player's picture, filling the card frame.
 *
 * `.pd-card` is 132x176 with `overflow: hidden`, so the image is sized to the frame and the absolutely
 * positioned badge rows above it sit on top. `object-fit: cover` rather than a stretch, so a portrait is
 * cropped rather than squashed — the frame is a fixed portrait shape and the art is not guaranteed to match
 * it.
 *
 * The background is set because a picture that fails to load leaves an empty box; a dark fill reads as a
 * deliberate card with no art, where white would read as a broken image.
 */
.pd-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #161d27;
}



.pd-head { flex: 1; min-width: 12rem; }


.pd-head h2 { margin: 0 0 0.15rem; font-size: 1.3rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }


.pd-sub { color: var(--text-dim); font-size: 0.8rem; margin-bottom: 0.6rem; }



.pd-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }



.pd-retired {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #2a2226;
  color: #c9a2a2;
  border: 1px solid #453034;
}



.pd-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}



/* Two columns on a wide dialog, one on a narrow. */
.pd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.3rem 0.8rem;
}



.pd-cell { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.8rem; padding: 0.15rem 0; }


.pd-cell .k { color: var(--text-faint); }


.pd-cell .v { color: var(--text-strong); font-weight: 600; font-variant-numeric: tabular-nums; }



.pd-xf { display: flex; gap: 0.3rem; flex-wrap: wrap; }


.pd-teams { display: flex; gap: 0.35rem; flex-wrap: wrap; }


.pd-team {
  font-size: 0.74rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-dim);
}


.pd-team i { color: var(--text-faint); font-style: normal; }



.pd-note { font-size: 0.76rem; color: var(--text-faint); }

/*
 * ─── X-Factor badges ───
 *
 * `.pd-xf` (the container) has existed since the card was built. `.xf-badge`, the thing INSIDE it, has never
 * had a rule anywhere in the project — so the list rendered as loose text with no pill, no spacing and no
 * sign that the names were one unit each.
 *
 * `xfactor-icons.css` defines `.xf-icon`, a different class with a coloured ring per tier, and the dashboard
 * does not load that stylesheet. These are deliberately self-contained, so the dashboard's styling does not
 * depend on a file another page happens to include.
 *
 * Read-only in appearance but focusable-looking on hover, because the only interaction is the `title`
 * tooltip that says what the X-Factor does to the sim.
 */
.xf-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  color: #cfe9ff;
  background: #16324a;
  border: 1px solid #2a5f86;
  cursor: help;
  white-space: nowrap;
}

.xf-badge:hover {
  color: #ffffff;
  border-color: var(--accent, #4fc3f7);
  background: #1b3f5c;
}

/*
 * The X-Factor row on a card.
 *
 * Reuses `pd-chips` for the flex behaviour and adds only the spacing that separates it from the rating chips
 * above. A row of badges pressed against the chips above reads as one crowded block; the gap is what makes
 * "these are his ratings" and "these are his X-Factors" two things.
 */
.pd-xf-row { margin-top: 0.5rem; }


    .ability-bar { display: flex; gap: 0.2rem; align-items: center; }


    .ability-bar .bar { width: 32px; height: 4px; background: #1a2430; border-radius: 4px; overflow: hidden; }


    .ability-bar .bar .fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg,#4fc3f7,#0288d1); transition: width 0.3s; }


    .ability-bar .label { font-size: 0.6rem; color: #7a8a9a; min-width: 16px; }



    /* ─── X-FACTOR ICONS ───────────────────────────────────────────────
       Shared across pages. Tier sets the ring colour; the emoji carries the
       identity. Keep in step with XF_CATALOG in assets/js/core.js. */
    .xf-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 1.25rem;
      height: 1.25rem;
      border-radius: 50%;
      font-size: 0.72rem;
      line-height: 1;
      margin-right: 0.15rem;
      vertical-align: middle;
      background: #10161e;
      border: 1px solid #2a3a4a;
      cursor: help;
      flex: 0 0 auto;
      transition: transform 0.15s ease;
    }


    .xf-icon:hover { transform: scale(1.18); z-index: 3; }


    .xf-icon.xf-bronze { border-color: #cd7f32; box-shadow: 0 0 4px rgba(205,127,50,0.45); }


    .xf-icon.xf-silver { border-color: #c0c0c0; box-shadow: 0 0 4px rgba(192,192,192,0.40); }


    .xf-icon.xf-gold   { border-color: #ffd700; box-shadow: 0 0 5px rgba(255,215,0,0.50); }


    .xf-icon.xf-elite  { border-color: #00e5ff; box-shadow: 0 0 7px rgba(0,229,255,0.60); }


    .xf-icon .xf-label { margin-left: 0.3rem; font-size: 0.7rem; white-space: nowrap; }


    tr .xf-icon, td .xf-icon, .club-player-card .xf-icon { width: 1.1rem; height: 1.1rem; font-size: 0.62rem; }


    .hut-cards-flex { display: flex; gap: 0.6rem; flex-wrap: wrap; }



    /* ══════════════════════════════════════════════════════════════════════
       PLAYER CARD
       The portrait fills the entire frame and everything else sits on top of it,
       the way a real hockey card is laid out. Previously the image was a 118px
       band above a text block, which read as a list row.

       Size: 124px wide, 3:4, so four fit a rink column without wrapping and three
       rows of a forward line stay on one screen. It was 148px, which was too big.
       ══════════════════════════════════════════════════════════════════════ */
    .hut-card {
      position: relative;
      width: 124px;
      aspect-ratio: 3 / 4;
      background: #0b1219;
      border: 1px solid #2a3a4a;
      border-radius: 10px;
      overflow: hidden;
      cursor: grab;
      user-select: none;
      transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }


    .hut-card:hover {
      border-color: #4fc3f7;
      transform: translateY(-3px);
      box-shadow: 0 10px 22px rgba(0, 0, 0, 0.6);
      z-index: 3;
    }


    .hut-card:active { cursor: grabbing; }


    .hut-card.dragging { opacity: 0.4; }



    /* Tier accent. */
    .hut-card.tier-gold    { border-color: #c9a227; }


    .hut-card.tier-silver  { border-color: #9aa7b4; }


    .hut-card.tier-bronze  { border-color: #8a6a45; }


    .hut-card.tier-diamond { border-color: #6fd3e8; }



    /* ─── The portrait, filling the frame ─── */
    .hut-card > img {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center 18%;   /* faces sit high in these portraits */
      display: block;
    }


    .hut-card > img.failed { display: none; }


    .hut-card .player-photo-fallback {
      position: absolute; inset: 0;
      display: flex; align-items: center; justify-content: center;
      font-size: 2.6rem; color: #2a3a4a;
    }



    /* ─── Bottom scrim ───
       A gradient rather than a solid bar, so the art stays visible while the
       name and attributes remain readable over any portrait. */
    .card-foot {
      position: absolute;
      left: 0; right: 0; bottom: 0;
      padding: 0.85rem 0.38rem 0.34rem;
      background: linear-gradient(to top,
        rgba(6, 10, 14, 0.96) 0%,
        rgba(6, 10, 14, 0.88) 55%,
        rgba(6, 10, 14, 0) 100%);
      display: flex; flex-direction: column; gap: 0.14rem;
      pointer-events: none;
    }


    .card-name {
      display: flex; align-items: center; justify-content: center; gap: 0.2rem;
      font-size: 0.7rem; font-weight: 700; color: #fff;
      line-height: 1.15; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
      white-space: nowrap; overflow: hidden;
    }


    .card-name span { overflow: hidden; text-overflow: ellipsis; }



    .card-stats {
      display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.28rem;
      font-size: 0.58rem; color: #dbe6f0;
      font-variant-numeric: tabular-nums;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    }


    .card-stats span { display: flex; justify-content: space-between; }


    .card-stats i {
      font-style: normal; color: #93a6b8;
      font-size: 0.53rem; letter-spacing: 0.02em;
    }


    .card-xf {
      display: flex; justify-content: center; gap: 0.08rem;
      flex-wrap: wrap; min-height: 0.85rem; margin-top: 0.06rem;
    }



    /* ─── Top row: rating and position, over the art ─── */
    .card-top {
      position: absolute; top: 5px; left: 5px; right: 5px;
      display: flex; justify-content: space-between; align-items: flex-start;
      pointer-events: none;
    }


    .card-ovr {
      min-width: 26px; padding: 0.04rem 0.3rem;
      border-radius: 7px;
      font-size: 0.82rem; font-weight: 800;
      background: rgba(6, 10, 14, 0.85);
      border: 1px solid #33465a;
      color: #e9f1f9;
      font-variant-numeric: tabular-nums;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    }


    .card-ovr.high { color: #8fd6a0; border-color: #2f7d4f; }


    .card-ovr.mid  { color: #e0c274; border-color: #7d6a2f; }


    .card-ovr.low  { color: #e08e8e; border-color: #7d3f3f; }



    .card-pos {
      padding: 0.06rem 0.32rem; border-radius: 7px;
      font-size: 0.56rem; font-weight: 800; letter-spacing: 0.04em;
      background: rgba(6, 10, 14, 0.85);
      border: 1px solid #33465a;
      color: #8ab4d8;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    }



    .card-badges {
      position: absolute; top: 30px; right: 5px;
      display: flex; flex-direction: column; gap: 0.12rem; align-items: flex-end;
      pointer-events: none;
    }


    .card-badges .badge-tag { font-size: 0.5rem; padding: 0.03rem 0.24rem; }


    .card-status .badge-tag { font-size: 0.5rem; padding: 0.02rem 0.2rem; }


    .hut-card-slot.drag-over .hut-card,
    .hut-card-slot.drag-over .empty-slot {
      border-color: #4fc3f7;
      box-shadow: inset 0 0 0 1px rgba(79, 195, 247, 0.4);
    }



    .badge-tag {
      display: inline-flex; align-items: center; justify-content: center;
      font-size: 0.56rem; font-weight: 700; letter-spacing: 0.03em;
      padding: 0.05rem 0.3rem; border-radius: 6px;
      background: #1a2430; color: #9fb2c4; border: 1px solid #2a3a4a;
      white-space: nowrap;
    }


    .badge-star    { background: #4a3a1a; color: #ffd54f; border-color: #5a4a2a; }



    .badge-gem     { background: #1a3a4a; color: #6fd3e8; border-color: #2a5a6a; }


    .badge-penalty { background: #4a2a1a; color: #e0a874; border-color: #5a3a2a; }


    .badge-faceoff { background: #3a1a2a; color: #e08eb0; border-color: #5a2a3a; }



    /* The card in hand. An outline rather than a transform, so the card itself is
       unchanged — same size, same position, same art. */
    .hut-card.picked,
    .club-player-card.picked {
      outline: 2px solid #4fc3f7;
      outline-offset: 2px;
      box-shadow: 0 0 0 4px rgba(79, 195, 247, 0.18);
    }



    /* A slot that can take the held card says so on hover. */
    .hut-card-slot.clickable { cursor: pointer; }



    /* A goalie's card with no image gets a goalie mark, not a skater's. */
    .hut-card.no-photo.is-goalie .player-photo-fallback::after { content: '🥅'; }
