/* ============================================================
   Header Infolenca — v3
   Archivo y clases nuevas: no reutiliza el CSS del header anterior.
   Incluye los primitivos compartidos con el pie (logo, botón de app,
   punto en vivo, iconos de tema y bloqueo de scroll).
   ============================================================ */

/* ------------------------------------------------------------
   Header v3: 1) utilidades que se van al hacer scroll
   2) marca, secciones y acciones (barra fija)
   3) franja de temas (en móvil, navegación deslizable)
   ------------------------------------------------------------ */
.hd {
    position: sticky;
    /* La franja de utilidades mide 36px: al fijarse queda fuera de vista. */
    top: -36px;
    z-index: 60;
    background: #ffffff;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --fx-hdr-ink: #0a0e13;
    --fx-hdr-navy: #203473;
    --fx-hdr-navy-deep: #0e1130;
    --fx-hdr-muted: #5c6570;
    --fx-hdr-line: #e7e5df;
    --fx-hdr-soft: #eef1fb;
    --fx-hdr-orange: #f58220;
}

/* Bloqueo de scroll mientras el menú lateral está abierto. */
html.fx-no-scroll,
html.fx-no-scroll body {
    overflow: hidden;
}

/* El header fijo mide ~100px: los anclajes no deben quedar por debajo. */
html {
    scroll-padding-top: 112px;
}

@media (max-width: 1080px) {
    html {
        scroll-padding-top: 118px;
    }
}

/* ------------------------------------------------------------
   1. Franja de utilidades
   ------------------------------------------------------------ */
.hd-utility {
    height: 36px;
    background: #1b2455;
    color: rgba(255, 255, 255, .74);
}

.hd-utility__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    height: 100%;
}

.hd-utility__date {
    margin: 0;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hd-utility__nav {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 0 0 auto;
}

.hd-utility__link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: rgba(255, 255, 255, .74);
    text-decoration: none;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color .15s ease;
}

.hd-utility__link:hover,
.hd-utility__link--live {
    color: #ffffff;
}

.fx-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff4d4d;
    flex: 0 0 auto;
    animation: fx-live-pulse 2.6s ease-out infinite;
}

@keyframes fx-live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, .55); }
    70% { box-shadow: 0 0 0 6px rgba(255, 77, 77, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

/* ------------------------------------------------------------
   2. Barra de marca
   ------------------------------------------------------------ */
.hd.is-scrolled .hd-brand {
    box-shadow: 0 10px 28px rgba(10, 14, 19, .16);
}

.hd-brand {
    position: relative;
    background: var(--fx-hdr-navy);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.hd-brand__inner {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: clamp(12px, 1.6vw, 28px);
    height: 64px;
}

/* Marca compartida con el pie de página. */
.fx-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    font-weight: 950;
    font-size: 1.12rem;
    letter-spacing: -.02em;
}

.fx-logo img {
    display: block;
    height: 30px;
    width: auto;
}

.fx-logo__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--fx-accent);
    display: inline-block;
}

/* La marca no participa del reparto de espacio: siempre visible. */
.hd-logo {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    text-decoration: none;
    color: inherit;
}

.hd-logo img {
    display: block;
    height: 34px;
    width: auto;
}

/* --- Secciones (escritorio) --- */
.hd-nav {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
}

.hd-nav__links {
    display: flex;
    align-items: center;
    height: 100%;
    min-width: 0;
    /* Aire vertical: el anillo de foco no queda recortado. */
    padding-block: 8px;
    margin-block: -8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}

.hd-nav__links::-webkit-scrollbar {
    display: none;
}

.hd-nav__link {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 100%;
    padding: 0 10px;
    flex: 0 0 auto;
    color: rgba(255, 255, 255, .82);
    text-decoration: none;
    font-size: .86rem;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color .15s ease;
}

.hd-nav__link::after {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 0;
    height: 3px;
    background: #ffffff;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .18s ease;
}

.hd-nav__link:hover {
    color: #ffffff;
}

