/* ============================================================
 * 全站搜索浮层样式
 * 暗色玻璃态设计，适配 spark1 和 websafe0 两套主题
 * ============================================================ */

/* 搜索按钮 — 导航栏内 */
.nav-search-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: inherit;
    font-family: inherit;
    padding: 0.5rem 0.8rem;
    transition: color 0.3s;
    line-height: 1;
}
.nav-search-btn:hover {
    color: #e0e7ff;
}
.nav-search-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.nav-search-btn .search-btn-text {
    font-size: 0.9rem;
}
.nav-search-btn .search-shortcut {
    display: inline-block;
    font-size: 0.7rem;
    padding: 1px 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 2px;
    line-height: 1.4;
}

/* 文章页悬浮搜索按钮 */
.article-search-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s, box-shadow 0.2s;
}
.article-search-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}
.article-search-btn svg {
    width: 20px;
    height: 20px;
}

/* 文章列表页 header 内嵌搜索栏 */
.articles-search-bar {
    display: flex;
    align-items: center;
    max-width: 420px;
    margin: 15px auto 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.articles-search-bar:hover {
    background: rgba(255, 255, 255, 0.25);
}
.articles-search-bar svg {
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}
.articles-search-bar > span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85em;
    margin-left: 8px;
}
.articles-search-bar .search-shortcut-hint {
    margin-left: auto;
    font-size: 0.7em;
    padding: 2px 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.4);
}

/* ============================================================
 * 搜索浮层
 * ============================================================ */

/* 遮罩层 */
.search-overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.search-overlay-backdrop.active {
    opacity: 1;
}

/* 搜索面板 */
.search-overlay-panel {
    position: fixed;
    top: 12%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    width: min(680px, 92vw);
    max-height: 70vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5),
                0 0 40px rgba(99, 102, 241, 0.1);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.search-overlay-panel.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 搜索头部 */
.search-overlay-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.search-overlay-header .search-icon {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}
.search-overlay-header input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 1.1rem;
    color: #e2e8f0;
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
    line-height: 1.5;
}
.search-overlay-header input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}
.search-esc-hint {
    font-size: 0.7rem;
    padding: 2px 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    font-family: monospace;
}

/* 搜索结果区域 */
.search-overlay-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.search-overlay-results::-webkit-scrollbar {
    width: 6px;
}
.search-overlay-results::-webkit-scrollbar-track {
    background: transparent;
}
.search-overlay-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* 空状态 */
.search-empty-state,
.search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.5);
}
.search-empty-state p,
.search-no-results p {
    margin: 8px 0;
}
.search-hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.3) !important;
}

/* 加载中 */
.search-loading {
    text-align: center;
    padding: 30px 20px;
    color: rgba(255, 255, 255, 0.4);
}
.search-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(99, 102, 241, 0.8);
    border-radius: 50%;
    animation: searchSpin 0.6s linear infinite;
}
@keyframes searchSpin {
    to { transform: rotate(360deg); }
}

/* 单条搜索结果 */
.search-result-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    cursor: pointer;
}
.search-result-item:hover,
.search-result-item.selected {
    background: rgba(99, 102, 241, 0.12);
}
.search-result-item.selected {
    background: rgba(99, 102, 241, 0.18);
}

/* 结果图标 */
.search-result-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-top: 2px;
}

/* 结果内容 */
.search-result-content {
    flex: 1;
    min-width: 0;
}
.search-result-title {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.95rem;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-desc {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.85rem;
    margin-top: 4px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.search-result-meta {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    flex-wrap: wrap;
}
.search-result-type {
    background: rgba(99, 102, 241, 0.15);
    color: rgba(165, 180, 252, 0.9);
    padding: 1px 6px;
    border-radius: 4px;
}
.search-result-site {
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
}

/* 高亮匹配词 */
.search-result-item mark,
.search-result-title mark,
.search-result-desc mark {
    background: rgba(245, 158, 11, 0.25);
    color: #fbbf24;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* 底部栏 */
.search-overlay-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}
.search-nav-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    font-family: monospace;
    font-size: 0.7rem;
    margin: 0 1px;
}

/* ============================================================
 * 移动端适配
 * ============================================================ */
@media (max-width: 768px) {
    .search-overlay-panel {
        top: 5%;
        width: 96vw;
        max-height: 85vh;
        border-radius: 12px;
    }
    .search-overlay-header {
        padding: 12px 16px;
    }
    .search-overlay-header input {
        font-size: 1rem;
    }
    .search-shortcut {
        display: none !important;
    }
    .search-nav-hint {
        display: none;
    }
    .search-result-icon {
        display: none;
    }
    .search-result-item {
        padding: 10px 12px;
    }
    .article-search-btn {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }
    .articles-search-bar {
        max-width: 90%;
    }
    .articles-search-bar .search-shortcut-hint {
        display: none;
    }
}

/* ============================================================
 * 无障碍 — 减少动画
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .search-overlay-backdrop,
    .search-overlay-panel,
    .search-result-item,
    .article-search-btn,
    .nav-search-btn {
        transition: none !important;
        animation: none !important;
    }
    .search-loading-spinner {
        animation: none !important;
    }
}
