/*
 * The card the season picker re-cuts: the two chip rows, the heatmap, the season
 * shot map and Season performance (PlayerPerformance.js).
 *
 * Four sections in one card, separated by hairlines rather than by gaps — they
 * are parts of one statement about one season, and four floating cards would
 * lose the picker's authority over the three below it.
 */

/*
 * One width for every graphic on this card — the heatmap, the pitch and the goal
 * frame. They are stacked in one column and read as one panel changing its
 * subject, so three different widths would read as three panels.
 *
 * **It does not ride --player-scale, and that is the rule for every graphic on
 * this page.** The scale is a density knob: it exists to fit more rows of type
 * on a screen. A card's *width* is the page's, not the scale's, so a picture
 * scaled with the type does not make the page denser — it makes the picture
 * smaller and the card emptier, and a 210px pitch centred in a 340px card reads
 * as a mistake rather than as a smaller pitch. Type, spacing and marks come down
 * with the scale; anything drawn against the card's own width stays against it.
 */
.player-performance-card {
  --graphic-width: 100%;

  gap: 0;
  padding-inline: 0;
}

.player-performance-card > * + * {
  padding-top: calc(var(--space-4) * var(--player-scale));
  border-top: 1px solid var(--border);
}

.player-performance-card > *:not(:last-child) {
  padding-bottom: calc(var(--space-4) * var(--player-scale));
}

/* --- Picker ----------------------------------------------------------------- */

.player-picker {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-3) * var(--player-scale));
}

.player-picker__group {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-picker__title {
  padding-inline: calc(var(--space-5) * var(--player-scale));
  font-size: calc(var(--text-xs) * var(--player-scale));
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/*
 * Both rows scroll sideways. The padding is on the row rather than on the card
 * so the first chip starts on the card's own margin and the last one can run
 * out under the edge — a scroller that stops short of the edge looks like it
 * has run out of content rather than out of room.
 */
.player-picker__row {
  display: flex;
  gap: calc(var(--space-2) * var(--player-scale));
  padding-inline: calc(var(--space-5) * var(--player-scale));
  overflow-x: auto;
  scrollbar-width: none;
}

.player-picker__row::-webkit-scrollbar {
  display: none;
}

/*
 * `.filter-chip` and `.segmented` are shared with the filter sheet and the
 * Statistics tab, so neither carries this page's scale — they are drawn at token
 * size everywhere else and must stay that way there. Scaled here rather than at
 * the source: a chip a third smaller inside the sheet is a different control,
 * and a control that only looks right on one screen is what a shared component
 * exists to prevent.
 */
.player-performance-card .filter-chip {
  flex: none;
  gap: calc(6px * var(--player-scale));
  padding: calc(var(--space-2) * var(--player-scale)) calc(var(--space-3) * var(--player-scale));
  font-size: calc(var(--text-sm) * var(--player-scale));
}

.player-performance-card .filter-chip__count {
  font-size: calc(var(--text-xs) * var(--player-scale));
}

.player-performance-card .segmented__option {
  padding-block: calc(var(--space-2) * var(--player-scale));
  font-size: calc(var(--text-xs) * var(--player-scale));
}

/* --- Heatmap ---------------------------------------------------------------- */

.player-heatmap {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-2) * var(--player-scale));
  padding-inline: calc(var(--space-5) * var(--player-scale));
}

/*
 * The pitch on its side, at its true 105:68 — `PitchMarkings` stretches to its
 * box, and a landscape pitch has the room to be drawn straight. The markings
 * and the cloud are two layers pinned to the same box, so a centre at 40% along
 * the model is 40% along the drawing whatever width the card gets.
 */
