/* 定义全局颜色变量 */
:root {
    --primary-color: #2c3e50;  /* 工程深蓝 */
    --secondary-color: #3498db; /* 工程浅蓝 */
    --background-color: #f8f9fa; /* 背景色 */
    --surface-color: #f0f2f5; /* 表面色，用于卡片、悬停效果等 */
    --text-secondary: #7f8c8d; /* 次要文本颜色 */
    --card-background: #ffffff; /* 卡片背景色 */
}

/* 全局样式设置 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell;
    line-height: 1.8;
    margin: 0;
    padding: 0;
    background: var(--background-color);
    color: var(--primary-color);
    -webkit-font-smoothing: antialiased; /* 字体平滑渲染 */
    scroll-behavior: smooth; /* 平滑滚动 */
}

/* 页面头部样式 */
.main-header {
    text-align: center;
    padding: 6rem 1rem 4rem;
    background: var(--background-color);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    z-index: 9000; /* 确保头部在较高层级 */
}

/* 头部装饰元素 - 创建倾斜的分隔线效果 */
.main-header::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: 50%;
    width: 200%;
    height: 150px;
    background: var(--background-color);
    transform: translateX(-50%) rotate(-3deg); /* 旋转创建倾斜效果 */
    z-index: -1; /* 放在内容后面 */
}

/* 搜索容器样式 */
.search-container {
    max-width: 680px;
    margin: 2rem auto 0;
    width: 90%;
    position: relative;
    z-index: 100000; /* 确保搜索框在最高层级 */
}

/* 搜索表单样式 */
.search-form {
    background: rgba(255,255,255,0.8);
    border-radius: 20px;
    padding: 2px;
    backdrop-filter: saturate(180%) blur(20px); /* 毛玻璃效果 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 100000; /* 确保搜索框在最高层级 */
}

/* 搜索表单悬停效果 */
.search-form:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* 搜索组样式 - 包含搜索引擎选择、输入框和按钮 */
.search-group {
    display: flex;
    gap: 0;
    height: 44px;
    position: relative;
}

