/* ==========================================
   RESET GENERAL & ANTI-DESBORDE HORIZONTAL
   ========================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: hidden; /* Corta de raíz cualquier desborde horizontal residual */
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: #121212;
    color: #fff;
    scroll-behavior: smooth;
    text-align: center;
}

/* --- Barra de navegación --- */
header.navbar {
    position: fixed;
    background: rgba(18,18,18,0.95);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 85px;
    padding: 5px 5%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    width: 100%;
    z-index: 1002;
}

#main-title {
    font-size: 6rem;
    text-align: center;
    margin-top: 50px;
    color: white;
    font-weight: bold;
    word-wrap: break-word;
}

@media (max-width: 1024px) {
    #main-title {
        font-size: 4rem;
    }
}

@media (max-width: 768px) {
    #main-title {
        font-size: 2.8rem;
    }
}

@media (max-width: 480px) {
    #main-title {
        font-size: 2rem;
    }
}

.navbar .logo {
    font-weight: bold;
    font-size: 1.4em;
    color: #81b8b2;
    cursor: pointer;
}

.navbar nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    z-index: 1000;
}

.navbar nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 15px;
    justify-content: flex-end;
    align-items: center;
}

.navbar nav ul li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar nav ul li a {
    display: inline-block;
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    transition: color 0.3s, transform 0.3s;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 1001;
}

.navbar nav ul li a:hover {
    color: #81b8b2;
    transform: scale(1.05);
}

header {
    position: relative;
    z-index: 1002;
}

/* Si tienes un overlay o menú móvil abierto: */
.menu-toggle {
    position: relative;
    z-index: 1100;
}

/* Hamburger icon */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    z-index: 1001;
}

.hamburger div {
    width: 28px;
    height: 3px;
    background-color: white;
    margin: 4px 0;
    transition: 0.4s;
}

/* --- Responsive navbar (móviles) --- */
@media (max-width: 768px) {
    .navbar {
        flex-direction: row;
        padding: 10px 5%;
    }

    .navbar nav {
        flex-grow: 1;
        justify-content: flex-end;
        position: static;
    }

    .navbar nav ul {
        flex-direction: column;
        align-items: center;
        max-height: 0;
        overflow: hidden;
        background-color: #1c1c1c;
        width: 100%;
        position: absolute;
        top: 85px;
        left: 0;
        padding: 0;
        margin: 0;
        transition: max-height 0.5s ease-out, padding 0.3s ease-out;
        z-index: 999;
    }

    .navbar nav ul.show {
        max-height: 600px;
        padding: 20px 0;
    }

    .navbar nav ul li {
        width: 90%;
        text-align: center;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .navbar nav ul li:last-child {
        border-bottom: none;
    }

    .navbar nav ul li a {
        display: block;
        width: 100%;
        padding: 10px 0;
    }

    .hamburger {
        display: flex;
    }
}

/* --- Sección Hero (Presentación Personal) --- */
.hero {
    position: relative;
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    text-align: center;
    background-color: #121212;
}

.background-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    opacity: 0.5;
    filter: brightness(0.6);
}

.hero-content {
    position: relative;
    z-index: 1;
    color: white;
    padding: 0 20px;
    max-width: 800px;
    margin-top: 85px;
}

.hero h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.hero p {
    font-size: 1.2em;
    line-height: 1.5;
    margin-bottom: 20px;
}

.hero img {
    border-radius: 50%;
    margin-top: 20px;
    width: 200px;
    height: 200px;
    object-fit: cover;
    border: 3px solid #81b8b2;
}

/* --- Animaciones de scroll para todas las secciones --- */
section {
    padding: 100px 20px;
    opacity: 0;
    transform: translateY(50px);
    transition: all 1s ease;
}

section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Ajustes generales para títulos de sección (h2) --- */
section h2 {
    font-size: 2.8em;
    margin-bottom: 40px;
    color: #81b8b2;
    text-align: center;
}

/* ==========================================
   MÓDULO "SOBRE MÍ" & TARJETA RESPONSIVA 
   ========================================== */
