/* ============================================================
   首页自定义样式 - 极简搜索门户
   ============================================================ */

.homepage-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* ---------- 搜索门户 ---------- */
.search-portal {
    text-align: center;
    padding: 60px 20px 40px;
    margin-bottom: 40px;
}

.portal-title {
    font-size: 2.8rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.portal-desc {
    font-size: 1.15rem;
    color: #888;
    margin-bottom: 40px;
}

/* ---------- 搜索框 ---------- */
.search-box {
    position: relative;
    max-width: 600px;
    margin: 0 auto 28px;
}

.search-box input {
    width: 100%;
    padding: 18px 60px 18px 24px;
    font-size: 1.15rem;
    border: 2px solid #e8e8e8;
    border-radius: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.search-box input:focus {
    border-color: #1a1a1a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.search-box input::placeholder {
    color: #aaa;
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: #1a1a1a;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover {
    background: #333;
    transform: translateY(-50%) scale(1.05);
}

/* ---------- 搜索结果下拉 ---------- */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
    border: 1px solid #eee;
}

.search-loading,
.search-no-result {
    padding: 20px 24px;
    color: #888;
    font-size: 14px;
    text-align: center;
}

.search-result-item {
    display: block;
    padding: 14px 20px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    line-height: 1.4;
}

.search-result-snippet {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

[data-md-color-scheme="slate"] .search-results-dropdown {
    background: #1e1e1e;
    border-color: #333;
}

[data-md-color-scheme="slate"] .search-result-item {
    border-bottom-color: #2a2a2a;
}

[data-md-color-scheme="slate"] .search-result-item:hover {
    background: #2a2a2a;
}

[data-md-color-scheme="slate"] .search-result-title {
    color: #eee;
}

[data-md-color-scheme="slate"] .search-result-snippet {
    color: #999;
}

.search-result-title mark,
.search-result-snippet mark {
    background: #ffeb3b;
    color: #1a1a1a;
    padding: 1px 2px;
    border-radius: 3px;
    font-weight: 600;
}

[data-md-color-scheme="slate"] .search-result-title mark,
[data-md-color-scheme="slate"] .search-result-snippet mark {
    background: #f9a825;
    color: #1a1a1a;
}

/* ---------- 分类标签 ---------- */
.search-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.search-tags a {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 20px;
    background: #f5f6f8;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.search-tags a:hover {
    background: #1a1a1a;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* ---------- 最近更新 ---------- */
.recent-section {
    background: #fff;
    border-radius: 20px;
    padding: 28px 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.article-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.article-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.article-item:hover {
    background: #f8f9fa;
    transform: translateX(4px);
}

.article-item::before {
    content: "📄";
    margin-right: 12px;
    font-size: 16px;
    flex-shrink: 0;
}

.article-title {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
}

/* ---------- 暗色模式 ---------- */
[data-md-color-scheme="slate"] .portal-title { color: #eee; }
[data-md-color-scheme="slate"] .portal-desc { color: #aaa; }
[data-md-color-scheme="slate"] .search-box input { background: #1e1e1e; border-color: #333; color: #eee; }
[data-md-color-scheme="slate"] .search-box input::placeholder { color: #666; }
[data-md-color-scheme="slate"] .search-box input:focus { border-color: #fff; }
[data-md-color-scheme="slate"] .search-btn { background: #fff; color: #1a1a1a; }
[data-md-color-scheme="slate"] .search-btn:hover { background: #ddd; }
[data-md-color-scheme="slate"] .search-tags a { background: #2a2a2a; color: #ccc; }
[data-md-color-scheme="slate"] .search-tags a:hover { background: #fff; color: #1a1a1a; }
[data-md-color-scheme="slate"] .recent-section { background: #1e1e1e; }
[data-md-color-scheme="slate"] .section-title { color: #eee; }
[data-md-color-scheme="slate"] .article-item { color: #ddd; }
[data-md-color-scheme="slate"] .article-item:hover { background: #252525; }
/* ---------- 隐藏首页左导航栏和右目录栏 ---------- */
body:has(.homepage-container) .md-sidebar--primary,
body:has(.homepage-container) .md-sidebar--secondary {
    display: none !important;
}

/* 首页内容区居中 */
body:has(.homepage-container) .md-content {
    margin-left: auto !important;
    margin-right: auto !important;
    max-width: 61rem !important;
}

/* ---------- 隐藏首页右上角的搜索按钮图标 ---------- */
body:has(.homepage-container) .md-header__button[for="__search"] {
    position: absolute;
    left: -9999px;
    opacity: 0;
}
body:has(.homepage-container) .md-search__icon {
    display: none !important;
}

/* 但保留搜索对话框的功能（当通过首页搜索框触发时） */
body:has(.homepage-container) .md-search__overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

body:has(.homepage-container) .md-search__inner {
    position: fixed !important;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 600px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow: hidden;
}

body:has(.homepage-container) .md-search__inner .md-search__input {
    width: 100%;
    padding: 20px 24px;
    font-size: 1.2rem;
    border: none;
    outline: none;
    background: transparent;
}

body:has(.homepage-container) .md-search__inner .md-search__output {
    max-height: 400px;
    overflow-y: auto;
}

body:has(.homepage-container) .md-search--active .md-search__overlay {
    opacity: 1;
    visibility: visible;
}

body:has(.homepage-container) .md-search--active .md-search__inner {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

body[data-md-color-scheme="slate"]:has(.homepage-container) .md-search__inner {
    background: #1e1e1e;
}
body[data-md-color-scheme="slate"]:has(.homepage-container) .md-search__inner .md-search__input {
    color: #eee;
}

/* ---------- 隐藏首页笔记按钮和面板 ---------- */
body:has(.homepage-container) #annotator-panel-toggle,
body:has(.homepage-container) .annotator-panel,
body:has(.homepage-container) .annotator-panel.open {
    display: none !important;
    transform: translateX(100%) !important;
}

body:has(.homepage-container) #annotator-panel-toggle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
