/* 动画效果 */

/* 淡入动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡出动画 */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* 缩放进入 */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 弹跳动画 */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 摇晃动画 */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* 旋转动画 */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 光晕效果 */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.8);
    }
}

/* 应用动画到元素 */

/* 页面淡入 */
.page.active {
    animation: fadeIn 0.5s ease-out;
}

/* 标题动画 */
.main-title {
    animation: scaleIn 0.6s ease-out;
}

/* 按钮悬停弹跳 */
.btn:active {
    animation: bounce 0.3s ease;
}

/* Hero 图片淡入 */
.hero-image img {
    animation: fadeIn 0.8s ease-out 0.2s both;
}

/* 场景图片淡入 */
.scene-image img {
    animation: fadeIn 0.6s ease-out;
}

/* 选择按钮逐个淡入 */
.choice-btn:nth-child(1) {
    animation: fadeIn 0.4s ease-out 0.1s both;
}

.choice-btn:nth-child(2) {
    animation: fadeIn 0.4s ease-out 0.2s both;
}

.choice-btn:nth-child(3) {
    animation: fadeIn 0.4s ease-out 0.3s both;
}

/* 进度条填充动画 */
.progress-fill {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 结果数字脉冲 */
.carbon-number {
    animation: pulse 2s ease-in-out infinite;
}

/* 评级星星动画 */
.rating-stars {
    animation: scaleIn 0.8s ease-out 0.3s both;
}

/* 图表容器淡入 */
.chart-container {
    animation: fadeIn 0.8s ease-out 0.5s both;
}

/* 建议列表项逐个淡入 */
.suggestions li:nth-child(1) {
    animation: fadeIn 0.4s ease-out 0.6s both;
}

.suggestions li:nth-child(2) {
    animation: fadeIn 0.4s ease-out 0.7s both;
}

.suggestions li:nth-child(3) {
    animation: fadeIn 0.4s ease-out 0.8s both;
}

.suggestions li:nth-child(4) {
    animation: fadeIn 0.4s ease-out 0.9s both;
}

/* 按钮组淡入 */
.action-buttons {
    animation: fadeIn 0.6s ease-out 1s both;
}

/* 输入框聚焦光晕 */
.input-group input:focus {
    animation: glow 1.5s ease-in-out infinite;
}

/* 碳排放显示数字变化动画 */
@keyframes countUp {
    from {
        transform: scale(1.2);
    }
    to {
        transform: scale(1);
    }
}

#total-carbon {
    display: inline-block;
    transition: all 0.3s ease;
}

/* 反馈提示滑入 */
.feedback-toast {
    animation: slideInBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideInBounce {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 场景切换过渡 */
.scene-content {
    transition: opacity 0.3s ease;
}

/* 加载动画（可选） */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 渐变背景动画 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

body {
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
}

/* 悬停提升效果增强 */
.choice-btn:hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 点击反馈 */
.choice-btn:active {
    transform: translateY(-3px) scale(0.98);
}

/* 响应式动画调整 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
