/* CINEMATIC VISUAL EFFECTS - AAA GAME QUALITY */
/* Advanced lighting, shadows, and particle effects for Unreal Engine-level visuals */

/* ========== GLOBAL CINEMATIC SETTINGS ========== */
:root {
    /* Cinematic color grading */
    --cinematic-contrast: 1.2;
    --cinematic-saturation: 1.1;
    --cinematic-brightness: 0.95;
    --cinematic-gamma: 0.9;
    
    /* Advanced lighting */
    --ambient-light: rgba(135, 206, 250, 0.1);
    --key-light: rgba(255, 248, 220, 0.8);
    --fill-light: rgba(173, 216, 230, 0.3);
    --rim-light: rgba(255, 215, 0, 0.2);
    
    /* Shadow quality */
    --shadow-blur: 8px;
    --shadow-spread: 2px;
    --shadow-opacity: 0.3;
    --shadow-color: rgba(0, 0, 0, 0.5);
    
    /* HDR emulation */
    --hdr-white-point: 10000;
    --hdr-exposure: 1.0;
    --hdr-gamma: 2.2;
}

/* Enable hardware acceleration for all cinematic elements */
.cinematic-quality *,
.cinematic-quality *::before,
.cinematic-quality *::after {
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: transform, opacity;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== ADVANCED LIGHTING SYSTEM ========== */

/* Global Illumination Simulation */
.cinematic-quality .game-screen {
    position: relative;
    background: radial-gradient(ellipse at center, 
        var(--ambient-light) 0%, 
        rgba(0, 0, 0, 0.1) 100%);
    filter: 
        contrast(var(--cinematic-contrast))
        saturate(var(--cinematic-saturation))
        brightness(var(--cinematic-brightness));
}

/* Advanced shadow casting system */
.cinematic-shadow {
    position: relative;
    filter: drop-shadow(0 0 var(--shadow-blur) var(--shadow-color))
            drop-shadow(0 var(--shadow-spread) calc(var(--shadow-blur) * 2) 
                       rgba(0, 0, 0, var(--shadow-opacity)));
}

/* Volumetric lighting effects */
.volumetric-light {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(45deg, 
        transparent 0%, 
        var(--key-light) 30%, 
        transparent 60%);
    opacity: 0.1;
    animation: volumetricShift 20s ease-in-out infinite;
    mix-blend-mode: overlay;
}

@keyframes volumetricShift {
    0%, 100% { transform: translateX(-20px) rotate(0.5deg); opacity: 0.05; }
    25% { transform: translateX(10px) rotate(-0.3deg); opacity: 0.15; }
    50% { transform: translateX(-5px) rotate(0.2deg); opacity: 0.1; }
    75% { transform: translateX(15px) rotate(-0.4deg); opacity: 0.12; }
}

/* ========== DRAGON CINEMATIC EFFECTS ========== */

/* Fire Dragon - Advanced particle and heat effects */
.dragon-fire.cinematic-quality {
    position: relative;
    filter: 
        drop-shadow(0 0 20px rgba(255, 69, 0, 0.8))
        drop-shadow(0 0 40px rgba(255, 140, 0, 0.4))
        drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
}

.dragon-fire.cinematic-quality::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    right: -20%;
    bottom: -20%;
    background: radial-gradient(ellipse at 50% 60%, 
        rgba(255, 69, 0, 0.3) 0%,
        rgba(255, 140, 0, 0.1) 30%,
        transparent 70%);
    animation: fireAura 3s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
}

.dragon-fire.cinematic-quality::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 20%;
    width: 60%;
    height: 80%;
    background: repeating-linear-gradient(90deg,
        transparent 0%,
        rgba(255, 69, 0, 0.05) 25%,
        transparent 50%);
    animation: heatShimmer 1.5s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes fireAura {
    0% { transform: scale(1) rotate(0deg); opacity: 0.6; }
    100% { transform: scale(1.1) rotate(0.5deg); opacity: 0.8; }
}

@keyframes heatShimmer {
    0%, 100% { transform: translateX(-2px) scaleY(1); }
    25% { transform: translateX(1px) scaleY(1.02); }
    50% { transform: translateX(2px) scaleY(0.98); }
    75% { transform: translateX(-1px) scaleY(1.01); }
}

