/**
 * Estilos del bloque: CTC - Cabecera
 * Este archivo se usa tanto en el editor como en el frontend.
 * Metodología: Desktop First.
 *
 * Consume los tokens de marca de css/ctc-css-base/ctc-css-base.css
 * (la hoja base se encola sola al detectar bloques onlines/ctc-*).
 */

/* ============================================
   Contenedor principal - Desktop
   ============================================ */
.ctc-header {
    margin-top: 0 !important;
    width: 100%;
    max-width: none !important;
    box-sizing: border-box;
}

.ctc-header,
.ctc-header::before,
.ctc-header::after,
.ctc-header *,
.ctc-header *::before,
.ctc-header *::after {
    box-sizing: border-box;
}

/* ============================================
   Barra
   El lateral del diseño (120px a 1440px) se hace
   fluido para no forzar un ancho fijo.
   ============================================ */
.ctc-header__barra {
    background: var(--ctc-color-fondo);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 20px clamp(24px, 8.33vw, 120px);
    border-bottom: 1px solid var(--ctc-color-borde);
    font-family: var(--ctc-font-base);
    color: var(--ctc-color-oscuro);
}

/* En las páginas del micrositio, el primer header institucional adopta
   los mismos laterales que la barra CTC. El :has() limita el ajuste a las
   páginas que contienen efectivamente este bloque. */
body:has(.wp-block-onlines-ctc-header) .header-institucion .header__wrapper {
    padding-right: 0 !important;
    padding-left: 0 !important;
}

body:has(.wp-block-onlines-ctc-header) .header-institucion .container {
    width: calc(100% - clamp(24px, 8.33vw, 120px) - clamp(24px, 8.33vw, 120px));
    max-width: none !important;
    margin-right: auto !important;
    margin-left: auto !important;
}

/* ============================================
   Logo (h1 clickeable)
   ============================================ */