.hd-nav__link:hover::after {
    transform: scaleX(1);
}

.hd-nav__link.is-active {
    color: #ffffff;
}

.hd-nav__link.is-active::after {
    transform: scaleX(1);
}

/* --- Acciones --- */
.hd-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    margin-left: auto;
}

.hd-search {
    display: flex;
    align-items: center;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 999px;
    background: rgba(255, 255, 255, .10);
    overflow: hidden;
    transition: border-color .15s ease, background .15s ease;
}

.hd-search:focus-within {
    border-color: rgba(255, 255, 255, .68);
    background: rgba(255, 255, 255, .16);
}

.hd-search input {
    width: 150px;
    padding: 0 4px 0 14px;
    border: 0;
    background: transparent;
    color: #ffffff;
    font-family: inherit;
    font-size: .85rem;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.hd-search input::placeholder {
    color: rgba(255, 255, 255, .62);
}

.hd-search button {
    display: grid;
    place-items: center;
    height: 100%;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .82);
    cursor: pointer;
}

.hd-search button:hover {
    color: #ffffff;
}

.hd-icon,
.hd-theme,
.hd-burger {
    display: none;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .26);
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .15s ease, border-color .15s ease;
}

.hd-theme {
    display: grid;
}

.hd-icon:hover,
.hd-theme:hover,
.hd-burger:hover {
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .5);
}

.fx-icon-close {
    display: none;
}

.hd.is-searching .fx-icon-search {
    display: none;
}

.hd.is-searching .fx-icon-close {
    display: block;
}

/* Botón de app (solo Android): pastilla blanca, la acción más clara de la barra. */
.fx-app-cta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    background: #ffffff;
    color: #203473;
    text-decoration: none;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: background .15s ease;
}

.fx-app-cta:hover {
    background: #eef1fb;
    color: #203473;
}

.fx-app-cta__icon {
    flex: 0 0 auto;
}

/* ------------------------------------------------------------
   3. Franja de temas
   ------------------------------------------------------------ */
.hd-topics {
    background: #ffffff;
    border-bottom: 1px solid var(--fx-hdr-line);
}

.hd-topics__track {
    display: none;
}

.hd-topics__track--desktop {
    display: flex;
    align-items: center;
    height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}

.hd-topics__track--desktop::-webkit-scrollbar {
    display: none;
}

.hd-topics__link {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 16px;
    flex: 0 0 auto;
    border-left: 1px solid var(--fx-hdr-line);
    color: var(--fx-hdr-muted);
    text-decoration: none;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color .15s ease;
}

.hd-topics__track > :first-child {
    border-left: 0;
    padding-left: 0;
}

.hd-topics__link:hover,
.hd-topics__link.is-active {
    color: var(--fx-hdr-navy);
}

.hd-topics__link.is-active {
    font-weight: 800;
}

/* Sección principal (Noticias): punto de marca y peso alto. */
.hd-nav__link.is-featured,
.hd-topics__link.is-featured,
.hd-drawer__link.is-featured {
    font-weight: 800;
}

.hd-nav__link.is-featured::before,
.hd-topics__link.is-featured::before,
.hd-drawer__link.is-featured::before {
    content: '';
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    margin-right: 8px;
    border-radius: 50%;
    background: #f58220;
}

/* En escritorio la franja solo existe si aporta algo. */
@media (min-width: 1081px) {
    .hd-topics:not(:has(.hd-topics__track--desktop > a)) {
        display: none;
    }

    /* Difuminado en el borde cuando quedan secciones por ver. */
    .hd-topics__track--desktop.is-overflowing {
        -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
        mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
    }
}

/* ------------------------------------------------------------
   4. Menú lateral (tablet y móvil)
   ------------------------------------------------------------ */
.hd-drawer {
    display: none;
}

.hd-scrim {
    display: none;
}

.hd-drawer__head,
.hd-drawer__foot {
    display: flex;
    align-items: center;
}

