/* ===================================
   Advanced Animations & Effects
   =================================== */

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

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

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

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

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

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

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

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

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

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

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

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

@keyframes pulseScale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

/* Swing Animation */
@keyframes swing {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(15deg);
    }
    75% {
        transform: rotate(-15deg);
    }
}

/* Wobble Animation */
@keyframes wobble {
    0%, 100% {
        transform: translateX(0);
    }
    15% {
        transform: translateX(-10px) rotate(-5deg);
    }
    30% {
        transform: translateX(8px) rotate(3deg);
    }
    45% {
        transform: translateX(-6px) rotate(-3deg);
    }
    60% {
        transform: translateX(4px) rotate(2deg);
    }
    75% {
        transform: translateX(-2px) rotate(-1deg);
    }
}

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

@keyframes floatCard {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-10px) rotate(1deg);
    }
    75% {
        transform: translateY(-5px) rotate(-1deg);
    }
}

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

/* Glow Animation */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(99, 102, 241, 0.5),
                    0 0 10px rgba(99, 102, 241, 0.3),
                    0 0 15px rgba(99, 102, 241, 0.2);
    }
    50% {
        box-shadow: 0 0 10px rgba(99, 102, 241, 0.8),
                    0 0 20px rgba(99, 102, 241, 0.5),
                    0 0 30px rgba(99, 102, 241, 0.3);
    }
}

/* Typing Animation */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

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

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

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

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

.reveal-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-right.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Stagger Animation Delays */
.stagger-1 {
    transition-delay: 0.1s;
}

.stagger-2 {
    transition-delay: 0.2s;
}

.stagger-3 {
    transition-delay: 0.3s;
}

.stagger-4 {
    transition-delay: 0.4s;
}

.stagger-5 {
    transition-delay: 0.5s;
}

.stagger-6 {
    transition-delay: 0.6s;
}

/* ===================================
   Hover Effects
   =================================== */

/* Lift Effect */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Glow Effect */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4),
                0 0 40px rgba(99, 102, 241, 0.2);
}

/* Scale Effect */
.hover-scale {
    transition: transform 0.3s ease;
}

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

/* Rotate Effect */
.hover-rotate {
    transition: transform 0.3s ease;
}

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

/* Border Animation */
.hover-border {
    position: relative;
}

.hover-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hover-border:hover::before {
    opacity: 1;
}

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

.hover-shine::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    transform: rotate(45deg) translateX(-100%);
    transition: transform 0.6s ease;
}

.hover-shine:hover::after {
    transform: rotate(45deg) translateX(100%);
}

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

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

