/* ========================================
   ANIMACIONES - PORTAFOLIO MARK ORSINI
   Autor: Mark Orsini Carrillo
   Descripción: Animaciones y efectos visuales
   ======================================== */

/* ============ ANIMACIONES DE ENTRADA ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

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

/* ============ ANIMACIONES DE HOVER ============ */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.6);
    }
}

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

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

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

@keyframes swing {
    20% { transform: rotate(15deg); }
    40% { transform: rotate(-10deg); }
    60% { transform: rotate(5deg); }
    80% { transform: rotate(-5deg); }
    100% { transform: rotate(0deg); }
}

/* ============ ANIMACIONES DE FONDO ============ */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes floatParticle {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    33% {
        transform: translate(30px, -30px) rotate(120deg);
    }
    66% {
        transform: translate(-20px, 20px) rotate(240deg);
    }
}

@keyframes waveAnimation {
    0% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(-25%) translateY(-10px);
    }
    100% {
        transform: translateX(-50%) translateY(0);
    }
}

/* ============ ANIMACIONES DE TEXTO ============ */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

@keyframes glitch {
    0% {
        transform: translate(0);
    }
    20% {
        transform: translate(-2px, 2px);
    }
    40% {
        transform: translate(-2px, -2px);
    }
    60% {
        transform: translate(2px, 2px);
    }
    80% {
        transform: translate(2px, -2px);
    }
    100% {
        transform: translate(0);
    }
}

/* ============ ANIMACIONES DE CARGA ============ */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============ ANIMACIONES 3D ============ */
@keyframes flip {
    0% {
        transform: perspective(400px) rotateY(0);
    }
    100% {
        transform: perspective(400px) rotateY(360deg);
    }
}

@keyframes flipInY {
    from {
        transform: perspective(400px) rotateY(90deg);
        opacity: 0;
    }
    to {
        transform: perspective(400px) rotateY(0);
        opacity: 1;
    }
}

@keyframes rollIn {
    from {
        opacity: 0;
        transform: translateX(-100%) rotate(-120deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) rotate(0);
    }
}

/* ============ CLASES DE ANIMACIÓN REUTILIZABLES ============ */
.animate-fade-in {
    animation: fadeIn 0.6s ease-in;
}

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

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

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

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

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

.animate-rotate-in {
    animation: rotateIn 0.6s ease-out;
}

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

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

.animate-spin {
    animation: spin 1s linear infinite;
}

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

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

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

/* ============ DELAYS PARA ANIMACIONES ESCALONADAS ============ */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }

/* ============ EFECTOS HOVER ESPECIALES ============ */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.hover-grow {
    transition: transform 0.3s ease;
}

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

.hover-shrink {
    transition: transform 0.3s ease;
}

.hover-shrink:hover {
    transform: scale(0.95);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

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

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    animation: pulseGlow 1.5s infinite;
}

/* ============ EFECTOS DE PARALLAX ============ */
.parallax-slow {
    transition: transform 0.1s ease-out;
}

.parallax-medium {
    transition: transform 0.2s ease-out;
}

.parallax-fast {
    transition: transform 0.3s ease-out;
}

/* ============ ANIMACIONES DE SCROLL ============ */
.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

.scroll-fade {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.scroll-fade.visible {
    opacity: 1;
}

/* ============ ANIMACIONES PARA ELEMENTOS ESPECÍFICOS ============ */

/* Animación para barras de progreso */
.progress-bar-animated {
    background-size: 200% 100%;
    animation: gradientShift 2s linear infinite;
}

/* Animación para badges */
.badge-float {
    animation: bounce 2s ease-in-out infinite;
}

/* Animación para iconos */
.icon-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.icon-spin {
    animation: spin 2s linear infinite;
}

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

/* ============ ANIMACIONES DE PARTÍCULAS ============ */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-primario);
    border-radius: 50%;
    opacity: 0.6;
    animation: floatParticle 20s infinite;
}

.particle:nth-child(2) {
    animation-delay: 2s;
    animation-duration: 15s;
}

.particle:nth-child(3) {
    animation-delay: 4s;
    animation-duration: 25s;
}

/* ============ EFECTOS DE TEXTO ANIMADO ============ */
.text-gradient-animate {
    background: linear-gradient(
        90deg,
        var(--color-primario),
        var(--color-secundario),
        var(--color-primario)
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s linear infinite;
}

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

@keyframes textGlow {
    0%, 100% {
        text-shadow: 0 0 10px var(--color-primario),
                     0 0 20px var(--color-primario);
    }
    50% {
        text-shadow: 0 0 20px var(--color-primario),
                     0 0 40px var(--color-primario);
    }
}

/* ============ ANIMACIONES DE BOTONES ============ */
.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: 300px;
    height: 300px;
}

/* ============ ANIMACIONES DE TRANSICIÓN DE PÁGINA ============ */
.page-transition-enter {
    animation: fadeInUp 0.6s ease-out;
}

.page-transition-exit {
    animation: fadeOut 0.4s ease-in;
}

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

/* ============ EFECTOS DE GLASSMORPHISM ANIMADO ============ */
.glass-morph {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.glass-morph:hover {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    transform: translateY(-5px);
}

/* ============ ANIMACIONES PARA MODO MÓVIL ============ */
@media (max-width: 768px) {
    /* Reducir intensidad de animaciones en móvil */
    .hover-lift:hover {
        transform: translateY(-5px);
    }
    
    .hover-grow:hover {
        transform: scale(1.03);
    }
    
    /* Animaciones más rápidas en móvil */
    .animate-fade-in-up,
    .animate-fade-in-down,
    .animate-fade-in-left,
    .animate-fade-in-right {
        animation-duration: 0.5s;
    }
}

/* ============ ANIMACIONES SUAVES PARA SCROLL ============ */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ============ EFECTOS DE CARGA SKELETON ============ */
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

/* ============ ANIMACIONES DE NOTIFICACIÓN ============ */
@keyframes slideInFromTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.notification-enter {
    animation: slideInFromTop 0.4s ease-out;
}

.notification-exit {
    animation: slideOutToTop 0.4s ease-in;
}

/* ============ EFECTOS DE CURSOR PERSONALIZADO ============ */
.cursor-pointer {
    cursor: pointer;
}

.cursor-trail {
    pointer-events: none;
    position: fixed;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primario);
    opacity: 0.5;
    transition: transform 0.1s ease-out;
    z-index: 9999;
}

/* ============ ANIMACIONES ESPECÍFICAS PARA PORTAFOLIO ============ */

/* Animación para imagen de perfil */
.profile-image-float {
    animation: floatParticle 6s ease-in-out infinite;
}

/* Animación para indicador de scroll */
.scroll-indicator {
    animation: bounce 2s infinite;
}

/* Animación para tarjetas de proyecto */
.project-card-enter {
    animation: fadeInUp 0.6s ease-out;
}

/* Animación para skills bars */
.skill-bar-fill {
    animation: fillSkillBar 1.5s ease-out forwards;
}

@keyframes fillSkillBar {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============ TRANSICIONES SUAVES GLOBALES ============ */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ DESACTIVAR ANIMACIONES SI EL USUARIO LO PREFIERE ============ */
@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;
    }
}