/**
 * dynamic-effects.css - 다이나믹 효과 및 애니메이션
 */

/* ===== 페이지 전환 효과 ===== */
.page-transition {
  animation: pageSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 페이드 인 효과 */
.fade-in {
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 슬라이드 업 효과 */
.slide-up {
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 스케일 인 효과 */
.scale-in {
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== 헤더 메뉴 활성화 상태 ===== */
.navbar {
  position: relative;
}

.navbar a {
  position: relative;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
}

.navbar a:hover {
  background: rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.navbar a.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white !important;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.navbar a.active::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 2px;
  animation: slideWidth 0.3s ease;
}

@keyframes slideWidth {
  from { width: 0; }
  to { width: 40%; }
}

/* 메뉴 아이콘 회전 효과 */
.navbar a i {
  transition: transform 0.3s ease;
  display: inline-block;
  margin-right: 0.5rem;
}

.navbar a:hover i {
  transform: rotate(5deg) scale(1.1);
}

.navbar a.active i {
  animation: iconBounce 0.5s ease;
}

@keyframes iconBounce {
  0%, 100% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-5deg) scale(1.1); }
  75% { transform: rotate(5deg) scale(1.1); }
}

/* ===== 레벨업 모달 효과 ===== */
.levelup-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(10px);
}

.levelup-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 2rem;
  padding: 3rem;
  text-align: center;
  color: white;
  max-width: 500px;
  position: relative;
  animation: levelupScale 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 60px rgba(102, 126, 234, 0.5);
}

@keyframes levelupScale {
  0% {
    transform: scale(0) rotate(180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

/* 레벨업 별 파티클 효과 */
.levelup-stars {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.star-particle {
  position: absolute;
  font-size: 1.5rem;
  animation: starFloat 3s ease-in-out infinite;
}

.star-particle:nth-child(1) {
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.star-particle:nth-child(2) {
  top: 20%;
  right: 10%;
  animation-delay: 0.5s;
}

.star-particle:nth-child(3) {
  bottom: 20%;
  left: 15%;
  animation-delay: 1s;
}

.star-particle:nth-child(4) {
  bottom: 10%;
  right: 20%;
  animation-delay: 1.5s;
}

@keyframes starFloat {
  0%, 100% {
    transform: translateY(0) rotate(0);
    opacity: 0.3;
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
    opacity: 1;
  }
}

.levelup-badge {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: badgeRotate 2s ease-in-out infinite;
}

@keyframes badgeRotate {
  0%, 100% { transform: rotate(-5deg) scale(1); }
  50% { transform: rotate(5deg) scale(1.1); }
}

.levelup-title {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 1rem;
  animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
  0%, 100% { text-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
  50% { text-shadow: 0 0 40px rgba(255, 255, 255, 0.8), 0 0 60px rgba(255, 255, 255, 0.5); }
}

/* ===== 퀴즈 통과 축하 모달 ===== */
.quiz-success-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(16, 185, 129, 0.1);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.quiz-success-content {
  background: white;
  border-radius: 2rem;
  padding: 3rem;
  text-align: center;
  max-width: 500px;
  position: relative;
  animation: successBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 20px 60px rgba(16, 185, 129, 0.3);
  overflow: hidden;
}

@keyframes successBounce {
  0% {
    transform: scale(0.3) translateY(100px);
    opacity: 0;
  }
  50% {
    transform: scale(1.05) translateY(-20px);
  }
  70% {
    transform: scale(0.9) translateY(10px);
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* 축하 컨페티 효과 */
.confetti-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, #667eea, #764ba2, #f093fb, #f5576c);
  animation: confettiFall 3s linear infinite;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-100vh) rotate(0);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.quiz-success-icon {
  font-size: 4rem;
  color: #10b981;
  margin-bottom: 1rem;
  animation: iconPulse 0.6s ease-in-out;
}

@keyframes iconPulse {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.quiz-success-title {
  font-size: 2rem;
  font-weight: bold;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.quiz-score {
  font-size: 3rem;
  font-weight: bold;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 1rem 0;
  animation: scoreCount 1s ease-out;
}

@keyframes scoreCount {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== 버튼 호버 효과 개선 ===== */
.btn, button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn::before, button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
}

.btn:hover::before, button:hover::before {
  width: 300px;
  height: 300px;
}

/* ===== 카드 호버 효과 ===== */
.card, .quiz-card, .dictation-card {
  transition: all 0.3s ease;
  cursor: pointer;
}

.card:hover, .quiz-card:hover, .dictation-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

/* ===== 입력 필드 포커스 효과 ===== */
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  animation: inputFocus 0.3s ease;
}

@keyframes inputFocus {
  from {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
  }
  to {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  }
}

/* ===== 로딩 애니메이션 개선 ===== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 2rem;
}

.loading-spinner i {
  font-size: 2rem;
  color: #667eea;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-spinner span {
  margin-top: 1rem;
  color: #6b7280;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== 스크롤 애니메이션 ===== */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease;
}

.scroll-reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* 다크모드 지원 */
@media (prefers-color-scheme: dark) {
  .levelup-modal {
    background: rgba(0, 0, 0, 0.95);
  }
  
  .quiz-success-content {
    background: #1f2937;
    color: white;
  }
  
  .quiz-success-title {
    color: white;
  }
}