/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "微软雅黑", sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px 0;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.header {
    text-align: center;
    padding: 40px 0;
    background-color: #2c3e50;
    color: white;
    border-radius: 8px 8px 0 0;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.8;
}

.main {
    margin-bottom: 30px;
}

.demo-section {
    margin-bottom: 50px;
}

.demo-section h2 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.demo-box {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.footer {
    text-align: center;
    padding: 20px 0;
    background-color: #2c3e50;
    color: white;
    border-radius: 0 0 8px 8px;
}

/* 1. 淡入动画 */
.fade-in-box img {
    animation: fadeIn 2s ease-in-out forwards;
    opacity: 0;
}

/* 定义淡入关键帧 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 2. 变换动画 */
.transform-boxes {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.transform-item {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #3498db;
    color: white;
    font-size: 1.2rem;
    border-radius: 8px;
    transition: all 0.3s ease; /* 过渡效果 */
    cursor: pointer;
}

/* 旋转 */
.rotate-item:hover {
    transform: rotate(360deg);
    background-color: #e74c3c;
}

/* 缩放 */
.scale-item:hover {
    transform: scale(1.2);
    background-color: #2ecc71;
}

/* 平移 */
.translate-item:hover {
    transform: translate(20px, -10px);
    background-color: #f39c12;
}

/* 倾斜 */
.skew-item:hover {
    transform: skew(10deg, 5deg);
    background-color: #9b59b6;
}

/* 3. 滚动触发动画 */
.scroll-animate-box {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.8s ease;
    text-align: center;
    padding: 50px 0;
}

.scroll-animate-box.animate {
    opacity: 1;
    transform: scale(1);
}

.scroll-animate-box p {
    font-size: 1.5rem;
    color: #3498db;
    font-weight: bold;
}

/* 4. 响应式过渡优化 */
.responsive-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    transition: all 0.5s ease; /* 响应式过渡核心 */
}

.responsive-item {
    padding: 20px;
    background-color: #f1f1f1;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.responsive-item:hover {
    background-color: #3498db;
    color: white;
    transform: translateY(-5px);
}

/* 5. 按钮交互动画 */
.button-box {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 20px 0;
}

.animated-btn {
    padding: 12px 30px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.animated-btn::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.animated-btn:hover::after {
    width: 300px;
    height: 300px;
}

.animated-btn:hover {
    background-color: #2980b9;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

/* 脉冲动画按钮 */
.pulse-btn {
    padding: 12px 30px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    cursor: pointer;
    position: relative;
}

.pulse-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background-color: rgba(231, 76, 60, 0.3);
    z-index: -1;
    animation: pulse 2s infinite;
}

/* 脉冲关键帧 */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    70% {
        transform: scale(1.2);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* 响应式适配 */
@media (max-width: 992px) {
    .responsive-box {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .responsive-box {
        grid-template-columns: 1fr;
    }
    
    .transform-boxes {
        flex-direction: column;
        align-items: center;
    }
    
    .button-box {
        flex-direction: column;
        align-items: center;
    }
    
    .animated-btn, .pulse-btn {
        width: 100%;
    }
}