body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: min(100%, 690px);
    margin-inline: auto;
}

body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) > li > a {
    height: 100%;
    font-size: calc(14px + 2pt) !important;
    text-align: center;
}

body.home :is(#publicaciones-docentes, #problemas-de-electrotecnia, #mis-publicaciones-religiosas) {
    scroll-margin-top: 52px;
}

@media (min-width: 900px) {
    body:is(.home, .page) #masthead .site-header-main:has(.jas-ancla-publicacion) {
        grid-template-columns: minmax(0, 1fr);
        padding-inline: 0;
    }

    body:is(.home, .page) #masthead #site-header-menu:has(.jas-ancla-publicacion) {
        width: calc(100% - 2 * clamp(12px, 2.5vw, 40px) - 40px);
        max-width: 1400px;
    }

    body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        width: 100% !important;
        gap: 6px;
        padding: 0;
    }

    body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) > li > a {
        padding: 8px 6px !important;
        min-height: 42px;
        font-size: calc(clamp(11px, 1vw, 13px) + 2pt) !important;
        white-space: normal;
        text-align: center;
    }
}


body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion)::before,
body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion)::after {
    content: none !important;
    display: none !important;
}

body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) > li:nth-child(1) { grid-column: 2; grid-row: 1; }
body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) > li:nth-child(2) { grid-column: 3; grid-row: 1; }
body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) > li:nth-child(n+3):nth-child(-n+6) { grid-row: 2; }

/* El foco se mantiene en el título de destino para facilitar la navegación. */
body.home h2:is(#publicaciones-docentes, #problemas-de-electrotecnia, #mis-publicaciones-religiosas):focus {
    outline: none !important;
}

@media (max-width: 700px) {
    body:is(.home, .page) #page #masthead {
        min-height: 0;
    }

    body:is(.home, .page) #page #masthead .site-header-main {
        grid-template-columns: minmax(0, 1fr);
        padding: 30px 14px 16px;
    }

    body:is(.home, .page) #page #masthead .site-title,
    body:is(.home, .page) #page #masthead .site-title a {
        font-size: clamp(2.25rem, 10.6vw, 3.7rem) !important;
    }

    body:is(.home, .page) #page #masthead .site-description {
        margin: 13px 0 19px !important;
    }

    body:is(.home, .page) #masthead .site-branding .site-description {
        font-size: clamp(10px, 3.6vw, 17px) !important;
        white-space: nowrap;
    }

    body:is(.home, .page) #masthead #menu-toggle {
        display: block !important;
        min-height: 44px;
        margin: 0 auto;
        padding: 8px 20px;
        border: 1px solid #ffffff80;
        border-radius: 5px;
        background: #182534ed;
        color: #fff;
        font: 600 14px/1.3 system-ui, sans-serif;
    }

    body:is(.home, .page) #masthead #site-header-menu {
        display: grid !important;
        grid-template-rows: 0fr;
        width: min(100%, 360px);
        padding-top: 0;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: grid-template-rows 650ms cubic-bezier(.7, 0, .84, 0),
            padding-top 650ms cubic-bezier(.7, 0, .84, 0),
            opacity 650ms cubic-bezier(.7, 0, .84, 0), visibility 0s 650ms;
    }

    body:is(.home, .page) #masthead #site-header-menu.toggled-on {
        grid-template-rows: 1fr;
        padding-top: 10px;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition-timing-function: cubic-bezier(.16, 1, .3, 1);
        transition-delay: 0s;
    }

    body:is(.home, .page) #masthead #site-header-menu > #site-navigation {
        min-height: 0;
        overflow: hidden;
    }

    body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 5px;
    }

    body:is(.home, .page) #masthead #site-navigation .primary-menu:has(> .jas-ancla-publicacion) > li > a {
        min-height: 44px;
        padding: 8px 12px !important;
        font-size: 14px !important;
        white-space: normal;
    }

    body:is(.home, .page) #page #content.site-content {
        width: 100% !important;
        max-width: none;
        margin: 0 0 32px;
        padding-inline: clamp(16px, 5vw, 28px) !important;
        border: 0;
        background: #fff !important;
        box-shadow: none;
    }

    body:is(.home, .page) #page.site {
        background: #fff !important;
    }
}

@media (max-width: 700px) and (prefers-reduced-motion: reduce) {
    body:is(.home, .page) #masthead #site-header-menu {
        transition: none;
    }
}
