/* Premium motion belongs to the complete card, not an image rectangle. */
.rift-card:is([data-rarity=epic],[data-rarity=legendary]),
.prestige-hero:is([data-rarity=epic],[data-rarity=legendary]) {
  --rarity-cycle: 25s;
  --rarity-phase: -5s;
  --rarity-peak: .65;
}
.rift-card[data-rarity=legendary],.prestige-hero[data-rarity=legendary] { --rarity-peak: .9; }
body .rift-card:is([data-rarity=epic],[data-rarity=legendary])::after,
.prestige-hero:is([data-rarity=epic],[data-rarity=legendary]) .rift-character-info::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  pointer-events: none;
  background: none;
  box-shadow: inset 0 0 0 2px rgba(var(--rarity-rgb),.95), inset 0 0 20px rgba(var(--rarity-rgb),.3);
  opacity: 0;
  animation: whole-card-glint var(--rarity-cycle) ease-in-out var(--rarity-phase) infinite;
}
:is(.rift-card[data-rarity=epic],.rift-card[data-rarity=legendary]) .rarity-tag,
.prestige-hero:is([data-rarity=epic],[data-rarity=legendary]) .character-rarity {
  animation: rarity-label-glint var(--rarity-cycle) ease-in-out var(--rarity-phase) infinite;
}
/* Remove the obsolete image-only rim and ribbon; retain sparse painted stars. */
:is(.rift-card[data-rarity] .rift-card-art,.rift-portrait-panel[data-rarity]) > .rarity-sparks::before,
:is(.rift-card[data-rarity] .rift-card-art,.rift-portrait-panel[data-rarity]) > .rarity-sparks::after {
  content: none;
  animation: none;
}
:is(.rift-card[data-rarity] .rift-card-art,.rift-portrait-panel[data-rarity]) > .rarity-sparks i,
.prestige-hero .rift-character-info > .rarity-sparks i {
  animation-name: premium-star;
  animation-duration: var(--rarity-cycle);
  animation-delay: var(--star-phase, -3s);
}
:is(.rift-card[data-rarity] .rift-card-art,.rift-portrait-panel[data-rarity]) > .rarity-sparks i:nth-child(2),
.prestige-hero .rift-character-info > .rarity-sparks i:nth-child(2) { animation-delay: calc(var(--star-phase, -3s) - 7s); }
:is(.rift-card[data-rarity] .rift-card-art,.rift-portrait-panel[data-rarity]) > .rarity-sparks i:nth-child(3),
.prestige-hero .rift-character-info > .rarity-sparks i:nth-child(3) { animation-delay: calc(var(--star-phase, -3s) - 15s); }
@keyframes whole-card-glint {
  0%,76%,91%,100% { opacity: 0; }
  82% { opacity: var(--rarity-peak); }
}
@keyframes rarity-label-glint {
  0%,76%,91%,100% { box-shadow: 0 0 0 transparent; text-shadow: none; }
  82% { box-shadow: 0 0 12px rgba(var(--rarity-rgb),.5), inset 0 0 8px rgba(var(--rarity-rgb),.2); text-shadow: 0 0 6px currentColor; }
}
@keyframes premium-star {
  0%,78%,89%,100% { opacity: 0; transform: scale(.5); }
  83% { opacity: var(--rarity-peak); transform: scale(1.2); }
}
@media(prefers-reduced-motion:reduce) {
  body .rift-card::after,.prestige-hero .rift-character-info::after,
  .rift-card .rarity-tag,.prestige-hero .character-rarity { animation: none!important; }
  .prestige-hero .rift-character-info::after { opacity: 0; }
}