/* 搜索引擎选择器样式 */
.search-engine {
    flex: 0 0 120px;
    padding: 0 20px;
    border: none;
    border-radius: 18px 0 0 18px;
    background: transparent;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 600;
    appearance: none; /* 移除默认样式 */
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid rgba(0,0,0,0.1);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* 搜索引擎选择器聚焦样式 */
.search-engine:focus {
    outline: none;
    background-color: rgba(52,152,219,0.1);
}

/* 自定义下拉选项样式 */
.search-engine option {
    font-size: 15px;
    padding: 10px;
    background-color: white;
}

/* 为IE浏览器隐藏默认下拉箭头 */
select.search-engine::-ms-expand {
    display: none;
}

/* 下拉菜单展开动画 */
@keyframes selectExpand {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 为Firefox浏览器移除默认样式 */
.search-engine {
    -moz-appearance: none;
}

/* 为Chrome/Safari浏览器添加聚焦样式 */
.search-engine:focus {
    border-color: var(--secondary-color);
}

/* 自定义下拉菜单包装器 */
.custom-select-wrapper {
    position: relative;
    z-index: 99999; /* 高层级确保下拉菜单可见 */
}

/* 自定义下拉菜单容器 */
.custom-select-dropdown {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none; /* 初始状态不可交互 */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 下拉菜单显示状态 */
.custom-select-dropdown.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* 显示时可交互 */
    animation: selectExpand 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 下拉菜单选项 */
.custom-select-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 下拉菜单选项悬停效果 */
.custom-select-option:hover {
    background-color: var(--surface-color);
    color: var(--secondary-color);
}

/* 下拉菜单选中选项样式 */
.custom-select-option.selected {
    background-color: rgba(52,152,219,0.1);
    color: var(--secondary-color);
    font-weight: 600;
}

/* 搜索输入框样式 */
.search-input {
    flex: 1;
    padding: 0 20px;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--primary-color);
}

/* 搜索输入框占位符样式 */
.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

/* 搜索按钮样式 */
.search-button {
    flex: 0 0 60px;
    padding: 0;
    border: none;
    border-radius: 0 18px 18px 0;
    background: transparent;
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    letter-spacing: 0.5px;
    text-transform: uppercase; /* 文字大写 */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 搜索按钮悬停效果 */
.search-button:hover {
    background: rgba(52,152,219,0.1);
    color: #2980b9;
}

/* 搜索按钮点击效果 */
.search-button:active {
    transform: scale(0.98); /* 轻微缩小 */
}

/* 搜索按钮下划线装饰 */
.search-button::before {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--secondary-color);
    transform: translateX(-50%);
    transition: width 0.2s ease;
}

/* 搜索按钮悬停时下划线展开 */
.search-button:hover::before {
    width: 30px;
}

/* 网站标题样式 */
.site-title {
    font-size: 4rem;
    margin: 0 0 0.8rem;
    letter-spacing: -1px;
    font-weight: 700;
    background: linear-gradient(45deg, #2c3e50 60%, #3498db); /* 渐变背景 */
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent; /* 使文字显示背景色 */
    line-height: 1.2;
}

/* 网站副标题样式 */
.site-subtitle {
    font-size: 1.2rem;
    line-height: 1.6;
    margin: 0 auto;
    max-width: 640px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* 资源容器 - 网格布局 */
.resource-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* 减小最小宽度，从290px改为250px */
    gap: 1.7rem; /* 从1.5rem增加到1.7rem */
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 22px; /* 从20px增加到22px */
    position: relative;
    z-index: 1;
}

/* 分类卡片样式 */
.category-card {
    background: var(--card-background);
    border-radius: 18px;
    padding: 1.6rem; /* 从1.5rem增加到1.6rem */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 
                0 4px 12px rgba(0,0,0,0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: none;
}

/* 分类卡片悬停效果 */
.category-card:hover {
    transform: translateY(-5px); /* 上浮效果 */
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

/* 资源项目样式 */
.resource-item {
    margin: 0.9rem 0; /* 从0.8rem增加到0.9rem */
    position: relative;
}

/* 资源链接样式 */
.resource-link {
    text-decoration: none;
    color: var(--primary-color);
    display: block;
    padding: 0.9rem 1.3rem 2.3rem; /* 从0.8rem 1.2rem 2.2rem增加到0.9rem 1.3rem 2.3rem */
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    background: linear-gradient(to right, rgba(255,255,255,0.7), rgba(240,242,245,0.3));
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    backdrop-filter: blur(5px);
}

/* 资源链接悬停效果 */
.resource-link:hover {
    background: var(--surface-color);
    transform: translateX(8px); /* 右移效果 */
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.08);
}

/* 为资源链接添加微妙的装饰线 */
.resource-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(to bottom, var(--secondary-color), transparent);
    border-radius: 3px 0 0 3px;
    opacity: 0.2;
    transition: opacity 0.3s ease;
}

/* 资源链接悬停时装饰线效果增强 */
.resource-link:hover::before {
    opacity: 1;
}

/* 资源链接内的标题样式 */
.resource-link h3 {
    margin-top: 0.3rem; /* 从0.2rem增加到0.3rem */
    margin-bottom: 0.5rem; /* 从0.4rem增加到0.5rem */
    font-size: 1.15rem; /* 从1.1rem增加到1.15rem */
}

/* 资源链接内的段落样式 */
.resource-link p {
    margin-top: 0.4rem; /* 从0.3rem增加到0.4rem */
    margin-bottom: 0.4rem; /* 从0.3rem增加到0.4rem */
    font-size: 0.92rem; /* 从0.9rem增加到0.92rem */
    line-height: 1.45; /* 从1.4增加到1.45 */
}

/* 切换子菜单按钮样式 */
.toggle-submenu {
    background: none;
    border: 1px solid var(--surface-color);
    color: var(--secondary-color);
    padding: 0.25rem 0.6rem; /* 减小内边距 */
    margin: 0;
    border-radius: 6px; /* 从8px减小到6px */
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8em; /* 从0.85em减小到0.8em */
    position: absolute;
    bottom: 10px; /* 调整位置 */
    right: 12px; /* 调整位置 */
}

/* 切换子菜单按钮悬停效果 */
.toggle-submenu:hover {
    background: var(--secondary-color);
    color: white;
}

/* 子链接容器样式 */
.sub-links {
    margin: 0 0 0 0.8rem; /* 从1rem减小到0.8rem */
    border-left: 2px solid var(--surface-color);
    padding-left: 0.8rem; /* 从1rem减小到0.8rem */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

/* 子链接容器展开状态 */
.sub-links.expanded {
    max-height: 400px; /* 展开高度 */
}

/* 子链接样式 */
.sub-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85em; /* 从0.9em减小到0.85em */
    padding: 0.7rem; /* 从0.8rem减小到0.7rem */
    border-radius: 8px;
    transition: all 0.2s ease;
}

/* 子链接悬停效果 */
.sub-link:hover {
    background: var(--surface-color);
    color: var(--secondary-color);
}

/* 动画优化 - 仅在用户未设置减少动画时应用 */
@media (prefers-reduced-motion: no-preference) {
    .resource-link {
        transition: transform 0.3s ease, background 0.2s ease;
    }
    
    .category-card {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
}

/* 响应式设计 - 不同屏幕尺寸适配 */
@media (max-width: 768px) {
    .site-title {
        font-size: 2.4rem; /* 移动设备上减小标题 */
    }
    
    .resource-container {
        grid-template-columns: 1fr; /* 单列布局 */
        padding: 0 16px;
    }
}

/* 中等屏幕尺寸 - 确保最多显示4个卡片 */
@media (min-width: 769px) and (max-width: 1320px) {
    .resource-container {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

/* 大屏幕 - 允许显示5个卡片 */
@media (min-width: 1321px) and (max-width: 1660px) {
    .resource-container {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* 超宽屏幕 - 优化布局，保持合理间距 */
@media (min-width: 1661px) {
    .resource-container {
        grid-template-columns: repeat(5, 1fr); /* 固定5列，避免自动适应导致卡片过小 */
        max-width: 1800px; /* 增大最大宽度，适应超宽屏幕 */
        margin: 0 auto; /* 保持居中 */
        gap: 2rem; /* 略微增加卡片间距 */
    }
    
    .category-card {
        padding: 1.8rem; /* 稍微增加内边距 */
    }
}

/* 页脚样式 */
.main-footer {
    text-align: center;
    padding: 3rem 1rem;
    margin-top: 4rem;
    color: var(--text-secondary);
    font-size: 0.9em;
}
