/**
 * VBA教程 - Canvas特效样式
 * 粒子动画 | 形变效果 | 过渡动画
 */

/* ===== Canvas容器样式 ===== */
.particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none !important;
    z-index: 9999;
    cursor: none;
}

/* 鼠标轨迹特效样式 */
.mouse-trail-active {
    cursor: none;
}

/* 点击波纹效果增强 */
.click-ripple {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    animation: ripple-expand 0.8s ease-out forwards;
    background: radial-gradient(circle, rgba(33, 115, 70, 0.4) 0%, rgba(255, 107, 53, 0.2) 50%, transparent 70%);
}

@keyframes ripple-expand {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* 星空闪烁效果 */
.star-twinkle {
    animation: star-twinkle 2s ease-in-out infinite;
}

@keyframes star-twinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 鼠标悬停发光 */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(33, 115, 70, 0.5), 0 0 40px rgba(255, 107, 53, 0.3);
}

/* 粒子爆发按钮效果 */
.particle-burst-btn {
    position: relative;
    overflow: visible;
}

.particle-burst-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 107, 53, 0.6) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.particle-burst-btn:active::after {
    transform: translate(-50%, -50%) scale(2);
    opacity: 1;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

/* 能量流动效果 */
.energy-flow {
    position: relative;
}

.energy-flow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(33, 115, 70, 0.2), transparent);
    animation: energy-flow 3s ease-in-out infinite;
}

@keyframes energy-flow {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* 主内容区Canvas容器 */
.main-content {
    position: relative;
}

.content-wrapper {
    position: relative;
    z-index: 10;
}

.content-container {
    position: relative;
    z-index: 10;
}

/* ===== 滚动触发动画 ===== */
.section,
.feature-card,
.tip-box,
.code-block,
.exercise {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.section.animate-in,
.feature-card.animate-in,
.tip-box.animate-in,
.code-block.animate-in,
.exercise.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* 错开动画延迟 */
.feature-card:nth-child(1) { transition-delay: 0.1s; }
.feature-card:nth-child(2) { transition-delay: 0.2s; }
.feature-card:nth-child(3) { transition-delay: 0.3s; }

/* ===== 粒子爆发效果 ===== */
@keyframes particle-burst {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.particle-burst-effect {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: particle-burst 0.6s ease-out forwards;
}

/* ===== 脉冲动画 ===== */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(33, 115, 70, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(33, 115, 70, 0.6), 0 0 40px rgba(33, 115, 70, 0.3);
    }
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* ===== 浮动动画 ===== */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.float-animation {
    animation: float 3s ease-in-out infinite;
}

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

.rotate-slow {
    animation: rotate-slow 20s linear infinite;
}

/* ===== 形变动画 ===== */
@keyframes morph-shape {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    25% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
    50% {
        border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%;
    }
    75% {
        border-radius: 60% 40% 60% 30% / 70% 30% 50% 60%;
    }
}

.morph-shape {
    animation: morph-shape 8s ease-in-out infinite;
}

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

.gradient-animate {
    background-size: 200% 200%;
    animation: gradient-shift 15s ease infinite;
}

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

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(33, 115, 70, 0.3);
    pointer-events: none;
    animation: ripple 1s ease-out forwards;
}

/* ===== 按钮悬停特效 ===== */
.btn-primary,
.start-btn,
.btn-next {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-primary::before,
.start-btn::before,
.btn-next::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-primary:hover::before,
.start-btn:hover::before,
.btn-next:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover,
.start-btn:hover,
.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(33, 115, 70, 0.4);
}

/* ===== 卡片悬停特效 ===== */
.feature-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

/* ===== 导航项特效 ===== */
.nav-item {
    position: relative;
    overflow: hidden;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #ff6b35, #ffd93d);
    transition: width 0.3s ease;
}

.nav-item:hover::after {
    width: 100%;
}

/* ===== 代码块光效 ===== */
.code-block {
    position: relative;
}

.code-block::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #217346, #ff6b35, #ffd93d, #217346);
    background-size: 400% 400%;
    border-radius: 10px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: gradient-shift 3s ease infinite;
}

.code-block:hover::before {
    opacity: 0.5;
}

/* ===== 进度条动画 ===== */
.progress-fill {
    background: linear-gradient(90deg, #217346 0%, #2e8f5a 50%, #217346 100%);
    background-size: 200% 100%;
    animation: progress-shine 2s linear infinite;
}

@keyframes progress-shine {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===== 打字机效果 ===== */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: #217346;
    }
}

.typewriter {
    overflow: hidden;
    border-right: 2px solid #217346;
    white-space: nowrap;
    animation: 
        typing 3.5s steps(40, end),
        blink-caret 0.75s step-end infinite;
}

/* ===== 摇晃动画（错误提示） ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* ===== 弹跳动画 ===== */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(-25px);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

.bounce {
    animation: bounce 1s infinite;
}

/* ===== 闪烁动画 ===== */
@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.flash {
    animation: flash 2s ease-in-out infinite;
}

/* ===== 缩放进入动画 ===== */
@keyframes zoom-in {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.zoom-in {
    animation: zoom-in 0.5s ease-out;
}

/* ===== 滑入动画变体 ===== */
@keyframes slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slide-in-left 0.5s ease-out;
}

.slide-in-right {
    animation: slide-in-right 0.5s ease-out;
}

/* ===== 呼吸效果 ===== */
@keyframes breathe {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

.breathe {
    animation: breathe 3s ease-in-out infinite;
}

/* ===== 粒子配置面板 ===== */
.particle-config-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 250px;
    transform: translateY(120%);
    transition: transform 0.3s ease;
}

.particle-config-panel.visible {
    transform: translateY(0);
}

.particle-config-panel h4 {
    margin: 0 0 15px 0;
    color: #217346;
    font-size: 14px;
}

.particle-config-panel .config-item {
    margin-bottom: 12px;
}

.particle-config-panel label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.particle-config-panel input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.particle-config-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #217346;
    cursor: pointer;
}

.particle-config-panel select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 12px;
    background: white;
}

/* ===== 性能指示器 ===== */
.fps-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #4caf50;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fps-indicator.visible {
    opacity: 1;
}

.fps-indicator.low {
    color: #ff6b6b;
}

.fps-indicator.medium {
    color: #ffa726;
}

/* ===== 响应式调整 ===== */
@media (max-width: 768px) {
    .particle-config-panel {
        left: 10px;
        right: 10px;
        bottom: 10px;
        min-width: auto;
    }
    
    .fps-indicator {
        top: 10px;
        right: 10px;
        font-size: 10px;
        padding: 6px 8px;
    }
}

/* ===== 减少动画偏好设置 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .particle-canvas {
        display: none;
    }
}

/* ===== 暗色模式支持 ===== */
@media (prefers-color-scheme: dark) {
    .particle-config-panel {
        background: rgba(45, 45, 45, 0.95);
        color: #fff;
    }

    .particle-config-panel label {
        color: #aaa;
    }

    .particle-config-panel select {
        background: #3d3d3d;
        color: #fff;
        border-color: #555;
    }
}

/* ===== 强制隐藏所有光标 ===== */
* {
    cursor: none !important;
}
