/* Reseteo General */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-main: #0f172a;       
    --bg-surface: #1e293b;    
    --accent: #3b82f6;        
    --accent-grad: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%); 
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
}

/* ==========================================================================
   NAVEGACIÓN Y MENÚ MÓVIL (MÉTODO MOBILE-FIRST)
   ========================================================================== */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.3s ease;
}

nav.scrolled {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.logo a {
    color: var(--text-primary);
    text-decoration: none;
}

.logo span {
    color: var(--accent);
}

/* Estructura del Menú Desplegable en Móvil */
.nav-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    list-style: none;
    
    /* Estado inicial: Oculto arriba con opacidad */
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: calc(100vh - 100%);
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Estado Activo: Menú Abierto en Móvil */
.nav-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.nav-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.nav-menu a:hover {
    color: var(--text-primary);
}

/* Botón Hamburguesa Interactivo (Modo Líneas) */
.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
}

.menu-toggle .bar {
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);
    transform-origin: left center;
}

/* Animación de Hamburguesa a "X" */
.menu-toggle.open .bar:nth-child(1) {
    transform: rotate(45deg) translateY(-2px);
    background-color: var(--accent);
}

.menu-toggle.open .bar:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

.menu-toggle.open .bar:nth-child(3) {
    transform: rotate(-45deg) translateY(2px);
    background-color: var(--accent);
}

/* ==========================================================================
   SECCIONES Y CONTENIDOS (MÓVIL POR DEFECTO)
   ========================================================================== */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
}

.hero-content {
    width: 100%;
    text-align: left;
    padding-top: 2rem;
}

.hero-subtitle {
    display: inline-block;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.hero h1 {
    font-size: clamp(2.2rem, 8vw, 4rem);
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.1;
    margin-bottom: 0.5rem;
}

.hero h2 {
    font-size: clamp(1.3rem, 5vw, 2.2rem);
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.hero p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-buttons {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.cta-button, .cta-secondary {
    padding: 0.8rem 1.8rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%; /* Botones de ancho completo en móviles pequeños */
}

.cta-button {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(59, 130, 246, 0.4);
}

.cta-secondary {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.cta-secondary:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
}

section {
    padding: 5rem 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 35px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
}

/* Sobre Mí */
.about-content {
    display: grid;
    gap: 2.5rem;
}

.about-text {
    color: var(--text-secondary);
    font-size: 1rem;
}

.about-text p {
    margin-bottom: 1rem;
}

.profile-img-container {
    position: relative;
    width: 240px;
    height: 280px;
    margin: 0 auto;
}

.profile-img-container::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    width: 100%;
    height: 100%;
    border: 2px solid var(--accent);
    border-radius: 12px;
}

.profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    position: relative;
    z-index: 2;
    background: var(--bg-surface);
}

/* Cuadrículas Adaptables */
.tech-grid, .projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* Tarjetas de Tecnologías con Hover de Resaltado */
.tech-card {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.75rem;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                border-color 0.3s ease, 
                box-shadow 0.3s ease;
}

.tech-card:hover {
    transform: translateY(-5px);
    border-color: rgba(59, 130, 246, 0.4); 
    box-shadow: 0 15px 30px -10px rgba(0,0,0,0.5), 
                0 0 15px -3px rgba(59, 130, 246, 0.1);
}

.tech-badge {
    display: inline-block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.tech-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.tech-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Tarjetas de Proyectos con Hover de Resaltado */
.project-card {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                border-color 0.3s ease, 
                box-shadow 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.4); 
    box-shadow: 0 15px 30px -10px rgba(0,0,0,0.5), 
                0 0 15px -3px rgba(139, 92, 246, 0.1);
}

/* Se unificaron aquí los estilos en línea del HTML */
.project-image {
    width: 100%;
    height: 170px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-secondary);
    font-weight: 600;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.project-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.project-info h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.project-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
}

.project-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
}

.project-tags span {
    font-size: 0.7rem;
    background: rgba(255,255,255,0.05);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    color: var(--text-secondary);
}

.project-links {
    display: flex;
    gap: 1.2rem;
    margin-top: auto; /* Mantiene alineados los botones al fondo */
}

.project-link {
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.project-link:hover {
    text-decoration: underline;
}

.project-link.platform { color: #3b82f6; }
.project-link.github { color: var(--text-primary); opacity: 0.7; }
.project-link.github:hover { opacity: 1; }

/* Animaciones por Scroll de JavaScript */
.about-text, .about-image, .tech-card, .project-card {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Esta clase sobreescribe el estado opaco inicial cuando el scroll llega al elemento */
.animate {
    opacity: 1;
    transform: translateY(0);
}

/* Partículas */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: particle-float 8s linear infinite;
}

@keyframes particle-float {
    0% { transform: translateY(100vh); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-5vh); opacity: 0; }
}

/* ==========================================================================
   MEDIA QUERIES: OPTIMIZACIÓN PANTALLAS GRANDES (ESCRITORIO / TABLET)
   ========================================================================== */
@media (min-width: 576px) {
    .cta-button, .cta-secondary {
        width: auto; /* Desactiva el ancho completo en pantallas medianas */
    }
}

@media (min-width: 768px) {
    /* Navbar Escritorio */
    .menu-toggle {
        display: none; /* Oculta botón hamburguesa */
    }

    .nav-menu {
        display: flex;
        flex-direction: row;
        position: static;
        width: auto;
        height: auto;
        background: none;
        backdrop-filter: none;
        border-top: none;
        gap: 2.5rem;
        opacity: 1;
        transform: none;
        pointer-events: all;
    }

    .nav-menu a {
        font-size: 0.95rem;
    }

    .about-content {
        grid-template-columns: 1fr 280px;
        align-items: center;
    }

    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .tech-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}