/*--------------------------------------------------
    Estilos específicos para la cabecera (header.css)
-------------------------------------------------- */

/* 1. Reseteo y Base */
/* Asegura que el body no tenga márgenes/paddings por defecto */
html,
body {
    /* No forzar el margin del html para no interferir con el admin bar de WordPress. */
    margin: 0;
    padding: 0 !important;
    overflow-x: hidden;
    font-size: 16px;
}

/* 2. Corrección para la barra de administración de WordPress */
body.admin-bar .site-header {
    top: var(--wp-admin--admin-bar--height, 32px);
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 180px;
    background-color: transparent;
    z-index: 1000;
    padding: 8px 60px;
    border-bottom-left-radius: 35px;
    border-bottom-right-radius: 35px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    transition:
        height 200ms ease,
        padding 200ms ease,
        background-color 200ms ease,
        box-shadow 200ms ease,
        border-radius 200ms ease;
}

/* 4. Estilo del encabezado al hacer scroll */
.site-header.scrolled {
    background-color: var(--c-bg);
    height: 72px;
    padding: 6px 60px;
    border-bottom-left-radius: 22px;
    border-bottom-right-radius: 22px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* 5. Logos */
.site-logo {
    min-height: 150px;
    max-height: 150px;
    width: 100%;
    display: none;
}

.scroll-logo {
    max-height: 300px;
    width: 100%;
    display: none;
}

.site-header--front:not(.scrolled) {
    justify-content: center;
}

.site-header--front:not(.scrolled) .main-navigation {
    margin-left: 0;
    margin-right: 0;
    flex: 1;
    justify-content: center;
}

.site-header--front:not(.scrolled) .site-branding {
    display: none;
}

.site-header--front:not(.scrolled) .menu-menu_principal-container {
    justify-content: center;
}

.site-header--front:not(.scrolled) .main-navigation ul {
    justify-content: center;
}

.site-header.scrolled .site-logo {
    min-height: 0;
    max-height: 52px;
    width: auto;
}

/* 6. Branding (Contenedor del logo) */
.site-branding {
    display: flex;
    align-items: center;
}

/* 8. Navegación principal (Escritorio) */
.main-navigation {
    flex-shrink: 1;
    display: flex;
    align-items: center;
    position: relative;
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    min-width: 0;
}

.main-navigation li {
    margin-left: 20px;
}

.main-navigation a {
    color: var(--c-primary);
    font-size: 1.1rem;
    text-decoration: none;
    font-weight: 600;
    padding: 5px 10px;
    display: block;
}

.site-header--front:not(.scrolled) .main-navigation a {
    color: var(--c-surface);
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

/* Menú blanco en top: Portada + Servicios + Experiencia (solo desktop) */
@media screen and (min-width: 769px) {
    body.page-template-page-servicios .site-header:not(.scrolled) .main-navigation a,
    body.page-template-page-servicios-php .site-header:not(.scrolled) .main-navigation a,
    body.page-template-page-experiencia .site-header:not(.scrolled) .main-navigation a,
    body.page-template-page-experiencia-php .site-header:not(.scrolled) .main-navigation a {
        color: var(--c-surface);
        text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
    }
}

.site-header--front:not(.scrolled) .main-navigation a:hover {
    color: var(--c-surface);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

@media screen and (min-width: 769px) {
    body.page-template-page-servicios .site-header:not(.scrolled) .main-navigation a:is(:hover, :focus-visible),
    body.page-template-page-servicios-php .site-header:not(.scrolled) .main-navigation a:is(:hover, :focus-visible),
    body.page-template-page-experiencia .site-header:not(.scrolled) .main-navigation a:is(:hover, :focus-visible),
    body.page-template-page-experiencia-php .site-header:not(.scrolled) .main-navigation a:is(:hover, :focus-visible) {
        color: var(--c-surface);
        text-decoration: underline;
        text-decoration-thickness: 2px;
        text-underline-offset: 6px;
    }
}

/* Estado activo (header sin scroll) */
.site-header:not(.scrolled) .main-navigation .current-menu-item > a,
.site-header:not(.scrolled) .main-navigation .current_page_item > a,
.site-header:not(.scrolled) .main-navigation .current-menu-ancestor > a,
.site-header:not(.scrolled) .main-navigation .current_page_ancestor > a,
.site-header:not(.scrolled) .main-navigation .current-menu-parent > a,
.site-header:not(.scrolled) .main-navigation .current_page_parent > a {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

.site-header.scrolled .main-navigation a {
    color: var(--c-primary);
}

.site-header.scrolled .main-navigation a:is(:hover, :focus-visible) {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

.main-navigation a:hover {
    color: var(--c-primary-strong);
    /* Color al pasar el ratón por encima */
}

.site-header.scrolled .main-navigation a:hover {
    color: var(--c-primary);
    /* Color al pasar el ratón por encima cuando el encabezado está en scroll */
}


/* 9. Contenedor generado por wp_nav_menu */
.menu-menu_principal-container {
    display: flex;
    flex-grow: 1;
    flex-shrink: 1;
    justify-content: flex-end;
    min-width: 0;
}

/* 10. Botón de menú hamburguesa (oculto en escritorio) */
.site-header .menu-toggle {
    display: none;
}

.site-header .menu-toggle .menu-toggle-icon,
.site-header .menu-toggle .menu-toggle-icon::before,
.site-header .menu-toggle .menu-toggle-icon::after {
    content: "";
    display: block;
    width: 28px;
    height: 3px;
    border-radius: 2px;
    background-color: currentColor;
}

.site-header .menu-toggle .menu-toggle-icon {
    position: relative;
}

.site-header .menu-toggle .menu-toggle-icon::before {
    position: absolute;
    top: -8px;
    left: 0;
}

.site-header .menu-toggle .menu-toggle-icon::after {
    position: absolute;
    top: 8px;
    left: 0;
}

/* 11. Contenedor del menú móvil (oculto en escritorio) */
#mobile-menu-wrapper {
    display: block;
}


/* ----------------------------------------------------- */
/* Media Queries para Responsividad                      */
/* ----------------------------------------------------- */

/* Breakpoint para tabletas y móviles */
@media screen and (max-width: 768px) {

    .site-header {
        height: 180px;
        padding: 8px 60px;
        background-color: var(--c-bg);
    }

    .site-header.scrolled {
        height: 90px;
        padding: 6px 24px;
        background-color: var(--c-bg);
    }

    .main-navigation {
        position: static;
    }

    .site-header .menu-toggle {
        display: block !important;
        background: none;
        border: none;
        color: var(--c-primary);
        line-height: 1;
        cursor: pointer;
        padding: 10px;
        margin-left: 20px;
    }

    .site-header.scrolled .menu-toggle {
        color: var(--c-primary);
    }

    #mobile-menu-wrapper {
        display: none;
        position: absolute;
        top: 100%;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(92vw, 420px);
        max-width: none;
        background-color: var(--c-surface);
        z-index: 1001;
        overflow-y: auto;
        overflow-x: hidden;
        box-sizing: border-box;
        border-radius: 35px;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16);
        border: 1px solid var(--c-border);
    }

    .menu-menu_principal-container {
        display: block;
        width: 100%;
    }

    .main-navigation ul {
        flex-direction: column;
        align-items: center;
        padding: 1rem 0;
        width: 100%;
    }

    .main-navigation li {
        margin: 8px;
        width: 100%;
        text-align: center;
    }

    .main-navigation ul li:nth-child(2) {
        border-top: 1px solid var(--c-soft);
        border-bottom: 1px solid var(--c-soft);
        padding: 10px 0;
    }

    .main-navigation a {
        padding: 8px 16px;
        color: var(--c-primary);
        text-shadow: none;
    }

    .main-navigation a:hover {
        color: var(--c-primary-strong);
    }

    .site-header--front:not(.scrolled) {
        background-color: transparent;
    }

    .site-header--front:not(.scrolled) .main-navigation a {
        color: var(--c-primary);
        text-shadow: none;
    }

    .site-header--front:not(.scrolled) .main-navigation a:hover {
        color: var(--c-primary-strong);
    }

    .site-header--front:not(.scrolled) .menu-toggle {
        color: var(--c-surface);
    }

    body.admin-bar .site-header {
        top: var(--wp-admin--admin-bar--height, 46px);
    }

}

/* Breakpoint para móviles más pequeños */
@media screen and (max-width: 480px) {

    .site-header {
        height: 100px;
        padding: 8px;
    }

    .site-header.scrolled {
        height: 50px;
        padding: 6px 8px;
        border-bottom-left-radius: 18px;
        border-bottom-right-radius: 18px;
    }

    .site-header.scrolled .site-logo {
        max-height: 36px;
    }

    .site-header .menu-toggle {
        font-size: 1.5rem;
        margin-left: 10px;
    }

    #mobile-menu-wrapper {
        top: 100%;
        width: min(92vw, 360px);
        max-height: calc(100vh - 100px);
    }
}

/* Estado activo (header scrolled, desktop) */
.site-header.scrolled .main-navigation .current-menu-item > a,
.site-header.scrolled .main-navigation .current_page_item > a,
.site-header.scrolled .main-navigation .current-menu-ancestor > a,
.site-header.scrolled .main-navigation .current_page_ancestor > a,
.site-header.scrolled .main-navigation .current-menu-parent > a,
.site-header.scrolled .main-navigation .current_page_parent > a {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}
