/*
 * Site search: the header trigger (desktop bar + mobile drawer) and the popup
 * it opens. Depends on ud-header-footer.css for --c-white/--c-black/--c-offwhite/
 * --c-navy/--c-line, declared as a wp_enqueue_style dependency in
 * includes/search.php so the load order is guaranteed rather than assumed.
 */

/* ============================================================
 * Trigger button
 * ============================================================ */

.ud-search-trigger {
    display: flex;
    flex: none;
    align-items: center;
    gap: 10px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--c-offwhite);
    cursor: pointer;
}

.ud-header--page .ud-search-trigger {
    color: var(--c-black);
}

/* .ud-header__lang is flex/flex-end with the language switcher as its only
   other child — a gap of its own would need a header-footer.css change, so
   the trigger carries the space instead. */
.ud-header__lang .ud-search-trigger {
    margin-right: 16px;
}

/* Collapsed mobile bar shows only the logo, language switch and burger — the
   drawer carries its own copy of the trigger (.ud-search-trigger--drawer-icon,
   below the menu list), so search is not lost, just moved out of the bar. */
@media (max-width: 767.98px) {
    .ud-header__lang .ud-search-trigger {
        display: none;
    }
}

.ud-search-trigger__icon {
    flex: none;
    width: 22px;
    height: 22px;
}

/* Icon-only in the top bar — the accessible name is still there for anyone
   not seeing the lens shape, just visually hidden. */
.ud-search-trigger__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* The drawer's copy sits below the menu list, icon-only like the desktop
   trigger (the base rule already keeps .ud-search-trigger__label visually
   hidden) — centred as a block box via its own fixed 40px width + auto
   margins, since .ud-drawer__inner is plain block flow, not a flex row. */
.ud-search-trigger--drawer-icon {
    margin: 0 0 0 8px;
}

/* ============================================================
 * Popup
 * ============================================================ */

/*
 * z-index above everything else the header stacks (.ud-burger is the highest
 * at 999) so the popup always wins regardless of what else is open — though
 * js/ud-header.js also closes the drawer/lang dropdown before opening this.
 */
.ud-search-popup {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 96px 20px 20px;
    background: rgba(1, 1, 1, .6);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility 0s linear .2s;
}

.ud-search-popup--open {
    opacity: 1;
    visibility: visible;
    transition: opacity .2s ease, visibility 0s linear 0s;
}

.ud-search-popup__panel {
    width: 100%;
    max-width: 560px;
    padding: 28px;
    border-radius: 12px;
    background: var(--c-white);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    transform: translateY(-12px);
    transition: transform .2s ease;
}

.ud-search-popup--open .ud-search-popup__panel {
    transform: translateY(0);
}

.ud-search-popup__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 20px;
}

.ud-search-popup__title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--c-navy);
}

.ud-search-popup__close {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--c-black);
    cursor: pointer;
}

.ud-search-popup__close svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 575.98px) {
    .ud-search-popup {
        padding: 72px 12px 12px;
    }

    .ud-search-popup__panel {
        padding: 20px;
    }
}

/* ============================================================
 * Form (searchform.php via get_search_form()) — shared by the popup and the
 * empty-results state in index.php.
 * ============================================================ */

.ud-search-form__row {
    display: flex;
    gap: 10px;
}

.ud-search-form__label {
    display: block;
    flex: 1 1 auto;
}

.ud-search-form__label-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.ud-search-form__input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--c-line);
    border-radius: 6px;
    font: inherit;
    font-size: 17px;
}

.ud-search-form__input:focus-visible {
    outline: 2px solid var(--c-navy);
    outline-offset: 2px;
}

.ud-search-form__submit {
    flex: none;
    height: 48px;
    padding: 0 24px;
    border: 0;
    border-radius: 6px;
    background: var(--c-navy);
    color: var(--c-white);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: pointer;
}

/* Same off-screen technique as .udlf-hp in ud-lead-form.css. */
.ud-search-form__hp {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

@media (max-width: 575.98px) {
    .ud-search-form__row {
        flex-direction: column;
    }

    .ud-search-form__submit {
        width: 100%;
    }
}
