/* =========================
   Rider card — the shield layout, from 576px and always on the pack page
   -----------------------------------------------------------------------------
   Switched by the media attribute of its <link> (partials/_rider_card_styles.html); the markup is
   partials/_rider_card.html, the rules both layouts share are in _rider_card.css and the layout below 576px in
   _rider_card_compact.css. Scripts set classes on it: rider_card_tilt.js .is-sweeping (the sheen); the glow of the
   pack-opening card is in _pack_showcase.css. Blocks top to bottom: .rider-card (the shield),
   .rider-selection-button (the round + or − on its point), and under the card .rider-card-unit, .rider-card-actions,
   .recent-averages, .duplicate-convert and .rider-craft.
   ========================= */

/* =========================
   .rider-card — the shield: frame and fill, sheen, rating column, jersey, name, stats, the star or hammer in the point
   -----------------------------------------------------------------------------
     ┌─╮                    ╭─┐
     │  82  │               │     <- rating column | jersey "portrait"
     │ flag │    jersey     │
     │ TLA  │               │     <- team code
     │      │               │
     │      first name      │
     │      LAST NAME       │
     │ CLI HIL SPR TT  COB  │     <- stat labels over values
      ╲________ ★ ⚒ _______╱      <- star or hammer in the point

   __identity and __hero become display: contents, so their children sit straight on the card grid. The shield is
   __face (frame) and its ::before (fill), clipped with --card-shape behind the content; the overlays that cover the
   card use the same clip-path. Type scale (1cqi ≈ 2.7px on a full 300px card; small text never under 0.7rem):
   15cqi OVR value, 10cqi last name, 9.5cqi the + or − of the round button, 8.5cqi stat values, 8cqi star and hammer,
   6-6.5cqi the cost row, 5.5cqi first name and Craft label, 5cqi team code and recent averages, 4.5cqi stat
   abbreviations and the convert title.
   ========================= */

.rider-card {
  --card-dark: color-mix(in srgb, var(--rarity-color) 40%, black);
  --card-light: color-mix(in srgb, var(--rarity-color) 50%, white);
  --rarity-glow: transparent;
  /* One width : height for every shield card and empty team slot (styles.css) */
  aspect-ratio: var(--card-aspect);
  column-gap: var(--space-sm);
  container-type: inline-size;
  /* Only the pack-opening card has a shield-shaped drop-shadow glow (_pack_showcase.css): a filter on every grid
     card makes scrolling slow. No content-visibility: a skipped card paints too late while scrolling. */
  display: grid;
  grid-template-areas:
    "ovr     jersey"
    "flag    jersey"
    "abbr    jersey"
    ".       jersey"
    "name    name"
    "stats   stats";
  grid-template-columns: 26% 1fr;
  grid-template-rows: auto auto auto 1fr auto auto;
  isolation: isolate;
  margin-inline: auto;
  max-width: var(--rider-card-max-width);
  /* Top clears the corner notches, bottom clears the pointed base */
  padding: 26px var(--space-md) 42px;
}

/* --- Shield face: metallic rarity frame (__face) around the fill (::before) --- */

.rider-card__face {
  background: linear-gradient(
    145deg,
    var(--card-light) 0%,
    var(--rarity-color) 26%,
    var(--card-dark) 52%,
    var(--rarity-color) 76%,
    var(--card-light) 100%
  );
  clip-path: var(--card-shape);
  inset: 0;
  position: absolute;
  z-index: -1; /* behind the content, inside the card's isolated stacking context */
}

.rider-card__face::before {
  background: /* a rarity tint, faint white diagonal stripes (also on the team card, _teams.css) and the fill */
    radial-gradient(
      110% 55% at 70% 20%,
      color-mix(in srgb, var(--rarity-color) 38%, transparent),
      transparent 65%
    ),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.025) 0 2px,
      transparent 2px 9px
    ),
    linear-gradient(
      170deg,
      color-mix(in srgb, var(--rarity-color) 30%, var(--color-shield-top)) 0%,
      color-mix(in srgb, var(--rarity-color) 10%, var(--color-shield-middle)) 50%,
      var(--color-shield-bottom) 100%
    );
  /* Rarity glow on the inside of the frame (transparent for Common and unowned cards); cheaper than a drop-shadow
     filter. It follows the box edges, so it lights the sides and top and fades out along the pointed base. */
  box-shadow: inset 0 0 16px 2px var(--rarity-glow);
  clip-path: var(--card-shape);
  content: "";
  inset: 2px;
  position: absolute;
}

