/**
 * Animations - JonitoDEV Portfolio
 * Soft, elegant, and calming animations
 */

/* =====================================================
   Keyframe Animations - Gentle & Smooth
   ===================================================== */

/* Fade Animations - Soft and subtle */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale Animations - Delicate scaling */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Gentle Rotate */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.95);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Soft Bounce */
@keyframes softBounce {
    0%, 20%, 53%, 100% {
        animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
        transform: translateY(0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
        transform: translateY(-12px);
    }
    70% {
        animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
        transform: translateY(-5px);
    }
    90% {
        transform: translateY(-2px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.03);
    }
    70% {
        transform: scale(0.98);
    }
    100% {
        transform: scale(1);
    }
}

/* Gentle Pulse */
@keyframes gentlePulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--primary-glow);
    }
    70% {
        transform: scale(1.02);
        box-shadow: 0 0 0 12px transparent;
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 transparent;
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 10px 30px var(--primary-glow);
    }
    50% {
        box-shadow: 0 15px 45px var(--primary-glow);
    }
}

/* Gentle Float - Dreamy movement */
@keyframes gentleFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-16px);
    }
}

@keyframes floatSlow {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-8px) rotate(2deg);
    }
}

/* Soft Sway */
@keyframes sway {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

/* Subtle Shake */
@keyframes gentleShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
    20%, 40%, 60%, 80% { transform: translateX(3px); }
}

