/* ================================
   天狗食日科幻效果样式
   高性能GPU加速动画
   ================================ */

/* ========== 太阳容器 ========== */
.solar-eclipse-container {
    position: absolute;
    top: 20%;
    right: 20%;
    transform: translateY(-50%);
    width: 400px;
    height: 400px;
    z-index: 1;
    will-change: transform;
    perspective: 1000px;
}

/* ========== 太阳主体 ========== */
.sun {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, 
        #FFF9E6 0%, 
        #FFE17B 25%, 
        #FFB800 50%, 
        #FF9500 75%, 
        #FF6B00 100%);
    box-shadow: 
        0 0 60px rgba(255, 184, 0, 0.8),
        0 0 120px rgba(255, 107, 0, 0.6),
        0 0 180px rgba(255, 107, 0, 0.4),
        inset 0 0 80px rgba(255, 255, 255, 0.3);
    animation: sunPulse 8s ease-in-out infinite;
    z-index: 2;
}

/* 太阳核心 */
.sun-core {
    position: absolute;
    top: 15%;
    left: 15%;
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(255, 255, 255, 0.4) 50%, 
        transparent 100%);
    animation: coreShimmer 6s ease-in-out infinite;
}

/* 太阳光晕 */
.sun-glow {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    border-radius: 50%;
    background: radial-gradient(circle, 
        rgba(255, 184, 0, 0.4) 0%, 
        rgba(255, 107, 0, 0.2) 40%, 
        transparent 70%);
    animation: glowPulse 4s ease-in-out infinite;
    filter: blur(20px);
}

/* ========== 太阳光线 ========== */
.sun-rays {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    animation: raysRotate 120s linear infinite;
}

.ray {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 4px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 184, 0, 0.6) 20%, 
        rgba(255, 184, 0, 0.3) 40%, 
        transparent 100%);
    transform-origin: 0 50%;
    filter: blur(2px);
    opacity: 0.7;
    animation: rayPulse 3s ease-in-out infinite;
}

.ray-1 { transform: translate(-50%, -50%) rotate(0deg); animation-delay: 0s; }
.ray-2 { transform: translate(-50%, -50%) rotate(45deg); animation-delay: 0.375s; }
.ray-3 { transform: translate(-50%, -50%) rotate(90deg); animation-delay: 0.75s; }
.ray-4 { transform: translate(-50%, -50%) rotate(135deg); animation-delay: 1.125s; }
.ray-5 { transform: translate(-50%, -50%) rotate(180deg); animation-delay: 1.5s; }
.ray-6 { transform: translate(-50%, -50%) rotate(225deg); animation-delay: 1.875s; }
.ray-7 { transform: translate(-50%, -50%) rotate(270deg); animation-delay: 2.25s; }
.ray-8 { transform: translate(-50%, -50%) rotate(315deg); animation-delay: 2.625s; }

/* ========== 天狗（月球暗影）========== */
.moon-shadow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle at 60% 40%, 
        #1a1a2e 0%, 
        #16213e 40%, 
        #0f1419 100%);
    box-shadow: 
        inset -20px -20px 40px rgba(0, 0, 0, 0.8),
        inset 10px 10px 30px rgba(255, 255, 255, 0.05),
        0 0 60px rgba(0, 0, 0, 0.9);
    transform: translate(-30%, -50%);
    z-index: 3;
    animation: eclipseMove 20s ease-in-out infinite;
}

/* ========== 日冕效果 ========== */
.corona {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    opacity: 0;
    animation: coronaFlare 12s ease-in-out infinite;
    z-index: 1;
    filter: blur(8px);
}

.corona-1 {
    width: 320px;
    height: 320px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, 
        transparent 60%, 
        rgba(255, 184, 0, 0.4) 70%, 
        rgba(255, 107, 0, 0.2) 85%, 
        transparent 100%);
    animation-delay: 0s;
}

.corona-2 {
    width: 360px;
    height: 360px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, 
        transparent 65%, 
        rgba(255, 149, 0, 0.3) 75%, 
        rgba(255, 107, 0, 0.15) 90%, 
        transparent 100%);
    animation-delay: 4s;
}

.corona-3 {
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, 
        transparent 70%, 
        rgba(255, 107, 0, 0.2) 80%, 
        rgba(255, 107, 0, 0.1) 95%, 
        transparent 100%);
    animation-delay: 8s;
}

/* ========== 动画定义 ========== */

