/* ============================================================
   志睿源官网 · search.css（2026-10-22）
   头部搜索入口 + 站内搜索浮层

   为什么单独一个文件，不并进 components.css：
   改主包会让 12 个页面的 ?v= 全部失效、整包重新下发；
   站内搜索是新增能力，独立文件可单独回滚（删两个引用即可）。
   ============================================================ */

/* ── 头部入口（伪输入框，不抢焦点）────────────────────── */
.search-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 8px 0 11px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 14.5px;
    font-family: inherit;
    letter-spacing: 0;
    cursor: pointer;
    transition: border-color .18s, background .18s, color .18s;
}

.search-btn:hover {
    border-color: var(--muted-2);
    background: #fff;
    color: var(--ink-2);
}

.search-btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.search-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
}

.search-btn kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.5;
    color: var(--muted-2);
    white-space: nowrap;
}

/* ── 浮层骨架 ──────────────────────────────────────────── */
.search-layer {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

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

.search-layer__mask {
    position: absolute;
    inset: 0;
    background: rgba(36, 27, 24, .34);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.search-layer__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 660px;
    max-width: calc(100% - 40px);
    max-height: min(74vh, 640px);
    margin-top: calc(var(--header-h) + 20px);
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: sl-in .16s ease-out;
}

@keyframes sl-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── 输入行 ────────────────────────────────────────────── */
.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 14px 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.search-box__icon {
    width: 18px;
    height: 18px;
    color: var(--muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 0;
    background: none;
    font-family: inherit;
    font-size: 16px;          /* 16px 是 iOS 不自动放大页面的下限 */
    line-height: 1.4;
    color: var(--ink);
}

.search-box input::placeholder {
    color: var(--muted-2);
}

.search-box input::-webkit-search-cancel-button {
    display: none;
}

.search-box__cancel {
    border: 0;
    background: none;
    padding: 4px 2px;
    font-family: inherit;
    font-size: 14px;
    color: var(--brand);
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── 类型页签 ──────────────────────────────────────────── */
.search-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-2);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.search-tabs::-webkit-scrollbar {
    display: none;
}

.search-tab {
    flex-shrink: 0;
    border: 0;
    background: none;
    padding: 5px 11px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink-3);
    cursor: pointer;
    white-space: nowrap;
}

.search-tab:hover {
    background: var(--surface);
}

.search-tab.is-on {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 650;
}

.search-tab b {
    font-weight: 600;
    opacity: .62;
    margin-left: 3px;
    font-size: 12px;
}

/* ── 结果区 ────────────────────────────────────────────── */
.search-body {
    flex: 1;
    min-height: 132px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 0 8px;
}

.sr-group {
    padding: 4px 0;
}

.sr-group__h {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 4px;
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: .04em;
}

.sr-group__h span {
    color: var(--muted-2);
}

.sr-item {
    display: block;
    padding: 9px 16px 9px 14px;
    border-left: 2px solid transparent;
    text-decoration: none;
    cursor: pointer;
}

.sr-item:hover,
.sr-item.is-active {
    background: var(--surface);
    border-left-color: var(--brand);
}

.sr-item__top {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.sr-tag {
    flex-shrink: 0;
    font-size: 11px;
    line-height: 1.6;
    padding: 0 5px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: .02em;
    transform: translateY(-1px);
}

.sr-tag--service { background: var(--brand-soft); color: var(--brand); }
.sr-tag--product { background: var(--doing-bg); color: var(--doing-fg); }
.sr-tag--article { background: var(--surface-2); color: var(--ink-3); }
.sr-tag--intel   { background: var(--plan-bg); color: var(--plan-fg); }

.sr-item__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sr-item__date {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--muted-2);
    font-variant-numeric: tabular-nums;
    transform: translateY(-1px);
}

.sr-item__desc {
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.62;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sr-item mark {
    background: none;
    color: var(--brand);
    font-weight: 700;
    padding: 0;
}

/* ── 空态 / 加载态 ────────────────────────────────────── */
.sr-empty {
    padding: 26px 20px 30px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.sr-empty b {
    color: var(--ink-2);
}

.sr-hot {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.sr-hot button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink-3);
    cursor: pointer;
}

.sr-hot button:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}

.sr-loading {
    padding: 22px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13.5px;
}

.sr-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand);
    animation: sl-blink .9s infinite ease-in-out;
}

@keyframes sl-blink {
    0%, 100% { opacity: .25; transform: scale(.85); }
    50%      { opacity: 1;   transform: scale(1); }
}

/* ── 底部 ──────────────────────────────────────────────── */
.search-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 16px;
    border-top: 1px solid var(--line-2);
    background: var(--surface);
    font-size: 12.5px;
    color: var(--muted);
    flex-shrink: 0;
}

.search-foot__keys {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted-2);
}

.search-foot__keys kbd {
    font-family: var(--mono);
    font-size: 11px;
    padding: 1px 4px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #fff;
    margin: 0 1px;
}

.search-foot__more {
    border: 0;
    background: none;
    padding: 0;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--brand);
    cursor: pointer;
}

/* ── 响应式 ────────────────────────────────────────────── */
@media (max-width: 1080px) {
    .search-btn kbd { display: none; }
}

@media (max-width: 960px) {
    .search-btn__text { display: none; }
    .search-btn { width: 40px; padding: 0; justify-content: center; }
}

@media (max-width: 700px) {
    /* 浮层全屏接管：手机上没有「下拉浮层」的空间，整屏更像原生搜索 */
    .search-layer__panel {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        margin-top: 0;
        border-radius: 0;
        animation: none;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .search-box {
        padding: 12px 12px 12px 14px;
    }

    .search-body {
        min-height: 0;
    }

    /* 手机上整屏留白多，空态/初始态在剩余空间里垂直居中更平衡 */
    .sr-empty {
        padding-top: 0;
        min-height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .search-foot {
        padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
    }

    .search-foot__keys {
        display: none;
    }

    .sr-item {
        padding: 11px 14px 11px 12px;
    }

    .sr-item__title {
        font-size: 15.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .search-layer__panel { animation: none; }
    .sr-dot { animation: none; }
}

body.search-locked {
    overflow: hidden;
}
