.moon-container {
    position: absolute;
    top: 20%;
    right: 15%;
    width: 150px;
    height: 150px;
    pointer-events: none;
    z-index: 3;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.moon {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #f5f5f5;
    box-shadow: 
        inset -15px 10px 8px -8px rgba(255, 255, 255, 0.9),
        inset 25px -25px 60px 50px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    will-change: transform, box-shadow;
    overflow: hidden;
}

/* Moon surface texture */
.moon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: 
        radial-gradient(circle at 30% 40%, rgba(200, 200, 200, 0.3) 2px, transparent 2px),
        radial-gradient(circle at 70% 25%, rgba(180, 180, 180, 0.4) 1px, transparent 1px),
        radial-gradient(circle at 20% 70%, rgba(160, 160, 160, 0.2) 3px, transparent 3px),
        radial-gradient(circle at 80% 80%, rgba(190, 190, 190, 0.3) 2px, transparent 2px),
        radial-gradient(circle at 60% 60%, rgba(170, 170, 170, 0.2) 1px, transparent 1px);
    background-size: 20px 20px, 15px 15px, 25px 25px, 18px 18px, 12px 12px;
    opacity: 0.6;
}

/* Moon craters */
.moon::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: 
        radial-gradient(ellipse 8px 6px at 35% 45%, rgba(0, 0, 0, 0.2) 40%, transparent 70%),
        radial-gradient(ellipse 12px 10px at 65% 30%, rgba(0, 0, 0, 0.15) 30%, transparent 60%),
        radial-gradient(ellipse 6px 5px at 25% 75%, rgba(0, 0, 0, 0.18) 50%, transparent 80%),
        radial-gradient(ellipse 10px 8px at 75% 70%, rgba(0, 0, 0, 0.12) 35%, transparent 65%);
    opacity: 0.4;
}

/* 2. Moon Phase System */
.moon-phase-shadow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #1a1a1a;
    transform-origin: center;
    transition: all 2s ease-in-out;
    z-index: 1;
}

/* Moon Phase Classes */
.moon--new-moon .moon-phase-shadow {
    transform: scaleX(1);
    left: 0;
}

.moon--waxing-crescent .moon-phase-shadow {
    transform: scaleX(0.7);
    left: 15%;
    border-radius: 50% 0 0 50%;
}

.moon--first-quarter .moon-phase-shadow {
    transform: scaleX(0.5);
    left: 50%;
    border-radius: 0 50% 50% 0;
}

.moon--waxing-gibbous .moon-phase-shadow {
    transform: scaleX(0.3);
    left: 70%;
    border-radius: 0 50% 50% 0;
}

.moon--full-moon .moon-phase-shadow {
    transform: scaleX(0);
    opacity: 0;
}

.moon--waning-gibbous .moon-phase-shadow {
    transform: scaleX(0.3);
    right: 70%;
    left: auto;
    border-radius: 50% 0 0 50%;
}

.moon--third-quarter .moon-phase-shadow {
    transform: scaleX(0.5);
    right: 50%;
    left: auto;
    border-radius: 50% 0 0 50%;
}

.moon--waning-crescent .moon-phase-shadow {
    transform: scaleX(0.7);
    right: 15%;
    left: auto;
    border-radius: 50% 0 0 50%;
}

