/* --- Variables y Estilos Globales --- */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --background-color: #ffffff;
    --text-color: #333;
    --light-gray: #f4f4f4;
    --font-family: 'Poppins', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.6;
    overflow-x: hidden;
    /* Evita scroll horizontal en móviles */
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

section {
    padding: 6rem 0;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.section-description {
    text-align: center;
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 3rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Header y Navegación --- */
.header {
    background-color: var(--background-color);
    padding: 1rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    /* Para posicionar el menú móvil */
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.8s ease;
    /* transición suave al colapsar */
    display: inline-block;
    white-space: nowrap;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    transition: color 0.3s ease;
}

.nav-menu a:hover {
    color: var(--secondary-color);
}

/* --- Botón de Hamburguesa --- */
.hamburger-menu {
    display: none;
    /* Oculto por defecto en desktop */
    width: 30px;
    height: 20px;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    z-index: 1001;
    /* Asegura que esté encima del menú */
    padding: 0;
    /* Remover padding por defecto del botón */
}

.hamburger-menu span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

.hamburger-menu.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* --- Sección Hero (Inicio) --- */
.hero {
    padding-top: 10rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    /* Fondo suave opcional */
    background: linear-gradient(-45deg, #0d0d0d, #111827, #1e3a8a, #0ea5e9);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.hero-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .1rem;
}

.hero-text h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    color: #ffffff;
}

.hero-text h1 span {
    display: block;
}

.hero-text h1 span strong {
    color: var(--secondary-color);
}

.hero-text p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #fefefe;
}

.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: #fff;
    padding: 0.8rem 1.8rem;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-3px);
}

.btn-small {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
}

.hero-image img {
    max-width: 550px;
}

/* --- Servicios --- */
.services{
    background-color: var(--light-gray);
}
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.service-card {
    background-color: #fff;
    padding: 2.5rem;
    text-align: center;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.service-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.service-card .icon {
    font-size: 3rem;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
    /* La animación se aplicará con .reveal.visible */
}

/* --- Portfolio --- */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.portfolio-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.portfolio-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 62, 80, 0.85);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.portfolio-item:hover .portfolio-overlay {
    opacity: 1;
}

.portfolio-item:hover img {
    transform: scale(1.1);
}

.portfolio-overlay h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* --- Demos Interactivos --- */
.demos{
    background-color: var(--light-gray);
}
.demos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.demo-card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.demo-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.demo-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.demo-info {
    padding: 1.5rem;
}

.demo-info h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.demo-info p {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 1rem;
}

.demo-info .tech-used {
    font-size: 0.85rem;
    color: #888;
    margin-top: -0.5rem;
    margin-bottom: 1.2rem;
}

/* --- Sobre mí --- */
.about-text {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    font-size: 1.1rem;
}

.about-headline {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 600;
    color: #222;
    margin: 20px auto 30px auto;
    max-width: 700px;
    line-height: 1.4;
    position: relative;
}

