/* =========================
   Mobile Rider Card Styles
   Horizontal compact layout for small screens
   ========================= */

.rider-card-mobile {
  background-image: linear-gradient(
    160deg,
    color-mix(in srgb, var(--rarity-color) 25%, var(--color-surface)),
    var(--color-surface)
  );
  border: 2px solid var(--rarity-color);
  border-radius: var(--border-radius);
  overflow: visible;
  padding: 8px 10px;
  position: relative;
  width: 100%;
}

.rider-card-mobile.rarity-common    { box-shadow: 0 0 4px  var(--rarity-color); }
.rider-card-mobile.rarity-rare      { box-shadow: 0 0 8px  var(--rarity-color); }
.rider-card-mobile.rarity-epic      { box-shadow: 0 0 12px var(--rarity-color); }
.rider-card-mobile.rarity-legendary { box-shadow: 0 0 16px var(--rarity-color); }
.rider-card-mobile.rarity-all-star  { box-shadow: 0 0 16px var(--rarity-color); }

/* Unowned: dark background + dim overlay, matching desktop behaviour */
.rider-card-mobile.unowned {
  background-color: var(--color-background-dark);
  background-image: none;
  border: 2px solid var(--rarity-color);
}

.rider-card-mobile.unowned::before {
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--border-radius);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

/* Action footer stays fully visible above the dim overlay */
.rider-card-mobile.unowned .rcm-actions {
  filter: none;
  opacity: 1;
  position: relative;
  z-index: 3;
}

/* Duplicate badge floats above card top edge */
.rider-card-mobile .rcm-badge-duplicate {
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translate(-50%, -50%);
  z-index: 10;
}

/* =========================
   Main horizontal body
   ========================= */

.rider-card-mobile .rcm-body {
  align-items: center;
  display: flex;
  gap: 10px;
}

/* --- Jersey column (left, fixed width) --- */

.rider-card-mobile .rcm-jersey-col {
  align-items: center;
  display: flex;
  flex: 0 0 52px;
  flex-direction: column;
  position: relative;
}

.rider-card-mobile .rcm-jersey-wrap {
  width: 52px;
}

.rider-card-mobile .rcm-jersey-wrap svg {
  display: block;
  height: auto;
  width: 100%;
}

/* Crafted hammer icon — bottom-left of jersey */
.rider-card-mobile .rcm-crafted-icon {
  bottom: -4px;
  color: var(--green);
  font-size: 0.8rem;
  left: -4px;
  position: absolute;
  z-index: 5;
}

/* Favorite star — bottom-right of jersey */
.rider-card-mobile .rcm-favorite-btn {
  background: transparent;
  border: none;
  bottom: -4px;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  position: absolute;
  right: -10px;
  z-index: 5;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.8);
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.75);
}

.rider-card-mobile .rcm-favorite-btn.is-favorite,
.rider-card-mobile .rcm-favorite-btn:hover {
  color: #ffd966;
}

/* --- Info column (right, fills remaining width) --- */

.rider-card-mobile .rcm-info-col {
  flex: 1;
  min-width: 0;
}

/* Identity row: flag · name stack · OVR+team block */
.rider-card-mobile .rcm-identity {
  align-items: center;
  display: flex;
  gap: 6px;
}

.rider-card-mobile .rcm-flag {
  aspect-ratio: 5 / 3;
  border-radius: 3px;
  flex-shrink: 0;
  height: 14px;
  object-fit: cover;
  width: auto;
}

.rider-card-mobile .rcm-name-stack {
  flex: 0 0 auto;
  line-height: 1.15;
  overflow: hidden;
}

