/* =============================================================================
   SYSTEM.exe · Game Client · cards.css
   Card component: rarity system, hover, selection animations.
   ============================================================================= */

/* ── Card base ───────────────────────────────────────────────────────────────── */

.card {
  position: relative;
  flex: 1 1 120px;
  min-width: 110px;
  max-width: 200px;
  background: #0D0D0D;
  border: 1px solid var(--rarity-color, var(--rarity-common));
  border-radius: 3px;
  padding: 12px 12px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition:
    transform  160ms var(--ease-out),
    box-shadow 160ms var(--ease-out),
    border-color 160ms;
  transform-origin: bottom center;
  /* Isolate stacking context for z-index during animation */
  isolation: isolate;
}

/* Rarity glow on border hover */
.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 16px var(--rarity-glow, rgba(90,90,90,0.3));
  z-index: 10;
}

/* ── Rarity CSS variables (set via inline style on .card) ────────────────────── */
/*
  Each card element gets:
    style="--rarity-color: #…; --rarity-glow: rgba(…);"
  These are computed in cards.js based on the rarity 0–1 float.
*/

/* ── Rarity indicator dot ────────────────────────────────────────────────────── */

.card__rarity-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rarity-color, var(--rarity-common));
  box-shadow: 0 0 4px var(--rarity-glow, transparent);
}

/* ── Card text ───────────────────────────────────────────────────────────────── */

.card__text {
  font-family: var(--font-game);
  font-size: var(--fs-base);
  color: var(--c-cream);
  line-height: 1.5;
  flex: 1;
  /* Prevent very long cards from overflowing */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

/* ── Card origin badge (user-written vs. ai-generated) ───────────────────────── */

.card__badge {
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--c-dim);
  text-transform: uppercase;
  align-self: flex-start;
}

.card__badge--user { color: var(--c-amber-dim); }

/* ── A-priori rating row (shown on hover, slides up from bottom of card) ──────── */

.card__prior-rating {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 200ms, transform 200ms;
  pointer-events: none;
  height: 22px;
}

.card:hover .card__prior-rating {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Smaller stars for the a-priori in-card rating */
.card__prior-rating .star-btn {
  font-size: 14px;
}

/* ── Custom card button (+ slot) ─────────────────────────────────────────────── */

.card--custom-btn {
  flex: 0 0 48px;
  min-width: 48px;
  max-width: 48px;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: rgba(90,82,72,0.4);
  color: var(--c-dim);
  font-size: 22px;
  background: transparent;
  transition: border-color 160ms, color 160ms, box-shadow 160ms;
  padding: 0;
}

.card--custom-btn:hover {
  transform: translateY(-3px);
  border-color: var(--c-amber-dim);
  color: var(--c-amber);
  box-shadow: 0 0 12px var(--c-amber-glow);
}

/* ── Selection animation states ──────────────────────────────────────────────── */

/*
  When the player picks a card:
    1. The chosen card gets .is-selected  → rises then fades out
    2. All other cards get .is-dismissed  → shrink and fade out
    3. Once done, JavaScript removes the card-area content and shows loading
*/

.card.is-selected {
  animation: card-chosen 420ms var(--ease-in) forwards;
  pointer-events: none;
  z-index: 20;
}

.card.is-dismissed {
  animation: card-dismissed 300ms var(--ease-in) forwards;
  pointer-events: none;
}
.cardArea.is-animating .card:hover {
  transform: none;
  box-shadow: none;
}
@keyframes card-chosen {
  0%   { transform: translateY(-5px) scale(1);    opacity: 1; }
  35%  { transform: translateY(-22px) scale(1.06); opacity: 1; }
  100% { transform: translateY(-22px) scale(1.06); opacity: 0; }
}

@keyframes card-dismissed {
  0%   { transform: scale(1);    opacity: 1; }
  100% { transform: scale(0.92); opacity: 0; }
}

/* ── Card entrance animation (when a new set of cards arrives) ───────────────── */

.card.is-entering {
  animation: card-enter 350ms var(--ease-out) backwards;
}

/* Each card gets a staggered delay set via inline style: animation-delay */
@keyframes card-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Disabled state (while generation is running) ────────────────────────────── */

.card.is-disabled {
  pointer-events: none;
  opacity: 0.5;
}
