/**
 * SHEIN Style Animations
 * 高端简约风格动画效果
 * 保持黑白灰主色调一致性
 */

/* ========== 基础动画定义 ========== */

/* 淡入上滑 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡入 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 心跳动画 */
@keyframes heartbeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.2); }
    60% { transform: scale(1); }
}

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

/* 涟漪效果 */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.5;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* 轻微摇晃 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

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

/* ========== 商品卡片动画 ========== */

/* 商品卡片悬停效果 - 高级感 */
.S-product-item,
.shein-product-card {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                box-shadow 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    position: relative;
}

.S-product-item::before,
.shein-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.02) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 1;
}

.S-product-item:hover,
.shein-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
}

.S-product-item:hover::before,
.shein-product-card:hover::before {
    opacity: 1;
}

/* 商品图片悬停放大 - 更柔和 */
.S-product-item__img,
.shein-product-card__img {
    overflow: hidden;
    position: relative;
}

.S-product-item__img img,
.shein-product-card__img img {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.S-product-item:hover .S-product-item__img img,
.shein-product-card:hover .shein-product-card__img img {
    transform: scale(1.05);
}

/* ========== 按钮动画 ========== */

/* 主按钮悬停效果 */
.shein-btn,
.btn-primary,
[class*="btn--primary"] {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.shein-btn:hover,
.btn-primary:hover,
[class*="btn--primary"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 34, 34, 0.25);
}

.shein-btn:active,
.btn-primary:active,
[class*="btn--primary"]:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(34, 34, 34, 0.2);
}

/* 按钮涟漪效果 */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.btn-ripple:active::after {
    animation: ripple 0.6s ease-out;
}

/* 次要按钮悬停 */
.shein-btn--secondary,
.btn-outline {
    transition: all 0.25s ease;
}

.shein-btn--secondary:hover,
.btn-outline:hover {
    background: #222;
    color: #fff;
    border-color: #222;
}

/* ========== 心愿单动画 ========== */

/* 心愿单图标 */
.S-product-item__wishlist,
.wishlist-btn,
[class*="wishlist"] {
    transition: all 0.25s ease;
}

.S-product-item__wishlist:hover,
.wishlist-btn:hover,
[class*="wishlist"]:hover {
    transform: scale(1.15);
}

/* 心愿单激活状态 - 心跳动画 */
.S-product-item__wishlist.active,
.wishlist-btn.active,
[class*="wishlist"].active,
.S-product-item__wishlist.liked {
    animation: heartbeat 0.6s ease-in-out;
    color: #e53935 !important;
}

.S-product-item__wishlist.active svg,
.wishlist-btn.active svg {
    fill: #e53935;
    stroke: #e53935;
}

/* ========== 分类图标动画 ========== */

