/* ========================================
   特效样式 - Effects CSS
   ======================================== */

/* 自定义光标 */
.cursor {
    position: fixed;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    transition: transform 0.15s ease, width 0.3s ease, height 0.3s ease, background 0.3s ease;
    transform: translate(-50%, -50%);
    mix-blend-mode: difference;
}

.cursor-dot {
    position: fixed;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10001;
    transform: translate(-50%, -50%);
}

.cursor.hover {
    width: 60px;
    height: 60px;
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--secondary-color);
}

.cursor.clicking {
    transform: translate(-50%, -50%) scale(0.8);
}

/* 隐藏默认光标 */
@media (pointer: fine) {
    body.custom-cursor {
        cursor: none;
    }
    
    body.custom-cursor a,
    body.custom-cursor button,
    body.custom-cursor input,
    body.custom-cursor textarea,
    body.custom-cursor [role="button"] {
        cursor: none;
    }
}

/* 移动端不显示自定义光标 */
@media (pointer: coarse) {
    .cursor,
    .cursor-dot {
        display: none !important;
    }
}

/* ========================================
   预加载器
   ======================================== */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.preloader.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-logo {
    font-size: 4rem;
    margin-bottom: 40px;
    animation: pulse-glow 2s ease-in-out infinite;
}

.preloader-bar {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.preloader-progress {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.preloader-text {
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    letter-spacing: 3px;
    text-transform: uppercase;
}

@keyframes pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 40px rgba(236, 72, 153, 0.8));
        transform: scale(1.05);
    }
}

/* ========================================
   粒子背景
   ======================================== */
#particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* ========================================
   Glassmorphism 毛玻璃效果
   ======================================== */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================
   噪点纹理
   ======================================== */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* ========================================
   动态渐变
   ======================================== */
.gradient-bg {
    background: linear-gradient(-45deg, #6366f1, #ec4899, #8b5cf6, #06b6d4);
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.gradient-text {
    background: linear-gradient(-45deg, #6366f1, #ec4899, #8b5cf6, #06b6d4);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 8s ease infinite;
}

/* ========================================
   3D Tilt 卡片效果
   ======================================== */
.tilt-card {
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.1s ease;
}

.tilt-card .tilt-inner {
    transform: translateZ(30px);
    transition: transform 0.3s ease;
}

.tilt-card:hover .tilt-inner {
    transform: translateZ(50px);
}

/* ========================================
   磁性按钮
   ======================================== */
.magnetic-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.magnetic-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    border-radius: 50%;
}

.magnetic-btn:hover::before {
    width: 300%;
    height: 300%;
}

/* ========================================
   文字动画效果
   ======================================== */
.split-text .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(50px) rotateX(-90deg);
    transform-origin: center bottom;
}

.split-text.animate .char {
    animation: char-reveal 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes char-reveal {
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.text-reveal.visible span {
    transform: translateY(0);
}

/* ========================================
   发光效果
   ======================================== */
.glow {
    animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3),
                    0 0 40px rgba(99, 102, 241, 0.2),
                    0 0 60px rgba(99, 102, 241, 0.1);
    }
    50% {
        box-shadow: 0 0 30px rgba(236, 72, 153, 0.4),
                    0 0 60px rgba(236, 72, 153, 0.3),
                    0 0 90px rgba(236, 72, 153, 0.2);
    }
}

.text-glow {
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5),
                 0 0 20px rgba(99, 102, 241, 0.3),
                 0 0 40px rgba(99, 102, 241, 0.2);
}

/* ========================================
   滚动动画基础类
   ======================================== */
.reveal {
    opacity: 0;
    visibility: hidden;
}

.reveal.active {
    opacity: 1;
    visibility: visible;
}

.reveal-up {
    opacity: 0;
    transform: translateY(80px);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-80px);
}

.reveal-right {
    opacity: 0;
    transform: translateX(80px);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.8);
}

.reveal-rotate {
    opacity: 0;
    transform: rotateY(30deg);
}

/* ========================================
   视差效果
   ======================================== */
.parallax-container {
    overflow: hidden;
    position: relative;
}

.parallax-element {
    will-change: transform;
}

/* ========================================
   主题切换按钮
   ======================================== */
.theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.6);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    transform: rotate(180deg) scale(0);
    opacity: 0;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    transform: rotate(0) scale(1);
    opacity: 1;
}

[data-theme="light"] .theme-toggle .icon-sun {
    transform: rotate(0) scale(1);
    opacity: 1;
}

[data-theme="light"] .theme-toggle .icon-moon {
    transform: rotate(-180deg) scale(0);
    opacity: 0;
}

/* ========================================
   滚动进度条
   ======================================== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent-gradient);
    z-index: 10000;
    transition: width 0.1s ease;
}

/* ========================================
   悬停涟漪效果
   ======================================== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease;
    opacity: 0;
}

.ripple:active::after {
    width: 300%;
    height: 300%;
    opacity: 1;
    transition: 0s;
}

/* ========================================
   浮动元素增强
   ======================================== */
.float-enhanced {
    animation: float-enhanced 6s ease-in-out infinite;
}

@keyframes float-enhanced {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(2deg);
    }
    50% {
        transform: translateY(-25px) rotate(0deg);
    }
    75% {
        transform: translateY(-15px) rotate(-2deg);
    }
}

/* ========================================
   边框动画
   ======================================== */
.border-animate {
    position: relative;
}

.border-animate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid transparent;
    border-radius: inherit;
    background: linear-gradient(90deg, #6366f1, #ec4899, #6366f1) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    background-size: 200% 100%;
    animation: border-flow 3s linear infinite;
}

@keyframes border-flow {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* ========================================
   图片懒加载占位
   ======================================== */
.lazy-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ========================================
   技能条动画
   ======================================== */
.skill-bar {
    height: 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.skill-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    width: 0%;
    transition: width 1.5s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ========================================
   移动端优化
   ======================================== */
@media (max-width: 768px) {
    .theme-toggle {
        bottom: 20px;
        right: 20px;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }
    
    /* 减少移动端动画 */
    .float-enhanced {
        animation-duration: 8s;
    }
    
    .gradient-bg {
        animation-duration: 20s;
    }
}

/* ========================================
   性能优化
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .cursor,
    .cursor-dot,
    .noise-overlay {
        display: none !important;
    }
}