.player-heatmap__pitch {
  position: relative;
  width: 100%;
  max-width: var(--graphic-width);
  aspect-ratio: 105 / 68;
  margin-inline: auto;
  /* White, not --pitch: the cloud is read for its colour, and a grey ground
     dulled the green — see --heat-* in tokens.css. The markings go grey to
     match, below. */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.player-heatmap__pitch-lines,
.player-heatmap__cloud,
.player-heatmap__marks,
.player-heatmap__generation {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The cloud is a bitmap (see `HeatCanvas` in HeatCloud.js), stretched
   to the pitch; two of them overlap for one `--duration` on a re-cut. */
.player-heatmap__generation {
  display: block;
}

/* Grey markings on white — the heatmap's own ground, not the position card's
   chalk-on-grey (player-details.css); see --heat-* in tokens.css. */
.player-heatmap__pitch-line {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 0.8;
}

.player-heatmap__pitch-spot {
  fill: var(--border-strong);
  stroke: none;
}

/* The direction-of-play chevron sits in its own thin SVG over the bitmap. The
   field's colours and opacities live with the painter in HeatCloud.js,
   read from the rating-band tokens at paint time. */
.player-heatmap__marks {
  pointer-events: none;
}

/* The direction-of-play badge: a grey pill on the halfway line with white
   chevrons — `AttackBadge` in HeatCloud.js. */
.player-heatmap__attack-badge {
  fill: var(--text-muted);
}

.player-heatmap__attack {
  fill: none;
  stroke: var(--surface);
  stroke-width: 0.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Shot map --------------------------------------------------------------- */

.player-shots {
  --shot-colour: rgb(var(--club-rgb));

  display: flex;
  flex-direction: column;
  gap: calc(var(--space-3) * var(--player-scale));
  padding-inline: calc(var(--space-5) * var(--player-scale));
}

.player-shots__header {
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: calc(var(--space-3) * var(--player-scale));
}

.player-shots__header .segmented {
  flex: none;
  width: calc(118px * var(--player-scale));
}

.player-shots__header .segmented[hidden] {
  display: none;
}

/*
 * A block, not a flex row: the two views are alternatives, and a flex container
 * would lay the hidden one out beside the visible one the moment the `hidden`
 * attribute failed to apply — which is exactly the failure `setHidden` in
 * ShotMap.js exists to stop. One of them is on screen at a time and it is
 * centred by its own margin.
 */
.player-shots__graphic > .shot-map__pitch,
.player-shots__graphic > .shot-map__goal {
  display: block;
  width: 100%;
  max-width: var(--graphic-width);
  height: auto;
  margin-inline: auto;
}

/* Beats `.shot-map__pitch { display: block }`, which beats the UA's own
   `[hidden]` rule on its own. */
.player-shots__graphic > [hidden] {
  display: none;
}

/*
 * The selected placement dot in the goal-mouth view. The fixture page's panel
 * only ever draws one dot so it never needed this; here the view is the whole
 * season at once, and the one the card below is describing has to be findable
 * in it.
 */
.player-shots .shot-map__mouth-mark {
  opacity: 0.45;
  transition: opacity var(--duration) var(--easing);
}

.player-shots [data-selected="true"] .shot-map__mouth-mark {
  opacity: 1;
}

.player-shots__figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-shots__figures[hidden] {
  display: none;
}

.player-shots__figure {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: calc(2px * var(--player-scale));
}

.player-shots__figure dt {
  font-size: calc(var(--text-xs) * var(--player-scale));
  color: var(--text-muted);
}

.player-shots__figure dd {
  font-size: calc(var(--text-lg) * var(--player-scale));
  font-weight: var(--weight-bold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* --- The selected shot ------------------------------------------------------ */

.player-shots__card {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-3) * var(--player-scale));
  padding-top: calc(var(--space-3) * var(--player-scale));
  border-top: 1px solid var(--border);
}

.player-shots__card[hidden] {
  display: none;
}

.player-shots__card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-shots__step {
  display: grid;
  place-items: center;
  width: calc(30px * var(--player-scale));
  height: calc(30px * var(--player-scale));
  background: var(--surface-sunken);
  border-radius: var(--radius-full);
  font-size: calc(var(--text-lg) * var(--player-scale));
  line-height: 1;
  color: var(--text);
}

.player-shots__fixture {
  display: flex;
  align-items: center;
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-shots__scoreline {
  font-size: calc(var(--text-md) * var(--player-scale));
  font-weight: var(--weight-bold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.player-shots__card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--space-4) * var(--player-scale));
}

.player-shots__detail {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-2) * var(--player-scale));
  font-size: calc(var(--text-sm) * var(--player-scale));
}

.player-shots__detail-row {
  display: flex;
  align-items: baseline;
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-shots__detail-label {
  flex: none;
  width: calc(68px * var(--player-scale));
  color: var(--text-muted);
}

.player-shots__detail-value {
  min-width: 0;
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.player-shots__mouth {
  flex: none;
  /* A share of the card body, capped. Neither rides the scale — see the note on
     --graphic-width above. */
  width: 42%;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-1) * var(--player-scale));
}

.player-shots__mouth .shot-map__goal {
  display: block;
  width: 100%;
  height: auto;
}

.player-shots__values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-shots__value {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.player-shots__value-number {
  font-size: calc(var(--text-md) * var(--player-scale));
  font-weight: var(--weight-bold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.player-shots__value-label {
  font-size: calc(var(--text-xs) * var(--player-scale));
  color: var(--text-muted);
}

/* --- Filter ----------------------------------------------------------------- */

.player-shots__filter {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-shots__filter[hidden] {
  display: none;
}

.player-shots__filter-title {
  font-size: calc(var(--text-sm) * var(--player-scale));
  font-weight: var(--weight-bold);
  color: var(--text);
}

/* Wrapping rather than scrolling: nine chips is a block a reader takes in at
   once, and a horizontal scroller would hide half of them behind a gesture. */
.player-shots__filters {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space-2) * var(--player-scale));
}

/* --- Season performance ------------------------------------------------------ */

.player-performance {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-3) * var(--player-scale));
  padding-inline: calc(var(--space-5) * var(--player-scale));
}

.player-performance__legend {
  font-size: calc(var(--text-xs) * var(--player-scale));
  color: var(--text-muted);
}

.player-performance__sections {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-5) * var(--player-scale));
}