/* 3. Realistic Moon Textures and Shadows */
.moon--realistic {
    background: linear-gradient(145deg, #f5f5f5 0%, #e8e8e8 50%, #d0d0d0 100%);
    box-shadow: 
        inset -20px 15px 12px -10px rgba(255, 255, 255, 0.8),
        inset 30px -30px 80px 60px rgba(0, 0, 0, 0.2),
        0 0 25px rgba(255, 255, 255, 0.4),
        0 0 50px rgba(255, 255, 255, 0.2);
}

.moon--realistic::before {
    background: 
        radial-gradient(circle at 35% 40%, rgba(0, 0, 0, 0.08) 3px, transparent 3px),
        radial-gradient(circle at 65% 25%, rgba(0, 0, 0, 0.06) 2px, transparent 2px),
        radial-gradient(circle at 25% 70%, rgba(0, 0, 0, 0.1) 4px, transparent 4px),
        radial-gradient(circle at 80% 75%, rgba(0, 0, 0, 0.07) 2px, transparent 2px),
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 30px 30px, 20px 20px, 35px 35px, 25px 25px, 15px 15px;
}

/* Enhanced crater details */
.moon--realistic::after {
    background: 
        radial-gradient(ellipse 15px 12px at 38% 42%, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.05) 60%, transparent 80%),
        radial-gradient(ellipse 20px 16px at 68% 28%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.04) 50%, transparent 70%),
        radial-gradient(ellipse 10px 8px at 22% 72%, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.06) 65%, transparent 85%),
        radial-gradient(ellipse 18px 14px at 78% 68%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.03) 40%, transparent 60%);
}

/* 4. Orbital Animations */
@keyframes moonOrbit {
    0% {
        transform: rotate(0deg) translateX(200px) rotate(0deg);
    }
    100% {
        transform: rotate(360deg) translateX(200px) rotate(-360deg);
    }
}

@keyframes moonRotation {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

@keyframes moonPhasesCycle {
    0% { /* New Moon */
        box-shadow: 
            inset 50px 0 0 rgba(0, 0, 0, 0.8),
            0 0 15px rgba(255, 255, 255, 0.2);
    }
    12.5% { /* Waxing Crescent */
        box-shadow: 
            inset 30px 0 0 rgba(0, 0, 0, 0.6),
            0 0 18px rgba(255, 255, 255, 0.25);
    }
    25% { /* First Quarter */
        box-shadow: 
            inset 15px 0 0 rgba(0, 0, 0, 0.4),
            0 0 20px rgba(255, 255, 255, 0.3);
    }
    37.5% { /* Waxing Gibbous */
        box-shadow: 
            inset 5px 0 0 rgba(0, 0, 0, 0.2),
            0 0 25px rgba(255, 255, 255, 0.35);
    }
    50% { /* Full Moon */
        box-shadow: 
            0 0 30px rgba(255, 255, 255, 0.5),
            0 0 60px rgba(255, 255, 255, 0.3),
            0 0 90px rgba(255, 255, 255, 0.1);
    }
    62.5% { /* Waning Gibbous */
        box-shadow: 
            inset -5px 0 0 rgba(0, 0, 0, 0.2),
            0 0 25px rgba(255, 255, 255, 0.35);
    }
    75% { /* Third Quarter */
        box-shadow: 
            inset -15px 0 0 rgba(0, 0, 0, 0.4),
            0 0 20px rgba(255, 255, 255, 0.3);
    }
    87.5% { /* Waning Crescent */
        box-shadow: 
            inset -30px 0 0 rgba(0, 0, 0, 0.6),
            0 0 18px rgba(255, 255, 255, 0.25);
    }
    100% { /* Back to New Moon */
        box-shadow: 
            inset -50px 0 0 rgba(0, 0, 0, 0.8),
            0 0 15px rgba(255, 255, 255, 0.2);
    }
}

@keyframes moonFloat {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-8px) rotate(1deg);
    }
    50% {
        transform: translateY(-5px) rotate(0deg);
    }
    75% {
        transform: translateY(-12px) rotate(-1deg);
    }
}

@keyframes moonPulse {
    0%, 100% {
        box-shadow: 
            inset -15px 10px 8px -8px rgba(255, 255, 255, 0.9),
            inset 25px -25px 60px 50px rgba(0, 0, 0, 0.15),
            0 0 20px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 
            inset -15px 10px 8px -8px rgba(255, 255, 255, 0.9),
            inset 25px -25px 60px 50px rgba(0, 0, 0, 0.15),
            0 0 35px rgba(255, 255, 255, 0.5),
            0 0 70px rgba(255, 255, 255, 0.2);
    }
}

/* 5. Moon Glow Effects */
.moon--glow {
    position: relative;
}

.moon--glow::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    z-index: -1;
    animation: moonGlow 4s ease-in-out infinite;
}

