:root {
    --deep-obsidian: #0B0F14;
    --slate-grey: #151B23;
    --electric-cyan: #00D1FF;
    --electric-cyan-glow: rgba(0, 209, 255, 0.3);
    --neon-mint: #00FF94;
    --cloud-grey: #A0AEC0;
    --pure-white: #FFFFFF;
}

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

body {
    background-color: var(--deep-obsidian);
    color: var(--pure-white);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ========================================
   NAVEGACIÓN UNIVERSAL
   ======================================== */
header {
    background: rgba(11, 15, 20, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-content { display: flex; justify-content: space-between; align-items: center; }
.logo { font-weight: 800; letter-spacing: 2px; color: var(--electric-cyan); text-decoration: none; font-size: 1rem; z-index: 1001; }
nav { display: flex; gap: 15px; align-items: center; }
nav a { color: var(--cloud-grey); text-decoration: none; font-size: 0.85rem; transition: 0.3s; }
nav a:hover { color: var(--electric-cyan); }

.nav-btn {
    background: var(--electric-cyan) !important;
    color: #000 !important;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.7rem;
    box-shadow: 0 0 15px var(--electric-cyan-glow);
}

.menu-toggle { display: none; flex-direction: column; gap: 5px; cursor: pointer; z-index: 1001; }
.menu-toggle span { width: 25px; height: 3px; background: var(--electric-cyan); border-radius: 2px; transition: 0.3s; }

/* ========================================
   HERO SECTION (VIDEO)
   ======================================== */
.hero-video-container {
    position: relative;
    height: 80vh;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; background: #000;
}

.hero-video {
    position: absolute; top: 50%; left: 50%;
    min-width: 100%; min-height: 100%; width: auto; height: auto;
    z-index: 1; transform: translate(-50%, -50%);
    object-fit: cover; filter: brightness(0.65) contrast(1.1);
}

.video-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(180deg, rgba(11, 15, 20, 0.2) 0%, var(--deep-obsidian) 100%);
    z-index: 2;
}

.hero-content { position: relative; z-index: 3; text-align: center; max-width: 850px; padding: 0 25px; }
.hero-content h1 { font-size: clamp(2rem, 8vw, 3.5rem); font-weight: 800; line-height: 1.1; margin-bottom: 20px; text-shadow: 0 0 20px rgba(0,0,0,0.9); }
.hero-content p { font-size: 1.05rem; color: #FFFFFF; text-shadow: 0 2px 10px rgba(0,0,0,0.8); }
.accent-mint { color: var(--neon-mint); }

/* ========================================
   SECCIONES Y TARJETAS (LOS CUADROS DINÁMICOS)
   ======================================== */
.info-section { padding: 60px 0; background: #0F1319; border-top: 1px solid rgba(255,255,255,0.05); }

/* Esta es la regla que forma los dos cuadros de "Aprender en público" */
.grid-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 40px; }

.category-tag { font-family: 'Fira Code', monospace; font-size: 0.7rem; color: var(--neon-mint); letter-spacing: 2px; text-transform: uppercase; display: block; margin-bottom: 10px; }

/* Esta es la regla que forma los tres cuadros del Laboratorio */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 40px; }

/* Este es el diseño y borde del cuadro */
.card { background: var(--slate-grey); padding: 30px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.05); transition: 0.3s; }
.card:hover { border-color: var(--electric-cyan); transform: translateY(-5px); }
.card-link { color: var(--electric-cyan); text-decoration: none; font-weight: 800; font-size: 0.75rem; }

footer { padding: 40px 0; text-align: center; color: #4A5568; font-size: 0.8rem; }

/* ========================================
   MEDIA QUERIES (AJUSTES PARA MÓVIL)
   ======================================== */
@media (max-width: 768px) {
    header { padding: 10px 0; }
    
    .menu-toggle { display: flex; }
    nav {
        position: fixed; top: 0; right: -100%; width: 75%; height: 100vh;
        background: var(--slate-grey); flex-direction: column; justify-content: center;
        transition: 0.4s ease-in-out; box-shadow: -10px 0 30px rgba(0,0,0,0.5); z-index: 1000;
    }
    nav.active { right: 0; }
    nav a { font-size: 1.2rem; padding: 15px; width: 100%; text-align: center; display: block; }
    .nav-btn { width: 80%; margin: 20px auto 0; text-align: center; }
    
    .hero-video-container { height: 70vh; }
    .hero-video { width: 220%; max-width: none; }
    
    .hero-content h1 { font-size: 1.8rem; }
    .hero-content p { font-size: 0.95rem; line-height: 1.5; }
    
    .info-section { padding: 40px 0; }
    .grid-two { gap: 30px; }
}

/* ========================================
   SECCIÓN PORTFOLIO (TARJETAS DESTACADAS)
   ======================================== */
.portfolio-hero { padding: 80px 0 50px; text-align: center; }
.portfolio-hero h1 { font-size: clamp(2.5rem, 6vw, 3.5rem); font-weight: 800; margin-bottom: 20px; }
.hero-desc { color: var(--cloud-grey); max-width: 700px; font-size: 1.1rem; margin: 0 auto; }

.project-display { display: flex; justify-content: center; padding-bottom: 100px; }

/* Tarjeta Gigante del Portfolio */
.card-featured {
    background: var(--slate-grey);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    max-width: 650px;
    width: 100%;
    transition: all 0.4s ease;
}

.card-featured:hover {
    border-color: var(--electric-cyan);
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 209, 255, 0.1);
}

.status-tag {
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    font-weight: 800;
    margin-bottom: 15px;
    display: inline-block;
    background: rgba(0, 255, 148, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    color: var(--neon-mint);
}

.card-featured h3 { margin-bottom: 15px; font-size: 1.8rem; }
.card-featured p { color: var(--cloud-grey); font-size: 1.05rem; margin-bottom: 30px; }

.card-footer-featured {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 25px;
}

/* Ajustes móvil específicos del Portfolio */
@media (max-width: 768px) {
    .portfolio-hero { padding: 50px 0 30px; }
    .portfolio-hero h1 { font-size: 2.2rem; }
    .card-featured { padding: 30px; }
}

/* ========================================
   SECCIÓN RESEARCH (CAJAS DE FÓRMULAS LATEX)
   ======================================== */
.research-hero { padding: 80px 0 50px; }
.research-hero h1 { font-size: clamp(2.2rem, 6vw, 3.5rem); font-weight: 800; margin-bottom: 20px; line-height: 1.1; }
.hero-desc { color: var(--cloud-grey); max-width: 750px; font-size: 1.1rem; }

.formula-box {
    background: rgba(0, 209, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    color: var(--electric-cyan);
    font-size: 0.9rem;
    text-align: center;
    overflow-x: auto; /* Permite scroll horizontal en móviles */
    border: 1px solid rgba(0, 209, 255, 0.1); /* Toque extra de diseño */
}

/* Reutilizamos la clase .cards-grid que ya existe para la cuadrícula */
.card-footer-research {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

@media (max-width: 768px) {
    .research-hero { padding: 50px 0 30px; }
    .research-hero h1 { font-size: 2rem; }
}

/* ========================================
   SECCIÓN ASISTENTE (CONSOLA DE CHAT)
   ======================================== */
.chat-console {
    background: var(--slate-grey);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 15px;
    height: 65vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    margin-bottom: 40px;
}

#chat-window {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ai-msg {
    align-self: flex-start;
    background: rgba(0, 209, 255, 0.05);
    border: 1px solid var(--electric-cyan-glow);
    color: var(--electric-cyan);
    border-bottom-left-radius: 2px;
}

.user-msg {
    align-self: flex-end;
    background: rgba(255,255,255,0.05);
    color: var(--pure-white);
    border: 1px solid rgba(255,255,255,0.1);
    border-bottom-right-radius: 2px;
}

.input-area {
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    background: var(--deep-obsidian);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 12px;
    color: white;
    outline: none;
    font-size: 16px; /* Evita el zoom automático en Safari/iPhone */
}

#user-input:focus { border-color: var(--electric-cyan); }

@media (max-width: 768px) {
    .chat-console { height: 75vh; }
    .message { max-width: 90%; font-size: 0.85rem; }
}

/* ========================================
   SECCIÓN PROYECTOS: CALCULADORA ESTADÍSTICA
   ======================================== */
.doc-section { 
    padding: 40px 0; 
    border-bottom: 1px solid rgba(255,255,255,0.05); 
}

.math-box { 
    background: rgba(0, 209, 255, 0.05); 
    padding: 20px; 
    border-radius: 12px; 
    border-left: 4px solid var(--electric-cyan); 
    margin: 20px 0; 
    border: 1px solid rgba(255,255,255,0.05);
}

.code-block { 
    background: #000; 
    padding: 25px; 
    border-radius: 12px; 
    font-family: 'Fira Code', monospace; 
    font-size: 0.9rem; 
    overflow-x: auto; 
    border: 1px solid rgba(255,255,255,0.05); 
    color: var(--neon-mint); 
    position: relative; 
    margin: 25px 0;
    line-height: 1.6;
}

.code-header { 
    position: absolute; 
    top: 10px; 
    right: 20px; 
    font-size: 0.7rem; 
    color: #4A5568; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 8px;
    border-radius: 4px;
}

.interactive-demo {
    background: var(--slate-grey);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    margin: 30px 0;
}

.demo-input {
    width: 100%;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(11, 15, 20, 0.5);
    color: var(--pure-white);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.demo-input:focus {
    outline: none;
    border-color: var(--electric-cyan);
    box-shadow: 0 0 0 3px var(--electric-cyan-glow);
}

.btn-demo {
    background: var(--electric-cyan);
    color: #000;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    width: 100%;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-demo:hover {
    background: #00e5ff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--electric-cyan-glow);
}

.results-display {
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 255, 148, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--neon-mint);
    display: none;
}

.results-display.show {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

.result-item { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid rgba(0, 255, 148, 0.2); }
.result-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.result-label { color: var(--neon-mint); font-weight: 700; margin-bottom: 5px; display: block; }
.result-value { color: var(--pure-white); font-size: 1.2rem; font-weight: 600; }