/* Water Dragon - Caustic light reflections */
.dragon-water.cinematic-quality {
    position: relative;
    filter: 
        drop-shadow(0 0 15px rgba(0, 191, 255, 0.6))
        drop-shadow(0 3px 10px rgba(0, 0, 0, 0.4));
}

.dragon-water.cinematic-quality::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 100% 50% at 30% 20%, rgba(0, 191, 255, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse 80% 40% at 70% 70%, rgba(173, 216, 230, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse 60% 30% at 20% 80%, rgba(135, 206, 250, 0.1) 0%, transparent 50%);
    animation: waterCaustics 4s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes waterCaustics {
    0%, 100% { transform: translateX(0px) translateY(0px) scale(1); }
    25% { transform: translateX(3px) translateY(-2px) scale(1.05); }
    50% { transform: translateX(-2px) translateY(3px) scale(0.95); }
    75% { transform: translateX(2px) translateY(2px) scale(1.02); }
}

/* Lightning Dragon - Electrical discharge effects */
.dragon-lightning.cinematic-quality {
    position: relative;
    filter: 
        drop-shadow(0 0 25px rgba(138, 43, 226, 0.8))
        drop-shadow(0 0 50px rgba(75, 0, 130, 0.4))
        drop-shadow(0 3px 10px rgba(0, 0, 0, 0.6));
}

.dragon-lightning.cinematic-quality::before {
    content: '';
    position: absolute;
    top: -10%;
    left: -10%;
    right: -10%;
    bottom: -10%;
    background: 
        linear-gradient(45deg, transparent 40%, rgba(138, 43, 226, 0.1) 45%, transparent 55%),
        linear-gradient(-45deg, transparent 40%, rgba(75, 0, 130, 0.1) 45%, transparent 55%);
    animation: electricalDischarge 0.3s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: screen;
}

@keyframes electricalDischarge {
    0%, 90%, 100% { opacity: 0.3; transform: scale(1); }
    5%, 15%, 25% { opacity: 0.8; transform: scale(1.05); }
    10%, 20% { opacity: 0.1; transform: scale(0.98); }
}

/* Shadow Dragon - Reality distortion effects */
.dragon-shadow.cinematic-quality {
    position: relative;
    filter: 
        drop-shadow(0 0 30px rgba(75, 0, 130, 0.9))
        drop-shadow(0 8px 20px rgba(0, 0, 0, 0.8));
}

.dragon-shadow.cinematic-quality::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    right: -20%;
    bottom: -20%;
    background: radial-gradient(ellipse at center,
        rgba(75, 0, 130, 0.2) 0%,
        rgba(25, 25, 112, 0.1) 40%,
        transparent 80%);
    animation: shadowDistortion 6s ease-in-out infinite alternate;
    pointer-events: none;
    mix-blend-mode: multiply;
}

.dragon-shadow.cinematic-quality::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-conic-gradient(from 0deg at 50% 50%,
        transparent 0deg 10deg,
        rgba(75, 0, 130, 0.05) 10deg 20deg);
    animation: shadowRipple 8s linear infinite;
    pointer-events: none;
    opacity: 0.3;
}

@keyframes shadowDistortion {
    0% { transform: scale(1) skew(0deg, 0deg); }
    100% { transform: scale(1.05) skew(1deg, -1deg); }
}

@keyframes shadowRipple {
    0% { transform: rotate(0deg) scale(1); }
    100% { transform: rotate(360deg) scale(1.1); }
}

/* ========== HERO CINEMATIC EFFECTS ========== */

/* Advanced character lighting and rim lighting */
.hero-portrait.cinematic-quality {
    position: relative;
    filter: 
        drop-shadow(-5px 0 10px var(--rim-light))
        drop-shadow(0 5px 15px rgba(0, 0, 0, 0.4));
}

.hero-portrait.cinematic-quality::before {
    content: '';
    position: absolute;
    top: -10%;
    left: -50%;
    width: 200%;
    height: 120%;
    background: linear-gradient(120deg,
        var(--key-light) 0%,
        transparent 30%,
        transparent 70%,
        var(--fill-light) 100%);
    opacity: 0.3;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* Fire Warrior - Flame effects */
.hero-fire.cinematic-quality::after {
    content: '';
    position: absolute;
    top: 10%;
    right: 10%;
    width: 20%;
    height: 30%;
    background: radial-gradient(ellipse at center,
        rgba(255, 69, 0, 0.4) 0%,
        rgba(255, 140, 0, 0.2) 50%,
        transparent 100%);
    animation: heroFireAura 2s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes heroFireAura {
    0% { transform: scale(0.8) translateY(2px); opacity: 0.6; }
    100% { transform: scale(1.2) translateY(-2px); opacity: 0.9; }
}

/* Ice Mage - Frost effects */
.hero-ice.cinematic-quality::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(135deg, rgba(173, 216, 230, 0.1) 0%, transparent 30%),
        radial-gradient(ellipse at 20% 80%, rgba(0, 191, 255, 0.15) 0%, transparent 40%);
    animation: frostShimmer 3s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes frostShimmer {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.02); }
}

