/**
 * DAF学院 - 动态背景效果
 * 星空、流星等动画效果
 */

/* ========================================
   星空背景容器
======================================== */
.animated-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1a2e 30%, #16213e 60%, #0f172a 100%);
}

[data-theme="light"] .animated-background {
    background: linear-gradient(135deg, #e8f0f8 0%, #f0f4f8 30%, #f8fafc 60%, #ffffff 100%);
}

/* 确保背景在页面内容之后但在其他元素之前 */
body {
    position: relative;
}

.auth-container,
.invite-container,
.user-center-page {
    position: relative;
    z-index: 1;
}

/* ========================================
   星空粒子
======================================== */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    opacity: 0.9;
    animation: twinkle 3s infinite ease-in-out;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .star {
    background: #3a7bd5;
    opacity: 0.5;
    box-shadow: 0 0 3px rgba(58, 123, 213, 0.6);
}

.star:nth-child(1) { top: 15%; left: 8%; animation-delay: 0s; }
.star:nth-child(2) { top: 25%; left: 18%; animation-delay: 0.3s; }
.star:nth-child(3) { top: 10%; left: 28%; animation-delay: 0.6s; }
.star:nth-child(4) { top: 35%; left: 38%; animation-delay: 0.9s; }
.star:nth-child(5) { top: 20%; left: 48%; animation-delay: 1.2s; }
.star:nth-child(6) { top: 55%; left: 12%; animation-delay: 0.2s; }
.star:nth-child(7) { top: 65%; left: 22%; animation-delay: 0.5s; }
.star:nth-child(8) { top: 45%; left: 58%; animation-delay: 1.1s; }
.star:nth-child(9) { top: 30%; left: 68%; animation-delay: 1.4s; }
.star:nth-child(10) { top: 40%; left: 78%; animation-delay: 1.7s; }
.star:nth-child(11) { top: 75%; left: 32%; animation-delay: 0.4s; }
.star:nth-child(12) { top: 5%; left: 52%; animation-delay: 1.0s; }
.star:nth-child(13) { top: 60%; left: 62%; animation-delay: 0.8s; }
.star:nth-child(14) { top: 50%; left: 72%; animation-delay: 1.5s; }
.star:nth-child(15) { top: 70%; left: 82%; animation-delay: 1.3s; }
.star:nth-child(16) { top: 12%; left: 15%; animation-delay: 0.7s; }
.star:nth-child(17) { top: 42%; left: 25%; animation-delay: 1.6s; }
.star:nth-child(18) { top: 28%; left: 45%; animation-delay: 0.1s; }
.star:nth-child(19) { top: 38%; left: 55%; animation-delay: 1.8s; }
.star:nth-child(20) { top: 58%; left: 88%; animation-delay: 0.9s; }

/* 大星星 */
.star-large {
    width: 3px;
    height: 3px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 1), 0 0 12px rgba(255, 255, 255, 0.6);
    animation-duration: 2s;
}

[data-theme="light"] .star-large {
    box-shadow: 0 0 8px rgba(58, 123, 213, 0.8), 0 0 12px rgba(58, 123, 213, 0.4);
}

/* 闪烁动画 */
@keyframes twinkle {
    0%, 100% { 
        opacity: 0.4; 
        transform: scale(1);
    }
    50% { 
        opacity: 1; 
        transform: scale(1.3);
    }
}

[data-theme="light"] .star {
    animation-duration: 4s;
}

/* ========================================
   流星效果
======================================== */
.meteor {
    position: absolute;
    width: 3px;
    height: 120px;
    background: linear-gradient(to bottom, 
        rgba(255, 255, 255, 1) 0%, 
        rgba(255, 255, 255, 0.6) 30%,
        rgba(255, 255, 255, 0.3) 60%,
        transparent 100%);
    border-radius: 50% 50% 0 0;
    opacity: 0;
    transform-origin: top;
    filter: blur(1px);
}

[data-theme="light"] .meteor {
    background: linear-gradient(to bottom, 
        rgba(58, 123, 213, 0.9) 0%, 
        rgba(58, 123, 213, 0.5) 30%,
        rgba(58, 123, 213, 0.2) 60%,
        transparent 100%);
}

.meteor::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 1);
}

[data-theme="light"] .meteor::before {
    background: #3a7bd5;
    box-shadow: 0 0 10px rgba(58, 123, 213, 0.8);
}

