/* ===================================
   动画效果
   ================================== */

/* 页面切换动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-100%);
    }
}

/* 呼吸动画 - CTA 按钮 */
@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 40px rgba(0, 217, 255, 0.3);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 50px rgba(0, 217, 255, 0.5);
    }
}

.cta-button {
    animation: breathe 2s ease-in-out infinite;
}

/* 加载点动画 */
@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 扫描线动画 */
@keyframes scan {
    0% {
        top: 0;
    }

    100% {
        top: 100%;
    }
}

/* 脉冲动画 */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* 波纹效果 */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* 闪光效果 - 拍照时 */
@keyframes flash {

    0%,
    100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

.flash-effect {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    pointer-events: none;
    animation: flash 0.3s ease-out;
    z-index: 9999;
}

/* 数字滚动动画 */
@keyframes countUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.score-number {
    animation: countUp 0.8s ease-out;
}

/* 雷达图展开动画 */
@keyframes radarExpand {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

#radar-chart {
    animation: radarExpand 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 卡片进入动画 */
@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.detail-card {
    animation: slideUp 0.5s ease-out backwards;
}

.detail-card:nth-child(1) {
    animation-delay: 0.1s;
}

.detail-card:nth-child(2) {
    animation-delay: 0.2s;
}

.detail-card:nth-child(3) {
    animation-delay: 0.3s;
}

.detail-card:nth-child(4) {
    animation-delay: 0.4s;
}

.detail-card:nth-child(5) {
    animation-delay: 0.5s;
}

.detail-card:nth-child(6) {
    animation-delay: 0.6s;
}

/* 进度条填充动画 */
.detail-progress-fill {
    animation: fillProgress 1s ease-out forwards;
}

@keyframes fillProgress {
    from {
        width: 0;
    }
}

/* Tab 切换动画 */
.tab-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-item:active {
    transform: scale(0.9);
}

/* 按钮点击反馈 */
.btn-primary:active,
.btn-secondary:active,
.cta-button:active {
    transform: scale(0.95);
}

/* 微交互 - 卡片悬停 */
.history-card,
.stat-card,
.detail-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.history-card:active {
    transform: translateY(2px);
}

/* 人脸检测框呼吸效果 */
@keyframes outlineBreath {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.face-outline {
    animation: outlineBreath 2s ease-in-out infinite;
}

/* 环境状态变化动画 */
.env-status {
    transition: all 0.3s ease;
}

.env-status.good {
    animation: statusGlow 2s ease-in-out infinite;
}

@keyframes statusGlow {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(0, 230, 118, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(0, 230, 118, 0.6);
    }
}

/* 页面转场效果 */
.page-transition-enter {
    animation: slideInRight 0.3s ease-out;
}

.page-transition-exit {
    animation: slideOutLeft 0.25s ease-in;
}

/* 渐变背景动画 */
@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;
}

/* 骨架屏加载动画 */
@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }

    100% {
        background-position: 468px 0;
    }
}

.skeleton {
    background: linear-gradient(to right,
            var(--color-surface) 0%,
            var(--color-surface-elevated) 20%,
            var(--color-surface) 40%,
            var(--color-surface) 100%);
    background-size: 800px 104px;
    animation: shimmer 1.5s infinite;
}

/* 分享按钮动画 */
#share-btn {
    transition: transform 0.3s ease;
}

#share-btn:active {
    animation: shareRotate 0.5s ease;
}

@keyframes shareRotate {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-10deg);
    }

    75% {
        transform: rotate(10deg);
    }
}

/* 通知提示动画 */
@keyframes toastIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    z-index: 1000;
    animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s;
}

/* 加载旋转器 */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    border: 3px solid var(--color-surface);
    border-top-color: var(--color-info);
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

/* 减少动画 - 尊重用户偏好 */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}