/* ==========================================================================
   1. Variables y Resets Globales
   ========================================================================== */
:root {
    --bg-dark: #000000;
    --bg-card: #0a0a0a;
    --bg-input: #111111;
    --border-color: #222222;
    --border-focus: #333333;
    --text-light: #e0e0e0;
    --text-muted: #888888;
    --accent-cyan: #00e5ff;
    --accent-purple: #8a2be2;
    --gradient-accent: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    --nav-bg: rgba(0, 0, 0, 0.9);
    
    --padd-section-desktop: 100px 20px;
    --padd-section-mobile: 80px 15px;
    --nav-height: 70px;
}

/* Variables para el MODO CLARO */
body.light-mode {
    --bg-dark: #ffffff;
    --bg-card: #f9f9f9;
    --bg-input: #f0f0f0;
    --border-color: #dddddd;
    --border-focus: #bbbbbb;
    --text-light: #111111;
    --text-muted: #555555;
    --nav-bg: rgba(255, 255, 255, 0.9);
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: clip; /* Fix para scroll en iOS */
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-overflow-scrolling: touch; /* Obliga a iOS a usar scroll fluido */
}

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

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.6;
    transition: background-color 0.4s ease, color 0.4s ease; 
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ==========================================================================
   2. Tipografía y Elementos Globales
   ========================================================================== */
h1, h2, h3 {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

a {
    text-decoration: none;
    color: var(--accent-cyan);
    transition: all 0.3s ease;
}

a:hover {
    color: var(--accent-purple);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   3. Botones 
   ========================================================================== */
.btn {
    display: inline-block;
    padding: 15px 30px;
    background: var(--gradient-accent);
    color: #fff;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1.5px;
    font-size: 0.9rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: center;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 20px rgba(138, 43, 226, 0.4);
}

.btn-full { width: 100%; }

/* ==========================================================================
   4. Navegación Fija
   ========================================================================== */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--nav-bg); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-container {
    display: flex;
    gap: 25px;
    align-items: center;
}

nav a {
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
}

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

nav a:hover::after { width: 100%; }
nav a:hover { color: var(--accent-cyan); }

.nav-divider {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 0 5px;
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s ease;
}

.toggle-btn:hover {
    color: var(--accent-cyan);
}

/* ==========================================================================
   5. Estilos de Sección Generales
   ========================================================================== */
section {
    padding: var(--padd-section-desktop);
    min-height: 100vh;
    min-height: 100dvh; /* Fix dinámico para la barra de Safari en iOS */
    display: flex;
    align-items: center;
}

.text-center { text-align: center; }

.section-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 50px;
    text-align: center;
    border-bottom: 2px solid;
    border-image: var(--gradient-accent) 1;
    padding-bottom: 10px;
    display: inline-block;
}

/* ==========================================================================
   6. Hero Section Brutalista (Stage Banner)
   ========================================================================== */
.stage-banner {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: var(--bg-dark);
    --light-x: 50%;
    --light-y: 50%;
}

.stage-banner::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle 250px at var(--light-x) var(--light-y), rgba(255, 255, 255, 0.15) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 2;
    pointer-events: none;
    transition: background 0.1s ease;
}