/* Escritorio compacto: secciones más juntas antes de pasar al menú lateral. */
@media (max-width: 1280px) {
    .hd-search input {
        width: 108px;
    }
}

/* ------------------------------------------------------------
   5. Tablet y móvil
   ------------------------------------------------------------ */
@media (max-width: 1080px) {
    .hd {
        top: 0;
    }

    .hd-utility {
        display: none;
    }

    .hd-brand__inner {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 8px;
        height: 58px;
    }

    .hd-burger {
        display: grid;
        grid-column: 1;
        justify-self: start;
    }

    .hd-logo {
        grid-column: 2;
        justify-self: center;
    }

    .hd-logo img {
        height: 28px;
    }

    .hd-nav {
        display: none;
    }

    .hd-actions {
        grid-column: 3;
        justify-self: end;
        gap: 6px;
        margin-left: 0;
    }

    /* El tema vive en el menú lateral para dejar aire a la marca. */
    .hd .hd-theme {
        display: none;
    }

    .hd-icon {
        display: grid;
    }

    .fx-app-cta {
        height: 34px;
    }

    /* Buscador: fila desplegable a todo el ancho bajo la barra. */
    .hd-brand .hd-search {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 3;
        display: none;
        height: 56px;
        padding: 0 16px;
        border: 0;
        border-top: 1px solid var(--fx-hdr-line);
        border-bottom: 1px solid var(--fx-hdr-line);
        border-radius: 0;
        background: #ffffff;
        box-shadow: 0 16px 32px rgba(15, 23, 42, .12);
        overflow: visible;
    }

    .hd.is-searching .hd-search {
        display: flex;
    }

    .hd-search input {
        flex: 1 1 auto;
        width: 100%;
        padding-left: 2px;
        color: var(--fx-hdr-ink);
        font-size: 1rem;
    }

    .hd-search input::placeholder {
        color: var(--fx-hdr-muted);
    }

    .hd-search button {
        padding: 0 4px;
        color: var(--fx-hdr-navy);
    }

    /* Franja de secciones: navegación deslizable. */
    .hd-topics__track--desktop {
        display: none;
    }

    .hd-topics__track--mobile {
        display: flex;
        align-items: center;
        height: 46px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .hd-topics__track--mobile::-webkit-scrollbar {
        display: none;
    }

    .hd-topics__link--mobile {
        height: 46px;
        padding: 0 14px;
        color: var(--fx-hdr-ink);
        font-size: .78rem;
        letter-spacing: .04em;
    }

    .hd-topics__link--mobile.is-active {
        color: var(--fx-hdr-navy);
        box-shadow: inset 0 -2px 0 var(--fx-hdr-navy);
    }

    /* Panel lateral */
    .hd-drawer {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 90;
        display: flex;
        flex-direction: column;
        width: min(380px, 90vw);
        max-width: 100%;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #ffffff;
        color: var(--fx-hdr-ink);
        box-shadow: -18px 0 44px rgba(15, 23, 42, .22);
        transform: translateX(102%);
        visibility: hidden;
        overflow: hidden;
        /* visibility se resuelve al instante al abrir y al terminar de cerrar. */
        transition: transform .3s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .3s;
    }

    .hd-drawer.fx-is-open {
        transform: none;
        visibility: visible;
        transition: transform .3s cubic-bezier(.22, 1, .36, 1), visibility 0s linear 0s;
    }

    .hd-drawer__head {
        justify-content: space-between;
        gap: 12px;
        flex: 0 0 auto;
        padding: 12px 12px 12px 18px;
        border-bottom: 1px solid var(--fx-hdr-line);
    }

    .hd-drawer__title {
        font-size: .72rem;
        font-weight: 800;
        letter-spacing: .14em;
        text-transform: uppercase;
        color: var(--fx-hdr-muted);
    }

    .hd-drawer__close {
        display: grid;
        place-items: center;
        width: 38px;
        height: 38px;
        padding: 0;
        border-radius: 999px;
        border: 1px solid var(--fx-hdr-line);
        background: #f4f3ef;
        color: var(--fx-hdr-ink);
        cursor: pointer;
    }

    .hd-drawer__list {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .hd-drawer__link {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        padding: 15px 18px;
        border-bottom: 1px solid #f0eee8;
        color: var(--fx-hdr-ink);
        text-decoration: none;
        font-size: 1rem;
        font-weight: 650;
    }

    .hd-drawer__link::after {
        content: '';
        flex: 0 0 auto;
        margin-left: auto;
        width: 7px;
        height: 7px;
        border-right: 1.6px solid currentColor;
        border-bottom: 1.6px solid currentColor;
        transform: rotate(-45deg);
        opacity: .35;
    }

    .hd-drawer__link:hover {
        background: #f7f6f2;
    }

    .hd-drawer__link.is-active {
        background: var(--fx-hdr-soft);
        color: var(--fx-hdr-navy);
        font-weight: 800;
    }

    .hd-drawer__link.is-active::after {
        opacity: .8;
    }

    .hd-drawer__foot {
        gap: 8px;
        flex-wrap: wrap;
        flex: 0 0 auto;
        padding: 12px 18px 16px;
        border-top: 1px solid var(--fx-hdr-line);
        background: #fbfaf7;
    }

    .hd-drawer__theme,
    .hd-drawer__util {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        height: 34px;
        padding: 0 12px;
        border-radius: 999px;
        border: 1px solid var(--fx-hdr-line);
        background: #ffffff;
        color: var(--fx-hdr-ink);
        text-decoration: none;
        font-family: inherit;
        font-size: .74rem;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
        cursor: pointer;
    }

    .hd-drawer__theme:hover,
    .hd-drawer__util:hover {
        border-color: var(--fx-hdr-navy);
        color: var(--fx-hdr-navy);
    }

    .hd-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 80;
        background: rgba(10, 14, 19, .46);
        opacity: 0;
        visibility: hidden;
        transition: opacity .3s ease, visibility 0s linear .3s;
    }

    .hd.is-nav-open .hd-scrim {
        opacity: 1;
        visibility: visible;
        transition: opacity .3s ease, visibility 0s linear 0s;
    }
}

/* Teléfonos: barra más baja y controles compactos. */
@media (max-width: 560px) {
    .hd-brand__inner {
        height: 56px;
    }

    .hd-logo img {
        height: 26px;
    }

    .hd-burger,
    .hd-icon {
        width: 34px;
        height: 34px;
    }

    .fx-app-cta {
        height: 34px;
    }

    .hd-topics__link--mobile {
        font-size: .76rem;
        padding: 0 12px;
    }
}

/* Teléfonos angostos: el botón de app queda solo con icono (aria-label completo). */
@media (max-width: 420px) {
    .fx-app-cta {
        width: 34px;
        padding: 0;
        justify-content: center;
    }

    .fx-app-cta__label {
        display: none;
    }
}

/* ------------------------------------------------------------
   6. Tema, foco y movimiento
   ------------------------------------------------------------ */
.fx-icon-moon {
    display: none;
}

[data-theme="dark"] .fx-icon-sun {
    display: none;
}

[data-theme="dark"] .fx-icon-moon {
    display: block;
}

.hd-utility :focus-visible,
.hd-brand :focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.hd-topics :focus-visible,
.hd-drawer :focus-visible {
    outline: 2px solid var(--fx-hdr-navy);
    outline-offset: -2px;
}

/* La píldora ya marca el foco del campo: el input no duplica el anillo. */
.hd-search input:focus-visible {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    .hd-drawer,
    .hd-scrim,
    .hd-nav__link,
    .hd-nav__link::after,
    .hd-topics__link,
    .fx-app-cta,
    .hd-theme,
    .hd-burger,
    .hd-icon,
    .fx-live-dot {
        transition: none;
        animation: none;
    }
}


@media print {
    .hd,
    .hd-scrim {
        display: none !important;
    }
}
