/* ===================================
   ESTILOS PERSONALIZADOS
   ================================== */

/* Variables CSS */
:root {
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --transition-speed: 0.3s;
}

/* Scroll suave */
html {
    scroll-behavior: smooth;
}

/* Ocultar scrollbar pero mantener funcionalidad */
body::-webkit-scrollbar {
    width: 10px;
}

body::-webkit-scrollbar-track {
    background: #1f2937;
}

body::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}

body::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* ===================================
   MENÚ MÓVIL
   ================================== */

/* Backdrop oscuro con blur */
.mobile-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Contenedor del menú móvil */
#mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-height: 0;
    overflow: hidden;
    z-index: 50;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55),
                opacity 0.3s ease,
                max-height 0.4s ease;
}

#mobile-menu.active {
    transform: translateY(0);
    opacity: 1;
    max-height: 100vh;
}

/* Animación de los enlaces del menú */
#mobile-menu a {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease, 
                opacity 0.4s ease,
                transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#mobile-menu.active a {
    opacity: 1;
    transform: translateX(0);
}

/* Efecto cascada para los enlaces */
#mobile-menu.active a:nth-child(1) { transition-delay: 0.1s; }
#mobile-menu.active a:nth-child(2) { transition-delay: 0.15s; }
#mobile-menu.active a:nth-child(3) { transition-delay: 0.2s; }
#mobile-menu.active a:nth-child(4) { transition-delay: 0.25s; }
#mobile-menu.active a:nth-child(5) { transition-delay: 0.3s; }

/* Hover effect mejorado */
#mobile-menu a:hover {
    transform: translateX(8px);
    padding-left: 1.5rem;
}

/* ===================================
   ANIMACIONES
   ================================== */

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

.fade-in {
    opacity: 1;
    animation: fadeIn 0.8s ease forwards;
}

/* Fallback para iOS - asegurar visibilidad */
@supports (-webkit-touch-callout: none) {
    .fade-in {
        opacity: 1 !important;
    }
}

/* Fade in desde la izquierda */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-left {
    opacity: 0;
}

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

/* Fade in desde la derecha */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-right {
    opacity: 0;
}

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

/* Pulse lento para la imagen de perfil */
@keyframes pulseSlow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.animate-pulse-slow {
    animation: pulseSlow 3s ease-in-out infinite;
}

/* Animación de estrellas */
.stars-container {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Mejor rendimiento y parallax: permitimos transformaciones en la capa de estrellas */
.stars-container {
    pointer-events: none;
    will-change: transform;
    transform: translateZ(0);
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
}

/* Variedades de tamaño para dar profundidad */
.star.small { width: 1px; height: 1px; opacity: 0.7; }
.star.medium { width: 2px; height: 2px; opacity: 0.9; }
.star.large { width: 3px; height: 3px; opacity: 1; }

@keyframes twinkle {
    0%, 100% {
        opacity: 0;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.5);
    }
}

/* Transición suave entre secciones: la sección siguiente empieza desplazada y se anima al entrar */
.section-enter {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 700ms cubic-bezier(0.22, 1, 0.36, 1), transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}
.section-enter.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Cursor typing */
.typing-cursor {
    animation: blink 1s infinite;
}

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

/* ===================================
   COMPONENTES
   ================================== */

/* Títulos de sección */
.section-title {
    font-size: 2.5rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
    display: inline-block;
    width: 100%;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(to right, var(--primary), var(--accent));
    border-radius: 2px;
}

/* Botones */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: transparent;
    color: white;
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
}

.btn-secondary:hover {
    background: var(--primary);
    transform: translateY(-2px);
}

/* Iconos sociales */
.social-icon {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    color: #9ca3af;
    transition: all var(--transition-speed) ease;
    position: relative;
    overflow: hidden;
}

.social-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.social-icon:hover {
    transform: translateY(-4px) scale(1.1);
    color: white;
}

.social-icon:hover::before {
    opacity: 1;
}

.social-icon i {
    position: relative;
    z-index: 1;
}

/* Tarjetas de estadísticas */
.stat-card {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition-speed) ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Tarjetas de habilidades */
.skill-card {
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 1rem;
    padding: 2rem;
    transition: all var(--transition-speed) ease;
    backdrop-filter: blur(10px);
    opacity: 1;
    visibility: visible;
}

/* Fallback para iOS */
@supports (-webkit-touch-callout: none) {
    .skill-card {
        opacity: 1 !important;
        visibility: visible !important;
    }
}

.skill-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    background: rgba(31, 41, 55, 0.8);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.2);
}

/* Barras de progreso */
.skill-bar {
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.skill-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
    animation: shimmer 2s infinite;
}

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

/* Filtros de proyectos */
.filter-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 0.5rem;
    color: #9ca3af;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
}

.filter-btn:hover {
    color: white;
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Tarjetas de proyectos */
.project-card {
    opacity: 1;
    animation: fadeIn 0.6s ease forwards;
    transition: all var(--transition-speed) ease;
}

/* Fallback para iOS */
@supports (-webkit-touch-callout: none) {
    .project-card {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }
}

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

/* Interacción con proyectos */
.project-item {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.project-content {
    pointer-events: none;
}

.project-content a,
.project-content .pointer-events-auto {
    pointer-events: auto;
}

/* Hover effect para desktop */
@media (hover: hover) and (pointer: fine) {
    .project-item:hover .project-content {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }
    
    .project-item:hover .project-bg img {
        filter: blur(4px);
        transform: scale(1.1);
    }
    
    .project-item:hover .project-bg .absolute {
        background: linear-gradient(to top, rgba(17, 24, 39, 0.95), rgba(17, 24, 39, 0.8), rgba(17, 24, 39, 0.6)) !important;
    }
}

/* Efecto blur para imágenes de fondo en proyectos */
.project-card .group:hover img {
    filter: blur(4px);
}

/* Altura mínima para las tarjetas de proyectos */
.project-card > div {
    min-height: 280px;
}

/* ===================================
   EFECTOS DE GLASSMORPHISM
   ================================== */

.glass {
    background: rgba(31, 41, 55, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===================================
   EFECTOS DE HOVER
   ================================== */

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

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

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

/* ===================================
   UTILIDADES
   ================================== */

/* Gradientes de texto */
.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Separador con gradiente */
.gradient-divider {
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--primary), 
        var(--accent), 
        transparent
    );
}

/* ===================================
   RESPONSIVE
   ================================== */

@media (max-width: 768px) {
    .section-title {
        font-size: 2rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
    }
    
    .skill-card {
        padding: 1.5rem;
    }
}

/* ===================================
   EFECTOS DE PARTÍCULAS (OPCIONAL)
   ================================== */

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

.floating {
    animation: float 6s ease-in-out infinite;
}

/* ===================================
   LOADER (OPCIONAL)
   ================================== */

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(99, 102, 241, 0.2);
    border-bottom-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

/* ===================================
   FIX PARA iOS/SAFARI
   ================================== */

/* Asegurar que los contenedores sean visibles en iOS */
@supports (-webkit-touch-callout: none) {
    #skills-container,
    #projects-container {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .skill-card,
    .project-card {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
    
    /* Mejorar táctil en iOS */
    .project-item {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        /*-webkit-user-select: none;*/
        touch-action: manipulation;
    }
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ===================================
   TRANSICIONES SUAVES
   ================================== */

* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-duration: 150ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Eliminar transición para transforms y opacity para mejor rendimiento */
.no-transition {
    transition: none !important;
}
