/* ==========================================================================
   导航站站内搜索（配合 assets/js/nav-search.js）
   替换主题原版的「百度 suggestion + 多引擎切换」搜索框。原版有两个硬伤：
     1. 弹窗版表单 action 指向主题作者的站点 nav.iowen.cn，会把流量送出去；
     2. content-search.js 里的 thisSearch 变量从未定义，点候选词会 window.open("undefined…")。
   本版改成纯站内检索 144 张卡片，不依赖任何外部服务，结果指向主站说明页。

   颜色跟随主题：主题日间/夜间由 body 上的 io-black-mode 类切换。
   ========================================================================== */

.nav-search {
    position: relative;
    max-width: 46rem;
    margin: 0 auto;
}

.nav-search-form {
    display: flex;
    align-items: stretch;
    gap: .5rem;
}

.nav-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 3.25rem;
    padding: 0 1.1rem;
    border: 1px solid transparent;
    border-radius: .6rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .10);
    outline: 0;
    -webkit-appearance: none;
    appearance: none;
}

.nav-search-input::placeholder { color: #9aa3ab; }

.nav-search-input:focus {
    border-color: #2f6fed;
    box-shadow: 0 6px 24px rgba(47, 111, 237, .20);
}

.nav-search-btn {
    flex: 0 0 auto;
    width: 3.25rem;
    border: 0;
    border-radius: .6rem;
    color: #fff;
    background: #2f6fed;
    font-size: 1.15rem;
    cursor: pointer;
}

.nav-search-btn:hover { background: #2358c8; }

/* ---- 结果下拉 ---- */

.nav-search-results {
    position: absolute;
    z-index: 40;
    top: calc(100% + .5rem);
    right: 0;
    left: 0;
    max-height: 26rem;
    overflow-y: auto;
    padding: .35rem;
    border-radius: .6rem;
    background: #fff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
    text-align: left;
    -webkit-overflow-scrolling: touch;
}

.nav-search-results[hidden] { display: none; }

.nav-search-count {
    padding: .4rem .7rem .3rem;
    font-size: .75rem;
    color: #8a939c;
}

.nav-search-hit {
    display: block;
    padding: .55rem .7rem;
    border-radius: .45rem;
    color: #212529;
    text-decoration: none;
}

.nav-search-hit:hover,
.nav-search-hit.is-active {
    color: #1b4fd8;
    background: #f1f5ff;
    text-decoration: none;
}

.nav-search-hit-name { font-weight: 600; }

.nav-search-hit-cat {
    margin-left: .4rem;
    padding: .05rem .4rem;
    border-radius: .25rem;
    font-size: .7rem;
    font-weight: 400;
    color: #2f6fed;
    background: #eaf0ff;
}

.nav-search-hit-desc {
    display: block;
    margin-top: .15rem;
    overflow: hidden;
    font-size: .78rem;
    color: #6b7280;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-search-empty {
    padding: 1rem .8rem 1.2rem;
    text-align: center;
    font-size: .85rem;
    color: #6b7280;
}

.nav-search-empty a { color: #2f6fed; text-decoration: underline; }

/* ---- 夜间模式（主题在 body 上挂 io-black-mode）---- */

body.io-black-mode .nav-search-input,
body.io-black-mode .nav-search-results {
    color: #e6e9ee;
    background: #1c2128;
    border-color: #2c333c;
}

body.io-black-mode .nav-search-input::placeholder { color: #7d8792; }

body.io-black-mode .nav-search-hit { color: #e6e9ee; }

body.io-black-mode .nav-search-hit:hover,
body.io-black-mode .nav-search-hit.is-active {
    color: #9fc0ff;
    background: #232b36;
}

body.io-black-mode .nav-search-hit-cat {
    color: #9fc0ff;
    background: #23324d;
}

body.io-black-mode .nav-search-hit-desc { color: #9aa5b1; }

body.io-black-mode .nav-search-count { color: #7d8792; }

body.io-black-mode .nav-search-empty { color: #9aa5b1; }

/* ---- 小屏 ---- */

@media (max-width: 575.98px) {
    .nav-search-input {
        height: 2.9rem;
        font-size: .95rem;
    }

    .nav-search-btn { width: 2.9rem; }

    .nav-search-results { max-height: 60vh; }
}
