/* ==========================================================================
   Animations — gaffr
   Three hero moments with premium broadcast-quality animation.
   1. Card reveal (pack-opening)
   2. MOTM announcement
   3. Tier-up (rating threshold cross)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CARD REVEAL — Cinematic Pack Opening
   -------------------------------------------------------------------------- */
.card-reveal-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(10,17,40,0.95) 0%, rgba(0,0,0,0.98) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  animation: reveal-bg-in 0.5s ease-out;
}
@keyframes reveal-bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Pack wrapper */
.card-reveal-pack {
  width: 240px;
  height: 340px;
  perspective: 1200px;
  cursor: pointer;
}

.card-reveal-pack__wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
}
.card-reveal-pack--opening .card-reveal-pack__wrapper {
  animation: pack-shake 0.6s ease, pack-dissolve 0.8s ease 0.6s forwards;
}
@keyframes pack-shake {
  0%, 100% { transform: rotate(0) scale(1); }
  15% { transform: rotate(-2deg) scale(1.02); }
  30% { transform: rotate(2deg) scale(1.04); }
  45% { transform: rotate(-1.5deg) scale(1.05); }
  60% { transform: rotate(1deg) scale(1.04); }
  75% { transform: rotate(-0.5deg) scale(1.02); }
}
@keyframes pack-dissolve {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  50% { transform: scale(1.1); filter: brightness(2); }
  100% { transform: scale(1.2); opacity: 0; filter: brightness(3); }
}

