/* ================================================================
   PORTAFOLIO PROFESIONAL — Nelson Hernández Morales
   ================================================================
   Índice:
   1. Reset & normalización
   2. Variables de diseño (design tokens)
   3. Tipografía base
   4. Header / navegación
   5. Hero
   6. Secciones genéricas
   7. Acerca de
   8. Demo interactiva
   9. Timeline (experiencia)
   10. Skills
   11. Contacto
   12. Footer
   13. Animaciones (keyframes)
   14. Responsive (mobile-first breakpoints)
   15. Accesibilidad / preferencias del usuario
   ================================================================ */


/* ----------------------------------------------------------------
   1. RESET & NORMALIZACIÓN
   Elimina inconsistencias entre navegadores
   ---------------------------------------------------------------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

img,
canvas,
svg {
    max-width: 100%;
    display: block;
}

ul, ol {
    list-style: none;
}

a {
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}


/* ----------------------------------------------------------------
   2. VARIABLES DE DISEÑO (Design Tokens)
   ---------------------------------------------------------------- */
:root {
    /* Colores */
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-accent: #0ea5e9;
    --color-accent-dark: #0284c7;
    --color-accent-light: #e0f2fe;

    /* Tipografía */
    --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Espaciado */
    --spacing-section: 6rem;
    --spacing-section-mobile: 4rem;

    /* Bordes */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(14, 165, 233, 0.1);

    /* Transiciones */
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}


/* ----------------------------------------------------------------
   3. TIPOGRAFÍA BASE
   ---------------------------------------------------------------- */
body {
    font-family: var(--font-base);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

strong {
    color: var(--color-accent);
    font-weight: 600;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}


/* ================================================================
   4. HEADER / NAVEGACIÓN
   ================================================================ */
.site-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--color-border);
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    background-color: rgba(250, 250, 250, 0.95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    z-index: 100;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .site-header {
        background-color: rgba(250, 250, 250, 0.7);
    }
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: inline-flex;
    align-items: center;
}

.logo-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--color-accent);
    border-radius: 50%;
    margin-left: 0.5rem;
    animation: pulse 2s ease-in-out infinite;
}

.nav-links {
    display: flex;
    gap: 2.5rem;
}

.nav-links a {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    transition: color 0.2s ease;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-accent);
    transition: width 0.3s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
    color: var(--color-text);
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 0.5rem;
}

.nav-toggle-bar {
    width: 22px;
    height: 2px;
    background-color: var(--color-text);
    transition: transform 0.3s ease, opacity 0.3s ease;
}


/* ================================================================
   5. HERO
   ================================================================ */
.hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: 7rem 2rem 5rem;
    text-align: center;
}

.hero-content {
    margin-bottom: 5rem;
    animation: slideInDown 0.8s var(--ease-bounce);
}

.badge {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    background-color: var(--color-accent-light);
    border: 1px solid var(--color-accent);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-accent-dark);
    margin-bottom: 1.5rem;
    animation: fadeIn 0.8s ease-out 0.2s both;
}

.hero h1 {
    font-size: 3rem;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    margin-bottom: 1rem;
    line-height: 1.1;
    letter-spacing: -1.5px;
    animation: fadeIn 0.8s ease-out 0.3s both;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeIn 0.8s ease-out 0.4s both;
}

.research-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 2rem;
    animation: fadeIn 0.8s ease-out 0.5s both;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    animation: fadeIn 0.8s ease-out 0.6s both;
}

.btn {
    padding: 0.85rem 2rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    display: inline-block;
    transition: transform 0.3s var(--ease-bounce), box-shadow 0.3s ease, background-color 0.3s ease;
}

.btn-primary {
    background-color: var(--color-accent);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background-color: var(--color-accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.3);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--color-accent);
    border: 2px solid var(--color-accent);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
    background-color: var(--color-accent-light);
    transform: translateY(-2px);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: 4rem;
    animation: slideInUp 0.8s var(--ease-bounce) 0.7s both;
}

.stat {
    padding: 2rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.stat:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-accent);
}

.stat-label {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 0.75rem;
}


/* ================================================================
   6. SECCIONES GENÉRICAS
   ================================================================ */
.section {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-section) 2rem;
    border-top: 1px solid var(--color-border);
}

.section-title {
    font-size: 2.5rem;
    margin-bottom: 3rem;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 80px;
    height: 3px;
    background-color: var(--color-accent);
    border-radius: 999px;
}


/* ================================================================
   7. ACERCA DE
   ================================================================ */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: start;
    margin-top: 3rem;
}

.about-text h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.about-text p {
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
    font-size: 1.05rem;
    line-height: 1.8;
}

.plain-list li {
    padding: 0.35rem 0;
    color: var(--color-text-muted);
}

.plain-list li::before {
    content: '✓ ';
    color: var(--color-accent);
    font-weight: 700;
}


/* ================================================================
   8. DEMO INTERACTIVA
   ================================================================ */
.demo-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    margin-top: 3rem;
    box-shadow: var(--shadow-sm);
}