.about-headline::after {
    content: "";
    display: block;
    width: 60px;
    height: 3px;
    background-color: #0077b6; /* Color de acento */
    margin: 10px auto 0 auto;
    border-radius: 2px;
}
/* --- Contacto --- */
.contact p {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.contact-form {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #fff;
    padding: 2.5rem;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.contact-form input,
.contact-form textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.contact-form textarea {
    resize: vertical;
    min-height: 120px;
}

/* --- Footer --- */
.footer {
    background-color: var(--primary-color);
    color: #fff;
    text-align: center;
    padding: 3rem 0;
}

.social-icons {
    margin-bottom: 1.5rem;
}

.social-icons a {
    color: #fff;
    font-size: 1.8rem;
    margin: 0 0.8rem;
    transition: color 0.3s ease, transform 0.3s ease;
}

.social-icons a:hover {
    color: var(--secondary-color);
    transform: scale(1.2);
}

.footer p {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* --- Animaciones de Scroll --- */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Animaciones específicas al hacer scroll */
.service-card.reveal.visible .icon {
    animation: bounceIn 0.8s ease-out forwards;
}

.tech-category.reveal.visible .tech-icons i {
    animation: fadeInScale 0.8s ease-out forwards;
    /* Añadir delay para escalonar animaciones */
}

/* Delays para iconos de Lenguajes */
.tech-category:nth-child(1).reveal.visible .tech-icons i:nth-child(1) {
    animation-delay: 0.1s;
}

.tech-category:nth-child(1).reveal.visible .tech-icons i:nth-child(2) {
    animation-delay: 0.2s;
}

.tech-category:nth-child(1).reveal.visible .tech-icons i:nth-child(3) {
    animation-delay: 0.3s;
}

.tech-category:nth-child(1).reveal.visible .tech-icons i:nth-child(4) {
    animation-delay: 0.4s;
}

/* Delays para iconos de Frameworks & Librerías */
.tech-category:nth-child(2).reveal.visible .tech-icons i:nth-child(1) {
    animation-delay: 0.1s;
}

.tech-category:nth-child(2).reveal.visible .tech-icons i:nth-child(2) {
    animation-delay: 0.2s;
}

.tech-category:nth-child(2).reveal.visible .tech-icons i:nth-child(3) {
    animation-delay: 0.3s;
}

/* Delays para iconos de Diseño UX/UI */
.tech-category:nth-child(3).reveal.visible .tech-icons i:nth-child(1) {
    animation-delay: 0.1s;
}

.tech-category:nth-child(3).reveal.visible .tech-icons i:nth-child(2) {
    animation-delay: 0.2s;
}

/* Delays para iconos de Herramientas */
.tech-category:nth-child(4).reveal.visible .tech-icons i:nth-child(1) {
    animation-delay: 0.1s;
}

.tech-category:nth-child(4).reveal.visible .tech-icons i:nth-child(2) {
    animation-delay: 0.2s;
}

.tech-category:nth-child(4).reveal.visible .tech-icons i:nth-child(3) {
    animation-delay: 0.3s;
}

/* Delays para iconos de Bases de Datos & CMS */
.tech-category:nth-child(5).reveal.visible .tech-icons i:nth-child(1) {
    animation-delay: 0.1s;
}

.tech-category:nth-child(5).reveal.visible .tech-icons i:nth-child(2) {
    animation-delay: 0.2s;
}

.tech-category:nth-child(5).reveal.visible .tech-icons i:nth-child(3) {
    animation-delay: 0.3s;
}


/* --- Botón Volver Arriba --- */
.back-to-top {
    display: none;
    /* Oculto por defecto, JS lo mostrará */
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
    z-index: 999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    /* Ocultar inicialmente para la animación de JS */
}

.back-to-top:hover {
    background-color: var(--secondary-color);
    transform: translateY(-5px);
}

.back-to-top.show {
    display: flex;
    /* Mostrar cuando tenga la clase 'show' */
    opacity: 1;
}

/* --- Keyframes para Animaciones --- */
@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Diseño Responsivo --- */
@media (max-width: 768px) {
    .section-title {
        font-size: 2rem;
    }

    .section-description {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .hero {
        padding-top: 8rem;
    }

    .hero-content {
        flex-direction: column-reverse;
        text-align: center;
    }

    .hero-text h1 {
        font-size: 2.8rem;
    }

    .hero-image {
        margin-top: 0;
        margin-bottom: 2rem;
    }

    .hero-image img {
        max-width: 280px;
    }

    /* Mostrar botón de hamburguesa y ocultar menú normal */
    .hamburger-menu {
        display: flex;
    }

    .nav-menu {
        display: none;
        /* Oculto por defecto en móvil */
        flex-direction: column;
        background-color: var(--background-color);
        position: absolute;
        top: 100%;
        /* Debajo del header */
        left: 0;
        width: 100%;
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.05);
        padding: 1rem 2rem;
        border-top: 1px solid var(--light-gray);
        transform: translateY(-10px);
        /* Inicialmente un poco arriba */
        opacity: 0;
        pointer-events: none;
        /* No interactuable hasta que sea visible */
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .nav-menu.active {
        display: flex;
        /* Mostrar cuando esté activo */
        opacity: 1;
        transform: translateY(0);
        pointer-events: all;
    }

    .nav-menu li {
        margin: 0.5rem 0;
    }

    .nav-menu a {
        display: block;
        padding: 0.5rem 0;
        font-size: 1.1rem;
        text-align: center;
    }


    /* Ajustes para las nuevas secciones en móvil */
    .demos-grid,
    .tech-grid,
    .services-grid {
        /* Ahora también servicios */
        grid-template-columns: 1fr;
    }

    .demo-card img {
        height: 180px;
    }

    .tech-category {
        padding: 1.5rem;
    }

    .tech-icons i {
        font-size: 2rem;
    }

    .contact-form {
        padding: 1.5rem;
    }

    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .hero-text h1 {
        font-size: 2.4rem;
    }

    .hero-text p {
        font-size: 1rem;
    }

    .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }

    .container {
        padding: 0 1rem;
        /* Menos padding en pantallas muy pequeñas */
    }
}


.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    background: #1e1e1e;
    border-radius: 10px;
    max-width: 900px;
    width: 90%;
    padding: 20px;
    color: #fff;
    animation: fadeIn 0.3s ease-in-out;
    text-align: center;
}

.modal-content img {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    margin: 15px 0;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #fff;
}

.nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    user-select: none;
}

.nav:hover {
    background: rgba(0, 0, 0, 0.7);
}

.prev {
    left: 10px;
}

.next {
    right: 10px;
}

#modal-body h4 {
    font-size: 18px;
    font-weight: normal;
    margin-bottom: 15px;
    color: #ccc;
}

.modal-content h2 {
    margin-top: 10px;
    font-size: 24px;
    color: var(--secondary-color, #00bfff);
}

.modal-content p {
    font-size: 16px;
    margin: 10px 0;
}

.modal-content .view-project {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 18px;
    background: var(--secondary-color, #00bfff);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.3s;
}

.modal-content .view-project:hover {
    background: #0099cc;
}

/* Estilo para ocultar el campo anti-spam (Honeypot) */
.honeypot {
    display: none;
}

/* Estilos para los mensajes de éxito y error del formulario */
.success-message {
    padding: 15px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

.error-message {
    padding: 15px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}