/* CSS Animations and Transitions for Happy Learn 香港 website */
/* Smooth animations for better user experience */

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(1.2);
    }
}

/* Bounce Animation */
@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -15px, 0);
    }
    70% {
        transform: translate3d(0, -7px, 0);
    }
    90% {
        transform: translate3d(0, -3px, 0);
    }
}

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

/* Slide Animations */
@keyframes slideInUp {
    from {
        transform: translate3d(0, 100%, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInDown {
    from {
        transform: translate3d(0, -100%, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translate3d(-100%, 0, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInRight {
    from {
        transform: translate3d(100%, 0, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

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

@keyframes rotateY {
    from {
        transform: rotateY(0deg);
    }
    to {
        transform: rotateY(360deg);
    }
}

/* Question Rotation Animations */
@keyframes fadeUpOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

@keyframes fadeUpIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes questionRotate {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    25% {
        opacity: 0;
        transform: translateY(-20px);
    }
    50% {
        opacity: 0;
        transform: translateY(20px);
    }
    75% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation Classes */
.animate-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.8s ease-out forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.8s ease-out forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.8s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.5s ease-out forwards;
}

.animate-bounce {
    animation: bounce 1s ease-in-out;
}

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

.animate-slide-in-up {
    animation: slideInUp 0.8s ease-out forwards;
}

.animate-slide-in-down {
    animation: slideInDown 0.8s ease-out forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.8s ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.8s ease-out forwards;
}

.animate-rotate {
    animation: rotate 2s linear infinite;
}

.animate-rotate-y {
    animation: rotateY 3s linear infinite;
}

/* Animation Delays */
.delay-100 {
    animation-delay: 100ms;
}

.delay-200 {
    animation-delay: 200ms;
}

.delay-300 {
    animation-delay: 300ms;
}

.delay-400 {
    animation-delay: 400ms;
}

.delay-500 {
    animation-delay: 500ms;
}

.delay-600 {
    animation-delay: 600ms;
}

.delay-700 {
    animation-delay: 700ms;
}

.delay-800 {
    animation-delay: 800ms;
}

.delay-900 {
    animation-delay: 900ms;
}

.delay-1000 {
    animation-delay: 1000ms;
}

/* Animation Durations */
.duration-100 {
    animation-duration: 100ms;
}

.duration-200 {
    animation-duration: 200ms;
}

.duration-300 {
    animation-duration: 300ms;
}

.duration-400 {
    animation-duration: 400ms;
}

.duration-500 {
    animation-duration: 500ms;
}

.duration-600 {
    animation-duration: 600ms;
}

.duration-700 {
    animation-duration: 700ms;
}

.duration-800 {
    animation-duration: 800ms;
}

.duration-900 {
    animation-duration: 900ms;
}

.duration-1000 {
    animation-duration: 1000ms;
}

/* Hover Effects */
.hover-lift {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

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

.hover-scale {
    transition: transform var(--transition-normal);
}

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

.hover-rotate {
    transition: transform var(--transition-normal);
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

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

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(74, 107, 255, 0.3);
}

/* Loading Animations */
@keyframes loadingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: loadingPulse 1.5s ease-in-out infinite;
}

/* Progress Bar Animation */
@keyframes progressBar {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

.progress-bar {
    animation: progressBar 2s ease-in-out;
}

/* Text Animations */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--primary-color);
    white-space: nowrap;
    animation: typewriter 3s steps(40) forwards;
}

/* Gradient Background Animation */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.animated-gradient {
    background: linear-gradient(-45deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* Staggered Animation for Grid Items */
.feature-grid .feature-card:nth-child(1) { animation-delay: 100ms; }
.feature-grid .feature-card:nth-child(2) { animation-delay: 200ms; }
.feature-grid .feature-card:nth-child(3) { animation-delay: 300ms; }
.feature-grid .feature-card:nth-child(4) { animation-delay: 400ms; }
.feature-grid .feature-card:nth-child(5) { animation-delay: 500ms; }
.feature-grid .feature-card:nth-child(6) { animation-delay: 600ms; }

/* Question Rotator Styles */
.question-rotator {
    transition: all 0.3s ease;
    will-change: transform, opacity;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Accessibility Considerations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .animate-in,
    .animate-fade-in-up,
    .animate-fade-in-down,
    .animate-fade-in-left,
    .animate-fade-in-right,
    .animate-scale-in,
    .animate-bounce,
    .animate-pulse,
    .animate-slide-in-up,
    .animate-slide-in-down,
    .animate-slide-in-left,
    .animate-slide-in-right,
    .animate-rotate,
    .animate-rotate-y {
        animation: none !important;
    }
}

/* Performance Optimized Animations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.will-change-transform-opacity {
    will-change: transform, opacity;
}

/* Custom easing curves */
.ease-in-out-back {
    animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ease-out-quart {
    animation-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
}

.ease-in-out-quart {
    animation-timing-function: cubic-bezier(0.77, 0, 0.175, 1);
}