/* Slide Animations - Smooth slides */
@keyframes slideInLeft {
    from {
        transform: translateX(-60px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(60px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(60px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Gentle Wave */
@keyframes wave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(10deg); }
    20% { transform: rotate(-6deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-3deg); }
    50% { transform: rotate(6deg); }
    60% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* Soft Gradient Shift */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Breathing Glow */
@keyframes breathe {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.03);
    }
}

/* Typing Cursor - Soft blink */
@keyframes blink {
    0%, 45% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Soft Ripple */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.4;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* Gentle Morph */
@keyframes morph {
    0%, 100% {
        border-radius: 40% 60% 70% 30% / 40% 40% 60% 50%;
    }
    34% {
        border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%;
    }
    67% {
        border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%;
    }
}

/* Drift - Slow floating movement */
@keyframes drift {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(10px, -10px) rotate(2deg); }
    50% { transform: translate(20px, 0) rotate(0deg); }
    75% { transform: translate(10px, 10px) rotate(-2deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Shimmer - Subtle shine effect */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* =====================================================
   Animation Classes
   ===================================================== */

.animate-fadeIn { animation: fadeIn 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-fadeInUp { animation: fadeInUp 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-fadeInDown { animation: fadeInDown 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-fadeInLeft { animation: fadeInLeft 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-fadeInRight { animation: fadeInRight 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-scaleIn { animation: scaleIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-zoomIn { animation: zoomIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-bounceIn { animation: bounceIn 0.9s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.animate-pulse { animation: gentlePulse 2.5s infinite; }
.animate-float { animation: gentleFloat 7s ease-in-out infinite; }
.animate-spin { animation: spin 1.5s linear infinite; }
.animate-breathe { animation: breathe 4s ease-in-out infinite; }
.animate-drift { animation: drift 20s ease-in-out 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-fast { animation-duration: 0.4s; }
.duration-normal { animation-duration: 0.7s; }
.duration-slow { animation-duration: 1.2s; }
.duration-slower { animation-duration: 2s; }

/* =====================================================
   Hover Animations - Gentle interactions
   ===================================================== */

/* Soft Lift Effect */
.hover-lift {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(61, 61, 61, 0.1);
}

/* Soft Glow Effect */
.hover-glow {
    transition: box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-glow:hover {
    box-shadow: 0 10px 40px var(--primary-glow);
}

/* Gentle Scale Effect */
.hover-scale {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-scale:hover {
    transform: scale(1.03);
}

/* Subtle Rotate Effect */
.hover-rotate {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-rotate:hover {
    transform: rotate(3deg);
}

/* Soft Shake on Hover */
.hover-shake:hover {
    animation: gentleShake 0.6s ease;
}

/* Gentle Bounce on Hover */
.hover-bounce:hover {
    animation: softBounce 0.7s ease;
}

/* Wave on Hover (for emoji) */
.hover-wave:hover {
    animation: wave 2s ease infinite;
    transform-origin: 70% 70%;
    display: inline-block;
}

/* =====================================================
   Scroll Triggered Animations
   ===================================================== */

.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-right.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.92);
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-scale.active {
    opacity: 1;
    transform: scale(1);
}

/* Staggered Children - Graceful sequential reveal */
.stagger-children > * {
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-children.active > *:nth-child(1) { transition-delay: 0.1s; opacity: 1; transform: translateY(0); }
.stagger-children.active > *:nth-child(2) { transition-delay: 0.2s; opacity: 1; transform: translateY(0); }
.stagger-children.active > *:nth-child(3) { transition-delay: 0.3s; opacity: 1; transform: translateY(0); }
.stagger-children.active > *:nth-child(4) { transition-delay: 0.4s; opacity: 1; transform: translateY(0); }
.stagger-children.active > *:nth-child(5) { transition-delay: 0.5s; opacity: 1; transform: translateY(0); }
.stagger-children.active > *:nth-child(6) { transition-delay: 0.6s; opacity: 1; transform: translateY(0); }
.stagger-children.active > *:nth-child(7) { transition-delay: 0.7s; opacity: 1; transform: translateY(0); }
.stagger-children.active > *:nth-child(8) { transition-delay: 0.8s; opacity: 1; transform: translateY(0); }

/* =====================================================
   Button Animations - Soft interactions
   ===================================================== */

/* Soft Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
}

.btn-ripple:active::after {
    animation: ripple 0.7s ease-out;
}

/* Gentle Shine Effect */
.btn-shine {
    position: relative;
    overflow: hidden;
}

.btn-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255, 255, 255, 0.25),
        transparent
    );
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-shine:hover::before {
    left: 100%;
}

/* Soft Fill Effect */
.btn-fill {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.btn-fill:hover::before {
    transform: scaleX(1);
    transform-origin: left;
}

/* =====================================================
   Text Animations - Elegant typography
   ===================================================== */

/* Soft Gradient Text Animation */
.text-gradient-animate {
    background: linear-gradient(
        90deg,
        var(--primary),
        var(--secondary),
        var(--accent-mint),
        var(--primary)
    );
    background-size: 300% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 5s linear infinite;
}

/* Gentle Typing Cursor */
.typed-cursor {
    animation: blink 0.9s infinite;
    color: var(--primary);
}

/* Soft Highlight Effect */
.text-highlight {
    position: relative;
    display: inline-block;
}

.text-highlight::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 0;
    height: 35%;
    background: var(--primary-light);
    z-index: -1;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
}

.text-highlight:hover::after {
    width: 100%;
}

/* Underline Animation */
.text-underline {
    position: relative;
    display: inline-block;
}

.text-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--radius-full);
}

.text-underline:hover::after {
    width: 100%;
}

/* =====================================================
   Card Animations - Elegant cards
   ===================================================== */

/* Soft 3D Tilt */
.card-tilt {
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-tilt:hover {
    transform: perspective(1000px) rotateX(3deg) rotateY(-3deg);
}

/* Gentle Flip Card */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
    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%;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
}

.flip-card-back {
    transform: rotateY(180deg);
}

/* =====================================================
   Loading Animations - Gentle loaders
   ===================================================== */

/* Soft Spinner */
.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

/* Gentle Dots Loader */
.dots-loader {
    display: flex;
    gap: 8px;
}

.dots-loader span {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    animation: softBounce 0.6s ease infinite alternate;
}

.dots-loader span:nth-child(2) {
    animation-delay: 0.15s;
}

.dots-loader span:nth-child(3) {
    animation-delay: 0.3s;
}

/* Soft Bar Loader */
.bar-loader {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.bar-loader::after {
    content: '';
    display: block;
    width: 35%;
    height: 100%;
    background: var(--gradient-primary);
    animation: barLoading 1.8s ease infinite;
    border-radius: var(--radius-full);
}

@keyframes barLoading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Skeleton Loading - Soft shimmer */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s ease infinite;
    border-radius: var(--radius-md);
}

/* =====================================================
   Special Effects - Subtle & Elegant
   ===================================================== */

/* Soft Glow */
.soft-glow {
    box-shadow: 
        0 0 20px var(--primary-glow),
        0 0 40px rgba(124, 154, 130, 0.1);
}

/* Ambient Light Effect */
.ambient-light {
    position: relative;
}

.ambient-light::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at center,
        var(--primary-light) 0%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.ambient-light:hover::before {
    opacity: 1;
}

/* Subtle Noise Overlay */
.noise {
    position: relative;
}

.noise::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    border-radius: inherit;
}

/* Soft Blur Background */
.blur-bg {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: var(--bg-glass);
}

/* Glass Card Effect */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

/* Decorative Blob */
.blob {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    animation: morph 8s ease-in-out infinite;
}

/* =====================================================
   Page Transition
   ===================================================== */
.page-transition {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =====================================================
   Scroll Behavior
   ===================================================== */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* =====================================================
   Reduced Motion Support - Accessibility
   ===================================================== */
@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;
    }
    
    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale,
    .stagger-children > * {
        opacity: 1;
        transform: none;
    }
}
