/*
 * 动物世界 - CSS 样式文件
 * 这是一个可外部引用的样式模块
 */

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #56ab2f;
    --warning-color: #f2994a;
    --danger-color: #e74c3c;
    --background-gradient-start: #667eea;
    --background-gradient-end: #764ba2;
    --card-shadow: 0 10px 30px rgba(0,0,0,0.1);
    --hover-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background: linear-gradient(135deg, var(--background-gradient-start) 0%, var(--background-gradient-end) 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* 容器样式 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    text-align: center;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

header h1 {
    color: var(--primary-color);
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    font-weight: 700;
}

header .subtitle {
    color: var(--secondary-color);
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    opacity: 0.9;
    font-weight: 500;
}

/* 控制面板 - 吸顶固定 */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    padding: 14px 20px;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.search-box, .category-filter {
    width: 100%;
    max-width: 400px;
    padding: 15px 20px;
    border: 2px solid transparent;
    border-radius: 50px;
    font-size: 1rem;
    box-shadow: var(--card-shadow);
    background: white;
    transition: all 0.3s ease;
}

.search-box:focus, .category-filter:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.search-box::placeholder, .category-filter::placeholder {
    color: #999;
}

/* 分类筛选器 */
.filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    position: sticky;
    top: 74px;
    z-index: 99;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.filter-btn {
    padding: 10px 20px;
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.9rem;
}

.filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.filter-btn.active, .filter-btn:hover.active {
    background: var(--primary-color);
    color: white;
}

/* 动物网格 */
.animals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

/* 动物卡片 */
.animal-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.animal-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--hover-shadow);
}

/* 卡片头部 */
.animal-header {
    position: relative;
    height: 340px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    overflow: hidden;
}

.animal-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    position: absolute;
    top: -35px;
        left: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 10;
}

.animal-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.animal-image-broken {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    background: linear-gradient(135deg, #e0eafc, #cfdef3);
    height: 100%;
}

.animal-card:hover .animal-image {
    transform: scale(1.05);
}

/* 卡片信息区 */
.animal-info {
    padding: 60px 20px 20px;
    position: relative;
}

.animal-name {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.animal-category {
    display: inline-block;
    padding: 5px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 15px;
    font-size: 0.85rem;
    margin-bottom: 12px;
    font-weight: 500;
}

.animal-scientific {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 15px;
    font-style: italic;
}

/* 统计标签 */
.animal-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
}

/* 描述文字 */
.animal-desc {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 操作按钮 */
.animal-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn-favorite {
    background: #fff5f5;
    color: var(--danger-color);
    border: 1px solid #fee2e2;
}

.btn-favorite:hover {
    background: #fee2e2;
    transform: translateY(-2px);
}

.btn-favorite.favorite-active {
    background: #fef2f2;
    color: var(--danger-color);
    border-color: #fecaca;
}

.btn-detail {
    background: #f0f9ff;
    color: var(--primary-color);
    border: 1px solid #bfdbfe;
}

.btn-detail:hover {
    background: #dbeafe;
    transform: translateY(-2px);
}

/* 统计数据栏 */
.stats-bar {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    margin-top: 30px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: var(--card-shadow);
}

.stat-item {
    text-align: center;
    padding: 15px;
    min-width: 120px;
}

.stat-number {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.stat-label {
    color: var(--secondary-color);
    font-size: 0.9rem;
    font-weight: 500;
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 1.2rem;
}

/* 无结果提示 */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 15px;
    color: #666;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header {
        padding: 30px 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .search-box, .category-filter {
        width: 100%;
        max-width: 300px;
    }

    .animals-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .stats-bar {
        flex-direction: column;
        text-align: center;
    }

    .stat-item {
        min-width: 100%;
    }

    .animal-info {
        padding: 55px 15px 15px;
    }

    .animal-avatar {
        width: 60px;
        height: 60px;
        font-size: 28px;
        top: -30px;
        left: 15px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animal-card {
    animation: fadeIn 0.5s ease-out;
}

.animal-card:nth-child(1) { animation-delay: 0.1s; }
.animal-card:nth-child(2) { animation-delay: 0.2s; }
.animal-card:nth-child(3) { animation-delay: 0.3s; }
.animal-card:nth-child(4) { animation-delay: 0.4s; }

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    right: 28px;
    bottom: 40px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 24px;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.55);
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
