/**
 * animations.css - 애니메이션 스타일시트
 * 대구 집수리 교육 - 행집사
 * Toss-style smooth animations + Cosmic effects
 */

/* ========================================
   Keyframe Animations
======================================== */

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide In Up */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Bounce */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

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

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

/* Shimmer */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Glow Pulse */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(102, 126, 234, 0.6);
    }
}

/* Cosmic Gradient */
@keyframes cosmicGradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

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

/* Counter Animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing Cursor */
@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Star Twinkle */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Wave */
@keyframes wave {
    0% {
        transform: translateX(0) translateZ(0) scaleY(1);
    }
    50% {
        transform: translateX(-25%) translateZ(0) scaleY(0.55);
    }
    100% {
        transform: translateX(-50%) translateZ(0) scaleY(1);
    }
}

/* ========================================
   Animation Classes
======================================== */

/* Basic Fade */
.animate-fadeIn {
    animation: fadeIn 0.6s ease forwards;
}

.animate-fadeInUp {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fadeInDown {
    animation: fadeInDown 0.6s ease forwards;
}

.animate-fadeInLeft {
    animation: fadeInLeft 0.6s ease forwards;
}

.animate-fadeInRight {
    animation: fadeInRight 0.6s ease forwards;
}

/* Scale */
.animate-scaleIn {
    animation: scaleIn 0.5s ease forwards;
}

/* Bounce */
.animate-bounce {
    animation: bounce 2s infinite;
}

/* Pulse */
.animate-pulse {
    animation: pulse 2s infinite;
}

/* Float */
.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Glow */
.animate-glow {
    animation: glowPulse 2s ease-in-out infinite;
}

/* ========================================
   Scroll Reveal Animations
======================================== */

/* Initial hidden state for scroll animations */
[data-animate] {
    opacity: 0;
}

[data-animate="fadeIn"] {
    opacity: 0;
}

[data-animate="fadeInUp"] {
    opacity: 0;
    transform: translateY(30px);
}

[data-animate="fadeInDown"] {
    opacity: 0;
    transform: translateY(-30px);
}

[data-animate="fadeInLeft"] {
    opacity: 0;
    transform: translateX(-30px);
}

[data-animate="fadeInRight"] {
    opacity: 0;
    transform: translateX(30px);
}

[data-animate="scaleIn"] {
    opacity: 0;
    transform: scale(0.9);
}

/* Animated state */
[data-animate].animated {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stagger delay classes */
.delay-100 { transition-delay: 100ms !important; }
.delay-200 { transition-delay: 200ms !important; }
.delay-300 { transition-delay: 300ms !important; }
.delay-400 { transition-delay: 400ms !important; }
.delay-500 { transition-delay: 500ms !important; }
.delay-600 { transition-delay: 600ms !important; }
.delay-700 { transition-delay: 700ms !important; }
.delay-800 { transition-delay: 800ms !important; }

/* ========================================
   Hover Animations - Toss Style
======================================== */

/* Card Lift */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

/* Card Scale */
.hover-scale {
    transition: transform var(--transition-base);
}

.hover-scale:hover {
    transform: scale(1.02);
}

/* Card Glow */
.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: var(--shadow-cosmic);
}

/* Button Bounce */
.hover-bounce:hover {
    animation: bounce 0.5s ease;
}

/* Link Underline */
.hover-underline {
    position: relative;
}

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

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

/* ========================================
   Loading Animations
======================================== */

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}

.skeleton-image {
    height: 200px;
}

/* Dots Loading */
.loading-dots {
    display: flex;
    gap: var(--space-2);
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

/* ========================================
   Cosmic Background Effects
======================================== */

/* Stars Background */
.cosmic-stars {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.cosmic-stars::before,
.cosmic-stars::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    box-shadow:
        100px 100px 0 0 rgba(255, 255, 255, 0.5),
        200px 150px 0 0 rgba(255, 255, 255, 0.4),
        300px 200px 0 0 rgba(255, 255, 255, 0.6),
        400px 50px 0 0 rgba(255, 255, 255, 0.3),
        500px 250px 0 0 rgba(255, 255, 255, 0.5),
        600px 100px 0 0 rgba(255, 255, 255, 0.4),
        700px 300px 0 0 rgba(255, 255, 255, 0.6),
        800px 180px 0 0 rgba(255, 255, 255, 0.3),
        150px 300px 0 0 rgba(255, 255, 255, 0.5),
        250px 400px 0 0 rgba(255, 255, 255, 0.4);
    animation: twinkle 4s ease-in-out infinite;
}

.cosmic-stars::after {
    animation-delay: 2s;
    transform: translateX(100px);
}

/* Gradient Orbs */
.cosmic-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

.cosmic-orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.cosmic-orb-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    top: 50%;
    right: -50px;
    animation-delay: 5s;
}

