/* Enhanced Animation Classes */

/* Slide In Animations */
.animate-slide-in {
    opacity: 0;
    transform: translateX(-50px);
    animation: slideIn 0.8s ease forwards;
    animation-fill-mode: both;
}

.animate-slide-in-delay {
    opacity: 0;
    transform: translateX(-50px);
    animation: slideIn 0.8s ease 0.3s forwards;
    animation-fill-mode: both;
}

.animate-slide-up {
    opacity: 0;
    transform: translateY(50px);
    animation: slideUp 0.8s ease forwards;
    animation-fill-mode: both;
}

.animate-slide-down {
    opacity: 0;
    transform: translateY(-50px);
    animation: slideDown 0.8s ease forwards;
    animation-fill-mode: both;
}

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

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

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

/* Fade In Animations */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
    animation-fill-mode: both;
}

.animate-fade-in-delay {
    opacity: 0;
    animation: fadeIn 0.8s ease 0.3s forwards;
    animation-fill-mode: both;
}

.animate-fade-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 0.8s ease forwards;
    animation-fill-mode: both;
}

.animate-fade-down {
    opacity: 0;
    transform: translateY(-30px);
    animation: fadeDown 0.8s ease forwards;
    animation-fill-mode: both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

/* Scale Animations */
.animate-scale-in {
    opacity: 0;
    transform: scale(0.8);
    animation: scaleIn 0.6s ease-out forwards;
    animation-fill-mode: both;
}

.animate-scale-out {
    animation: scaleOut 0.3s ease-in forwards;
    animation-fill-mode: both;
}

@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(0.8);
    }
}

/* Rotate Animations */
.animate-rotate-in {
    opacity: 0;
    transform: rotate(-10deg) scale(0.8);
    animation: rotateIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-fill-mode: both;
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

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

@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px);
    }
    100% {
        transform: translateY(0px);
    }
}

/* Hover Float Animation */
.hover-float {
    transition: transform 0.3s ease;
}

.hover-float:hover {
    transform: translateY(-5px);
}

/* Loading Animations */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 1s ease-in-out infinite;
}

.loading-spinner-dark {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-color);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Advanced Loading Animations */
.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

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

/* Button Hover Effects */
.button-hover-scale {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button-hover-scale:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-hover);
}

.button-hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Glow Effect */
.glow {
    box-shadow: 0 0 15px rgba(var(--primary-color-rgb, 94, 53, 177), 0.5);
    transition: box-shadow 0.3s ease;
}

.glow:hover {
    box-shadow: 0 0 25px rgba(var(--primary-color-rgb, 94, 53, 177), 0.8);
}

/* Shine Effect */
.shine {
    position: relative;
    overflow: hidden;
}

.shine::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20px;
    height: 200%;
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(25deg);
    transition: all 0.6s;
}

.shine:hover::before {
    left: 120%;
}

/* Pulse Animation for Notifications */
.pulse {
    animation: pulseEffect 2s infinite;
}

@keyframes pulseEffect {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 94, 53, 177), 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(var(--primary-color-rgb, 94, 53, 177), 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 94, 53, 177), 0);
    }
}

/* Shake Animation for Form Errors */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* Bounce In Animation */
.bounce-in {
    animation: bounceIn 0.8s ease forwards;
    opacity: 0;
    animation-fill-mode: both;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* Text Typing Animation */
.typing-effect {
    overflow: hidden;
    white-space: nowrap;
    animation: typing 3s steps(40, end) forwards;
    opacity: 0;
    animation-fill-mode: both;
}

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

/* Glitch Effect for Titles */
.glitch-effect {
    position: relative;
    animation: glitch 2s infinite;
}

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

.glitch-effect::before {
    left: 2px;
    text-shadow: -2px 0 #ff00ff;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite alternate-reverse;
}

.glitch-effect::after {
    left: -2px;
    text-shadow: -2px 0 #00ffff;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim2 5s infinite alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(24px, 9999px, 21px, 0);
    }
    20% {
        clip: rect(11px, 9999px, 89px, 0);
    }
    40% {
        clip: rect(62px, 9999px, 51px, 0);
    }
    60% {
        clip: rect(33px, 9999px, 29px, 0);
    }
    80% {
        clip: rect(71px, 9999px, 95px, 0);
    }
    100% {
        clip: rect(32px, 9999px, 53px, 0);
    }
}

@keyframes glitch-anim2 {
    0% {
        clip: rect(65px, 9999px, 31px, 0);
    }
    20% {
        clip: rect(41px, 9999px, 19px, 0);
    }
    40% {
        clip: rect(22px, 9999px, 74px, 0);
    }
    60% {
        clip: rect(84px, 9999px, 49px, 0);
    }
    80% {
        clip: rect(16px, 9999px, 89px, 0);
    }
    100% {
        clip: rect(52px, 9999px, 29px, 0);
    }
}

/* Reveal Animation for Sections */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
    animation-fill-mode: both;
}

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

/* Parallax Effect */
.parallax-element {
    transform: translateZ(0);
    will-change: transform;
}

/* Animated Background */
.animated-background {
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
    transition: 0s;
}

/* Flip Card Effect */
.flip-card {
    perspective: 1000px;
}

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

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

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

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

/* Wave Animation */
.wave {
    display: inline-block;
    animation: wave 2s infinite;
    transform-origin: 70% 70%;
}

@keyframes wave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* Ensure animations don't repeat unnecessarily */
.animate-slide-in,
.animate-slide-in-delay,
.animate-slide-up,
.animate-slide-down,
.animate-fade-in,
.animate-fade-in-delay,
.animate-fade-up,
.animate-fade-down,
.animate-scale-in,
.animate-scale-out,
.animate-rotate-in,
.bounce-in,
.typing-effect,
.glitch-effect,
.reveal {
    animation-iteration-count: 1;
    animation-fill-mode: both;
}

/* Custom animation delays for staggered elements */
.animate-delay-1 {
    animation-delay: 0.1s;
}

.animate-delay-2 {
    animation-delay: 0.2s;
}

.animate-delay-3 {
    animation-delay: 0.3s;
}

.animate-delay-4 {
    animation-delay: 0.4s;
}

.animate-delay-5 {
    animation-delay: 0.5s;
}

.animate-delay-6 {
    animation-delay: 0.6s;
}

.animate-delay-7 {
    animation-delay: 0.7s;
}

.animate-delay-8 {
    animation-delay: 0.8s;
}

/* Add animation to project cards with staggered delays */
.projects-grid .project-card:nth-child(1) {
    animation-delay: 0.1s;
}

.projects-grid .project-card:nth-child(2) {
    animation-delay: 0.2s;
}

.projects-grid .project-card:nth-child(3) {
    animation-delay: 0.3s;
}

.projects-grid .project-card:nth-child(4) {
    animation-delay: 0.4s;
}

.projects-grid .project-card:nth-child(5) {
    animation-delay: 0.5s;
}

.projects-grid .project-card:nth-child(6) {
    animation-delay: 0.6s;
}

/* Prevent animations from triggering on page load before scrolling */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Responsive animation adjustments */
@media (max-width: 768px) {
    .animate-slide-in,
    .animate-slide-in-delay,
    .animate-slide-up,
    .animate-slide-down,
    .animate-fade-in,
    .animate-fade-in-delay,
    .animate-fade-up,
    .animate-fade-down,
    .animate-scale-in,
    .animate-scale-out,
    .animate-rotate-in,
    .bounce-in,
    .typing-effect,
    .glitch-effect,
    .reveal {
        animation-duration: 0.6s;
    }
}