/* --- Sheen: an occasional one-off sweep on Legendary, triggered at random by rider_card_tilt.js via .is-sweeping
   (the animation at the end of this section); hover adds nothing --- */

.rider-card__shine {
  background-image: linear-gradient( /* a band with white edges and a rarity tint in the middle */
    115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.14) 42%,
    color-mix(in srgb, var(--card-light) 35%, transparent) 50%,
    rgba(255, 255, 255, 0.04) 58%,
    transparent 68%
  );
  background-size: 260% 260%;
  clip-path: var(--card-shape);
  mix-blend-mode: screen;
  opacity: 0;
}

/* --- Grid placement: the wrappers step aside, so their children sit straight on the card grid --- */

.rider-card__identity,
.rider-card__hero {
  display: contents;
}

/* --- Rating column: OVR, flag, team code --- */

.rider-card__overall {
  /* Markup is label-then-value; the shield shows the number first */
  display: flex;
  flex-direction: column-reverse;
  grid-area: ovr;
  justify-self: center;
  /* Drops the rating/flag group a little below the top edge */
  margin-top: 4cqi;
  text-align: center;
}

/* The number speaks for itself on the shield, so the "OVR" label is only for screen readers (the compact card shows
   it); the same declarations as u-visually-hidden, which the shared markup cannot carry */
