/* ==========================================================================
   COMBINE-FC — css/pitch-card.css
   The player card, moved here out of css/pitch-screens.css when the builder
   moved out of js/pitch-ui.js into js/pitch-card.js. One card, four callers:
   the reveal modal, the read-only squad dossier, a shared #card= link, and the
   inline preview panel in the Starting XI rail.

   Every colour is a var() out of css/pitch-tokens.css. Two ramps run at once
   and are meant to disagree: --tier-color is the FUT bronze/silver/gold ladder
   and paints the frame; --grade-color is the Fortnite-rarity letter ramp and
   paints only the grade badge. Both are set as inline custom properties by
   js/pitch-card.js.

   .fc-stat (the category face cell) deliberately stays in pitch-screens.css —
   the spin screen paints its live preview out of the same cell.
   ========================================================================== */

.fc-card {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card), var(--glow-lg);
}

.fc-card__frame {
  position: relative;
  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--tier-color) 34%, transparent), transparent 62%),
    linear-gradient(168deg,
      color-mix(in srgb, var(--tier-color) 22%, var(--c-panel-3)) 0%,
      var(--c-panel) 54%,
      var(--c-bg-deep) 100%);
  border: 2px solid color-mix(in srgb, var(--tier-color) 62%, var(--c-line-2));
  padding: var(--s-5) var(--s-4) var(--s-4);
}
.fc-card__frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 38%, var(--c-sheen) 46%, transparent 54%);
  pointer-events: none;
}

.fc-card__top {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: start;
  gap: var(--s-2);
  /* Keep OVR/POS/name in view while the sub-attribute table below scrolls,
     so SAVE TO SQUAD is never reached having lost sight of who this is. */
  position: sticky;
  top: calc(var(--s-5) * -1);
  margin-top: calc(var(--s-5) * -1);
  padding-top: var(--s-5);
  padding-bottom: var(--s-2);
  z-index: 2;
  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--tier-color) 34%, transparent), transparent 62%),
    linear-gradient(168deg,
      color-mix(in srgb, var(--tier-color) 22%, var(--c-panel-3)) 0%,
      var(--c-panel) 84%);
}
.fc-card__ovr {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fc-card__ovr-num {
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 4.25rem);
  line-height: 0.9;
  color: var(--tier-color);
  text-shadow: var(--shadow-text);
  font-variant-numeric: tabular-nums;
}
.fc-card__ovr-label {
  color: var(--c-text-2);
}
.fc-card__tier {
  width: fit-content;
  margin-top: 2px;
}
/* The letter grade is the ONLY thing on the card drawn from the rarity ramp,
   which is the whole point of having two ramps: a GOLD card can carry a C. */
.fc-card__grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  font-family: var(--font-display);
  color: var(--grade-color, var(--tier-color));
  border: 1px solid var(--grade-color, var(--tier-color));
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--grade-color, var(--tier-color)) 12%, transparent);
}
.fc-card__pos {
  color: var(--c-text-2);
  padding-top: var(--s-1);
  position: relative;
}
.fc-card__pos::before {
  content: "";
  display: block;
  width: 50%;
  height: 2px;
  background: var(--tier-color);
  margin-bottom: var(--s-1);
}

.fc-card__portrait {
  position: relative;
  justify-self: center;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fc-card__silhouette {
  width: 72px;
  height: 72px;
  color: var(--group-color);
  opacity: 0.30;
}
.fc-card__kit {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--group-color);
  opacity: 0.55;
}

.fc-card__flag {
  justify-self: end;
  color: var(--c-text-2);
  border: var(--bw) solid var(--c-line-2);
  border-radius: var(--r-pill);
  padding: 4px 10px;
}

.fc-card__nameplate {
  text-align: center;
  border-block: 1px solid color-mix(in srgb, var(--tier-color) 40%, transparent);
  padding-block: var(--s-2);
  margin-block: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fc-card__name {
  font-family: var(--font-display);
  text-transform: uppercase;
}
.fc-card__sub {
  color: var(--c-text-2);
}

/* ------ Physicals strip — HEIGHT / WEIGHT / AGE / POTENTIAL / VALUE.
   Five cells because data.CARD_PHYSICALS declares five; the count is not
   hardcoded anywhere in the JS, but the grid is sized for it here and drops to
   three then two columns rather than letting a cell go unreadably narrow. --- */
.fc-card__phys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  padding: var(--s-2);
  background: var(--c-flood-a10);
  border: var(--bw) solid color-mix(in srgb, var(--c-flood) 30%, transparent);
  border-radius: var(--r-sm);
}
.fc-phys {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  text-align: center;
}
.fc-phys__key {
  color: var(--c-text-3);
  font-size: 0.5625rem;
}
.fc-phys__val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--fs-small);
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fc-phys__sub {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  color: var(--c-text-3);
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The two numbers a football card is actually read for get the floodlight. */
.fc-phys[data-phys="potential"] .fc-phys__val,
.fc-phys[data-phys="value"] .fc-phys__val {
  color: var(--c-flood-bright);
}
/* POTENTIAL is the longest of data.CARD_PHYSICALS' five labels and, at the
   .t-label tracking the other four wear happily, it measured 70px inside a
   51px cell — so it ran into VALUE beside it on every card in the game. Only
   this one key is tightened; the other four keep the strip's normal tracking.
   MEASURED at the 340px --fc-card-w: 52px, i.e. it fits. */
.fc-phys[data-phys="potential"] .fc-phys__key {
  font-size: 0.5rem;
  letter-spacing: 0.02em;
}

.fc-card__faces {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3) var(--s-4);
}

