/* Variables para facilitar el mantenimiento */
:root {
    --color-primario: #1a1a2e;
    --color-secundario: #16213e;
    --color-acento: #0f3460;
    --color-hover: #e94560;
    --color-texto: #333;
    --color-fondo: #f5f6fa;
    --altura-barra: 40px;
}

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

html {
    /* PASO 13 */
    /* Compensa la altura de la barra fixed (~40px) + el menú sticky (~60px) + un pequeño margen visual */
    scroll-padding-top: 120px;

    /* Ya que estamos, esto hará que el salto al hacer clic sea animado y suave */
    scroll-behavior: smooth;
}

body {
    /* PASO 12 */
    /* Vital: Evita que el contenido quede oculto bajo la barra fixed */
    padding-top: var(--altura-barra);
    background-color: var(--color-fondo);
    color: var(--color-texto);
    font-family:
        system-ui,
        -apple-system,
        sans-serif;
    line-height: 1.6;
}

/* --- ELEMENTO FIXED --- */
.barra-superior {
    /* PASO 05 */
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: var(--altura-barra);
    background-color: var(--color-primario);
    color: white;
    font-size: 0.9rem;
    animation: deslizarAbajo 0.6s ease-out;
}

/* --- CABECERA Y FONDO (Contenedor Relative) --- */
.cabecera-hero {
    /* PASO 06 */
    position: relative; /* Clave para que el logo absoluto no se salga */
    display: flex;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    height: 60vh;
    min-height: 400px;
    /* Imagen de Picsum con gradiente superpuesto para mejorar legibilidad */
    background-image: linear-gradient(rgba(26, 26, 46, 0.7), rgba(26, 26, 46, 0.7)), url("../../../assets/img/hero.jpg");
    background-position: center;
    background-size: cover;
    color: white;
    text-align: center;
    background-attachment: fixed; /* Efecto parallax */
}

/* --- ELEMENTO ABSOLUTE --- */
.logo-absoluto {
    /* PASO 07 */
    position: absolute;
    top: 20px;
    left: 40px;
    width: 80px;
    height: 80px;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.4s ease;
    object-fit: cover;
}

.logo-absoluto:hover {
    /* PASO 08 */
    transform: scale(1.1) rotate(10deg);
}

/* Animaciones del texto hero */
.hero-contenido h1 {
    margin-bottom: 0.5rem;
    font-size: 3.5rem;
    /* PASO 09 */
    animation: aparecerFade 1s ease-out;
}

.hero-contenido p {
    font-size: 1.5rem;
    font-weight: 300;
    /* PASO 10 */
    opacity: 0;
    animation: aparecerFade 1s ease-out 0.4s forwards;
}

/* --- ELEMENTO STICKY --- */
/* 1. CONTENEDOR PRINCIPAL: EL COMPORTAMIENTO STICKY */
.menu-pegajoso {
    /* PASO 11 */
    position: sticky;
    /* Se ancla teniendo en cuenta la altura de la barra superior (fixed) para no solaparse */
    top: var(--altura-barra);
    z-index: 900;
    padding: 1rem 0;
    background-color: white;
    /* Sombra estática para separar visualmente el menú del contenido inferior */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* 2. MAQUETACIÓN DE LA LISTA: DISTRIBUCIÓN HORIZONTAL */
.menu-pegajoso ul {
    /* PASO 02 */
    display: flex;
    justify-content: center;
    gap: 2rem;
    list-style: none;
}

/* 3. ENLACES: ESTILO BASE ESTÁTICO */
.menu-pegajoso a {
    /* PASO 03 */
    color: var(--color-secundario);
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
}

/* 4. ESTADOS INTERACTIVOS: ACCESIBILIDAD INMEDIATA */
.menu-pegajoso a:hover,
.menu-pegajoso a:focus {
    /* PASO 04 */
    color: var(--color-hover);
    text-decoration: underline;
    outline: none;
}

/* --- ESTILOS DEL CONTENIDO --- */
main {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

section {
    margin-bottom: 2rem;
    padding: 3rem 2.5rem;
    border-radius: 12px;
    background: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

section h2 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-fondo);
    color: var(--color-acento);
}

.espaciador-scroll {
    height: 1000px;
}

/* --- KEYFRAMES --- */
@keyframes deslizarAbajo {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

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