.rider-card__overall-label {
  border: 0;
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.rider-card__overall-value {
  background: linear-gradient(180deg, white 20%, var(--card-light) 120%); /* white at the top, into the rarity */
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 15cqi;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 0.9;
}

.rider-card__flag {
  border-radius: var(--radius-sm);
  grid-area: flag;
  height: clamp(18px, 9cqi, 28px);
  justify-self: center;
  margin-top: 2.5cqi;
}

/* Team code: the "club" slot of the rating column */
.rider-card__team {
  color: color-mix(in srgb, var(--card-light) 70%, var(--color-text-muted));
  font-size: max(5cqi, 0.7rem); /* never under the minimum text size */
  font-weight: 700;
  grid-area: abbr;
  justify-self: center;
  letter-spacing: 0.14em;
  line-height: 1;
  margin-right: -0.14em; /* letter-spacing also follows the last letter: pulls the code back to the centre */
  margin-top: 2.5cqi;
  text-transform: uppercase;
}

/* --- Jersey "portrait" with a floor shadow under it --- */

.rider-card__jersey {
  align-self: center;
  background: radial-gradient(34% 5% at 50% 94%, var(--overlay-strong), transparent);
  grid-area: jersey;
  width: 100%;
}

/* --- Name: full card width, centred --- */

.rider-card__name {
  grid-area: name;
  line-height: 1;
  margin-top: 2cqi;
  text-align: center;
}

.rider-card__firstname {
  font-size: max(5.5cqi, 0.7rem); /* never under the minimum text size */
  font-weight: 500;
  letter-spacing: 0.14em;
  margin-bottom: 0.25em;
  opacity: 0.65;
  text-transform: uppercase;
}

.rider-card__lastname {
  background: linear-gradient(180deg, white 30%, var(--card-light) 130%); /* white at the top, into the rarity */
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 10cqi;
  letter-spacing: 0.02em;
}

/* --- Stats: labels over values under a hairline --- */

.rider-card__stats {
  border-top: 1px solid color-mix(in srgb, var(--card-light) 35%, transparent);
  grid-area: stats;
  margin-top: 2.5cqi;
  padding-top: 2.5cqi;
}

.rider-card__stat {
  flex: 1;
}

.rider-card__stat-tla {
  font-size: max(4.5cqi, 0.7rem); /* never under the minimum text size */
  letter-spacing: 0.12em;
  margin-right: -0.12em; /* letter-spacing also follows the last letter: pulls it back to the centre */
  opacity: 0.65;
}

.rider-card__stat-value {
  font-size: 8.5cqi;
  line-height: 1.1;
}

/* --- Favorite star (riders not owned) or crafted hammer (owned): one slot in the shield's point under the stats, in
   the bottom padding, so it adds no height to the card; the same place and 12cqi box for both --- */

.rider-card__favorite {
  bottom: 2px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
}

.rider-card__favorite-button {
  height: 12cqi;
  width: 12cqi;
}

/* The star's icon font glyph, as large as the hammer */
.rider-card__favorite-button i {
  font-size: 8cqi;
}

.rider-card__crafted {
  align-items: center;
  bottom: 2px;
  display: flex;
  height: 12cqi;
  justify-content: center;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 12cqi;
}

/* The hammer's head leans left, so its box sits a little to the right to look centered (the star is symmetric) */
.rider-card__crafted-icon {
  font-size: 8cqi;
  transform: translateX(1cqi);
}

/* Every rarity above Common glows; an unowned card does not (both set the same property: this order matters) */
.rider-card:not(.rarity-common) {
  --rarity-glow: color-mix(in srgb, var(--rarity-color) 45%, transparent);
}

.rider-card.is-unowned {
  --rarity-glow: transparent;
}

.rider-card.is-unowned .rider-card__face {
  background: color-mix(in srgb, var(--rarity-color) 45%, #1a1a24); /* a grey frame, only for an unowned card */
}

.rider-card.is-unowned .rider-card__face::before {
  background: linear-gradient(170deg, #0c0824, var(--color-shield-bottom)); /* untinted fill of an unowned card */
}

/* The dimming overlays (_rider_card.css) follow the shield too */
.rider-card.is-unowned::before,
.rider-card--duplicate::after {
  clip-path: var(--card-shape);
}

/* Room for the half of the round button under the card (about 22px on a full card) */
.rider-card:has(> .rider-selection-button) {
  margin-bottom: var(--space-lg);
}

@keyframes rider-card-sheen-sweep {
  /* 100% → 0% moves the band from top-left to bottom-right across the card */
  0%   { background-position: 100% 100%; opacity: 0; }
  20%  { opacity: 0.5; }
  80%  { opacity: 0.5; }
  100% { background-position: 0% 0%;     opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .rider-card.is-sweeping .rider-card__shine {
    animation: rider-card-sheen-sweep 1.8s ease-in-out 1;
  }
}

/* =========================
   .rider-selection-button — the round + or − on the card: centred on the shield's point, half over the edge
   ========================= */

.rider-selection-button {
  bottom: 0;
  font-size: 9.5cqi;
  height: 19cqi;
  left: 50%;
  transform: translate(-50%, calc(50% - 4px));
  width: 19cqi;
}

/* =========================
   .rider-card-unit — the card with its actions under it (unit() in partials/_rider_card.html), as wide as the card
   ========================= */

.rider-card-unit {
  margin-inline: auto;
  max-width: var(--rider-card-max-width);
}

/* =========================
   .rider-card-actions — the actions under the card, with the card's side padding, so 1cqi is as wide as on the card
   ========================= */

.rider-card-actions {
  container-type: inline-size;
  margin-top: var(--space-sm);
  padding: 0 var(--space-md);
}

/* =========================
   .recent-averages — two columns, the label right-aligned against its value
   ========================= */

.recent-averages {
  column-gap: var(--space-xs);
  display: grid;
  font-size: max(5cqi, 0.7rem); /* never under the minimum text size */
  grid-template-columns: 1fr 1fr;
  margin-top: 2cqi;
}

.recent-averages dt {
  opacity: 0.6;
  text-align: right;
}

/* =========================
   .duplicate-convert — under a duplicate: the spaced-out title over the shard buttons
   ========================= */

.duplicate-convert {
  margin-top: 3cqi;
}

.duplicate-convert__title {
  font-size: max(4.5cqi, 0.7rem); /* never under the minimum text size */
  letter-spacing: 0.14em;
  opacity: 0.75;
}

/* =========================
   .rider-craft — the Craft footer: the button and the cost row under it, each 14cqi high
   ========================= */

.rider-craft {
  margin-top: 3cqi;
}

.rider-craft__button {
  align-items: center;
  border-radius: var(--radius-sm);
  display: flex;
  height: 14cqi;
  justify-content: center;
  padding: 0 3cqi;
}

.rider-craft__label {
  font-size: max(5.5cqi, 0.7rem); /* never under the minimum text size */
  letter-spacing: 0.12em;
}

.rider-craft__costs {
  align-items: center;
  background: var(--overlay-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  height: 14cqi;
  margin-top: 2cqi;
  /* Still scrollable if a huge balance overflows, but without a visible scrollbar eating into the fixed-height row
     (the ::-webkit-scrollbar rule for Safari before 18.2) */
  scrollbar-width: none;
}

.rider-craft__costs::-webkit-scrollbar {
  display: none;
}

.rider-craft__cost-list {
  gap: 1.5cqi;
  padding: 0 2cqi;
}

.rider-craft__cost,
.rider-craft__balance,
.rider-craft__separator,
.rider-craft__required {
  font-size: max(6cqi, 0.7rem); /* never under the minimum text size */
  line-height: 1;
}

.rider-craft__cost-icon {
  font-size: 6.5cqi;
  line-height: 1;
  margin-right: 0.3em;
}