.about-content {
    display: flex;
    flex-direction: column; /* Columna por defecto en móviles */
    justify-content: center;
    align-items: center;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.about-text {
    width: 100%;
    max-width: 600px;
    text-align: justify;
}

.about-image {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* --- Tarjeta Adaptable (Evita cortes y desbordes) --- */
.card {
    width: 100%;
    max-width: 320px; /* Tamaño responsivo perfecto en smartphones */
    aspect-ratio: 1 / 1; /* Forzamos un contenedor cuadrado perfecto */
    background: #171717;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: 0px 0px 3px 1px #00000088;
    cursor: pointer;
    border-radius: 5px;
}

.card .content {
    border-radius: 5px;
    background: #171717;
    width: 92%;
    height: 92%;
    z-index: 1;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.card .content img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

/* Efectos de brillo hover */
.content::before {
    opacity: 0;
    transition: opacity 300ms;
    content: " ";
    display: block;
    background: white;
    width: 5px;
    height: 50px;
    position: absolute;
    filter: blur(50px);
    overflow: hidden;
}

.card:hover .content::before {
    opacity: 1;
}

.card::before {
    opacity: 0;
    content: " ";
    position: absolute;
    display: block;
    width: 150px;
    height: 400px;
    background: linear-gradient(#ff2288, #387ef0);
    transition: opacity 300ms;
    animation: rotation_9018 8000ms infinite linear;
    animation-play-state: paused;
}

.card:hover::before {
    opacity: 1;
    animation-play-state: running;
}

/* Solución definitiva al desborde: El blur se adapta al 100% de la tarjeta */
.card::after {
    position: absolute;
    content: " ";
    display: block;
    width: 100%;
    height: 100%;
    background: #17171733;
    backdrop-filter: blur(50px);
}

@keyframes rotation_9018 {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Media Queries de escritorio para Sobre Mí (Modificado para centrar y equilibrar) --- */
@media (min-width: 769px) {
    .about-content {
        flex-direction: row; /* Se alinea horizontalmente en monitores */
        justify-content: center; /* Junta los elementos hacia el centro armónicamente */
        align-items: center;    /* Centra verticalmente la foto con respecto al bloque de texto */
        padding: 0 20px;
        gap: 60px; /* Controla la separación justa entre el texto y la foto */
    }

    .about-text {
        flex: 0 1 600px; /* Impide que el texto se estire demasiado y pierda legibilidad */
        padding-right: 0;
    }

    .about-image {
        width: auto;
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .card {
        max-width: 350px; /* Tamaño original adaptado en PC */
    }
}

@media (max-width: 768px) {
    .about-text h2 {
        text-align: center;
    }
    .about-text p {
        text-align: left;
    }
}

/* --- Carrusel de programas --- */
.software-carousel {
    overflow: hidden;
    position: relative;
    padding: 120px;
}

.carousel-track {
    display: flex;
    animation: scroll 30s linear infinite;
    white-space: nowrap;
    width: fit-content;
    justify-content: center;
    align-items: center;
}

.carousel-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 60px;
    flex-shrink: 0;
}

.carousel-item img {
    max-height: 40px;
    filter: grayscale(100%) brightness(0.7) invert(100%);
    transition: filter 0.3s ease;
}

.carousel-item img:hover {
    filter:
        invert(100%)
        grayscale(0%)
        sepia(100%)
        hue-rotate(140deg)
        saturate(200%);
}

@keyframes scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Clientes / logos --- */
.clients {
    padding: 80px 20px;
    background-color: #1a1a1a;
}

.client-logos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    margin-top: 40px;
    filter: invert(100%);
}

.client-logos a {
    text-decoration: none;
    display: inline-block;
}

.clients img {
    height: 80px;
    width: auto;
    filter: grayscale(100%);
    transition: filter 0.3s, transform 0.3s;
}

.clients img:hover {
    filter: grayscale(0%);
    transform: scale(1.05);
}

/* --- CTA por Categoría (Tarjetas) --- */
.cta-categories {
    padding: 80px 20px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 50px 40px;
    justify-items: center;
    padding: 20px 0;
    margin-top: 40px;
}

.category-card {
    background: #1f1f1f;
    padding: 30px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s, border 0.3s;
    text-align: center;
    width: 100%;
    max-width: 300px;
    box-sizing: border-box;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.category-card .material-symbols-outlined {
    font-size: 60px;
    color: #81b8b2;
    margin-bottom: 10px;
    line-height: 1;
}

.category-card:hover {
    transform: translateY(-10px);
    background: #2a2a2a;
    border: 1px solid #81b8b2;
    box-shadow: 0 0 10px rgba(129,184,178,0.2);
}

/* --- Contacto --- */
.contact {
    padding: 80px 20px;
    background-color: #1a1a1a;
}

.contact p {
    margin: 10px 0;
    font-size: 1.1em;
}

.contact a {
    color: #81b8b2;
    margin: 0 10px;
    text-decoration: none;
}

.contact a:hover {
    text-decoration: underline;
}

/* --- Media Query de Adaptación General Móvil --- */
@media (max-width: 768px) {
    .card {
        height: auto; /* Permite que aspect-ratio controle la altura */
    }

    section {
        padding: 60px 15px;
    }

    section h2 {
        font-size: 1.8em;
    }

    .hero h1 {
        font-size: 2em;
    }

    .hero p {
        font-size: 1em;
    }

    .hero img {
        width: 150px;
        height: 150px;
    }

    .categories-grid {
        grid-template-columns: 1fr;
    }

    .software-carousel {
        padding: 60px 20px;
    }

    .software-carousel .carousel-item {
        margin: 0 30px;
    }
    
    .software-carousel .carousel-item img {
        max-height: 45px;
    }
    
    .carousel-track {
        animation: scroll 20s linear infinite;
    }
}

/* --- Blur animation --- */
h2.blur-text span {
    display: inline-block;
    filter: blur(10px);
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s ease-out;
    will-change: transform, filter, opacity;
}

h2.blur-text.visible span {
    filter: blur(0);
    opacity: 1;
    transform: translateY(0);
}

/* --- Ruido de fondo --- */
.noise-overlay {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

/* --- Lightbox --- */
.lightbox {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
    box-shadow: 0 0 20px #7bafaa;
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.close-lightbox:hover {
    color: #bbb;
}