.fc-card__radar {
  max-width: 220px;
  margin: var(--s-4) auto 0;
}
/* The <svg> carries a viewBox but no width/height attribute, so without this
   it is sized as a replaced element and can overflow a narrow container — the
   Starting XI rail is narrower than anywhere the card used to be drawn. */
.fc-radar__svg {
  display: block;
  width: 100%;
  height: auto;
}
.fc-radar__grid {
  fill: none;
  stroke: var(--c-line-2);
  stroke-width: 1;
}
.fc-radar__shape {
  fill: color-mix(in srgb, var(--group-color) 26%, transparent);
  stroke: var(--group-color);
  stroke-width: 2;
  transform-origin: 100px 100px;
  animation: fc-radar-in var(--dur-reveal) var(--ease-pop) both;
}
@keyframes fc-radar-in {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.fc-radar__node {
  fill: var(--group-color);
}
.fc-radar__label {
  fill: var(--c-text-3);
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: var(--ls-label);
  text-anchor: middle;
}

.fc-card__badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-2);
  margin-top: var(--s-4);
}
/* Badge chips take the badge's own category colour, and carry a tooltip
   (js/pitch-tooltip.js) explaining what the badge takes and which link-ups it
   can trigger. .has-tip is added only when that tooltip actually attached. */
.fc-badge-chip {
  color: var(--fc-chip-hue, var(--c-chalk));
}
.fc-badge-chip.has-tip {
  cursor: help;
}
.fc-badge-chip.has-tip:focus-visible {
  outline: 2px solid var(--c-lime-bright);
  outline-offset: 2px;
}

.fc-card__comp {
  margin-top: var(--s-3);
  text-align: center;
  color: var(--c-text-3);
  letter-spacing: 0.08em;
}

.fc-card__detail {
  position: relative;
  background: color-mix(in srgb, var(--tier-color, var(--c-line-2)) 8%, var(--c-panel));
  padding: var(--s-4);
  border-top: 1px solid var(--c-line);
}
.fc-attr-group {
  margin-bottom: var(--s-4);
}
.fc-attr-group:last-child {
  margin-bottom: 0;
}
.fc-attr-group__head {
  display: flex;
  justify-content: space-between;
  padding-bottom: var(--s-1);
  border-bottom: 1px solid var(--c-line);
  margin-bottom: var(--s-2);
}
.fc-attr-group__head .t-num {
  color: var(--attr-color, var(--c-chalk));
  margin-left: auto;
}
.fc-attr-group.is-autofilled {
  opacity: 0.55;
}
.fc-attr-group.is-autofilled .fc-attr-group__head::after {
  content: "AUTO";
  font-family: var(--font-display);
  font-size: 0.5625rem;
  letter-spacing: var(--ls-label);
  color: var(--c-text-3);
  padding-left: var(--s-2);
}
.fc-attr-row {
  display: grid;
  grid-template-columns: 1fr 72px 34px;
  align-items: center;
  gap: var(--s-2);
  padding-block: 4px;
}
.fc-attr-row__label {
  color: var(--c-text-2);
}
.fc-attr-row__bar {
  height: var(--fc-bar-h);
  background: var(--c-bar-track);
  border-radius: var(--fc-bar-r);
  overflow: hidden;
}
.fc-attr-row__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--attr-color, var(--c-lime));
  transition: width var(--dur-slow) var(--ease);
}
.fc-attr-row__value {
  text-align: right;
}

.fc-card__actions {
  padding: var(--s-4);
  background: color-mix(in srgb, var(--tier-color, var(--c-line-2)) 8%, var(--c-panel));
  border-top: 1px solid var(--c-line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
}

.fc-card--elite .fc-card__frame::after {
  animation: fc-shine 3.2s ease-in-out infinite;
}
@keyframes fc-shine {
  0% { transform: translateX(-30%); }
  50% { transform: translateX(30%); }
  100% { transform: translateX(-30%); }
}

/* ------ Static variant — what render(player, { animate: false }) paints.
   Used by the Starting XI rail, where a card is opened and closed constantly
   while you shuffle the XI and a sweeping shimmer beside a live pitch is
   noise. Same card, no motion. --- */
.fc-card--static .fc-radar__shape,
.fc-card--static.fc-card--elite .fc-card__frame::after {
  animation: none;
}
.fc-card--static .fc-attr-row__fill,
.fc-card--static .fc-stat__fill {
  transition: none;
}
/* The rail is narrow; --fc-card-w is the width the card was drawn for. */
.fc-card--static {
  max-width: var(--fc-card-w);
  margin-inline: auto;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .fc-radar__shape,
  .fc-card--elite .fc-card__frame::after {
    animation: none !important;
  }
  .fc-attr-row__fill {
    transition: none;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .fc-card__phys {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 480px) {
  .fc-card__top {
    grid-template-columns: 68px 1fr;
  }
  .fc-card__flag {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .fc-card__radar {
    max-width: 180px;
  }
}
@media (max-width: 360px) {
  .fc-card__phys {
    grid-template-columns: repeat(2, 1fr);
  }
}