/* 流星轨迹动画 */
.meteor-1 {
    top: -100px;
    left: 10%;
    transform: rotate(45deg);
    animation: meteor-fall 3s infinite;
    animation-delay: 0s;
}

.meteor-2 {
    top: -100px;
    left: 30%;
    transform: rotate(45deg);
    animation: meteor-fall 4s infinite;
    animation-delay: 1.5s;
}

.meteor-3 {
    top: -100px;
    left: 60%;
    transform: rotate(45deg);
    animation: meteor-fall 3.5s infinite;
    animation-delay: 3s;
}

.meteor-4 {
    top: -100px;
    left: 80%;
    transform: rotate(45deg);
    animation: meteor-fall 4.5s infinite;
    animation-delay: 5s;
}

@keyframes meteor-fall {
    0% {
        opacity: 0;
        transform: translateY(0) rotate(45deg) scale(1);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(45deg) scale(0.5);
    }
}

/* ========================================
   光晕效果
======================================== */
.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.3;
    animation: pulse-glow 8s ease-in-out infinite;
}

[data-theme="light"] .glow {
    opacity: 0.2;
}

.glow-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(58, 123, 213, 0.6) 0%, transparent 70%);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(245, 166, 35, 0.4) 0%, transparent 70%);
    bottom: 20%;
    right: 15%;
    animation-delay: 2s;
}

.glow-3 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(58, 123, 213, 0.5) 0%, transparent 70%);
    top: 50%;
    left: 70%;
    animation-delay: 4s;
}

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

[data-theme="light"] .glow {
    opacity: 0.1;
}

[data-theme="light"] .glow {
    opacity: 0.1;
}

@keyframes pulse-glow-light {
    0%, 100% {
        transform: scale(1);
        opacity: 0.1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.2;
    }
}

/* ========================================
   浮动粒子
======================================== */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: float 15s infinite linear;
}

[data-theme="light"] .particle {
    background: rgba(58, 123, 213, 0.4);
}

.particle:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
    animation-duration: 20s;
}

.particle:nth-child(2) {
    left: 25%;
    animation-delay: 2s;
    animation-duration: 18s;
}

.particle:nth-child(3) {
    left: 40%;
    animation-delay: 4s;
    animation-duration: 22s;
}

.particle:nth-child(4) {
    left: 55%;
    animation-delay: 1s;
    animation-duration: 19s;
}

.particle:nth-child(5) {
    left: 70%;
    animation-delay: 3s;
    animation-duration: 21s;
}

.particle:nth-child(6) {
    left: 85%;
    animation-delay: 5s;
    animation-duration: 17s;
}

@keyframes float {
    0% {
        bottom: -10px;
        opacity: 0;
        transform: translateX(0);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        bottom: 100vh;
        opacity: 0;
        transform: translateX(30px);
    }
}

/* ========================================
   星座连线效果（可选）
======================================== */
.constellation {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.2;
}

.constellation-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%);
    animation: constellation-pulse 4s ease-in-out infinite;
}

[data-theme="light"] .constellation-line {
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(58, 123, 213, 0.2) 50%, 
        transparent 100%);
}

.constellation-line-1 {
    top: 25%;
    left: 20%;
    width: 150px;
    transform: rotate(30deg);
    animation-delay: 0s;
}

.constellation-line-2 {
    top: 40%;
    left: 60%;
    width: 120px;
    transform: rotate(-25deg);
    animation-delay: 1s;
}

.constellation-line-3 {
    top: 70%;
    left: 30%;
    width: 100px;
    transform: rotate(45deg);
    animation-delay: 2s;
}

@keyframes constellation-pulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.3; }
}

/* ========================================
   性能优化
======================================== */
.animated-background,
.stars,
.meteor,
.glow,
.particle {
    will-change: transform, opacity;
}

/* 减少动画时降低性能消耗 */
@media (prefers-reduced-motion: reduce) {
    .star,
    .meteor,
    .glow,
    .particle,
    .constellation-line {
        animation: none;
    }
}

/* 移动端简化动画 */
@media (max-width: 768px) {
    .glow {
        display: none;
    }
    
    .constellation {
        display: none;
    }
    
    .particle {
        display: none;
    }
    
    .meteor {
        height: 60px;
    }
}
