/* --- Search Toggle & Panel [itx_search] --- */

/*
 * Parent menu link. Prefixed with the menu wrapper IDs (not item IDs) so it
 * outranks Max Mega Menu's own link rules. Height is left to MMM (80px
 * desktop / 40px mobile) so the button stays centred in the bar.
 */
#mega-menu-wrap-max_mega_menu_1 #mega-menu-max_mega_menu_1 > li.mega-menu-item > a.mega-menu-link:has(> .itx-search-toggle) {
    display: inline-flex;
    align-items: center;
    line-height: normal;
    vertical-align: top;
    background: transparent;
    border-color: transparent;
    text-decoration: none;
}

.itx-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 38px;
    height: 38px;
    padding: 0;
    position: relative;
    top: 2px; /* optical alignment with menu text */
    border: 1px solid #d6d6d6;
    border-radius: 50%;
    background: #f1f1f1;
    color: #58595b;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.itx-search-toggle i {
    font-size: 14px;
    line-height: 1;
}

.itx-search-toggle:hover,
.itx-search-toggle:focus-visible,
.itx-search-toggle[aria-expanded="true"] {
    background: #ff8b22;
    border-color: #ff8b22;
    color: #fff;
}

@media only screen and (max-width: 768px) {
    .itx-search-toggle {
        top: 0; /* 38px button inside MMM's 40px mobile row */
    }
}

/* Sits one layer above the global UI overlay (9998). */
.itx-search-panel {
    position: fixed;
    top: calc(80px + var(--wp-admin--admin-bar--height, 0px));
    left: 50%;
    right: auto;
    width: min(var(--site-content-width, 1200px), calc(100% - 2rem));
    z-index: 9999;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 24px 0 rgba(244, 244, 244, 1);
    transform: translate(-50%, -100%);
    opacity: 0;
    visibility: hidden;
    transition: transform .3s ease, opacity .3s ease, visibility 0s linear .3s;
}

.itx-search-panel.is-active {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
    transition: transform .3s ease, opacity .3s ease;
}

.itx-search-panel__inner {
    width: 100%;
    padding: 1.5rem 2rem;
}

.itx-search-panel__form {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.itx-search-panel__input {
    flex: 1 1 auto;
    border: 0;
    border-bottom: 2px solid #ddd;
    padding: .5rem 0;
    font-size: 1.5rem;
    background: transparent;
    outline: none;
}

.itx-search-panel__input:focus {
    border-bottom-color: #000;
}

.itx-search-panel__close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2em;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: inherit;
}

.itx-search-panel__close:hover,
.itx-search-panel__close:focus-visible {
    opacity: .7;
}

/* Prevents the dimmed background from still being scrollable underneath. */
body.itx-search-is-open {
    overflow: hidden;
    user-select: none;
}

body.itx-search-is-open .itx-search-panel,
body.itx-search-is-open .itx-search-panel * {
    user-select: text;
}