.demo-title {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.demo-subtitle {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    max-width: 65ch;
}

#tspCanvas {
    width: 100%;
    height: 400px;
    background-color: var(--color-bg);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.demo-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.demo-btn {
    padding: 0.7rem 1.5rem;
    background-color: var(--color-accent);
    color: #ffffff;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.demo-btn:hover,
.demo-btn:focus-visible {
    background-color: var(--color-accent-dark);
    transform: translateY(-2px);
}

.demo-btn:active {
    transform: translateY(0);
}

.demo-btn-secondary {
    background-color: var(--color-accent-light);
    color: var(--color-accent-dark);
}

.demo-btn-secondary:hover,
.demo-btn-secondary:focus-visible {
    background-color: var(--color-accent);
    color: #ffffff;
}

.demo-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
    background-color: var(--color-accent-light);
    border-radius: var(--radius-md);
}

.demo-stat {
    padding: 1rem;
    background-color: #ffffff;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--color-accent);
}

.demo-stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.demo-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-accent);
    margin-top: 0.25rem;
}


/* ================================================================
   9. TIMELINE (Experiencia y educación)
   ================================================================ */
.timeline {
    position: relative;
    margin-top: 3rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background-color: var(--color-border);
}

.timeline-item {
    position: relative;
    margin-bottom: 3rem;
    width: 48%;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

.timeline-item:nth-child(odd) {
    margin-left: 0;
}

.timeline-item:nth-child(even) {
    margin-left: 52%;
}

.timeline-item:nth-child(1) { animation-delay: 0.1s; }
.timeline-item:nth-child(2) { animation-delay: 0.2s; }
.timeline-item:nth-child(3) { animation-delay: 0.3s; }
.timeline-item:nth-child(4) { animation-delay: 0.4s; }

.timeline-dot {
    position: absolute;
    left: 50%;
    top: 0.5rem;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background-color: var(--color-accent);
    border: 3px solid var(--color-bg);
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--color-accent-light);
    z-index: 2;
}

.timeline-content {
    padding: 1.75rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.timeline-content:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
    transform: translateX(8px);
}

.timeline-title {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.timeline-period {
    font-size: 0.9rem;
    color: var(--color-accent);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.timeline-description {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}


/* ================================================================
   10. SKILLS
   ================================================================ */
.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.skill-card {
    padding: 2rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s var(--ease-bounce), box-shadow 0.3s ease, border-color 0.3s ease;
}

.skill-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--color-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.skill-card:hover {
    border-color: var(--color-accent);
    box-shadow: 0 12px 32px rgba(14, 165, 233, 0.12);
    transform: translateY(-6px);
}

.skill-card:hover::before {
    transform: scaleX(1);
}

.skill-category {
    font-size: 1rem;
    color: var(--color-accent);
    margin-bottom: 1.25rem;
}

.skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.skill-tag {
    padding: 0.5rem 1rem;
    background-color: var(--color-accent-light);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--color-accent-dark);
    font-weight: 500;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.skill-tag:hover {
    background-color: var(--color-accent);
    color: #ffffff;
    transform: scale(1.05);
}


/* ================================================================
   11. CONTACTO
   ================================================================ */
.contact-wrapper {
    text-align: center;
    margin-top: 3rem;
}

.contact-intro {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: var(--color-text-muted);
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.social-links a {
    color: var(--color-text-muted);
    font-weight: 600;
    position: relative;
    transition: color 0.3s ease;
}

.social-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-accent);
    transition: width 0.3s ease;
}

.social-links a:hover,
.social-links a:focus-visible {
    color: var(--color-text);
}

.social-links a:hover::after,
.social-links a:focus-visible::after {
    width: 100%;
}

.contact-card {
    display: inline-block;
    margin-top: 1rem;
    padding: 2rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text-muted);
}

.contact-card p + p {
    margin-top: 0.5rem;
}


/* ================================================================
   12. FOOTER
   ================================================================ */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 3rem 2rem;
    text-align: center;
    color: var(--color-text-muted);
    margin-top: 5rem;
    background-color: var(--color-surface);
}

.footer-subtitle {
    font-size: 0.9rem;
    margin-top: 1rem;
}


/* ================================================================
   13. ANIMACIONES (keyframes)
   ================================================================ */
@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.7); }
    50%      { box-shadow: 0 0 0 6px rgba(14, 165, 233, 0); }
}


/* ================================================================
   14. RESPONSIVE (mobile-first breakpoints)
   ================================================================ */

/* Tablets y pantallas medianas */
@media (max-width: 900px) {
    .about-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
}

/* Móviles */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        background-color: var(--color-surface);
        border-bottom: 1px solid var(--color-border);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .nav-links.is-open {
        max-height: 300px;
    }

    .nav-links li {
        padding: 1rem 2rem;
        border-top: 1px solid var(--color-border);
    }

    .hero {
        padding: 4rem 1.5rem 3rem;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .timeline::before {
        left: 20px;
    }

    .timeline-item {
        width: 100%;
        margin-left: 0 !important;
        padding-left: 60px;
    }

    .timeline-dot {
        left: 20px;
    }

    .skills-container {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .research-title {
        font-size: 1.4rem;
    }

    .cta-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 300px;
        text-align: center;
    }

    .section {
        padding: var(--spacing-section-mobile) 1.5rem;
    }

    .social-links {
        flex-direction: column;
        gap: 1rem;
    }
}


/* ================================================================
   15. ACCESIBILIDAD / PREFERENCIAS DEL USUARIO
   ================================================================ */

/* Respeta la preferencia de "reducir movimiento" */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Modo de alto contraste */
@media (forced-colors: active) {
    .btn,
    .demo-btn,
    .skill-tag {
        border: 1px solid CanvasText;
    }
}