/* ========== BUILDING CINEMATIC EFFECTS ========== */

/* Advanced building lighting and atmosphere */
.building.cinematic-quality {
    position: relative;
    filter: 
        drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5))
        drop-shadow(-2px 0 5px var(--rim-light));
}

.building.cinematic-quality::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    right: -20%;
    height: 40%;
    background: linear-gradient(180deg,
        var(--key-light) 0%,
        rgba(255, 248, 220, 0.1) 50%,
        transparent 100%);
    opacity: 0.4;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* Castle/Fortress - Majestic lighting */
.building-castle.cinematic-quality {
    filter: 
        drop-shadow(0 15px 40px rgba(0, 0, 0, 0.6))
        drop-shadow(-5px -5px 15px rgba(255, 248, 220, 0.2))
        drop-shadow(5px 0 10px rgba(255, 215, 0, 0.1));
}

/* Farm - Warm, rustic lighting */
.building-farm.cinematic-quality {
    filter: 
        drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4))
        drop-shadow(2px 2px 8px rgba(255, 248, 220, 0.3));
}

.building-farm.cinematic-quality::after {
    content: '';
    position: absolute;
    top: 20%;
    right: 20%;
    width: 15%;
    height: 25%;
    background: rgba(255, 248, 220, 0.6);
    filter: blur(3px);
    animation: chimneySmokeGlow 4s ease-in-out infinite;
    pointer-events: none;
    border-radius: 50%;
}

@keyframes chimneySmokeGlow {
    0%, 100% { opacity: 0.3; transform: translateY(0px) scale(1); }
    50% { opacity: 0.7; transform: translateY(-5px) scale(1.1); }
}

/* ========== WEAPON & ITEM EFFECTS ========== */

/* Legendary weapon glow effects */
.weapon-legendary.cinematic-quality {
    position: relative;
    filter: 
        drop-shadow(0 0 15px rgba(255, 215, 0, 0.8))
        drop-shadow(0 0 30px rgba(255, 215, 0, 0.4))
        drop-shadow(0 3px 10px rgba(0, 0, 0, 0.5));
}

.weapon-legendary.cinematic-quality::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    right: -20%;
    bottom: -20%;
    background: radial-gradient(ellipse at center,
        rgba(255, 215, 0, 0.3) 0%,
        rgba(255, 215, 0, 0.1) 40%,
        transparent 80%);
    animation: legendaryPulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes legendaryPulse {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.6; }
    50% { transform: scale(1.1) rotate(1deg); opacity: 0.9; }
}

/* Potion liquid effects */
.potion.cinematic-quality {
    position: relative;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3));
}

.potion.cinematic-quality::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 25%;
    width: 50%;
    height: 60%;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: linear-gradient(45deg,
        rgba(255, 255, 255, 0.3) 0%,
        transparent 30%,
        transparent 70%,
        rgba(255, 255, 255, 0.2) 100%);
    animation: liquidReflection 2s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes liquidReflection {
    0%, 100% { transform: translateX(0px) scaleX(1); opacity: 0.4; }
    50% { transform: translateX(2px) scaleX(1.1); opacity: 0.7; }
}

/* Health potion - Red glow */
.potion-health.cinematic-quality {
    filter: 
        drop-shadow(0 0 10px rgba(255, 0, 0, 0.6))
        drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3));
}

/* Mana potion - Blue electrical effect */
.potion-mana.cinematic-quality {
    filter: 
        drop-shadow(0 0 12px rgba(0, 100, 255, 0.7))
        drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3));
}

.potion-mana.cinematic-quality::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 60%;
    height: 70%;
    background: 
        linear-gradient(45deg, transparent 40%, rgba(0, 191, 255, 0.1) 45%, transparent 55%),
        linear-gradient(-45deg, transparent 40%, rgba(100, 149, 237, 0.1) 45%, transparent 55%);
    animation: manaElectricity 0.5s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: screen;
    border-radius: inherit;
}

