/* ========================================
   导航网站 - 优雅极简风格
   ======================================== */

/* CSS 变量 */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --text-primary: #f5f5f5;
    --text-secondary: #999;
    --text-muted: #666;
    --accent: #c9a962;
    --accent-light: #e5d4a1;
    --border: #2a2a2a;
    --card-hover: #1f1f1f;
    --shadow: rgba(0, 0, 0, 0.5);
    --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

/* 浅色主题 */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #eeeeee;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent: #c9a962;
    --accent-light: #e5d4a1;
    --border: #e0e0e0;
    --card-hover: #ffffff;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* 重置 */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* 头部 */
.header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: var(--bg-primary);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.brand-main {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.brand-sub {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* 主题切换按钮 */
.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
}

.theme-icon {
    font-size: 1.25rem;
    display: block;
}

/* 搜索框 - 第二行居中，与主区域宽度一致 */
.header-bottom {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
}

.search-container {
    position: relative;
    width: 100%;
}

#searchInput {
    width: 100%;
    height: 48px;
    padding: 0 2.5rem 0 1.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: all 0.3s var(--transition);
    box-sizing: border-box;
    line-height: 48px;
}

#searchInput::placeholder {
    color: var(--text-muted);
}

#searchInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.1);
    background: var(--bg-tertiary);
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* 主内容区 - 瀑布流 */
.main-content {
    position: relative;
    z-index: 10;
    padding: 1.5rem 2rem 8rem;
    max-width: 1600px;
    margin: 0 auto;
    column-count: 3;
    column-gap: 1.5rem;
}

/* 加载中 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 分类区块 */
.category {
    break-inside: avoid;
    margin-bottom: 1.5rem;
}

.category-title {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.category-title .text {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

/* 链接网格 */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s, border-color 0.15s;
}

.link-favicon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 4px;
}

.link-card:hover {
    background: var(--card-hover);
    border-color: var(--accent);
}

.link-card.dimmed {
    opacity: 0.15;
}

.link-card.highlighted {
    opacity: 1;
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.link-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.link-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.link-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 页脚 */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1rem 2rem;
    background: var(--bg-primary);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    margin: 0 auto;
}

.shortcuts {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.shortcuts .label {
    color: var(--text-muted);
}

.shortcuts kbd {
    padding: 0.2rem 0.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.beian {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.beian a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s var(--transition);
}

.beian a:hover {
    color: var(--accent);
}

/* ========================
   移动端适配
   ======================== */
@media screen and (max-width: 900px) {
    .header {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .header-bottom {
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .brand-sub {
        display: none;
    }
    
    .theme-toggle {
        padding: 0.25rem;
    }
    
    .theme-icon {
        font-size: 1rem;
    }
    
    #searchInput {
        height: 36px;
        line-height: 36px;
        padding: 0 2.5rem 0 0.75rem;
        font-size: 0.875rem;
    }
    
    .main-content {
        padding: 0.75rem;
        padding-bottom: 7rem;
        column-count: auto !important;
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem;
    }
    
    .category {
        break-inside: auto;
        margin-bottom: 0;
        display: contents;
    }
    
    .category-title {
        grid-column: 1 / -1;
        margin-bottom: 0.5rem;
        padding-bottom: 0.25rem;
    }
    
    .category-title .text {
        font-size: 0.75rem;
        letter-spacing: 0.1em;
    }
    
    .links-grid {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }
    
    .link-card {
        padding: 0.5rem 0.35rem;
        flex-direction: column;
        text-align: center;
        gap: 0.25rem;
    }
    
    .link-favicon {
        width: 32px;
        height: 32px;
    }
    
    .link-icon {
        font-size: 1.25rem;
    }
    
    .link-name {
        font-size: 0.65rem;
        white-space: normal;
    }
    
    .link-desc {
        display: none;
    }
    
    .footer {
        padding: 0.5rem 0.75rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .shortcuts {
        display: none;
    }
    
    .beian {
        font-size: 0.6rem;
    }
}

/* ========================
   大屏幕适配
   ======================== */
@media screen and (max-width: 1200px) {
    .main-content {
        column-count: 2;
    }
}

/* ========================
   小屏幕适配
   ======================== */
@media screen and (max-width: 480px) {
    .main-content {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .links-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* 打印样式 */
@media print {
    .header, .footer {
        display: none;
    }
    
    .main-content {
        padding: 0;
        column-count: auto;
        display: block;
    }
    
    .category {
        page-break-inside: avoid;
        margin-bottom: 1.5rem;
        display: block;
    }
}