body.light-mode .stage-banner::before {
    background: radial-gradient(circle 250px at var(--light-x) var(--light-y), rgba(0, 0, 0, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
}

.photo-pit-collage {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
}

.pit-photo {
    position: absolute;
    height: auto;
    border: 2px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.8);
    filter: brightness(0.2) contrast(1.2) grayscale(50%);
    transition: filter 0.3s ease, transform 0.3s ease;
}

body.light-mode .pit-photo {
    filter: grayscale(90%) brightness(0.9) opacity(0.5);
    border: 2px solid rgba(0,0,0,0.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.p1 { top: 10%; left: 8%; max-width: 280px; transform: rotate(-5deg); }
.p2 { top: 5%; right: 12%; max-width: 320px; transform: rotate(4deg); }
.p3 { bottom: 8%; left: 12%; max-width: 250px; transform: rotate(3deg); }
.p4 { bottom: 12%; right: 10%; max-width: 300px; transform: rotate(-6deg); }
.p5 { top: 38%; left: 38%; max-width: 240px; transform: rotate(8deg); }

.stage-banner:hover .pit-photo {
    filter: brightness(0.35) contrast(1.2) grayscale(20%);
}

body.light-mode .stage-banner:hover .pit-photo {
    filter: grayscale(50%) brightness(0.95) opacity(0.8);
}

.pit-photo:hover {
    filter: brightness(1) contrast(1) grayscale(0%) !important;
    transform: scale(1.05) rotate(0deg) !important;
    z-index: 4;
}

.content {
    position: relative;
    z-index: 3; 
    text-align: center;
    pointer-events: none; 
    padding: 0 20px;
    width: 100%;
}

.content h1.hero-title-brutalist {
    font-family: 'Anton', sans-serif;
    font-size: clamp(3.5rem, 8vw, 7.5rem);
    text-transform: uppercase;
    line-height: 0.85;
    letter-spacing: 2px;
    color: transparent;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 2px rgba(255, 255, 255, 0.8);
    paint-order: stroke fill;
    text-shadow: 0 0 30px rgba(0,0,0,0.5);
    margin-bottom: 0;
    pointer-events: auto;
}

.content h1.hero-title-brutalist span {
    display: block;
    color: #fff;
    -webkit-text-fill-color: #fff; 
    -webkit-text-stroke: 0px;
    font-size: clamp(4.5rem, 11vw, 9.5rem);
}

body.light-mode .content h1.hero-title-brutalist {
    -webkit-text-stroke: 2px rgba(0, 0, 0, 0.8);
    text-shadow: 0 0 30px rgba(255,255,255,0.8);
}
body.light-mode .content h1.hero-title-brutalist span {
    color: #000;
    -webkit-text-fill-color: #000;
}

.content p.tagline {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 6px;
    margin-top: 25px;
    margin-bottom: 40px;
    color: #888;
    pointer-events: auto;
}

.hero-btn {
    pointer-events: auto;
}

/* ==========================================================================
   8. Crónicas (Editorial)
========================================================================== */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 30px;
    transition: transform 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    transform: translateY(-10px);
    border-color: var(--accent-purple);
    box-shadow: 0 10px 20px rgba(138, 43, 226, 0.1);
}

.article-card h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-light); 
    letter-spacing: 1px;
}

.article-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    flex-grow: 1; 
}

.read-more {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* ==========================================================================
   9. Sobre Mí 
========================================================================== */
.profile-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-start;
}

.profile-text { flex: 2 1 400px; }
.profile-text p { margin-bottom: 20px; font-size: 0.95rem; }

.profile-stats {
    flex: 1 1 300px; 
    background: var(--bg-card);
    padding: 25px;
    border-left: 3px solid var(--accent-cyan);
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.profile-stats:hover {
    transform: translateX(5px);
}

.profile-stats h3 { font-size: 1rem; margin-bottom: 20px; color: var(--text-light); }
.profile-stats ul { list-style: none; }
.profile-stats li { margin-bottom: 15px; font-size: 0.9rem; }
.profile-stats strong { color: var(--accent-cyan); }

/* ==========================================================================
   10. Contacto y Copyright 
========================================================================== */
.contact-wrapper { 
    max-width: 600px; 
    margin: 0 auto; 
    width: 100%;
}

.contact-intro { 
    text-align: center; 
    margin-bottom: 40px; 
    color: var(--text-muted); 
    font-size: 0.9rem; 
    padding: 0 10px; 
}

.contact-form { width: 100%; }
.form-group { margin-bottom: 15px; text-align: left; }

input, textarea {
    width: 100%;
    padding: 15px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-cyan);
    background-color: var(--bg-dark);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.social-icons {
    margin-top: 50px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap; 
}

.social-icons a {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    border: 1px solid var(--border-focus);
    padding: 10px 20px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.social-icons a:hover {
    border-color: var(--accent-purple);
    background: rgba(138, 43, 226, 0.1);
    transform: translateY(-3px);
}

.copyright {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 50px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color); 
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==========================================================================
   11. MEDIA QUERIES
========================================================================== */
@media (max-width: 768px) {
    :root { 
        --nav-height: auto; 
    }
    
    section { 
        padding: var(--padd-section-mobile); 
        padding-top: 120px; 
    }

    nav {
        padding: 10px 0;
    }
    
    .nav-container {
        display: flex;
        flex-wrap: wrap; 
        justify-content: center;
        gap: 12px 20px; 
        padding: 10px 15px;
    }

    nav a { 
        font-size: 0.75rem; 
        letter-spacing: 0.5px; 
    }

    .content h1.hero-title-brutalist {
        font-size: clamp(3rem, 10vw, 4.5rem);
    }

    .content h1.hero-title-brutalist span {
        font-size: clamp(4rem, 12vw, 5.5rem);
    }

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

    .pit-photo { max-width: 160px !important; }
    .p5 { display: none; }
}

@media (max-width: 480px) {
    .section-title { 
        margin-bottom: 30px; 
        font-size: 1.5rem;
    }
    
    .profile-layout { 
        gap: 20px; 
    }
    
    .profile-stats { 
        border-left: none; 
        border-top: 3px solid var(--accent-cyan); 
    }

    .social-icons {
        gap: 10px;
    }
    
    .social-icons a {
        padding: 10px 15px;
        font-size: 0.75rem;
    }

    .content h1.hero-title-brutalist {
        font-size: clamp(2.5rem, 8vw, 3.5rem);
    }

    .content h1.hero-title-brutalist span {
        font-size: clamp(3.5rem, 11vw, 4.5rem);
    }
}

/* ==========================================================================
   12. ANIMACIONES (Scroll y Load optimizados para GPU)
========================================================================== */
.hidden-animate {
    opacity: 0;
    filter: blur(3px); 
    transform: translate3d(0, 40px, 0); /* Aceleración GPU en iOS */
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94); 
    will-change: transform, opacity, filter;
}

.show-animate {
    opacity: 1;
    filter: blur(0);
    transform: translate3d(0, 0, 0);
}

.delay-1 { transition-delay: 100ms; }
.delay-2 { transition-delay: 250ms; }
.delay-3 { transition-delay: 400ms; }

.hero-title-brutalist {
    animation: fadeUpIn 1s ease-out forwards;
    opacity: 0; 
}

.tagline {
    animation: fadeUpIn 1s ease-out 0.3s forwards;
    opacity: 0; 
}

.hero-btn {
    animation: fadeUpIn 1s ease-out 0.6s forwards, pulseGlow 3s infinite 2s;
    opacity: 0; 
}

@keyframes fadeUpIn {
    0% { opacity: 0; filter: blur(5px); transform: translate3d(0, 30px, 0); }
    100% { opacity: 1; filter: blur(0); transform: translate3d(0, 0, 0); }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(138, 43, 226, 0.4); }
    50% { box-shadow: 0 0 20px 0 rgba(0, 229, 255, 0.4); }
    100% { box-shadow: 0 0 0 0 rgba(138, 43, 226, 0.4); }
}