/* Dots Loading */
.dots-loading {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.dot:nth-child(1) {
    animation-delay: 0s;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

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

/* Gradient Text Animation */
.gradient-text-animated {
    background: linear-gradient(
        90deg,
        var(--primary) 0%,
        var(--secondary) 25%,
        var(--accent) 50%,
        var(--secondary) 75%,
        var(--primary) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s linear infinite;
}

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

/* ===================================
   Button Animations
   =================================== */

/* Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

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

.btn-ripple:active::after {
    width: 200px;
    height: 200px;
}

/* Shake on Hover */
.btn-shake:hover {
    animation: shake 0.5s ease-in-out;
}

/* ===================================
   Card Animations
   =================================== */

/* 3D Flip */
.card-3d {
    perspective: 1000px;
}

.card-3d-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

.card-3d-front,
.card-3d-back {
    backface-visibility: hidden;
}

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

/* Tilt Effect */
.card-tilt {
    transition: transform 0.3s ease;
}

/* ===================================
   Particle Effects
   =================================== */

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

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    animation: particle 2s ease-out infinite;
}

/* ===================================
   Smooth Transitions
   =================================== */

.page-transition {
    animation: fadeIn 0.5s ease-in-out;
}

.section-transition {
    animation: fadeInUp 0.8s ease-out;
}

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

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

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

/* ===================================
   Progress Bar Animation
   =================================== */

@keyframes progressFill {
    from {
        width: 0;
    }
}

.progress-bar {
    animation: progressFill 1.5s ease-out;
}

/* ===================================
   Notification Animation
   =================================== */

@keyframes slideInNotification {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutNotification {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.notification {
    animation: slideInNotification 0.3s ease-out;
}

.notification.hiding {
    animation: slideOutNotification 0.3s ease-out;
}

/* ===================================
   Modal Animation
   =================================== */

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

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

.modal-overlay {
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

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

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

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

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

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

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

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

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

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

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

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

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

/* ===================================
   Performance Optimizations
   =================================== */

/* Use GPU acceleration for animations */
.animate-fade-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-rotate,
.animate-float {
    will-change: transform, opacity;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===================================
   Custom Scrollbar
   =================================== */

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

/* ===================================
   Selection Styling
   =================================== */

::selection {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

::-moz-selection {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

/* ===================================
   Focus Styles
   =================================== */

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===================================
   Smooth Scroll Behavior
   =================================== */

html {
    scroll-behavior: smooth;
}

/* ===================================
   Loading State
   =================================== */

.loading {
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================================
   Success/Error States
   =================================== */

.success {
    animation: fadeInUp 0.5s ease-out;
}

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

/* ===================================
   Tooltip Animation
   =================================== */

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

.tooltip {
    animation: tooltipFadeIn 0.2s ease-out;
}

/* ===================================
   Dropdown Animation
   =================================== */

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

.dropdown {
    animation: dropdownSlideDown 0.3s ease-out;
}

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

@keyframes accordionSlide {
    from {
        max-height: 0;
    }
    to {
        max-height: 500px;
    }
}

.accordion-content {
    animation: accordionSlide 0.3s ease-out;
}

/* ===================================
   Tab Animation
   =================================== */

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

.tab-content {
    animation: tabFadeIn 0.3s ease-out;
}

/* ===================================
   Cursor Effects
   =================================== */

.cursor-pointer {
    cursor: pointer;
}

.cursor-grab {
    cursor: grab;
}

.cursor-grabbing {
    cursor: grabbing;
}

/* Custom Cursor (optional) */
.custom-cursor {
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.1s ease;
    mix-blend-mode: difference;
}

.cursor-dot {
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
}

/* ===================================
   Parallax Effect
   =================================== */

.parallax {
    transform: translateZ(0);
    will-change: transform;
}

/* ===================================
   Grain Texture Effect
   =================================== */

.grain::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

/* ===================================
   Glassmorphism Effect
   =================================== */

.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .glass {
    background: rgba(15, 23, 42, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===================================
   Neumorphism Effect
   =================================== */

.neumorphic {
    background: var(--bg-secondary);
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1),
                -5px -5px 10px rgba(255, 255, 255, 0.8);
}

.neumorphic-inset {
    background: var(--bg-secondary);
    box-shadow: inset 5px 5px 10px rgba(0, 0, 0, 0.1),
                inset -5px -5px 10px rgba(255, 255, 255, 0.8);
}

/* ===================================
   Clip Path Animations
   =================================== */

@keyframes clipPathReveal {
    from {
        clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
    }
    to {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

.clip-path-reveal {
    animation: clipPathReveal 1s ease-out;
}

/* ===================================
   Text Reveal Animation
   =================================== */

@keyframes textReveal {
    from {
        clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
    }
    to {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

.text-reveal {
    animation: textReveal 1s ease-out;
}

/* ===================================
   Magnetic Effect
   =================================== */

.magnetic {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   Stagger Children Animation
   =================================== */

.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
}

.stagger-children.active > *:nth-child(1) {
    animation-delay: 0.1s;
}

.stagger-children.active > *:nth-child(2) {
    animation-delay: 0.2s;
}

.stagger-children.active > *:nth-child(3) {
    animation-delay: 0.3s;
}

.stagger-children.active > *:nth-child(4) {
    animation-delay: 0.4s;
}

.stagger-children.active > *:nth-child(5) {
    animation-delay: 0.5s;
}

.stagger-children.active > *:nth-child(6) {
    animation-delay: 0.6s;
}

/* ===================================
   Infinite Scroll Animation
   =================================== */

@keyframes infiniteScroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

.infinite-scroll {
    animation: infiniteScroll 20s linear infinite;
}

/* ===================================
   Morphing Animation
   =================================== */

@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    50% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
}

.morph {
    animation: morph 8s ease-in-out infinite;
}

/* ===================================
   Wave Animation
   =================================== */

@keyframes wave {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.wave {
    animation: wave 2s ease-in-out infinite;
}

.wave:nth-child(2) {
    animation-delay: 0.1s;
}

.wave:nth-child(3) {
    animation-delay: 0.2s;
}

.wave:nth-child(4) {
    animation-delay: 0.3s;
}

.wave:nth-child(5) {
    animation-delay: 0.4s;
}