/**
 * animations.css - 애니메이션 스타일
 * 청주집수리 교육 (행집사)
 * Cosmic Theme + Toss 스타일 인터랙션
 */

/* ========================================
   1. 기본 애니메이션 키프레임
   ======================================== */

/* 페이드 인 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 페이드 인 업 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 페이드 인 다운 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 페이드 인 레프트 */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 페이드 인 라이트 */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 스케일 인 */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 슬라이드 인 업 */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* 바운스 인 */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 흔들기 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* 펄스 */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 플로트 */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* 회전 */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 글로우 펄스 */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(107, 78, 230, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(107, 78, 230, 0.6),
                    0 0 60px rgba(240, 147, 251, 0.3);
    }
}

/* 별 반짝임 */
@keyframes starTwinkle {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 성운 이동 */
@keyframes nebulaFloat {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(20px, -20px) rotate(90deg);
    }
    50% {
        transform: translate(0, -40px) rotate(180deg);
    }
    75% {
        transform: translate(-20px, -20px) rotate(270deg);
    }
    100% {
        transform: translate(0, 0) rotate(360deg);
    }
}

/* 그라데이션 시프트 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 물결 효과 */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* 텍스트 글로우 */
@keyframes textGlow {
    0%, 100% {
        text-shadow: 0 0 10px rgba(107, 78, 230, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(107, 78, 230, 0.8),
                     0 0 40px rgba(240, 147, 251, 0.5);
    }
}

/* 타이핑 효과 */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* 블링크 커서 */
@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* 번호 카운트업 */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   2. 스크롤 트리거 애니메이션
   ======================================== */

/* 기본 상태 (스크롤 전) */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* 다양한 애니메이션 방향 */
.animate-fade-up {
    opacity: 0;
    transform: translateY(40px);
}

.animate-fade-up.animated {
    opacity: 1;
    transform: translateY(0);
}

.animate-fade-down {
    opacity: 0;
    transform: translateY(-40px);
}

.animate-fade-down.animated {
    opacity: 1;
    transform: translateY(0);
}

.animate-fade-left {
    opacity: 0;
    transform: translateX(-40px);
}

.animate-fade-left.animated {
    opacity: 1;
    transform: translateX(0);
}

.animate-fade-right {
    opacity: 0;
    transform: translateX(40px);
}

.animate-fade-right.animated {
    opacity: 1;
    transform: translateX(0);
}

.animate-scale {
    opacity: 0;
    transform: scale(0.9);
}

.animate-scale.animated {
    opacity: 1;
    transform: scale(1);
}

/* 지연 클래스 */
.delay-100 { transition-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; }
.delay-400 { transition-delay: 0.4s; }
.delay-500 { transition-delay: 0.5s; }
.delay-600 { transition-delay: 0.6s; }
.delay-700 { transition-delay: 0.7s; }
.delay-800 { transition-delay: 0.8s; }
.delay-900 { transition-delay: 0.9s; }
.delay-1000 { transition-delay: 1s; }

/* ========================================
   3. 호버 효과
   ======================================== */

/* 카드 호버 - 리프트 */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(107, 78, 230, 0.3);
}

/* 카드 호버 - 글로우 */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(107, 78, 230, 0.5),
                0 0 60px rgba(240, 147, 251, 0.3);
}

/* 이미지 호버 - 줌 */
.hover-zoom {
    overflow: hidden;
}

.hover-zoom img {
    transition: transform 0.5s ease;
}

.hover-zoom:hover img {
    transform: scale(1.1);
}

/* 버튼 호버 - 쉬머 */
.hover-shimmer {
    position: relative;
    overflow: hidden;
}

.hover-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.hover-shimmer:hover::before {
    left: 100%;
}

/* 링크 호버 - 언더라인 슬라이드 */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
}

.hover-underline:hover::after {
    width: 100%;
}

/* 3D 틸트 호버 */
.hover-tilt {
    transition: transform 0.3s ease;
    transform-style: preserve-3d;
}

.hover-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(5deg);
}

/* ========================================
   4. 로딩 애니메이션
   ======================================== */

/* 스피너 */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(107, 78, 230, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* 도트 로더 */
.dots-loader {
    display: flex;
    gap: 8px;
}

.dots-loader span {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 0.6s ease-in-out infinite;
}

.dots-loader span:nth-child(2) {
    animation-delay: 0.2s;
}

.dots-loader span:nth-child(3) {
    animation-delay: 0.4s;
}

/* 스켈레톤 로더 */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(107, 78, 230, 0.1) 0%,
        rgba(107, 78, 230, 0.2) 50%,
        rgba(107, 78, 230, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: gradientShift 1.5s ease infinite;
    border-radius: var(--radius-md);
}

/* 프로그레스 바 */
.progress-bar {
    height: 4px;
    background: rgba(107, 78, 230, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ========================================
   5. Cosmic 테마 전용 효과
   ======================================== */

/* 별 반짝임 */
.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: starTwinkle 2s ease-in-out infinite;
}

.star:nth-child(2n) {
    animation-delay: 0.5s;
}

.star:nth-child(3n) {
    animation-delay: 1s;
}

/* 성운 글로우 */
.nebula-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: nebulaFloat 20s ease-in-out infinite;
}

.nebula-purple {
    background: rgba(107, 78, 230, 0.3);
}

.nebula-pink {
    background: rgba(240, 147, 251, 0.2);
}

.nebula-cyan {
    background: rgba(6, 182, 212, 0.2);
}

/* 코스믹 파티클 */
.cosmic-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
    animation: float 3s ease-in-out infinite;
}

