/* level_arrival.css */
/* New Level Arrival Animation — encouraging welcome when visiting a new level */

/* Fullscreen overlay — lighter than celebration overlay */
.level-arrival-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9990;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.35) 100%);
  cursor: pointer;
  animation: level-arrival-fade-in 0.4s ease-out forwards;
}

/* Exit state */
.level-arrival--exiting {
  animation: level-arrival-fade-out 0.5s ease-in forwards;
}

/* Card — frosted glass with animated gradient border */
.level-arrival-card {
  position: relative;
  text-align: center;
  padding: clamp(32px, 5vw, 60px) clamp(40px, 7vw, 90px);
  border-radius: clamp(18px, 4vw, 36px);
  background: linear-gradient(135deg, rgba(20, 20, 20, 0.7), rgba(30, 30, 30, 0.5)) padding-box,
              var(--arrival-gradient) border-box;
  border: 2px solid transparent;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3),
              inset 0 0 24px var(--arrival-inner-glow);
  animation: level-arrival-enter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  max-width: 90vw;
  overflow: hidden;
}

/* ── Tiered color themes ── */

/* Bronze tier (levels 2-3): silver/blue */
.level-arrival--bronze {
  --arrival-gradient: linear-gradient(135deg, rgba(148, 187, 233, 0.7), rgba(185, 211, 238, 0.3));
  --arrival-inner-glow: rgba(148, 187, 233, 0.2);
  --arrival-number-color: #b9d3ee;
  --arrival-glow-color: rgba(148, 187, 233, 0.6);
  --arrival-sparkle-color: #c4daf4;
  --arrival-bar-color: #94bbe9;
}

/* Gold tier (levels 4-6): gold/amber */
.level-arrival--gold {
  --arrival-gradient: linear-gradient(135deg, rgba(255, 193, 37, 0.7), rgba(255, 215, 100, 0.3));
  --arrival-inner-glow: rgba(255, 193, 37, 0.2);
  --arrival-number-color: #ffd764;
  --arrival-glow-color: rgba(255, 193, 37, 0.6);
  --arrival-sparkle-color: #ffe08a;
  --arrival-bar-color: #ffc125;
}

/* Platinum tier (levels 7+): purple/diamond */
.level-arrival--platinum {
  --arrival-gradient: linear-gradient(135deg, rgba(167, 120, 255, 0.7), rgba(200, 160, 255, 0.3));
  --arrival-inner-glow: rgba(167, 120, 255, 0.2);
  --arrival-number-color: #c8a0ff;
  --arrival-glow-color: rgba(167, 120, 255, 0.6);
  --arrival-sparkle-color: #d4b8ff;
  --arrival-bar-color: #a778ff;
}

/* Level number */
.level-arrival__number {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
  color: var(--arrival-number-color);
  line-height: 1;
  margin-bottom: 8px;
  text-shadow:
    0 0 20px var(--arrival-glow-color),
    0 0 40px var(--arrival-glow-color),
    0 2px 4px rgba(0, 0, 0, 0.5);
  animation: level-number-scale 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
             level-glow-pulse 2s ease-in-out infinite 0.7s;
}

/* Title text */
.level-arrival__title {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Encouraging subtitle */
.level-arrival__subtitle {
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 16px;
}

/* Progress bar container */
.level-arrival__progress {
  margin-top: 12px;
  width: 100%;
  max-width: 240px;
  margin-left: auto;
  margin-right: auto;
}

.level-arrival__progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.level-arrival__progress-fill {
  height: 100%;
  background: var(--arrival-bar-color);
  border-radius: 3px;
  transition: width 0.8s ease-out;
  box-shadow: 0 0 8px var(--arrival-glow-color);
}

.level-arrival__progress-text {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.05em;
}

/* CSS sparkle particles */
.level-arrival__sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--arrival-sparkle-color);
  border-radius: 50%;
  left: var(--sparkle-x);
  top: var(--sparkle-y);
  opacity: 0;
  box-shadow: 0 0 8px var(--arrival-glow-color);
  animation: sparkle-twinkle 1.2s ease-in-out infinite;
  animation-delay: var(--sparkle-delay);
  pointer-events: none;
}

/* ── Keyframes ── */

@keyframes level-arrival-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes level-arrival-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes level-arrival-enter {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes level-number-scale {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  60% {
    transform: scale(1.15);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes level-glow-pulse {
  0%, 100% {
    text-shadow:
      0 0 20px var(--arrival-glow-color),
      0 0 40px var(--arrival-glow-color),
      0 2px 4px rgba(0, 0, 0, 0.5);
  }
  50% {
    text-shadow:
      0 0 30px var(--arrival-glow-color),
      0 0 60px var(--arrival-glow-color),
      0 0 80px var(--arrival-glow-color),
      0 2px 4px rgba(0, 0, 0, 0.5);
  }
}

@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 0.9; transform: scale(1.2); }
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .level-arrival-card {
    padding: clamp(24px, 4vw, 40px) clamp(28px, 5vw, 60px);
    border-radius: clamp(14px, 3vw, 28px);
  }
  .level-arrival__number {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
  }
}

@media (max-width: 480px) {
  .level-arrival-card {
    padding: clamp(20px, 3vw, 32px) clamp(24px, 4vw, 48px);
  }
  .level-arrival__number {
    font-size: clamp(2rem, 5vw, 3.5rem);
  }
  .level-arrival__sparkle {
    width: 4px;
    height: 4px;
  }
}

/* ── Accessibility: reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  .level-arrival-overlay,
  .level-arrival-card,
  .level-arrival__number,
  .level-arrival__sparkle {
    animation-duration: 0.01s !important;
    transition: none !important;
  }

  .level-arrival--exiting {
    animation-duration: 0.01s !important;
  }
}
