/* ========================================
   ANIMATIONS & EFFECTS
   ======================================== */

/* ========== KEYFRAME ANIMATIONS ========== */

/* Twinkling Stars - Enhanced Blinking */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.2;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.4);
    }
}

@keyframes twinkleFast {
    0%, 100% {
        opacity: 0.1;
        transform: scale(0.6);
    }
    50% {
        opacity: 1;
        transform: scale(1.5);
    }
}

@keyframes twinkleSlow {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.9);
    }
    25% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
    }
    75% {
        opacity: 0.6;
    }
}

@keyframes twinklePulse {
    0%, 100% {
        opacity: 0.15;
        transform: scale(0.7);
        filter: brightness(0.8);
    }
    33% {
        opacity: 0.8;
        transform: scale(1.2);
        filter: brightness(1.2);
    }
    66% {
        opacity: 0.4;
        transform: scale(0.9);
        filter: brightness(1);
    }
}

@keyframes twinkleBright {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
        box-shadow: 0 0 4px currentColor;
    }
    50% {
        opacity: 1;
        transform: scale(1.6);
        box-shadow: 0 0 12px currentColor, 0 0 20px currentColor;
    }
}

/* Milky Way Flow Animation */
@keyframes milkyWayFlow {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    100% {
        transform: translate(-100px, 50px) rotate(360deg);
    }
}

/* Nebula Flow Animation */
@keyframes nebulaFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(30px, -30px) scale(1.1);
        opacity: 0.5;
    }
}

/* Floating Text Animation */
@keyframes floatText {
    0%, 100% {
        transform: translateY(0px);
        text-shadow:
            0 0 10px rgba(212, 175, 55, 0.8),
            0 0 20px rgba(212, 175, 55, 0.6),
            0 0 30px rgba(212, 175, 55, 0.4),
            0 0 40px rgba(212, 175, 55, 0.3);
    }
    50% {
        transform: translateY(-15px);
        text-shadow:
            0 0 20px rgba(212, 175, 55, 1),
            0 0 30px rgba(212, 175, 55, 0.8),
            0 0 40px rgba(212, 175, 55, 0.6),
            0 0 60px rgba(212, 175, 55, 0.4),
            0 0 80px rgba(212, 175, 55, 0.2);
    }
}

/* Shimmer Star Effect for Text */
@keyframes shimmerStar {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fast Shimmer for Title Stars */
@keyframes shimmerStarFast {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) rotate(180deg);
    }
}

/* Continuous Shimmer */
@keyframes shimmerStarContinuous {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1) rotate(0deg);
    }
    33% {
        opacity: 1;
        transform: scale(1.3) rotate(120deg);
    }
    66% {
        opacity: 0.7;
        transform: scale(1.1) rotate(240deg);
    }
}

/* Pulse Shimmer */
@keyframes shimmerStarPulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(0.9);
        text-shadow: 0 0 10px currentColor;
    }
    50% {
        opacity: 1;
        transform: scale(1.4);
        text-shadow: 0 0 20px currentColor, 0 0 30px currentColor;
    }
}

/* Harry Potter Style Golden Shimmer on Letters */
@keyframes goldenShimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* Letter Sparkle Particle */
@keyframes letterSparkle {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0);
    }
    20% {
        opacity: 1;
        transform: translate(var(--tx), var(--ty)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(var(--tx) * 2), calc(var(--ty) * 2)) scale(0);
    }
}

/* Floating Sparkle Around Letters */
@keyframes floatSparkle {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) translateX(var(--drift-x)) scale(0);
    }
}

/* Magical Glow Pulse */
@keyframes magicalGlow {
    0%, 100% {
        text-shadow:
            0 0 10px rgba(212, 175, 55, 0.8),
            0 0 20px rgba(212, 175, 55, 0.6),
            0 0 30px rgba(212, 175, 55, 0.4),
            0 0 40px rgba(212, 175, 55, 0.3);
    }
    50% {
        text-shadow:
            0 0 20px rgba(212, 175, 55, 1),
            0 0 30px rgba(212, 175, 55, 0.8),
            0 0 40px rgba(212, 175, 55, 0.6),
            0 0 60px rgba(212, 175, 55, 0.4),
            0 0 80px rgba(212, 175, 55, 0.2),
            0 0 100px rgba(212, 175, 55, 0.1);
    }
}

/* Shooting Star Animations - Multiple Directions */
@keyframes shootingStar {
    0% {
        transform: translateX(0) translateY(0) rotate(-45deg);
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        transform: translateX(-600px) translateY(600px) rotate(-45deg);
        opacity: 0;
    }
}

@keyframes shootingStarAlt {
    0% {
        transform: translateX(0) translateY(0) rotate(-35deg);
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        transform: translateX(-700px) translateY(500px) rotate(-35deg);
        opacity: 0;
    }
}

@keyframes shootingStarSteep {
    0% {
        transform: translateX(0) translateY(0) rotate(-55deg);
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        transform: translateX(-400px) translateY(700px) rotate(-55deg);
        opacity: 0;
    }
}

@keyframes shootingStarFast {
    0% {
        transform: translateX(0) translateY(0) rotate(-42deg);
        opacity: 1;
    }
    60% {
        opacity: 1;
    }
    100% {
        transform: translateX(-800px) translateY(800px) rotate(-42deg);
        opacity: 0;
    }
}

.shooting-star {
    position: fixed;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 15px 3px rgba(255, 255, 255, 0.9);
    z-index: 1;
    pointer-events: none;
}

.shooting-star::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.5) 50%, transparent);
    transform: translateX(-100px);
}

