/*
 * 上の帯の検索（Filament のグローバル検索）を、スマホでは虫めがねの印だけにする（2026-11-02 ボブ氏）。
 * - 幅 767px 以下：虫めがねだけを出す。押すと、上の帯いっぱいに入力欄が開き、そのまま文字を入れて検索できる
 * - 入力欄の外を押す（フォーカスが外れる）と、虫めがねに戻る
 * - 仕組みは CSS だけ（:focus-within）。Filament の検索そのもの（候補の出し方・移動）は変えないので、更新に強い
 * - PC・タブレット（768px 以上）は今までどおり
 */
@media (max-width: 767px) {
    .fi-topbar .fi-global-search-ctn {
        flex: 0 0 auto;
    }

    /* 閉じているとき：40×40 の虫めがねのボタンに見せる。入力欄は透明にして、ボタン全体を覆う（押すと入力欄に入る） */
    .fi-topbar .fi-global-search-field .fi-input-wrp {
        position: relative;
        width: 40px;
        height: 40px;
        background: transparent;
        box-shadow: none;
        border-radius: 0.5rem;
    }

    .fi-topbar .fi-global-search-field .fi-input-wrp-prefix {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        pointer-events: none;
    }

    .fi-topbar .fi-global-search-field .fi-input-wrp-content-ctn {
        position: absolute;
        inset: 0;
    }

    .fi-topbar .fi-global-search-field input.fi-input {
        width: 100%;
        height: 100%;
        padding: 0;
        opacity: 0;
        cursor: pointer;
        /* iPhone で、押したときに画面が勝手に拡大されないよう 16px */
        font-size: 16px;
    }

    .fi-topbar .fi-global-search-field .fi-input-wrp:active {
        background: rgb(0 0 0 / 0.05);
    }

    /* 開いているとき：上の帯いっぱいの入力欄 */
    .fi-topbar .fi-global-search:focus-within .fi-input-wrp {
        position: fixed;
        top: 10px;
        left: 8px;
        right: 8px;
        z-index: 40;
        width: auto;
        height: 44px;
        background: #fff;
        box-shadow: 0 0 0 2px var(--primary-500, #f59e0b), 0 4px 16px rgb(0 0 0 / 0.15);
    }

    .fi-topbar .fi-global-search:focus-within .fi-input-wrp-prefix {
        inset: 0 auto 0 0;
        width: 40px;
    }

    .fi-topbar .fi-global-search:focus-within .fi-input-wrp-content-ctn {
        left: 40px;
        right: 8px;
    }

    .fi-topbar .fi-global-search:focus-within input.fi-input {
        opacity: 1;
        cursor: text;
    }

    .dark .fi-topbar .fi-global-search:focus-within .fi-input-wrp {
        background: var(--gray-900, #18181b);
    }

    /* 検索の結果は、開いた入力欄のすぐ下に、画面の幅いっぱいで出す */
    .fi-topbar .fi-global-search-results-ctn {
        position: fixed;
        top: 60px;
        left: 8px;
        right: 8px;
        width: auto;
        max-height: calc(100dvh - 80px);
        z-index: 40;
    }
}