/* Pack face */
.card-reveal-pack__front {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #141D3B 0%, #1B2650 50%, #0D1530 100%);
  border-radius: var(--al-radius-card, 0.75rem);
  border: 1px solid rgba(0,240,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), 0 0 30px rgba(0,240,255,0.1);
  backface-visibility: hidden;
  overflow: hidden;
}
.card-reveal-pack__front::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(0,240,255,0.05) 50%, transparent 60%);
  animation: pack-shimmer 3s ease-in-out infinite;
}
@keyframes pack-shimmer {
  0%, 100% { transform: translateX(-100%) rotate(45deg); }
  50% { transform: translateX(100%) rotate(45deg); }
}
.card-reveal-pack__front::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(0,240,255,0.15);
  border-radius: 50%;
}
.card-reveal-pack__logo {
  font-family: var(--al-font-heading);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--al-primary, #00F0FF);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: relative;
  z-index: 1;
}
.card-reveal-pack__tap {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  animation: pulse-text 2s ease infinite;
  position: relative;
  z-index: 1;
}
@keyframes pulse-text {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* Revealed card */
.card-reveal-result {
  opacity: 0;
  transform: scale(0.7) rotateY(90deg);
}
.card-reveal-result--visible {
  animation: card-burst-in 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes card-burst-in {
  0% { opacity: 0; transform: scale(0.5) rotateY(90deg); }
  60% { opacity: 1; transform: scale(1.08) rotateY(0deg); }
  80% { transform: scale(0.97) rotateY(0deg); }
  100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

/* Particle burst */
.card-reveal-particles {
  position: absolute;
  width: 300px;
  height: 300px;
  pointer-events: none;
}
.card-reveal-particles span {
  position: absolute;
  width: 3px;
  height: 12px;
  border-radius: 2px;
  top: 50%;
  left: 50%;
  opacity: 0;
}
.card-reveal-particles--active span {
  animation: particle-burst 1.2s ease-out forwards;
}
.card-reveal-particles span:nth-child(1) { --angle: 0deg; --dist: 90px; background: #00F0FF; animation-delay: 0.05s; }
.card-reveal-particles span:nth-child(2) { --angle: 45deg; --dist: 110px; background: #FFD700; animation-delay: 0.1s; }
.card-reveal-particles span:nth-child(3) { --angle: 90deg; --dist: 80px; background: #00F0FF; animation-delay: 0.02s; }
.card-reveal-particles span:nth-child(4) { --angle: 135deg; --dist: 100px; background: #7C3AED; animation-delay: 0.08s; }
.card-reveal-particles span:nth-child(5) { --angle: 180deg; --dist: 95px; background: #FF3D5A; animation-delay: 0.12s; }
.card-reveal-particles span:nth-child(6) { --angle: 225deg; --dist: 105px; background: #FFD700; animation-delay: 0.06s; }
.card-reveal-particles span:nth-child(7) { --angle: 270deg; --dist: 85px; background: #00F0FF; animation-delay: 0.04s; }
.card-reveal-particles span:nth-child(8) { --angle: 315deg; --dist: 98px; background: #7C3AED; animation-delay: 0.09s; }
@keyframes particle-burst {
  0% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(-1 * var(--dist))); opacity: 0; }
}

/* Dismiss button */
.card-reveal-dismiss {
  margin-top: 2rem;
  background: transparent;
  border: 1px solid rgba(0,240,255,0.3);
  color: var(--al-primary, #00F0FF);
  padding: 0.5rem 1.5rem;
  border-radius: var(--al-radius);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  opacity: 0;
  animation: fade-in 0.4s ease 1.5s forwards;
  transition: all 0.2s ease;
}
.card-reveal-dismiss:hover {
  background: rgba(0,240,255,0.08);
  border-color: var(--al-primary, #00F0FF);
  box-shadow: 0 0 12px rgba(0,240,255,0.2);
}
@keyframes fade-in {
  to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   2. MOTM ANNOUNCEMENT — Cinematic Award Reveal
   -------------------------------------------------------------------------- */
.motm-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(20,29,59,0.95) 0%, rgba(0,0,0,0.98) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  animation: motm-bg-in 0.6s ease-out;
}
@keyframes motm-bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.motm-crown {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: crown-bounce 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.5));
}
@keyframes crown-bounce {
  0% { opacity: 0; transform: translateY(-50px) scale(0.3); }
  60% { opacity: 1; transform: translateY(5px) scale(1.1); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.motm-title {
  font-family: var(--al-font-heading);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--al-secondary, #FFD700);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
  opacity: 0;
  animation: motm-text-in 0.6s ease 0.4s forwards;
  text-shadow: 0 0 20px rgba(255,215,0,0.3);
}
@keyframes motm-text-in {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.motm-card-wrapper {
  margin-top: 1.5rem;
  opacity: 0;
  animation: motm-card-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.8s forwards;
}
@keyframes motm-card-in {
  0% { opacity: 0; transform: scale(0.6) rotateZ(-3deg); }
  100% { opacity: 1; transform: scale(1) rotateZ(0deg); }
}

.motm-score {
  margin-top: 1rem;
  font-family: var(--al-font-mono);
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--al-primary, #00F0FF);
  opacity: 0;
  animation: motm-score-in 0.5s ease 1.2s forwards;
  text-shadow: 0 0 30px rgba(0,240,255,0.4);
}
@keyframes motm-score-in {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

.motm-subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0;
  animation: fade-in 0.4s ease 1.4s forwards;
}

/* Ambient glow behind card */
.motm-stars {
  position: absolute;
  width: 400px;
  height: 400px;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,215,0,0.08) 0%, transparent 60%);
  animation: motm-glow-pulse 3s ease-in-out infinite;
}
@keyframes motm-glow-pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* --------------------------------------------------------------------------
   3. TIER-UP — Rating Threshold Cross Animation
   -------------------------------------------------------------------------- */
.tier-up-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(10,17,40,0.95) 0%, rgba(0,0,0,0.98) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  animation: reveal-bg-in 0.4s ease-out;
}

.tier-up-label {
  font-family: var(--al-font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0;
  animation: fade-in 0.3s ease 0.2s forwards;
}

.tier-up-badge {
  margin-top: 0.75rem;
  font-family: var(--al-font-heading);
  font-size: 2rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0;
  animation: tier-badge-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s forwards;
}
@keyframes tier-badge-in {
  0% { opacity: 0; transform: scale(0.3) rotateZ(-5deg); }
  100% { opacity: 1; transform: scale(1) rotateZ(0deg); }
}
.tier-up-badge--silver { color: var(--al-tier-silver); text-shadow: 0 0 20px rgba(168,184,208,0.5); }
.tier-up-badge--gold { color: var(--al-tier-gold); text-shadow: 0 0 20px rgba(255,215,0,0.5); }
.tier-up-badge--inform { color: var(--al-tier-inform); text-shadow: 0 0 20px rgba(0,240,255,0.5); }

/* Card transition */
.tier-up-card-transition {
  position: relative;
  margin-top: 1.5rem;
}
.tier-up-card-old {
  animation: tier-old-out 0.6s ease 0.8s forwards;
}
@keyframes tier-old-out {
  0% { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(0.8) translateY(20px); filter: blur(4px); }
}
.tier-up-card-new {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  opacity: 0;
  animation: tier-new-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 1.4s forwards;
}
@keyframes tier-new-in {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5); filter: brightness(2); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); filter: brightness(1); }
}

/* Tier-up ring pulse */
.tier-up-ring {
  position: absolute;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  border: 2px solid;
  opacity: 0;
  pointer-events: none;
  animation: ring-pulse 1.2s ease 1.2s forwards;
}
@keyframes ring-pulse {
  0% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 0.6; }
  100% { opacity: 0; transform: scale(2.5); }
}
.tier-up-ring--silver { border-color: var(--al-tier-silver); box-shadow: 0 0 20px rgba(168,184,208,0.3); }
.tier-up-ring--gold { border-color: var(--al-tier-gold); box-shadow: 0 0 20px rgba(255,215,0,0.3); }
.tier-up-ring--inform { border-color: var(--al-tier-inform); box-shadow: 0 0 20px rgba(0,240,255,0.3); }