.shooting-star::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 2px;
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.8), rgba(212, 175, 55, 0.3) 50%, transparent);
    transform: translateX(-100px) translateY(1px);
}

/* Golden Meteor */
.shooting-star.golden {
    background: rgba(212, 175, 55, 1);
    box-shadow: 0 0 20px 4px rgba(212, 175, 55, 1);
}

.shooting-star.golden::before {
    background: linear-gradient(90deg, rgba(212, 175, 55, 1), rgba(255, 215, 100, 0.5) 50%, transparent);
}

.shooting-star.golden::after {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.3) 50%, transparent);
}

/* Fast Small Meteor */
.shooting-star.fast {
    width: 2px;
    height: 2px;
}

.shooting-star.fast::before,
.shooting-star.fast::after {
    width: 60px;
    transform: translateX(-60px);
}

/* Large Bright Meteor */
.shooting-star.bright {
    width: 4px;
    height: 4px;
    box-shadow: 0 0 25px 5px rgba(255, 255, 255, 1);
}

.shooting-star.bright::before {
    width: 150px;
    height: 3px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 1), rgba(200, 220, 255, 0.6) 40%, transparent);
    transform: translateX(-150px);
}

.shooting-star.bright::after {
    width: 150px;
    height: 3px;
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.9), rgba(212, 175, 55, 0.4) 40%, transparent);
    transform: translateX(-150px) translateY(2px);
}

/* Pulsing Glow */
@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.5;
        transform: translateX(-50%) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-50%) scale(1.1);
    }
}

/* Light Ray Animation */
@keyframes rayAnimation {
    0%, 100% {
        opacity: 0;
        transform: translateX(-50%) rotate(0deg) scaleY(0);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-50%) rotate(var(--rotation)) scaleY(1);
    }
}

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In From Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In From Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Float Animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Rotate Glow */
@keyframes rotateGlow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ========== BOOK GLOW EFFECT ========== */
.book-glow {
    position: absolute;
    width: 200px;
    height: 200px;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 102;
}

.light-ray {
    position: absolute;
    width: 2px;
    height: 150px;
    background: linear-gradient(to top, var(--gold), transparent);
    bottom: 0;
    left: 50%;
    transform-origin: bottom center;
    opacity: 0;
    animation: rayAnimation 4s infinite;
    filter: blur(1px);
}

.ambient-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(212, 175, 55, 0.3), transparent 70%);
    animation: pulseGlow 3s infinite;
    pointer-events: none;
    z-index: 99;
}

/* Sparkles */
.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--gold);
    border-radius: 50%;
    animation: sparkleAnimation 2s infinite;
    pointer-events: none;
}

@keyframes sparkleAnimation {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========== SCROLL ANIMATIONS ========== */
.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.fade-in-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.fade-in-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.scale-in {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scale-in.visible {
    opacity: 1;
    transform: scale(1);
}

/* ========== HOVER EFFECTS ========== */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.hover-glow {
    transition: box-shadow 0.3s ease, filter 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
    filter: brightness(1.1);
}

.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* ========== LOADING ANIMATION ========== */
.loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(212, 175, 55, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== PAGE TRANSITION ========== */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.page-transition.active {
    opacity: 1;
    pointer-events: all;
}

/* ========== TEXT ANIMATIONS ========== */
.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    opacity: 0;
    transform: translateY(100%);
    animation: textReveal 0.8s forwards;
}

@keyframes textReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gradient-text {
    background: linear-gradient(135deg, var(--gold), var(--light-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shimmer-text {
    background: linear-gradient(
        90deg,
        var(--gold) 0%,
        var(--light-gold) 50%,
        var(--gold) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

/* ========== PARTICLE EFFECTS ========== */
.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--gold);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 4s infinite;
}

@keyframes particleFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) translateX(var(--drift));
        opacity: 0;
    }
}

/* ========== CARD FLIP EFFECT ========== */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.flip-card-back {
    transform: rotateY(180deg);
}

/* ========== GLOWING BORDER ========== */
.glow-border {
    position: relative;
}

.glow-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--gold), var(--light-gold), var(--gold));
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
    background-size: 200% 200%;
    animation: rotateGlow 3s linear infinite;
}

.glow-border:hover::before {
    opacity: 1;
}

/* ========== LETTER SPARKLE PARTICLES (HARRY POTTER STYLE) ========== */
.letter-sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(255, 215, 0, 1), rgba(212, 175, 55, 0.8));
    border-radius: 50%;
    box-shadow:
        0 0 6px rgba(255, 215, 0, 1),
        0 0 12px rgba(212, 175, 55, 0.8),
        0 0 18px rgba(212, 175, 55, 0.4);
    pointer-events: none;
    z-index: 15;
    animation: letterSparkle 1.5s ease-out forwards;
}

.letter-sparkle.small {
    width: 2px;
    height: 2px;
}

.letter-sparkle.large {
    width: 6px;
    height: 6px;
}

.floating-magic-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: radial-gradient(circle, rgba(255, 215, 0, 1), rgba(212, 175, 55, 0.6));
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
    pointer-events: none;
    z-index: 15;
    animation: floatSparkle 2s ease-out forwards;
}

/* ========== METEOR TRAIL SPARKLES ========== */
.meteor-sparkle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    z-index: 1;
    animation: meteorSparkle 0.8s ease-out forwards;
}

@keyframes meteorSparkle {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.2);
    }
}

.meteor-sparkle.golden {
    background: rgba(212, 175, 55, 1);
    box-shadow: 0 0 10px rgba(212, 175, 55, 1);
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Hardware acceleration */
.accelerate {
    transform: translateZ(0);
    will-change: transform;
}
