/**
 * INATGI Theme Six — journal header repair V2 2026-08-24
 *
 * Fixes:
 * 1. fallback navigation order: menu first, Search last;
 * 2. removes the large blank gap between Search and the menu;
 * 3. dropdown opens immediately below its top-level title;
 * 4. preserves accessible skip links off-canvas until focused.
 */

/* =========================================================
   ACCESSIBLE SKIP LINKS
   ========================================================= */
body.inatgi-journal-context .pkp_structure_head .pkp_skip_to_content,
body.inatgi-journal-context .pkp_structure_head .pkp_skip_to_content_nav,
body.inatgi-journal-context .pkp_structure_head [class*="skip_to"] {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    z-index: 99999 !important;
}

body.inatgi-journal-context .pkp_structure_head .pkp_skip_to_content:focus-within,
body.inatgi-journal-context .pkp_structure_head .pkp_skip_to_content_nav:focus-within,
body.inatgi-journal-context .pkp_structure_head [class*="skip_to"]:focus-within {
    left: 16px !important;
    top: 16px !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    padding: 10px 14px !important;
    background: #fff !important;
    border: 2px solid #b51226 !important;
    box-shadow: 0 4px 14px rgba(0,0,0,.14) !important;
}

body.inatgi-journal-context .inatgi-journal-core-header-hidden {
    display: none !important;
}

/* =========================================================
   HEADER SLOT GEOMETRY
   ========================================================= */

/* The journal header remains the shared 3-column frame:
   cover/logo | navigation + search | submit. */
body.inatgi-journal-context .inatgi-journal-mainbar {
    align-items: center !important;
}

body.inatgi-journal-context .inatgi-journal-navigation-slot {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 18px !important;
    min-width: 0 !important;
    height: 196px !important;
    overflow: visible !important;
}

/* Hide the empty original wrapper used only as the source DOM. */
body.inatgi-journal-context.inatgi-journal-fallback-menu-active
.inatgi-journal-navigation-wrapper {
    display: none !important;
}

/* =========================================================
   FALLBACK PRIMARY NAVIGATION
   ========================================================= */

body.inatgi-journal-context .inatgi-fallback-primary {
    order: 10 !important;
    flex: 0 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: clamp(12px, 1vw, 20px) !important;

    /* Critical: do NOT inherit the 196px header height.
       The previous 100% height made dropdowns start ~150px
       below their titles. */
    width: auto !important;
    height: 46px !important;
    min-height: 46px !important;
    max-height: 46px !important;

    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    background: transparent !important;
    border: 0 !important;
}

body.inatgi-journal-context .inatgi-fallback-primary > li {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    height: 46px !important;
    min-height: 46px !important;
    max-height: 46px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

body.inatgi-journal-context .inatgi-fallback-primary > li > a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    height: 46px !important;
    min-height: 46px !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #161616 !important;
    background: transparent !important;
    border: 0 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: clamp(13px, .80vw, 15px) !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
    white-space: nowrap !important;
    text-decoration: none !important;
}

body.inatgi-journal-context .inatgi-fallback-primary > li > a:hover,
body.inatgi-journal-context .inatgi-fallback-primary > li > a:focus {
    color: #b51226 !important;
    text-decoration: none !important;
}

body.inatgi-journal-context .inatgi-fallback-primary .inatgi-menu-caret {
    display: inline-block !important;
    margin-left: 5px !important;
    color: #777 !important;
    font-size: 9px !important;
    line-height: 1 !important;
}

/* =========================================================
   DROPDOWN — TIGHT TO THE TITLE
   ========================================================= */

body.inatgi-journal-context .inatgi-fallback-primary .inatgi-fallback-submenu {
    position: absolute !important;

    /* 44px anchors the panel almost directly under the 46px title row.
       This replaces top:100%, which previously used the 196px header height. */
    top: 44px !important;
    left: -14px !important;
    z-index: 10020 !important;

    display: block !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;

    min-width: 250px !important;
    margin: 0 !important;
    padding: 7px 0 !important;
    list-style: none !important;

    background: #fff !important;
    border: 1px solid #dedede !important;
    border-top: 3px solid #b51226 !important;
    border-radius: 0 0 4px 4px !important;
    box-shadow: 0 8px 22px rgba(0,0,0,.10) !important;

    transform: translateY(1px) !important;
    transition: opacity .12s ease, transform .12s ease !important;
}

/* Small invisible hover bridge only — no visible gap. */
body.inatgi-journal-context .inatgi-fallback-primary
.inatgi-fallback-submenu::before {
    content: "" !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: -7px !important;
    height: 7px !important;
}

body.inatgi-journal-context .inatgi-fallback-primary > li:hover
> .inatgi-fallback-submenu,
body.inatgi-journal-context .inatgi-fallback-primary > li:focus-within
> .inatgi-fallback-submenu,
body.inatgi-journal-context .inatgi-fallback-primary > li.is-open
> .inatgi-fallback-submenu {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
}

body.inatgi-journal-context .inatgi-fallback-primary
.inatgi-fallback-submenu li {
    display: block !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

body.inatgi-journal-context .inatgi-fallback-primary
.inatgi-fallback-submenu a {
    display: block !important;
    padding: 9px 16px !important;
    color: #222 !important;
    background: #fff !important;
    border: 0 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    white-space: nowrap !important;
    text-decoration: none !important;
}

body.inatgi-journal-context .inatgi-fallback-primary
.inatgi-fallback-submenu a:hover,
body.inatgi-journal-context .inatgi-fallback-primary
.inatgi-fallback-submenu a:focus {
    color: #b51226 !important;
    background: #f7f7f7 !important;
    text-decoration: none !important;
}

/* =========================================================
   SEARCH — ALWAYS AFTER CONTACT
   ========================================================= */

/* Older ThemeSix CSS can place the OJS Search control before navigation.
   V2 explicitly restores menu -> Search order. */
body.inatgi-journal-context .inatgi-journal-navigation-slot
> .inatgi-journal-search {
    order: 20 !important;
    flex: 0 0 auto !important;

    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    float: none !important;
    transform: none !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;

    width: auto !important;
    min-width: 0 !important;
    height: 46px !important;
    min-height: 46px !important;
    max-height: 46px !important;

    margin: 0 !important;
    padding: 0 !important;
}

/* If the legacy Search wrapper contains its own margins, neutralize them. */
body.inatgi-journal-context .inatgi-journal-navigation-slot
> .inatgi-journal-search > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Keep submit aligned vertically with menu/search. */
body.inatgi-journal-context .inatgi-journal-submit {
    align-self: center !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1350px) {
    body.inatgi-journal-context .inatgi-journal-navigation-slot {
        gap: 13px !important;
    }

    body.inatgi-journal-context .inatgi-fallback-primary {
        gap: 12px !important;
    }

    body.inatgi-journal-context .inatgi-fallback-primary > li > a {
        font-size: 12.5px !important;
    }
}

@media (max-width: 1050px) {
    body.inatgi-journal-context .inatgi-journal-navigation-slot {
        width: 100% !important;
        height: 48px !important;
        min-height: 48px !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        gap: 14px !important;
    }

    body.inatgi-journal-context .inatgi-fallback-primary {
        min-width: max-content !important;
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
    }

    body.inatgi-journal-context .inatgi-fallback-primary > li,
    body.inatgi-journal-context .inatgi-fallback-primary > li > a {
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
    }

    body.inatgi-journal-context .inatgi-fallback-primary
    .inatgi-fallback-submenu {
        top: 46px !important;
    }

    body.inatgi-journal-context .inatgi-journal-navigation-slot
    > .inatgi-journal-search {
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
    }
}