/* 오로라 효과 */
.aurora {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(107, 78, 230, 0.1) 50%,
        rgba(240, 147, 251, 0.1) 70%,
        transparent 90%
    );
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    pointer-events: none;
}

/* ========================================
   6. 버튼 클릭 효과
   ======================================== */

/* 리플 효과 */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

/* 버튼 프레스 효과 */
.btn-press {
    transition: transform 0.1s ease;
}

.btn-press:active {
    transform: scale(0.95);
}

/* ========================================
   7. 폼 애니메이션
   ======================================== */

/* 입력 포커스 */
.input-animated {
    position: relative;
}

.input-animated label {
    position: absolute;
    top: 50%;
    left: var(--space-md);
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: all 0.3s ease;
    pointer-events: none;
}

.input-animated input:focus + label,
.input-animated input:not(:placeholder-shown) + label {
    top: 0;
    left: var(--space-sm);
    font-size: var(--font-size-xs);
    background: var(--bg-primary);
    padding: 0 var(--space-xs);
    color: var(--primary);
}

/* 체크박스 애니메이션 */
.checkbox-animated {
    position: relative;
    width: 20px;
    height: 20px;
}

.checkbox-animated input {
    opacity: 0;
    position: absolute;
}

.checkbox-animated .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-glass);
    border: 2px solid rgba(107, 78, 230, 0.3);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.checkbox-animated input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-animated .checkmark::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s ease;
}

.checkbox-animated input:checked + .checkmark::after {
    transform: rotate(45deg) scale(1);
}

/* ========================================
   8. 모달 & 팝업 애니메이션
   ======================================== */

/* 모달 오버레이 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.8);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 모달 컨텐츠 */
.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

.modal-overlay.active .modal-content {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* 토스트 알림 */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid rgba(107, 78, 230, 0.3);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 1002;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ========================================
   9. 슬라이더 트랜지션
   ======================================== */

/* 페이드 트랜지션 */
.slider-fade .slider-slide {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.slider-fade .slider-slide.active {
    position: relative;
    opacity: 1;
}

/* 슬라이드 트랜지션 */
.slider-slide {
    transition: transform 0.5s ease;
}

/* 줌 트랜지션 */
.slider-zoom .slider-slide {
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.slider-zoom .slider-slide:not(.active) {
    transform: scale(0.9);
    opacity: 0.5;
}

/* ========================================
   10. 스크롤 인디케이터
   ======================================== */

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    animation: float 2s ease-in-out infinite;
}

.scroll-mouse {
    width: 26px;
    height: 42px;
    border: 2px solid rgba(107, 78, 230, 0.5);
    border-radius: 20px;
    position: relative;
}

.scroll-mouse::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 8px;
    background: var(--primary);
    border-radius: 2px;
    animation: scrollWheel 1.5s ease infinite;
}

@keyframes scrollWheel {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(15px);
    }
}

/* ========================================
   11. 숫자 카운터 애니메이션
   ======================================== */

.counter {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.counter.counting {
    animation: countUp 0.5s ease-out forwards;
}

/* ========================================
   12. 텍스트 효과
   ======================================== */

/* 타이핑 효과 */
.typing-text {
    overflow: hidden;
    white-space: nowrap;
    animation: typing 3s steps(30) forwards;
}

.typing-cursor {
    display: inline-block;
    animation: blink 1s step-end infinite;
}

/* 글리치 효과 */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    animation: glitch-before 0.5s infinite;
    color: var(--accent-cyan);
    clip: rect(0, 900px, 0, 0);
}

.glitch::after {
    animation: glitch-after 0.3s infinite;
    color: var(--accent);
    clip: rect(0, 900px, 0, 0);
}

@keyframes glitch-before {
    0% { clip: rect(32px, 9999px, 35px, 0); transform: skew(0.5deg); }
    5% { clip: rect(18px, 9999px, 85px, 0); transform: skew(0.6deg); }
    10% { clip: rect(73px, 9999px, 96px, 0); transform: skew(0.7deg); }
    15% { clip: rect(62px, 9999px, 8px, 0); transform: skew(0.1deg); }
    20% { clip: rect(12px, 9999px, 67px, 0); transform: skew(0.3deg); }
    100% { clip: rect(32px, 9999px, 35px, 0); transform: skew(0.5deg); }
}

@keyframes glitch-after {
    0% { clip: rect(65px, 9999px, 79px, 0); transform: skew(0.3deg); }
    5% { clip: rect(52px, 9999px, 43px, 0); transform: skew(0.7deg); }
    10% { clip: rect(28px, 9999px, 71px, 0); transform: skew(0.5deg); }
    15% { clip: rect(85px, 9999px, 26px, 0); transform: skew(0.2deg); }
    20% { clip: rect(49px, 9999px, 14px, 0); transform: skew(0.6deg); }
    100% { clip: rect(65px, 9999px, 79px, 0); transform: skew(0.3deg); }
}

/* 그라데이션 텍스트 애니메이션 */
.gradient-text-animated {
    background: linear-gradient(
        270deg,
        var(--primary),
        var(--accent),
        var(--accent-cyan),
        var(--primary)
    );
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 5s ease infinite;
}

/* ========================================
   13. 페이지 트랜지션
   ======================================== */

.page-transition-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-transition-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-transition-exit {
    opacity: 1;
}

.page-transition-exit-active {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ========================================
   14. 애니메이션 축소 모드 (접근성)
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }

    .cosmic-background,
    .nebula,
    .stars,
    .aurora {
        animation: none;
    }
}
