/* ===================================
   Portfolio CSS - Estilo Profesional
   VERSIÓN CORREGIDA - Sin solapamiento
   =================================== */

/* Variables de colores y tipografía */
:root {
    --primary-color: #1a1a2e;
    --secondary-color: #16213e;
    --accent-color: #0f4c75;
    --text-primary: #333333;
    --text-secondary: #666666;
    --background-light: #f8f9fa;
    --background-white: #ffffff;
    --border-color: #e0e0e0;
    --link-color: #0066cc;
    --link-hover: #0052a3;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
}

/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--background-light) 0%, var(--background-white) 100%);
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    animation: fadeIn 0.8s ease-out;
}

/* Tipografía */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
    margin-top: 0;
    color: var(--primary-color);
}

h1.big {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.75rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--secondary-color);
    position: relative;
    padding-bottom: 0.5rem;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

section:hover h2::after {
    width: 100px;
}

h3 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

h3.small {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Enlaces */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: var(--link-hover);
    transition: width 0.3s ease;
}

a:hover::after {
    width: 100%;
}

a:hover {
    color: var(--link-hover);
}

/* Código */
pre {
    background: var(--background-light);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9em;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px var(--shadow-light);
    margin: 1rem 0;
}

code {
    background: var(--background-light);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
    color: var(--secondary-color);
    border: 1px solid var(--border-color);
}

pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--text-primary);
}

/* Párrafos */
p {
    margin-bottom: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Información del autor */
body > p:first-of-type {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

/* ===================================
   SECCIONES - CORREGIDO
   =================================== */
section {
    display: block; /* CAMBIO PRINCIPAL: de flex a block */
    margin-bottom: 3rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(224, 224, 224, 0.3);
    animation: fadeIn 0.6s ease-out;
}

section:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-color: rgba(15, 76, 117, 0.2);
}

section:first-of-type {
    margin-top: 0;
}

section:last-of-type {
    margin-bottom: 0;
}

section + section {
    margin-top: 2rem;
}

/* Descripción de gráficos */
.chart-description {
    margin-bottom: 1.5rem;
    width: 100%;
}

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

/* ===================================
   FIGURES - CORREGIDO
   =================================== */
figure {
    margin: 1.5rem 0;
    padding: 1rem 0;
    background: transparent;
    border-radius: 8px;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%; /* Ocupa todo el ancho */
    min-height: 350px;
    transition: all 0.3s ease;
    position: relative;
}

figure::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

figure:hover::after {
    width: 100px;
}

/* Separador entre figures consecutivos */
figure + figure {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(224, 224, 224, 0.3);
}

/* ===================================
   GRID PARA DOS GRÁFICOS LADO A LADO
   Usa esta clase cuando quieras 2 gráficos en fila
   =================================== */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.chart-grid figure {
    margin: 0;
    padding: 1rem;
    min-height: 350px;
    background: rgba(248, 249, 250, 0.5);
    border-radius: 8px;
}

.chart-grid figure + figure {
    margin-top: 0;
    padding-top: 1rem;
    border-top: none;
}

/* ===================================
   FRED Grid - Para la sección CC6
   =================================== */
.chart-grid-fred {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 1.5rem;
}

.chart-grid-fred figure {
    margin: 0;
    padding: 0.5rem;
    min-height: 280px;
    background: rgba(248, 249, 250, 0.5);
    border-radius: 8px;
}

.chart-grid-fred figure + figure {
    margin-top: 0;
    padding-top: 0.5rem;
    border-top: none;
}

/* ===================================
   VEGA EMBED
   =================================== */
.vega-embed {
    width: 100% !important;
    padding: 0.5rem 0;
}

.vega-embed summary {
    display: none !important;
}

/* ===================================
   IMÁGENES
   =================================== */
img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

/* ===================================
   IFRAMES
   =================================== */
iframe {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
}

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

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 900px) {
    .chart-grid,
    .chart-grid-fred {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 20px 15px;
    }
    
    h1.big {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3.small {
        font-size: 1rem;
    }
    
    section {
        padding: 1.5rem;
        margin-bottom: 2rem;
    }
    
    figure {
        min-height: 300px;
    }
    
    .chart-grid figure,
    .chart-grid-fred figure {
        min-height: 280px;
    }
}

@media (max-width: 480px) {
    h1.big {
        font-size: 1.75rem;
    }
    
    section {
        padding: 1rem;
        border-radius: 8px;
    }
    
    figure {
        padding: 0.5rem 0;
        min-height: 250px;
    }
}

/* ===================================
   ACCESIBILIDAD
   =================================== */
:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ===================================
   SCROLLBAR
   =================================== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-light);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* ===================================
   TRANSICIONES
   =================================== */
button, input, select, textarea {
    transition: all 0.3s ease;
}
