/* =========================
   Rider Card Styles
   ========================= */

.rider-card {
  background-image: linear-gradient(
    330deg,
    color-mix(in srgb, var(--rarity-color) 35%, var(--color-surface)),
    var(--color-surface)
  );
  border: 3px solid var(--rarity-color);
  border-radius: var(--border-radius);
  box-shadow: var(--rarity-color);
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
  padding: calc(var(--spacing-unit) * 2);
  position: relative;
  container-type: inline-size;
}

.rider-card.rarity-common {
  box-shadow: 0 0 calc(var(--spacing-unit) * 0.5) var(--rarity-color);
}

.rider-card.rarity-rare {
  box-shadow: 0 0 calc(var(--spacing-unit) * 1) var(--rarity-color);
}

.rider-card.rarity-epic {
  box-shadow: 0 0 calc(var(--spacing-unit) * 1.5) var(--rarity-color);
}

.rider-card.rarity-legendary {
  box-shadow: 0 0 calc(var(--spacing-unit) * 2) var(--rarity-color);
}

/* Rider Card Properties */

.rider-card.selection-slot:hover {
  cursor: pointer;
}

.rider-card.has-startlist .card-body {
  padding-top: 0px;
}

.rider-card.unowned {
  background-color: var(--color-background-dark);
  background-image: none;
  border: 2px solid var(--rarity-color);
  position: relative;
}

.rider-card.unowned::before { /* Pseudo-element overlay for dimming background */
  background: rgba(0, 0, 0, 0.5);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

/* Rider Card Layout */

.rider-card .badge-duplicate {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
}

.rider-card .badge-startlist {
  --bs-badge-font-size: 0.75rem;
  --bs-badge-font-weight: 200;
}

.rider-card .identity-row {
  align-items: center;
  display: flex;
  gap: var(--spacing-unit);
  margin: calc(var(--spacing-unit) * 0.5) 0 0 calc(var(--spacing-unit) * 0.5);
}

.rider-card .identity-row .flag {
  border-radius: 4px;
  object-fit: cover;
  height: clamp(24px, 2cqi, 40px);
  aspect-ratio: 5 / 3;
  width: auto;
}

.rider-card .identity-row .name-stack {
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rider-card .identity-row .name-stack .firstname {
  font-size: 8cqi;
  font-weight: 400;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rider-card .identity-row .name-stack .lastname {
  font-size: 10cqi;
  font-weight: 800;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rider-card .identity-row .overall-block {
  margin-left: auto;
  text-align: right;
  line-height: 1;
}

.rider-card .identity-row .overall-block .overall-label {
  font-size: 6cqi;
  font-weight: 600;
  opacity: 0.7;
  text-transform: uppercase;
}

.rider-card .identity-row .overall-block .overall-value {
  font-size: 10cqi;
  font-weight: 700;
}

.rider-card .jersey-wrap {
  display: block;
  margin: auto;
  margin-top: 10px;
  margin-bottom: -10px;
  width: 75%;
}

.rider-card .team-name {
  font-size: 7cqi;
  font-style: italic;
  margin: 0 0 0.4rem 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rider-card .stat-row {
  display: flex;
  justify-content: space-around;
}

.rider-card .stat-row .stat-box {
  align-items: center;
  display: flex;
  flex-direction: column;
}

.rider-card .stat-row .stat-tla {
  font-size: 6cqi;
  font-weight: 600;
  opacity: 0.85;
  text-transform: uppercase;
}

.rider-card .stat-row .stat-icon {
  font-size: 12cqi;
  font-size: 1.4rem;
}

.rider-card .stat-row .stat-value {
  --norm: calc((var(--stat) - 50) / 35);
  color: color-mix(
    in srgb,
    #ffffff calc(100% - var(--norm) * 100%),
    var(--rarity-color) calc(var(--norm) * 100%)
  );
  font-size: 10cqi;
  font-weight: 700;
}

.rider-card .recent-averages {
  font-size: 8cqi;
}

.rider-card .recent-averages .text,
.rider-card .recent-averages .value {
  padding: 0 2px;
}

.rider-card .recent-averages .text {
  text-align: right;
}

/* Rider Crafting Section */

.rider-card .crafting-section {
  margin-top: 5px;
  min-height: 115px;
}

.rider-card .crafting-section { /* Crafting on unowned cards should be fully visible */
  display: flex;
  flex-direction: column;
  filter: none;
  position: relative;
  opacity: 1;
  z-index: 3;
}

.rider-card .crafting-section .craft-button {
  border: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  width: 100%;
  padding: 12px 12px;
  background-color: #187e30;
  transition: all 0.3s ease;
}

.rider-card.unowned .crafting-section .craft-button:hover {
  background-color: #115f22;
  cursor: pointer;
}

.rider-card.unowned .crafting-section .craft-button:disabled {
  background-color: #636363;
  color: #e0e0e0;
  cursor: not-allowed;
  opacity: 0.5;
}

.rider-card .crafting-section .craft-button .craft-label {
  font-size: 8cqi;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
}

.rider-card .crafting-section .craft-owned-banner {
  display: flex;
  align-items: center;
  border: 1px solid #20e672;
  border-radius: var(--border-radius);
  font-size: 6cqi;
  font-weight: 600;
  height: 100px;
  width: 100%;
  padding: 12px 12px;
  text-align: center;
}

.rider-card .crafting-section .craft-owned-banner .craft-owned-label {
  color: #20e672;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  width: 100%;
}

.rider-card .crafting-section .craft-requirements-row {
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  margin: 10px 0 0 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
}

.rider-card .crafting-section .craft-requirements-row .craft-requirements-block {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  gap: calc(var(--spacing-unit) * 0.7);
  padding: calc(var(--spacing-unit) * 0.1) calc(var(--spacing-unit) * 0.1);
  white-space: nowrap;
}

.rider-card .crafting-section .craft-requirements-block .craft-requirement-item {
  font-size: 7cqi;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.rider-card .crafting-section .craft-requirements-row .craft-requirements-block .shard-icon {
  font-size: 8cqi;
  font-size: 1rem;
}

.rider-card .crafting-section .craft-requirements-row .craft-requirements-block .craft-cost-amount {
  font-size: 7cqi;
  color: var(--color-text);
  font-weight: 500;
}

.rider-card .crafting-section .craft-requirements-row .craft-requirements-block .craft-cost-amount.is-insufficient {
  color: var(--color-accent);
}

.rider-card .crafting-section .craft-requirements-row .craft-requirements-block .craft-cost-amount-required {
  font-size: 7cqi;
  color: var(--color-text);
  font-weight: 500;
  align-self: flex-end;
}

/* allow the badge to overflow outside the card */
.rider-card {
  overflow: visible;
}

/* duplicate dimming overlay (does NOT affect badge opacity) */
.col.is-duplicate .rider-card {
  position: relative;
}

.col.is-duplicate .rider-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  border-radius: inherit;
  z-index: 2;
  pointer-events: none;
}

/* ensure card content is below overlay */
.col.is-duplicate .rider-card > * {
  position: relative;
  z-index: 1;
}

/* put badge above overlay */
.col.is-duplicate .rider-card .badge-duplicate {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
}