/* 太阳脉动 */
@keyframes sunPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 
            0 0 60px rgba(255, 184, 0, 0.8),
            0 0 120px rgba(255, 107, 0, 0.6),
            0 0 180px rgba(255, 107, 0, 0.4),
            inset 0 0 80px rgba(255, 255, 255, 0.3);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        box-shadow: 
            0 0 80px rgba(255, 184, 0, 0.9),
            0 0 140px rgba(255, 107, 0, 0.7),
            0 0 200px rgba(255, 107, 0, 0.5),
            inset 0 0 100px rgba(255, 255, 255, 0.4);
    }
}

/* 核心闪烁 */
@keyframes coreShimmer {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* 光晕脉动 */
@keyframes glowPulse {
    0%, 100% { 
        opacity: 0.6;
        transform: scale(1);
    }
    50% { 
        opacity: 0.9;
        transform: scale(1.1);
    }
}

/* 光线旋转 */
@keyframes raysRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 光线脉动 */
@keyframes rayPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.9; }
}

/* 天狗食日移动 */
@keyframes eclipseMove {
    0% {
        transform: translate(-120%, -50%);
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    50% {
        transform: translate(-30%, -50%);
    }
    85% {
        opacity: 1;
    }
    100% {
        transform: translate(60%, -50%);
        opacity: 0;
    }
}

/* 日冕闪耀 */
@keyframes coronaFlare {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 0; }
    40%, 60% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ========== 响应式设计 ========== */

@media (max-width: 1200px) {
    .solar-eclipse-container {
        width: 350px;
        height: 350px;
        right: 5%;
    }
    
    .sun {
        width: 240px;
        height: 240px;
    }
    
    .moon-shadow {
        width: 220px;
        height: 220px;
    }
}

@media (max-width: 992px) {
    .solar-eclipse-container {
        width: 300px;
        height: 300px;
        right: 0;
        left: 50%;
        transform: translate(-50%, -50%);
        top: 30%;
    }
    
    .sun {
        width: 200px;
        height: 200px;
    }
    
    .moon-shadow {
        width: 180px;
        height: 180px;
    }
    
    .corona-1 { width: 260px; height: 260px; }
    .corona-2 { width: 300px; height: 300px; }
    .corona-3 { width: 340px; height: 340px; }
}

@media (max-width: 768px) {
    .solar-eclipse-container {
        width: 250px;
        height: 250px;
        top: 25%;
    }
    
    .sun {
        width: 160px;
        height: 160px;
        box-shadow: 
            0 0 40px rgba(255, 184, 0, 0.8),
            0 0 80px rgba(255, 107, 0, 0.6),
            0 0 120px rgba(255, 107, 0, 0.4);
    }
    
    .moon-shadow {
        width: 140px;
        height: 140px;
    }
    
    .corona-1 { width: 200px; height: 200px; }
    .corona-2 { width: 240px; height: 240px; }
    .corona-3 { width: 280px; height: 280px; }
    
    .ray {
        height: 3px;
    }
}

@media (max-width: 576px) {
    .solar-eclipse-container {
        width: 200px;
        height: 200px;
        top: 20%;
    }
    
    .sun {
        width: 130px;
        height: 130px;
    }
    
    .moon-shadow {
        width: 110px;
        height: 110px;
    }
    
    .corona-1,
    .corona-2,
    .corona-3 {
        display: none; /* 移动端隐藏日冕以提升性能 */
    }
    
    .sun-rays {
        animation: raysRotate 180s linear infinite; /* 放慢旋转 */
    }
}

/* ========== 性能优化 ========== */

/* 启用硬件加速 */
.solar-eclipse-container,
.sun,
.sun-core,
.sun-glow,
.sun-rays,
.ray,
.moon-shadow,
.corona {
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* 减少重绘 */
.sun,
.moon-shadow,
.corona {
    contain: layout style paint;
}

/* 优先使用transform和opacity */
.ray,
.corona {
    will-change: opacity, transform;
}

/* 暗黑模式适配 */
@media (prefers-color-scheme: dark) {
    .sun {
        filter: brightness(0.9);
    }
    
    .moon-shadow {
        background: radial-gradient(circle at 60% 40%, 
            #0a0a0f 0%, 
            #050510 40%, 
            #000000 100%);
    }
}

/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .sun,
    .sun-core,
    .sun-glow,
    .sun-rays,
    .ray,
    .moon-shadow,
    .corona {
        animation: none !important;
    }
    
    .moon-shadow {
        transform: translate(-30%, -50%);
    }
}