@keyframes moonGlow {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Enhanced glow for full moon */
.moon--full-moon.moon--glow::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 50%, transparent 80%);
    top: -30px;
    left: -30px;
    right: -30px;
    bottom: -30px;
}

.moon--full-moon.moon--glow::after {
    content: '';
    position: absolute;
    top: -50px;
    left: -50px;
    right: -50px;
    bottom: -50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 60%);
    z-index: -2;
    animation: moonOuterGlow 6s ease-in-out infinite;
}

@keyframes moonOuterGlow {
    0%, 100% {
        opacity: 0.2;
        transform: scale(0.8);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* 6. Interactive Moon Features */
.moon--interactive {
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.moon--interactive:hover {
    transform: scale(1.1);
    box-shadow: 
        inset -15px 10px 8px -8px rgba(255, 255, 255, 0.9),
        inset 25px -25px 60px 50px rgba(0, 0, 0, 0.15),
        0 0 40px rgba(255, 255, 255, 0.6),
        0 0 80px rgba(255, 255, 255, 0.3);
}

.moon--interactive:active {
    transform: scale(0.95);
}

/* Moon tooltip */
.moon--interactive::before {
    content: attr(data-phase);
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

.moon--interactive:hover::before {
    opacity: 1;
}

/* Click ripple effect */
.moon--interactive:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6), transparent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: moonRipple 0.6s ease-out;
}

@keyframes moonRipple {
    0% {
        width: 0;
        height: 0;
        opacity: 0.8;
    }
    100% {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

/* 7. Lunar Eclipse Effects */
.moon--eclipse {
    animation: lunarEclipse 8s ease-in-out infinite;
}

@keyframes lunarEclipse {
    0%, 20%, 80%, 100% {
        box-shadow: 
            inset -15px 10px 8px -8px rgba(255, 255, 255, 0.9),
            inset 25px -25px 60px 50px rgba(0, 0, 0, 0.15),
            0 0 20px rgba(255, 255, 255, 0.3);
        filter: brightness(1);
    }
    50% {
        box-shadow: 
            inset 0 0 50px rgba(139, 69, 19, 0.8),
            inset 0 0 100px rgba(139, 69, 19, 0.6),
            0 0 30px rgba(139, 69, 19, 0.4);
        filter: brightness(0.3) hue-rotate(20deg);
    }
}

/* Blood moon effect */
.moon--blood-moon {
    background: linear-gradient(145deg, #8B4513 0%, #A0522D 50%, #CD853F 100%);
    box-shadow: 
        inset -15px 10px 8px -8px rgba(255, 200, 150, 0.6),
        inset 25px -25px 60px 50px rgba(0, 0, 0, 0.3),
        0 0 25px rgba(139, 69, 19, 0.5);
}

/* 8. Moon Size Variants */
.moon--tiny {
    width: 60px;
    height: 60px;
}

.moon--small {
    width: 80px;
    height: 80px;
}

.moon--medium {
    width: 120px;
    height: 120px;
}

.moon--large {
    width: 180px;
    height: 180px;
}

.moon--xl {
    width: 250px;
    height: 250px;
}

/* 9. Performance Optimizations */
.moon-optimized {
    contain: layout style paint;
    transform: translateZ(0);
    will-change: transform, box-shadow;
    backface-visibility: hidden;
}

/* GPU acceleration for smooth animations */
.moon--gpu-accelerated {
    transform: translate3d(0, 0, 0);
    perspective: 1000px;
}

/* 10. Accessibility & Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .moon,
    .moon::before,
    .moon::after,
    .moon-phase-shadow {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .moon--interactive:hover {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .moon {
        border: 2px solid;
        box-shadow: none;
    }
    
    .moon-phase-shadow {
        background: #000;
        border: 1px solid;
    }
}

/* 11. Theme Integration */
[data-theme="dark"] .moon {
    box-shadow: 
        inset -15px 10px 8px -8px rgba(255, 255, 255, 0.7),
        inset 25px -25px 60px 50px rgba(0, 0, 0, 0.3),
        0 0 25px rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .moon--glow::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
}

[data-theme="light"] .moon {
    box-shadow: 
        inset -15px 10px 8px -8px rgba(255, 255, 255, 0.9),
        inset 25px -25px 60px 50px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(255, 255, 255, 0.3);
}

/* 12. Responsive Design */
@media (max-width: 768px) {
    .moon-container {
        width: 100px;
        height: 100px;
        top: 15%;
        right: 10%;
    }
    
    .moon--large {
        width: 120px;
        height: 120px;
    }
    
    .moon--xl {
        width: 150px;
        height: 150px;
    }
}

@media (max-width: 480px) {
    .moon-container {
        width: 80px;
        height: 80px;
        top: 10%;
        right: 5%;
    }
    
    .moon--medium {
        width: 80px;
        height: 80px;
    }
    
    .moon--large {
        width: 100px;
        height: 100px;
    }
    
    .moon--xl {
        width: 120px;
        height: 120px;
    }
}

/* Tablet landscape optimizations */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .moon-container {
        top: 25%;
        right: 20%;
    }
}

/* Large screen enhancements */
@media (min-width: 1200px) {
    .moon-container {
        width: 200px;
        height: 200px;
    }
    
    .moon--xl {
        width: 300px;
        height: 300px;
    }
}

/* Print styles - hide animations */
@media print {
    .moon,
    .moon-container {
        animation: none !important;
        transform: none !important;
        box-shadow: none !important;
    }
}

/* Animation Control Classes */
.moon--animate-orbit {
    animation: moonOrbit 30s linear infinite;
}

.moon--animate-rotation {
    animation: moonRotation 20s linear infinite;
}

.moon--animate-phases {
    animation: moonPhasesCycle 29.5s ease-in-out infinite;
}

.moon--animate-float {
    animation: moonFloat 8s ease-in-out infinite;
}

.moon--animate-pulse {
    animation: moonPulse 3s ease-in-out infinite;
}

/* Combined animations */
.moon--animate-all {
    animation: 
        moonFloat 8s ease-in-out infinite,
        moonPulse 3s ease-in-out infinite,
        moonPhasesCycle 29.5s ease-in-out infinite;
}

/* Utility classes for JavaScript control */
.moon--paused {
    animation-play-state: paused;
}

.moon--slow {
    animation-duration: 60s;
}

.moon--fast {
    animation-duration: 10s;
}

/* Moon positions for different sections */
.hero-section .moon-container {
    top: 20%;
    right: 15%;
}

.about-section .moon-container {
    top: 30%;
    left: 10%;
    animation: moonFloat 12s ease-in-out infinite;
}

.portfolio-section .moon-container {
    top: 60%;
    right: 5%;
    animation: moonPulse 4s ease-in-out infinite;
}

.contact-section .moon-container {
    top: 40%;
    right: 20%;
    animation: moonOrbit 40s linear infinite;
}

/* Moon constellation effect */
.moon-constellation {
    position: relative;
}

.moon-constellation::before {
    content: '';
    position: absolute;
    top: -100px;
    left: -100px;
    right: -100px;
    bottom: -100px;
    background: 
        radial-gradient(2px 2px at 30px 40px, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(1px 1px at 80px 20px, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(1px 1px at 120px 80px, rgba(255, 255, 255, 0.7), transparent);
    z-index: -1;
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Moon beam effect */
.moon-beam {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 100vh;
    background: linear-gradient(to bottom, 
        rgba(255, 255, 255, 0.8) 0%, 
        rgba(255, 255, 255, 0.4) 30%, 
        rgba(255, 255, 255, 0.1) 60%, 
        transparent 100%);
    transform: translateX(-50%) rotate(15deg);
    animation: moonBeamSway 10s ease-in-out infinite;
    z-index: -1;
}

@keyframes moonBeamSway {
    0%, 100% { transform: translateX(-50%) rotate(10deg); }
    50% { transform: translateX(-50%) rotate(20deg); }
}

/* CSS-only moon phase indicator */
.moon-phase-indicator {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.moon--interactive:hover .moon-phase-indicator {
    opacity: 1;
}

.phase-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.phase-dot.active {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.5);
        }
