/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* PREVENCIÓN DE PARPADEO */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    overflow-x: hidden;
    /* Prevenir saltos de layout */
    overflow-anchor: none;
}

/* Estabilizar elementos animados */
.animate__animated {
    animation-fill-mode: both;
    animation-duration: 0.8s;
}

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    transition: background 0.3s ease;
    /* Prevenir saltos de layout */
    will-change: background;
    transform: translateZ(0);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
}

.logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.3s ease;
}

.logo a:hover {
    color: #3498db;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.3s ease;
}

.menu-toggle i {
    font-size: 1.5rem;
    color: #2c3e50;
    transition: transform 0.3s ease;
}

.menu-toggle.active i {
    transform: rotate(90deg);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(52, 152, 219, 0.1), transparent);
    transition: left 0.5s ease;
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link:hover,
.nav-link.active {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0 2rem;
    /* Optimización para animaciones */
    will-change: transform;
    transform: translateZ(0);
}

.hero-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.hero-text h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-text h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.slogan {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.8;
}

.typed-container {
    margin-bottom: 2rem;
}

.typed {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
    /* Prevenir parpadeo del cursor */
    min-height: 2rem;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-download:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.hero-image {
    text-align: center;
}

.hero-image img {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid rgba(255, 255, 255, 0.2);
}

/* Section Styles */
.section-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 5rem 2rem;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #2c3e50;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: #3498db;
}

/* About Section */
.about-section {
    background: #f8f9fa;
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
    align-items: start;
}

.about-info {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.about-info p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.about-story h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.about-story p {
    margin-bottom: 1.5rem;
    text-align: justify;
    line-height: 1.8;
}

/* Skills Section - OPTIMIZADA PARA PREVENIR PARPADEO */
.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.skill {
    text-align: center;
    padding: 2rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    /* Optimización para animaciones */
    will-change: transform;
    transform: translateZ(0);
}

.skill:hover {
    transform: translateY(-5px);
}

.skill-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #3498db;
}

.skill h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.skill-bar {
    background: #ecf0f1;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    /* Asegurar que el contenedor mantenga su tamaño */
    position: relative;
}

.skill-progress {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border-radius: 5px;
    /* CAMBIO IMPORTANTE: Eliminar transition inicial para prevenir parpadeo */
    transition: none;
    /* Optimización GPU */
    will-change: width;
    transform: translateZ(0);
}

/* Clase añadida via JavaScript para animación controlada */
.skill-progress.animated {
    transition: width 2s ease;
}

.skill-percentage {
    font-weight: bold;
    color: #3498db;
}

/* Projects Section */
.projects-section {
    background: #f8f9fa;
}

.projects-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.project-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    /* Optimización para animaciones */
    will-change: transform;
    transform: translateZ(0);
}

.project-card:hover {
    transform: translateY(-5px);
}

.project-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    /* Prevenir salto de layout mientras carga */
    display: block;
}

.project-info {
    padding: 1.5rem;
}

.project-info h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.project-info p {
    color: #666;
    margin-bottom: 1rem;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tech-badge {
    padding: 0.3rem 0.8rem;
    background: #3498db;
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
}

.btn-demo, .btn-repo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.9rem;
    margin-right: 1rem;
    transition: all 0.3s ease;
}

.btn-demo {
    background: #2ecc71;
    color: white;
}

.btn-repo {
    background: #34495e;
    color: white;
}

.btn-demo:hover {
    background: #27ae60;
}

.btn-repo:hover {
    background: #2c3e50;
}

/* Experience Section */
.timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background: #3498db;
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
    /* Optimización para animaciones */
    will-change: transform;
    transform: translateZ(0);
}

.timeline-marker {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 0 0 4px #3498db;
}

.timeline-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    width: 45%;
    margin-left: 55%;
}

.timeline-item:nth-child(even) .timeline-content {
    margin-left: 0;
    margin-right: 55%;
}

.timeline-content h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.timeline-date {
    color: #3498db;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.timeline-company {
    color: #666;
    font-style: italic;
    margin-bottom: 1rem;
}

/* Contact Section */
.contact-section {
    background: #2c3e50;
    color: white;
}

.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.contact-info p {
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.contact-item i {
    color: #3498db;
    font-size: 1.2rem;
}

.contact-form {
    background: white;
    padding: 2rem;
    border-radius: 10px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #ecf0f1;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.btn-submit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-submit:hover {
    background: #2980b9;
}

/* Message Styles */
.form-message {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 5px;
    border-left: 4px solid;
    animation: slideIn 0.3s ease;
}

.form-message.success {
    background: #d4edda;
    color: #155724;
    border-left-color: #28a745;
}

.form-message.error {
    background: #f8d7da;
    color: #721c24;
    border-left-color: #dc3545;
}

.form-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left-color: #17a2b8;
}

.message-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-message {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.close-message:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Honeypot field (hidden from users) */
.honeypot {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 3rem 0 2rem;
    border-top: 1px solid #34495e;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.social-icons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    border-radius: 50%;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    /* Optimización para animaciones */
    will-change: transform;
    transform: translateZ(0);
}

.social-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.social-icon:hover::before {
    left: 100%;
}

.social-icon:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Specific social media colors on hover */
.social-icon:hover:nth-child(1) {
    background: #333; /* GitHub */
}

.social-icon:hover:nth-child(2) {
    background: #0077b5; /* LinkedIn */
}

.social-icon:hover:nth-child(3) {
    background: #ea4335; /* Gmail */
}

.copyright {
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.6;
}

.copyright a {
    color: #3498db;
    text-decoration: none;
}

.copyright a:hover {
    text-decoration: underline;
}

/* MEJORAS PARA PREVENIR PARPADEO Y OPTIMIZAR PERFORMANCE */

/* Optimización general para elementos animados */
.animate__animated {
    /* Forzar aceleración por hardware */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Estabilizar alturas para prevenir saltos de layout */
.section-container {
    /* Asegurar altura mínima */
    min-height: 200px;
}

/* Optimización de imágenes */
img {
    /* Prevenir saltos de layout */
    max-width: 100%;
    height: auto;
    display: block;
}

/* Optimización de transiciones para elementos que cambian frecuentemente */
.nav-link,
.btn-download,
.btn-demo,
.btn-repo,
.social-icon {
    /* Optimización GPU */
    will-change: transform;
    transform: translateZ(0);
}

/* Suavizar scroll */
html {
    scroll-behavior: smooth;
}

/* Prevenir parpadeo en webkit */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Estabilizar elementos posicionados */
.timeline-marker,
.section-title::after {
    will-change: auto;
    transform: translateZ(0);
}

/* Optimización para reducir repaints */
.skill-bar,
.timeline::before,
.nav-link::before,
.social-icon::before {
    /* Separar en capas propias */
    isolation: isolate;
}