/* --- 全局和颜色变量 --- */
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --text-color: #e0e0e0;
    --text-secondary-color: #a0a0a0;
    --border-color: #333;
    --card-text-color: #ffffff;
    --card-border-color: rgba(255, 255, 255, 0.1);
    --card-bg-color: rgba(30, 30, 30, 0.6);
    --card-text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
body.light-mode {
    --bg-color: #f0f2f5;
    --surface-color: #ffffff;
    --primary-color: #6200ee;
    --text-color: #000000;
    --text-secondary-color: #5f6368;
    --border-color: #e0e0e0;
    --card-text-color: #000000;
    --card-border-color: rgba(0, 0, 0, 0.05);
    --card-bg-color: rgba(255, 255, 255, 0.8);
    --card-text-shadow: none;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    color: var(--text-color);
    background-color: var(--bg-color);
}
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background-image: url('../images/background-desktop.webp');
    background-size: cover;
    background-position: center;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 0 20px 0; 
}

#links-container {
    padding: 0 20px;
}

/* --- 导航栏 --- */
.main-nav {
    position: sticky;
    top: 0; 
    z-index: 10;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    padding-top: 0; 
    margin-left: 0;
    margin-right: 0;
    height: auto; 
    padding: 10px 20px; 
    margin-top: 0; 
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-title { display: flex; align-items: center; gap: 15px; flex-shrink: 0; }
.header-logo { width: 36px; height: 36px; background-image: url('/logo.svg'); background-size: contain; background-position: center; background-repeat: no-repeat; }

/* 标题颜色跟随主题色 */
h1 { font-size: 1.2rem; color: var(--primary-color); margin: 0; white-space: nowrap; }

.main-nav ul { list-style: none; padding: 0; margin: 0; display: flex; justify-content: center; flex-wrap: wrap; flex: 1; }
.main-nav li { position: relative; }
.main-nav li a { display: block; padding: 0.5rem 1rem; text-decoration: none; color: var(--text-secondary-color); font-weight: 500; transition: color 0.2s; border-bottom: 2px solid transparent; cursor: pointer; position: relative; white-space: nowrap; }
.main-nav li a:hover { color: var(--primary-color); }
.main-nav li a.active { color: var(--primary-color); font-weight: bold; }
.main-nav li a.active::after { content: ''; position: absolute; bottom: 0.2rem; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; background-color: var(--primary-color); border-radius: 50%; transition: all 0.2s ease; }

.theme-switcher { display: flex; align-items: center; flex-shrink: 0; }
.theme-switcher label { width: 30px; height: 30px; cursor: pointer; position: relative; display: flex; align-items: center; justify-content: center; }
.theme-switcher svg { position: absolute; width: 12px; height: 12px; transition: opacity 0.3s ease; stroke: var(--text-color); }
.theme-switcher .sun-icon { opacity: 0; transform: rotate(-90deg); }
.theme-switcher .moon-icon { opacity: 1; transform: rotate(0deg); } body.light-mode .theme-switcher .sun-icon { opacity: 1; } body.light-mode .theme-switcher .moon-icon { opacity: 0; }
.theme-switcher input { display: none; }
.theme-switcher input:checked + label .sun-icon { opacity: 1; transform: rotate(0deg); }
.theme-switcher input:checked + label .moon-icon { opacity: 0; transform: rotate(90deg); }

.dropdown-content { opacity: 0; visibility: hidden; transform: translateY(-10px); transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s; position: absolute; background-color: transparent; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; list-style: none; padding: 5px; margin-top: -2px; }
.dropdown-content.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-content a { padding: 10px 14px; border-bottom: none !important; border-radius: 6px; text-shadow: var(--card-text-shadow); }
.dropdown-content a:hover { background-color: rgba(255, 255, 255, 0.1); }
.dropdown-content a.active { color: var(--primary-color); font-weight: bold; }

.search-section { max-width: 600px; margin: 2rem auto; padding-left: 20px; padding-right: 20px; }
.search-header { display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; gap: 5px; }
.search-tabs { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.search-tab { position: relative; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px; cursor: pointer; background: transparent; border: 1px solid transparent; transition: background-color 0.2s; }
.search-tab:hover { background: rgba(255,255,255,0.1); }
.search-tab.active::after { content: ''; position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; background-color: var(--primary-color); border-radius: 50%; }
.search-tab span { color: var(--text-secondary-color); font-weight: 500; font-size: 0.9rem; }
.search-tab.active span { color: var(--text-color); }
.search-input-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.search-input { width: 100%; background: rgba(0, 0, 0, 0.25); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--card-border-color); border-radius: 12px; padding: 15px 60px 15px 20px; font-size: 1.1rem; color: var(--text-color); outline: none; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); box-sizing: border-box; }
body.light-mode .search-input { background: rgba(255, 255, 255, 0.4); }
.search-button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: transparent; border: none; border-radius: 8px; width: 40px; height: 40px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.search-button svg { stroke: var(--text-secondary-color); transition: stroke 0.2s; }
.search-button:hover svg { stroke: var(--primary-color); }


/* --- 卡片基础样式 --- */
.link-group { margin-top: 1.5rem; }
.link-group ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; }