.rider-card-mobile .rcm-firstname {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rider-card-mobile .rcm-lastname {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Right-side block: [team name ···] [OVR] — both right-aligned as a group */
.rider-card-mobile .rcm-ovr-team {
  align-items: center;
  display: flex;
  flex: 1 1 0;
  gap: 5px;
  min-width: 0;
}

/* Team name: truncates when rider name is long */
.rider-card-mobile .rcm-team {
  flex: 1;
  font-size: 0.58rem;
  font-style: italic;
  min-width: 0;
  opacity: 0.8;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rider-card-mobile .rcm-ovr {
  flex-shrink: 0;
  line-height: 1;
  text-align: right;
}

.rider-card-mobile .rcm-ovr-label {
  font-size: 0.55rem;
  font-weight: 600;
  opacity: 0.7;
  text-transform: uppercase;
}

.rider-card-mobile .rcm-ovr-value {
  font-size: 1rem;
  font-weight: 700;
}

/* Startlist badge on its own row */
.rider-card-mobile .rcm-startlist-row {
  margin-top: 2px;
}

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

/* Stats row */
.rider-card-mobile .rcm-stats {
  display: flex;
  gap: 3px;
  margin-top: 5px;
}

.rider-card-mobile .rcm-stat-box {
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0;
  justify-content: center;
  padding: 3px 2px;
}

.rider-card-mobile .rcm-stat-tla {
  font-size: 0.5rem;
  font-weight: 600;
  opacity: 0.75;
  text-transform: uppercase;
}

.rider-card-mobile .rcm-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: 0.8rem;
  font-weight: 700;
}

/* Recent averages (compact, single line) */
.rider-card-mobile .rcm-recent-avgs {
  display: flex;
  font-size: 0.6rem;
  gap: 10px;
  margin-top: 3px;
  opacity: 0.8;
}

/* =========================
   Action footer
   ========================= */

.rider-card-mobile .rcm-actions {
  align-items: center;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
  padding-top: 7px;
  position: relative;
  z-index: 3;
}

/* Shared action button base */
.rider-card-mobile .rcm-action-btn {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 700;
  gap: 4px;
  letter-spacing: 0.03em;
  padding: 6px 20px;
  text-transform: uppercase;
  transition: background-color 0.2s ease;
}

.rider-card-mobile .rcm-action-add {
  background-color: #187e30;
}
.rider-card-mobile .rcm-action-add:hover {
  background-color: #115f22;
}

.rider-card-mobile .rcm-action-remove {
  background-color: var(--color-accent-dark);
}
.rider-card-mobile .rcm-action-remove:hover {
  background-color: #8c1a1a;
}

.rider-card-mobile .rcm-craft-form {
  display: contents;
}

.rider-card-mobile .rcm-action-craft {
  background-color: #187e30;
}
.rider-card-mobile .rcm-action-craft:hover {
  background-color: #115f22;
}
.rider-card-mobile .rcm-action-craft:disabled {
  background-color: #636363;
  color: #e0e0e0;
  cursor: not-allowed;
  opacity: 0.5;
}

/* Craft shard requirements */
.rider-card-mobile .rcm-craft-requirements {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.rider-card-mobile .rcm-craft-req-item {
  align-items: center;
  display: inline-flex;
  font-size: 0.7rem;
  gap: 2px;
}

/* User's owned balance: always white */
.rider-card-mobile .rcm-craft-req-item > span:first-of-type {
  color: #ffffff;
  font-weight: 600;
}

.rider-card-mobile .rcm-craft-req-item .is-insufficient {
  color: var(--color-accent) !important;
}

/* Required amount: inherits the shard text-class colour, boosted */
.rider-card-mobile .rcm-req-slash {
  color: inherit;
  filter: brightness(1.4);
  font-size: 0.65rem;
  font-weight: 700;
}

/* Already obtained label */
.rider-card-mobile .rcm-owned-label {
  align-items: center;
  color: #20e672;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 4px;
}

/* Duplicate shard conversion — centered full-width row */
.rider-card-mobile .rcm-dup-convert {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.rider-card-mobile .rcm-dup-label {
  font-size: 0.6rem;
  font-weight: 700;
  opacity: 0.7;
  text-transform: uppercase;
  width: 100%;
  text-align: center;
}

.rider-card-mobile .rcm-dup-btn {
  align-items: center;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  font-size: 0.65rem;
  gap: 1px;
  line-height: 1;
  min-width: 44px;
  padding: 5px 8px;
}

.rider-card-mobile .rcm-dup-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Hide horizontal card on wider screens — use .rider-card instead */
@media (min-width: 500px) {
  .rider-card-mobile {
    display: none !important;
  }
}
