/* Hide Astra's original icon/title immediately, before JavaScript replaces it. */
#masthead .site-branding:not([data-mfsa-brand]) > * {
    visibility: hidden !important;
}

#masthead .site-branding[data-mfsa-brand] {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    overflow: visible !important;
}

#masthead .site-branding[data-mfsa-brand] .mfsa-official-logo-link {
    display: block !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important;
    overflow: visible !important;
}

#masthead .site-branding[data-mfsa-brand] img.mfsa-official-logo {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 60px !important;
    min-height: 0 !important;
    max-height: 60px !important;
    margin: 0 !important;
    padding: 0 !important;
    object-fit: contain !important;
}

@media (min-width: 1401px) {
    #masthead .site-header-section-left,
    #masthead .site-header-above-section-left,
    #masthead .site-header-primary-section-left,
    #masthead [data-section="title_tagline"],
    #masthead .site-branding[data-mfsa-brand] {
        flex: 0 0 240px !important;
        width: 240px !important;
        min-width: 240px !important;
        max-width: 240px !important;
    }

    #masthead .site-branding[data-mfsa-brand] img.mfsa-official-logo {
        height: 64px !important;
        max-height: 64px !important;
    }
}

@media (min-width: 922px) and (max-width: 1400px) {
    #masthead .site-header-section-left,
    #masthead .site-header-above-section-left,
    #masthead .site-header-primary-section-left,
    #masthead [data-section="title_tagline"],
    #masthead .site-branding[data-mfsa-brand] {
        flex: 0 0 180px !important;
        width: 180px !important;
        min-width: 180px !important;
        max-width: 180px !important;
    }
}

@media (max-width: 921px) {
    #masthead .site-branding[data-mfsa-brand] img.mfsa-official-logo {
        height: 48px !important;
        max-height: 48px !important;
    }
}

/* WP Accessibility high-contrast mode: white logo on black. */
body.a11y-contrast #masthead img.mfsa-official-logo,
body.wp-accessibility-high-contrast #masthead img.mfsa-official-logo,
html.a11y-contrast #masthead img.mfsa-official-logo,
html.wp-accessibility-high-contrast #masthead img.mfsa-official-logo {
    filter: brightness(0) invert(1) !important;
}

/* =========================================================
   DESKTOP CONTROL SAFETY SPACE — 1.0.1
   Keep the language switcher and internal-page search inside the
   viewport, especially with the longer French navigation labels.
   ========================================================= */
@media (min-width: 1401px) {
    html body #masthead .site-header .ast-container,
    html body #masthead .ast-container,
    html body #masthead .ast-main-header-bar-alignment {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 28px !important;
        padding-right: 28px !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    html body #masthead .ast-builder-grid-row {
        width: 100% !important;
        min-width: 0 !important;
        gap: 10px !important;
        box-sizing: border-box !important;
    }

    html body #masthead .site-header-section-right,
    html body #masthead .site-header-above-section-right,
    html body #masthead .site-header-primary-section-right {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        padding-right: 8px !important;
        overflow: visible !important;
    }

    html body #masthead .main-header-menu {
        min-width: 0 !important;
        align-items: center !important;
    }

    html body #masthead .mfsa-menu-toggle-wrapper,
    html body #masthead .mfsa-lang-widget,
    html body #masthead .mfsa-search-item {
        flex: 0 0 auto !important;
    }

    html body #masthead .mfsa-search-item {
        margin-right: 10px !important;
    }

    html[lang^="fr"] body #masthead #ast-hf-menu-1 > .menu-item > a,
    html[lang^="fr"] body #masthead #ast-hf-menu-2 > .menu-item > a,
    html[class*="translatepress-fr"] body #masthead #ast-hf-menu-1 > .menu-item > a,
    html[class*="translatepress-fr"] body #masthead #ast-hf-menu-2 > .menu-item > a,
    html body[class*="translatepress-fr"] #masthead #ast-hf-menu-1 > .menu-item > a,
    html body[class*="translatepress-fr"] #masthead #ast-hf-menu-2 > .menu-item > a {
        padding-left: 6px !important;
        padding-right: 6px !important;
        font-size: 15px !important;
    }

    html[lang^="fr"] body #masthead .ast-builder-grid-row,
    html[class*="translatepress-fr"] body #masthead .ast-builder-grid-row,
    html body[class*="translatepress-fr"] #masthead .ast-builder-grid-row {
        gap: 4px !important;
    }
}