.link-group a { 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    text-decoration: none; color: var(--card-text-color); border-radius: 12px; padding: 15px; height: 110px; box-sizing: border-box; text-align: center; 
    background: var(--card-bg-color);
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border-color); 
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    
    /* 悬停过渡 */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
                box-shadow 0.3s ease,
                border-color 0.3s ease,
                background-color 0.3s ease;
    
    opacity: 0; /* 初始透明，等待 JS 添加动画类 */
    position: relative;
    overflow: hidden;
}

/* 悬停效果 */
.link-group a:hover { 
    transform: translateY(-8px); 
    box-shadow: 0 14px 25px -5px rgba(0, 0, 0, 0.2); 
    border-color: var(--primary-color); 
    background-color: rgba(40, 40, 40, 0.8); 
}
body.light-mode .link-group a:hover {
    background-color: rgba(255, 255, 255, 1);
}
.link-group a::before { display: none; }

/* --- 随机动画库 (Random Animations) --- */
/* 1. 向上淡入 */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
/* 2. 向左淡入 */
@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
/* 3. 向右淡入 */
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
/* 4. 缩放淡入 */
@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

/* --- 动画类 (供 JS 调用) --- */
.anim-up { animation: fadeInUp 0.6s cubic-bezier(0.215, 0.61, 0.355, 1) forwards; }
.anim-left { animation: fadeInLeft 0.6s cubic-bezier(0.215, 0.61, 0.355, 1) forwards; }
.anim-right { animation: fadeInRight 0.6s cubic-bezier(0.215, 0.61, 0.355, 1) forwards; }
.anim-zoom { animation: zoomIn 0.6s cubic-bezier(0.215, 0.61, 0.355, 1) forwards; }

/* 延迟设置，配合随机动画效果更佳 */
.link-group li:nth-child(1) a { animation-delay: 0.05s; } .link-group li:nth-child(2) a { animation-delay: 0.1s; } .link-group li:nth-child(3) a { animation-delay: 0.15s; } .link-group li:nth-child(4) a { animation-delay: 0.2s; } .link-group li:nth-child(5) a { animation-delay: 0.25s; } .link-group li:nth-child(6) a { animation-delay: 0.3s; } .link-group li:nth-child(7) a { animation-delay: 0.35s; } .link-group li:nth-child(8) a { animation-delay: 0.4s; } .link-group li:nth-child(9) a { animation-delay: 0.45s; } .link-group li:nth-child(10) a { animation-delay: 0.5s; } .link-group li:nth-child(11) a { animation-delay: 0.55s; } .link-group li:nth-child(12) a { animation-delay: 0.6s; }

.card-icon { 
    width: 36px; height: 36px; margin-bottom: 12px; border-radius: 50%; 
    background-color: transparent; background-size: cover; background-position: center; background-repeat: no-repeat; background-image: none; 
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.link-group a:hover .card-icon { transform: scale(1.15); }

.card-name { font-weight: 500; font-size: 1rem; line-height: 1.2; word-break: break-word; text-shadow: var(--card-text-shadow); }
.placeholder { text-align: center; font-size: 1.2rem; color: var(--text-secondary-color); padding: 4rem; }
.placeholder.error { color: var(--error-color); }


/* --- 手机端浏览器适配 --- */
@media (max-width: 768px) {
    .container { padding: 0 0 15px 0; }
    #links-container { padding: 0 15px; }
    
    .main-nav {
        /* 使用极淡半透明背景，实现沉浸式毛玻璃效果 */
        background: rgba(30, 30, 30, 0.3);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        
        box-shadow: none;
        margin-left: 0; margin-right: 0; padding-left: 15px; padding-right: 15px;
        height: auto; flex-wrap: wrap; padding-top: 5px; padding-bottom: 5px;
    }
    /* 浅色模式下的导航栏背景 */
    body.light-mode .main-nav {
        background: rgba(255, 255, 255, 0.3);
    }

    .logo-title { order: 1; }
    .theme-switcher { order: 2; }
    .main-nav ul { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; margin-top: 5px; flex-wrap: nowrap; padding-bottom: 5px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .main-nav ul::-webkit-scrollbar { display: none; }

    body::before { background-image: url('../images/background-mobile.webp'); background-attachment: scroll; }
    h1 { font-size: 1.2rem; }
    .header-logo { width: 28px; height: 28px; }
    .link-group ul { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
    .main-nav li a { padding: 0.6rem 0.8rem; font-size: 0.95rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
    .main-nav li a.active::after { content: none; }
    
    .card-icon { width: 30px; height: 30px; margin-bottom: 8px; }
    .card-name { font-size: 0.8rem; }
    
    /* 手机端样式：允许入场动画 */
    .link-group a { 
        height: 90px; 
        backdrop-filter: none; -webkit-backdrop-filter: none; 
    }
    
    .link-group a:hover { 
        transform: none; 
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); 
        border-color: var(--card-border-color);
        background-color: var(--card-bg-color);
    }
    .link-group a:hover .card-icon { transform: none; }
    
    .dropdown-content { backdrop-filter: none; -webkit-backdrop-filter: none; background-color: var(--surface-color); }
    .search-input { backdrop-filter: none; -webkit-backdrop-filter: none; }
    .search-section { margin: 1.5rem auto; }
    .search-input { padding: 12px 50px 12px 15px; font-size: 1rem; }
    .search-button { width: 36px; height: 36px; }
    .search-tab { padding: 6px 10px; }
    .search-tab span { font-size: 0.9rem; }
}