/* ==========================================================================
   13. FIX DE ESPACIOS VACÍOS
========================================================================== */
#portafolio {
    min-height: auto !important; 
    padding-top: 40px !important; 
    padding-bottom: 60px !important; 
    display: block; 
}

#portafolio .container {
    padding-top: 0 !important;  
    padding-bottom: 0 !important; 
}

#portafolio .text-center {
    margin-bottom: 0px; 
}

#portafolio .section-title {
    margin-bottom: 30px !important; 
}

/* ==========================================================================
   14. ESTILOS DEL CARRUSEL CLÁSICO HORIZONTAL
========================================================================== */
.carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin: 30px auto;
}

.carousel-container {
    width: 100%;
    overflow: hidden; 
}

.carousel-track {
    display: flex;
    gap: 20px;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: max-content;
    padding: 10px 0;
}

.carousel-slide {
    flex: 0 0 auto;
    height: 450px; 
    border-radius: 4px;
    overflow: hidden;
    display: block;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, border-color 0.3s ease;
    border: 1px solid var(--border-color);
}

.carousel-slide:hover {
    transform: scale(1.02);
    border-color: var(--accent-cyan);
}

.carousel-slide img {
    width: auto;      
    height: 100%;     
    object-fit: contain; 
    display: block;
}

.carousel-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    cursor: pointer;
    position: absolute;
    z-index: 50;
    font-size: 24px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.carousel-btn:hover {
    background: var(--accent-cyan);
    color: black;
    border-color: var(--accent-cyan);
}

.prev-btn { left: -10px; }
.next-btn { right: -10px; }

@media (max-width: 768px) {
    .carousel-slide {
        height: 320px; 
    }
    .carousel-btn {
        padding: 10px 15px;
        font-size: 18px;
    }
    .prev-btn { left: 5px; }
    .next-btn { right: 5px; }
}

/* ==========================================================================
   15. SECCIÓN DE PROYECTOS & DESARROLLO
========================================================================== */
#proyectos {
    min-height: auto !important;
    padding-top: 60px !important;
    padding-bottom: 60px !important;
    display: block;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: 4px;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), border-color 0.4s ease, box-shadow 0.4s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 280px;
}

.project-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-cyan);
    box-shadow: 0 12px 24px rgba(0, 229, 255, 0.1);
}

.project-content h3 {
    font-size: 1.3rem;
    color: var(--text-light);
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.project-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.project-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.project-tags span {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 3px;
    color: var(--accent-purple);
}

body.light-mode .project-tags span {
    background: #eef0f2;
    color: var(--accent-purple);
}

.project-link {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    transition: color 0.3s ease, transform 0.3s ease;
    display: inline-block;
    align-self: flex-start;
}

.project-link:hover {
    color: var(--text-light);
    transform: translateX(4px);
}