.cosmic-orb-3 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    bottom: -150px;
    left: 50%;
    animation-delay: 10s;
}

/* Animated Gradient Background */
.gradient-animate {
    background: linear-gradient(
        -45deg,
        var(--primary),
        var(--secondary),
        var(--accent),
        var(--primary-light)
    );
    background-size: 400% 400%;
    animation: cosmicGradient 15s ease infinite;
}

/* ========================================
   Slider Animations
======================================== */

/* Slide Transitions */
.slider-slide {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.slider-slide.active {
    opacity: 1;
    transform: scale(1);
}

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

/* Slide Content Animation */
.slide-content {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: 0.3s;
}

.slider-slide.active .slide-content {
    opacity: 1;
    transform: translateY(0);
}

/* Pagination Dot Animation */
.slider-dot {
    transition: all 0.3s ease;
}

.slider-dot:hover {
    transform: scale(1.2);
}

/* ========================================
   Number Counter Animation
======================================== */

.counter {
    display: inline-block;
}

.counter.counting {
    animation: countUp 0.3s ease forwards;
}

/* ========================================
   Page Transition
======================================== */

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

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

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

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

/* ========================================
   Form Animations
======================================== */

/* Input Focus Animation */
.form-input,
.form-textarea,
.form-select {
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    animation: scaleIn 0.2s ease;
}

/* Form Success Animation */
.form-success {
    animation: scaleIn 0.4s ease forwards;
}

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

.form-error {
    animation: shake 0.5s ease;
}

/* ========================================
   Menu Animations
======================================== */

/* Dropdown Animation */
.dropdown-menu {
    transform-origin: top center;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scaleY(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

.nav-item:hover .dropdown-menu {
    animation: dropdownIn 0.2s ease forwards;
}

/* Mobile Menu Animation */
.mobile-nav {
    transition: transform var(--transition-base);
}

.mobile-submenu {
    animation: fadeInDown 0.3s ease;
}

/* ========================================
   Scroll-triggered Animations
======================================== */

/* Parallax-like effect */
.parallax-slow {
    transition: transform 0.1s ease-out;
}

/* Reveal on scroll */
.reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered reveal for children */
.stagger-reveal > * {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-reveal.revealed > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-reveal.revealed > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-reveal.revealed > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-reveal.revealed > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-reveal.revealed > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-reveal.revealed > *:nth-child(6) { transition-delay: 0.6s; }

.stagger-reveal.revealed > * {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Button Ripple Effect
======================================== */

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    transform: scale(0);
    opacity: 0;
    transition: all 0.5s ease;
}

.btn-ripple:active::after {
    transform: scale(2);
    opacity: 1;
    transition: 0s;
}

/* ========================================
   Card Flip Animation
======================================== */

.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.card-flip-back {
    transform: rotateY(180deg);
}

/* ========================================
   Smooth Accordion Animation
======================================== */

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-item.active .accordion-content {
    max-height: 500px;
}

/* ========================================
   Image Zoom on Hover
======================================== */

.img-zoom {
    overflow: hidden;
}

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

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

/* ========================================
   Text Animations
======================================== */

/* Typing Animation */
.typing-text {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    white-space: nowrap;
    animation:
        typing 3.5s steps(40, end),
        blink 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0 }
    to { width: 100% }
}

/* Gradient Text Animation */
.text-gradient-animate {
    background: linear-gradient(
        90deg,
        var(--primary),
        var(--secondary),
        var(--accent),
        var(--primary)
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: cosmicGradient 5s linear infinite;
}

/* ========================================
   Reduced Motion Preferences
======================================== */

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

    .cosmic-orb,
    .cosmic-stars,
    .animate-float,
    .animate-pulse,
    .animate-bounce {
        animation: none !important;
    }

    [data-animate] {
        opacity: 1;
        transform: none;
    }
}