@keyframes manaElectricity {
    0%, 90%, 100% { opacity: 0.2; }
    5%, 15% { opacity: 0.8; }
}

/* ========== PARTICLE SYSTEM EFFECTS ========== */

/* Advanced particle base class */
.particle-system {
    position: absolute;
    pointer-events: none;
    overflow: visible;
}

/* Fire particles */
.particles-fire {
    width: 100%;
    height: 100%;
}

.particles-fire::before,
.particles-fire::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(255, 69, 0, 0.8) 0%, transparent 70%);
    border-radius: 50%;
    animation: fireParticle 2s ease-out infinite;
}

.particles-fire::before {
    top: 80%;
    left: 30%;
    animation-delay: 0s;
}

.particles-fire::after {
    top: 85%;
    left: 60%;
    animation-delay: 0.7s;
}

@keyframes fireParticle {
    0% { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
    100% { 
        transform: translateY(-50px) translateX(10px) scale(0.1); 
        opacity: 0; 
    }
}

/* Magic sparkles */
.particles-magic {
    width: 100%;
    height: 100%;
}

.particles-magic::before {
    content: '✨';
    position: absolute;
    top: 20%;
    left: 70%;
    font-size: 12px;
    animation: magicSparkle 3s ease-in-out infinite;
}

@keyframes magicSparkle {
    0%, 100% { 
        transform: rotate(0deg) scale(1); 
        opacity: 0; 
    }
    10%, 90% { 
        opacity: 0.8; 
    }
    50% { 
        transform: rotate(180deg) scale(1.2); 
        opacity: 1; 
    }
}

/* ========== UI ENHANCEMENT EFFECTS ========== */

/* Button hover effects with cinematic quality */
.btn.cinematic-quality {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.btn.cinematic-quality:hover {
    transform: translateY(-2px) scale(1.02);
    filter: 
        drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3))
        drop-shadow(0 0 8px rgba(255, 255, 255, 0.2));
}

.btn.cinematic-quality:active {
    transform: translateY(0px) scale(0.98);
    filter: 
        drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4))
        brightness(1.1);
}

/* Modal and panel effects */
.modal.cinematic-quality {
    backdrop-filter: blur(10px) saturate(120%);
    background: rgba(0, 0, 0, 0.3);
}

.modal-content.cinematic-quality {
    filter: 
        drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6))
        drop-shadow(0 0 20px rgba(255, 255, 255, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.05) 100%);
}

/* ========== RESPONSIVE QUALITY ADAPTATION ========== */

/* High-end devices - Full cinematic effects */
@media (min-width: 1920px) and (min-height: 1080px) {
    .cinematic-quality {
        --shadow-blur: 12px;
        --shadow-spread: 3px;
    }
}

/* Mid-range devices - Reduced effects */
@media (max-width: 1366px) or (max-height: 768px) {
    .cinematic-quality {
        --shadow-blur: 6px;
        --shadow-spread: 1px;
        --cinematic-contrast: 1.1;
    }
    
    .particles-fire::before,
    .particles-fire::after {
        animation-duration: 3s; /* Slower for performance */
    }
}

/* Low-end devices - Minimal effects */
@media (max-width: 768px) {
    .cinematic-quality {
        --shadow-blur: 3px;
        --shadow-spread: 0px;
        --cinematic-contrast: 1.05;
        --cinematic-saturation: 1.02;
    }
    
    /* Disable expensive effects on mobile */
    .dragon-fire.cinematic-quality::after,
    .dragon-shadow.cinematic-quality::after,
    .particles-fire,
    .particles-magic {
        display: none;
    }
    
    /* Reduce animation complexity */
    .volumetric-light {
        animation: none;
        opacity: 0.05;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .cinematic-quality * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .particles-fire,
    .particles-magic,
    .volumetric-light {
        display: none;
    }
}

/* ========== DEBUG AND DEVELOPMENT ========== */

/* Debug mode - Show effect boundaries */
.cinematic-debug .cinematic-quality *::before,
.cinematic-debug .cinematic-quality *::after {
    border: 1px dashed rgba(255, 0, 0, 0.3) !important;
}

.cinematic-debug .particle-system {
    border: 1px solid rgba(0, 255, 0, 0.5) !important;
}