.shein-category-item,
.category-item {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.shein-category-item:hover,
.category-item:hover {
    transform: translateY(-3px);
}

.shein-category-item__img,
.shein-category-item__img--main,
.shein-category-item__img--sub {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}

/* 高级光晕效果 */
.shein-category-item__img::after,
.shein-category-item__img--main::after,
.shein-category-item__img--sub::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px transparent;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.shein-category-item:hover .shein-category-item__img,
.shein-category-item:hover .shein-category-item__img--main,
.shein-category-item:hover .shein-category-item__img--sub {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.shein-category-item:hover .shein-category-item__img::after,
.shein-category-item:hover .shein-category-item__img--main::after,
.shein-category-item:hover .shein-category-item__img--sub::after {
    box-shadow: inset 0 0 0 2px rgba(34, 34, 34, 0.1);
}

/* 分类名称动画 */
.shein-category-item__name,
.shein-category-item__name--main,
.shein-category-item__name--sub {
    transition: all 0.3s ease;
}

.shein-category-item:hover .shein-category-item__name,
.shein-category-item:hover .shein-category-item__name--main {
    color: #000;
    font-weight: 600;
}

.shein-category-item:hover .shein-category-item__name--sub {
    color: #222;
}

/* ========== 滚动淡入动画 ========== */

/* 初始隐藏状态 - 更柔和的动画 */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 进入视口后显示 */
.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* 延迟动画 - 用于列表项，更细腻的间隔 */
.animate-on-scroll.delay-1 { transition-delay: 0.05s; }
.animate-on-scroll.delay-2 { transition-delay: 0.1s; }
.animate-on-scroll.delay-3 { transition-delay: 0.15s; }
.animate-on-scroll.delay-4 { transition-delay: 0.2s; }
.animate-on-scroll.delay-5 { transition-delay: 0.25s; }
.animate-on-scroll.delay-6 { transition-delay: 0.3s; }

/* 区块标题 - 优雅淡入 */
.shein-section__title,
.section-title {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.shein-section__title.animated,
.section-title.animated {
    opacity: 1;
    transform: translateY(0);
}

/* ========== 导航动画 ========== */

/* 导航链接下划线动画 */
.shein-nav__link {
    position: relative;
}

.shein-nav__link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: #fff;
    transition: width 0.3s ease, left 0.3s ease;
}

.shein-nav__link:hover::after {
    width: 100%;
    left: 0;
}

/* ========== 搜索框动画 ========== */

.shein-search__input {
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.shein-search__input:focus {
    box-shadow: 0 0 0 3px rgba(34, 34, 34, 0.1);
}

/* ========== 购物车图标动画 ========== */

.cart-icon,
[class*="cart-icon"] {
    transition: transform 0.3s ease;
}

.cart-icon:hover,
[class*="cart-icon"]:hover {
    transform: scale(1.1);
}

/* 购物车数量徽章弹跳 */
.cart-badge,
.cart-count {
    animation: none;
}

.cart-badge.updated,
.cart-count.updated {
    animation: bounce 0.4s ease;
}

/* ========== 价格动画 ========== */

/* 折扣价格脉冲 */
.S-product-item__price,
.price-sale {
    transition: color 0.3s ease;
}

.S-product-item:hover .S-product-item__price {
    color: #e53935;
}

/* 折扣标签 */
.S-product-item__discount,
.discount-badge {
    transition: transform 0.3s ease;
}

.S-product-item:hover .S-product-item__discount {
    transform: scale(1.1);
}

/* ========== 图片懒加载动画 ========== */

img.lazyload,
img[data-src] {
    opacity: 0;
    transition: opacity 0.4s ease;
}

img.lazyloaded,
img.loaded {
    opacity: 1;
}

/* ========== 模态框动画 ========== */

.modal,
.shein-modal {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active,
.shein-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal__content,
.shein-modal__content {
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal__content,
.shein-modal.active .shein-modal__content {
    transform: scale(1) translateY(0);
}

/* ========== 加载状态动画 ========== */

/* 骨架屏闪烁 */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton,
.loading-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ========== 响应式调整 - 移动端完整动画 ========== */

@media (max-width: 768px) {
    /* ===== 商品卡片动画 ===== */
    .S-product-item,
    .shein-product-card {
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                    box-shadow 0.3s ease;
    }
    
    /* 触摸反馈 - 使用:active代替:hover */
    .S-product-item:active,
    .shein-product-card:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    
    .S-product-item .S-product-item__img img,
    .shein-product-card .shein-product-card__img img {
        transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    /* ===== 滚动进入动画 ===== */
    .animate-on-scroll {
        opacity: 0;
        transform: translateY(20px);
        transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                    transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    .animate-on-scroll.animated {
        opacity: 1;
        transform: translateY(0);
    }
    
    /* 交错延迟动画 */
    .animate-on-scroll.delay-1 { transition-delay: 0.05s; }
    .animate-on-scroll.delay-2 { transition-delay: 0.1s; }
    .animate-on-scroll.delay-3 { transition-delay: 0.15s; }
    .animate-on-scroll.delay-4 { transition-delay: 0.2s; }
    .animate-on-scroll.delay-5 { transition-delay: 0.25s; }
    .animate-on-scroll.delay-6 { transition-delay: 0.3s; }
    
    /* ===== 分类图标动画 ===== */
    .shein-category-item {
        transition: transform 0.3s ease;
    }
    
    .shein-category-item:active {
        transform: scale(0.95);
    }
    
    .shein-category-item__img,
    .shein-category-item__img--main,
    .shein-category-item__img--sub {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    /* ===== 区块标题动画 ===== */
    .shein-section__title,
    .section-title {
        opacity: 0;
        transform: translateY(12px);
        transition: opacity 0.5s ease, transform 0.5s ease;
    }
    
    .shein-section__title.animated,
    .section-title.animated {
        opacity: 1;
        transform: translateY(0);
    }
    
    /* ===== 按钮点击动画 ===== */
    .shein-btn,
    .btn-primary,
    [class*="btn--primary"],
    button[type="submit"] {
        transition: transform 0.15s ease, background 0.2s ease;
    }
    
    .shein-btn:active,
    .btn-primary:active,
    [class*="btn--primary"]:active,
    button[type="submit"]:active {
        transform: scale(0.96);
    }
    
    /* ===== 心愿单按钮动画 ===== */
    .S-product-item__wishlist,
    .wishlist-btn,
    [class*="wishlist"] {
        transition: transform 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }
    
    .S-product-item__wishlist:active,
    .wishlist-btn:active {
        transform: scale(1.3);
    }
    
    .S-product-item__wishlist.active,
    .wishlist-btn.active {
        animation: heartBeat 0.4s ease;
    }
    
    /* ===== 图片淡入动画 ===== */
    .S-product-item__img img,
    .shein-product-card__img img {
        opacity: 1;
    }
    
    .lazyload {
        opacity: 0;
        transition: opacity 0.4s ease;
    }
    
    .lazyload.lazyloaded,
    img.lazyloaded,
    img.loaded {
        opacity: 1;
    }
    
    /* ===== 轮播图动画 ===== */
    .shein-carousel__slide {
        transition: opacity 0.5s ease;
    }
    
    /* ===== 底部导航动画 ===== */
    .shein-mobile-nav__item {
        transition: transform 0.2s ease, color 0.2s ease;
    }
    
    .shein-mobile-nav__item:active {
        transform: scale(0.9);
    }
    
    .shein-mobile-nav__item.active {
        color: #000;
    }
    
    /* ===== 侧边栏抽屉动画 ===== */
    .shein-drawer__item,
    .shein-drawer__link {
        transition: background 0.2s ease, padding-left 0.2s ease;
    }
    
    .shein-drawer__item:active,
    .shein-drawer__link:active {
        background: #f0f0f0;
        padding-left: 20px;
    }
    
    /* ===== 价格标签动画 ===== */
    .S-product-item__price,
    .shein-product-card__price {
        transition: color 0.2s ease;
    }
    
    /* ===== 加入购物车按钮动画 ===== */
    .add-to-cart-btn,
    .buy-now-btn {
        transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    }
    
    .add-to-cart-btn:active,
    .buy-now-btn:active {
        transform: scale(0.95);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    
    /* ===== 搜索框动画 ===== */
    .shein-search__input {
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    
    .shein-search__input:focus {
        border-color: #000;
        box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    }
    
    /* ===== 页面切换动画 ===== */
    .page-transition {
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    /* ===== 下拉刷新动画 ===== */
    .pull-to-refresh {
        transition: transform 0.3s ease;
    }
    
    /* ===== Toast提示动画 ===== */
    .toast,
    .flash-message {
        animation: slideInUp 0.3s ease;
    }
    
    @keyframes slideInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* 尊重用户的减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