.ctc-header__logo {
    margin: 0;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.ctc-header__logo-enlace {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

/* Wordmark del programa (contiene el nombre completo con el degradé) */
.ctc-header__logo-marca {
    height: 52px;
    width: auto;
    flex: none;
    display: block;
}

/* El nombre ya está en el logo: el span queda solo para lectores de
   pantalla (el h1 necesita texto real). */
.ctc-header__logo-texto {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Menú de navegación - fila inline en desktop
   ============================================ */
.ctc-header__menu {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.ctc-header__nav {
    display: flex;
    align-items: center;
    gap: 34px;
    font-size: 15px;
}

.ctc-header__enlace {
    color: var(--ctc-color-texto-sec);
    font-weight: 500;
    text-decoration: none;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: color var(--ctc-transition), border-color var(--ctc-transition);
}

a.ctc-header__enlace:hover {
    color: var(--ctc-color-oscuro);
}

.ctc-header__enlace--sin-enlace {
    cursor: default;
}

.ctc-header__enlace--activo {
    color: var(--ctc-color-oscuro);
    font-weight: 700;
    border-bottom-color: var(--ctc-color-acento);
}

/* ============================================
   Botón hamburguesa (oculto en desktop)
   ============================================ */
.ctc-header__burger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
}

.ctc-header__burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--ctc-color-oscuro);
    border-radius: 2px;
    transition: all 0.25s ease;
}

.ctc-header__burger span:nth-child(2) {
    width: 16px;
}

.ctc-header__burger--abierto span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.ctc-header__burger--abierto span:nth-child(2) {
    opacity: 0;
}

.ctc-header__burger--abierto span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ============================================
   Responsive - Tablet/Móvil (max-width: 1023px)
   La barra pasa a logo + hamburguesa; el menú
   se convierte en desplegable de ancho completo.
   ============================================ */
@media (max-width: 63.9375rem) {
    body:has(.wp-block-onlines-ctc-header) .header-institucion .container {
        width: calc(100% - clamp(20px, 6vw, 32px) - clamp(20px, 6vw, 32px));
    }

    .ctc-header__barra {
        padding: 16px clamp(20px, 6vw, 32px);
    }

    .ctc-header__logo-marca {
        height: 40px;
    }

    .ctc-header__logo-enlace {
        gap: 10px;
    }

    /* Logo y burger por encima del panel: el burger queda accesible
       para cerrar el menú cuando está abierto. */
    .ctc-header__logo,
    .ctc-header__burger {
        position: relative;
        z-index: 100;
    }

    .ctc-header__burger {
        display: flex;
    }

    /* Panel a pantalla completa */
    .ctc-header__menu {
        position: fixed;
        inset: 0;
        z-index: 90;
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--ctc-color-fondo);
        /* El padding-top tiene que despejar la barra (logo + burger), que
           quedan por encima del panel: si no, el filete se le superpone. */
        padding: 108px clamp(20px, 6vw, 32px) 36px;
        overflow-y: auto;
        overscroll-behavior: contain;
        /* Cerrado: sin ocupar ni recibir clics */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
    }

    .ctc-header__menu--abierto {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s;
    }

    /* Filete de marca: separa la barra del panel y trae el full color */
    .ctc-header__menu::before {
        content: '';
        flex: none;
        height: 3px;
        margin: 14px 0 4px;
        border-radius: 2px;
        background: var(--ctc-gradiente-marca);
    }

    .ctc-header__nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding-top: 6px;
    }

    /* Ítems: Inter semibold + flecha de acento (mismo motivo que el resto
       del micrositio). El activo y el hover se tiñen de rosa de marca. */
    .ctc-header__enlace {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        font-family: var(--ctc-font-base);
        font-size: 22px;
        font-weight: var(--ctc-font-weight-semibold);
        letter-spacing: -0.01em;
        color: var(--ctc-color-oscuro);
        padding: 19px 2px;
        border-bottom: 1px solid var(--ctc-color-borde);
        transition: color var(--ctc-transition);
    }

    .ctc-header__enlace::after {
        content: '→';
        color: var(--ctc-color-acento);
        opacity: 0;
        transform: translateX(-6px);
        transition: opacity var(--ctc-transition), transform var(--ctc-transition);
    }

    a.ctc-header__enlace:hover,
    a.ctc-header__enlace:focus-visible,
    .ctc-header__enlace--activo {
        color: var(--ctc-color-acento);
    }

    a.ctc-header__enlace:hover::after,
    a.ctc-header__enlace:focus-visible::after,
    .ctc-header__enlace--activo::after {
        opacity: 1;
        transform: translateX(0);
    }

    /* El acento ya está en el texto: el divisor queda neutro */
    .ctc-header__enlace--activo {
        border-bottom-color: var(--ctc-color-borde);
    }

    /* Ítem sin enlace (ej. sección pendiente): apagado y sin flecha */
    .ctc-header__enlace--sin-enlace {
        color: var(--ctc-color-texto-mute);
    }

    .ctc-header__enlace--sin-enlace::after {
        display: none;
    }

    /* Con el panel a pantalla completa, el fondo no debe scrollear.
       La clase la pone/saca ctc-header-frontend.js. */
    body.ctc-menu-abierto {
        overflow: hidden;
    }

}

/* ============================================
   Estilos específicos del editor
   ============================================ */
.editor-styles-wrapper .ctc-header {
    margin-left: 0;
    margin-right: 0;
}

.editor-styles-wrapper .ctc-header__logo-enlace,
.editor-styles-wrapper .ctc-header__enlace {
    cursor: default;
}

/* En el editor el logo es un <span>: se pinta como background-image
   (url relativa a este CSS). Ratio del wordmark 1600:789. */
.editor-styles-wrapper .ctc-header__logo-marca {
    background: url('ctc-header-images/ctc-header-logo.svg') no-repeat left center / contain;
    height: 52px;
    width: 106px;
}

@media (max-width: 63.9375rem) {
    .editor-styles-wrapper .ctc-header__logo-marca {
        height: 42px;
        width: 85px;
    }
}