.player-performance__section {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-2) * var(--player-scale));
}

.player-performance__section-title {
  font-size: calc(var(--text-md) * var(--player-scale));
  font-weight: var(--weight-bold);
  color: var(--text);
}

/* --- One statistic ----------------------------------------------------------- */

.player-stat {
  display: grid;
  grid-template-columns: 1fr auto calc(88px * var(--player-scale));
  align-items: center;
  gap: calc(var(--space-3) * var(--player-scale));
}

.player-stat__label {
  font-size: calc(var(--text-sm) * var(--player-scale));
  color: var(--text-secondary);
}

.player-stat__value {
  font-size: calc(var(--text-sm) * var(--player-scale));
  font-weight: var(--weight-semibold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.player-stat__track {
  height: calc(8px * var(--player-scale));
  background: var(--surface-sunken);
  border-radius: var(--radius-full);
  overflow: hidden;
}

/*
 * The bar is a percentile, and it borrows the rating bands rather than earning
 * a sixth tri-band of its own — see the note above `StatRow` in
 * PlayerPerformance.js. `--share` never falls below a few percent, so a bar at
 * the bottom of the scale still reads as a small quantity rather than as a
 * missing one.
 *
 * Full width, clipped to its share, rather than sized to it. A `width` that
 * animates is a layout every frame, and forty of these glide at once on a
 * re-cut — enough to stall a phone. A clip-path animates on the compositor,
 * and `round` keeps the cut end as rounded as the bar's own.
 */
.player-stat__fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  clip-path: inset(0 calc(100% - var(--share)) 0 0 round var(--radius-full));
}

.player-stat__fill[data-tier="high"] {
  background: var(--rating-high);
}

.player-stat__fill[data-tier="mid"] {
  background: var(--rating-mid);
}

.player-stat__fill[data-tier="low"] {
  background: var(--rating-low);
}
