/* Cosmic Brewery (Universe 2) Styles
   Interdimensional brewery with purple & cosmic effects */

/* Remove heavy pseudo-elements entirely to avoid performance issues */
body[data-universe="2"]::before,
body[data-universe="2"]::after {
    display: none !important;
    content: none !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
}

/* Base cosmic effects for Universe 2 */
body[data-universe="2"] {
    animation: cosmic-pulse 12s ease-in-out infinite;
}

@keyframes cosmic-pulse {
    0%, 100% { filter: brightness(1) saturate(1); }
    50% { filter: brightness(1.05) saturate(1.1); }
}

/* Animated starfield background */
body[data-universe="2"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    /* Constrain to viewport to avoid causing horizontal scroll */
    width: 100vw;
    height: 100vh;
    background: 
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 80%, white, transparent),
        radial-gradient(1px 1px at 15% 60%, white, transparent);
    background-size: 200% 200%, 200% 200%, 300% 300%, 250% 250%, 200% 200%, 180% 180%, 220% 220%;
    background-position: 0% 0%, 100% 100%, 50% 50%, 80% 20%, 0% 60%, 20% 70%, 90% 40%;
    animation: starfield-drift 120s linear infinite;
    /* reduced opacity for performance */
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

@keyframes starfield-drift {
    from { background-position: 0% 0%, 100% 100%, 50% 50%, 80% 20%, 0% 60%, 20% 70%, 90% 40%; }
    to { background-position: 200% 200%, -100% -100%, -50% -50%, -80% -20%, 200% -60%, -20% -70%, -90% -40%; }
}

/* Cosmic nebula overlay */
body[data-universe="2"]::after {
    content: '';
    position: fixed;
    /* constrain overlay to viewport to prevent horizontal overflow */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: 
        radial-gradient(ellipse at 30% 40%, rgba(168, 85, 247, 0.15) 0%, transparent 40%),
        radial-gradient(ellipse at 70% 60%, rgba(124, 58, 237, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(88, 28, 135, 0.1) 0%, transparent 45%);
    /* slower, subtler drift to reduce repaints */
    animation: nebula-drift 120s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes nebula-drift {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); }
    100% { transform: translate(5%, -5%) rotate(2deg) scale(1.1); }
}

/* Enhanced glass panels for Universe 2 */
body[data-universe="2"] .glass-panel {
    background: linear-gradient(135deg, 
        rgba(20, 10, 40, 0.85) 0%, 
        rgba(30, 15, 60, 0.78) 50%, 
        rgba(40, 20, 80, 0.85) 100%) !important;
    border: 1px solid rgba(168, 85, 247, 0.22);
    /* soften box-shadow to reduce GPU cost */
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.12);
    backdrop-filter: blur(8px) saturate(120%);
    position: relative;
    overflow: hidden;
}

/* Shimmer effect on panels */
body[data-universe="2"] .glass-panel::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.03) 50%,
        transparent 70%
    );
    animation: panel-shimmer 8s linear infinite;
    pointer-events: none;
}

@keyframes panel-shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Enhanced beer glass with cosmic liquid */
body[data-universe="2"] .beer-glass-container {
    box-shadow: 0 12px 30px rgba(168, 85, 247, 0.18), inset 0 0 12px rgba(168,85,247,0.08);
    animation: cosmic-glass-pulse 6s ease-in-out infinite;
    position: relative;
}

@keyframes cosmic-glass-pulse {
    0%, 100% { 
        box-shadow: 
            0 0 60px rgba(168, 85, 247, 0.5),
            0 20px 80px rgba(124, 58, 237, 0.3),
            inset 0 0 30px rgba(168, 85, 247, 0.2);
    }
    50% { 
        box-shadow: 
            0 0 80px rgba(168, 85, 247, 0.7),
            0 20px 100px rgba(124, 58, 237, 0.4),
            inset 0 0 50px rgba(168, 85, 247, 0.3);
    }
}

/* Cosmic liquid effect */
body[data-universe="2"] .liquid {
    background: linear-gradient(to top, #6b21a8 0%, #7c3aed 40%, #a855f7 75%);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.18) inset;
    animation: liquid-shimmer 6s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

body[data-universe="2"] .liquid::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.05) 10px,
        rgba(255, 255, 255, 0.05) 20px
    );
    animation: liquid-flow 4s linear infinite;
}

@keyframes liquid-shimmer {
    /* Avoid expensive filter animations; use transforms instead */
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes liquid-flow {
    from { transform: translateX(0) translateY(0); }
    to { transform: translateX(20px) translateY(20px); }
}

/* Enhanced cosmic bubbles */
body[data-universe="2"] .bubble {
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.85), rgba(168,85,247,0.25));
    box-shadow: 0 0 6px rgba(168,85,247,0.12);
    animation: cosmic-bubble-rise 4.5s ease-in infinite;
}

@keyframes cosmic-bubble-rise {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-180px) scale(0.45);
        opacity: 0;
    }
}

/* Enhanced click button */
body[data-universe="2"] #click-btn {
    box-shadow: 0 8px 28px rgba(168, 85, 247, 0.22);
    animation: cosmic-btn-pulse 4s ease-in-out infinite;
}

@keyframes cosmic-btn-pulse {
    0%, 100% {
        box-shadow: 
            0 10px 40px rgba(168, 85, 247, 0.4),
            0 0 60px rgba(124, 58, 237, 0.3) inset;
    }
    50% {
        box-shadow: 
            0 10px 60px rgba(168, 85, 247, 0.6),
            0 0 80px rgba(124, 58, 237, 0.5) inset;
    }
}

body[data-universe="2"] #click-btn:active {
    box-shadow: 
        0 5px 20px rgba(168, 85, 247, 0.6),
        0 0 100px rgba(124, 58, 237, 0.7) inset !important;
    transform: scale(0.95);
}

/* Money particle effects for Universe 2 */
body[data-universe="2"] .money-particle {
    text-shadow: 
        0 0 10px rgba(168, 85, 247, 0.8),
        0 0 20px rgba(124, 58, 237, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.8);
    animation: cosmic-particle-float 1s ease-out forwards;
}

@keyframes cosmic-particle-float {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) scale(1.5);
        opacity: 0;
    }
}

/* Enhanced money display */
body[data-universe="2"] .money-display,
body[data-universe="2"] #money-display {
    text-shadow: 
        0 0 20px rgba(168, 85, 247, 0.8),
        0 0 40px rgba(124, 58, 237, 0.5),
        0 0 60px rgba(88, 28, 135, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.8);
    animation: money-glow 3s ease-in-out infinite;
    font-weight: 900;
}

@keyframes money-glow {
    0%, 100% {
        text-shadow: 
            0 0 20px rgba(168, 85, 247, 0.8),
            0 0 40px rgba(124, 58, 237, 0.5),
            0 0 60px rgba(88, 28, 135, 0.3),
            0 4px 8px rgba(0, 0, 0, 0.8);
    }
    50% {
        text-shadow: 
            0 0 30px rgba(168, 85, 247, 1),
            0 0 60px rgba(124, 58, 237, 0.7),
            0 0 90px rgba(88, 28, 135, 0.5),
            0 4px 8px rgba(0, 0, 0, 0.8);
    }
}

/* Cosmic achievement cards */
body[data-universe="2"] .achievement-card {
    background: linear-gradient(135deg, 
        rgba(20, 10, 40, 0.8) 0%, 
        rgba(40, 20, 80, 0.6) 100%);
    border: 1px solid rgba(168, 85, 247, 0.4);
    box-shadow: 
        0 4px 20px rgba(124, 58, 237, 0.2),
        0 0 30px rgba(168, 85, 247, 0.1) inset;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-universe="2"] .achievement-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 
        0 8px 40px rgba(124, 58, 237, 0.4),
        0 0 50px rgba(168, 85, 247, 0.2) inset;
}

body[data-universe="2"] .achievement-card.unlocked {
    background: linear-gradient(135deg, 
        rgba(40, 20, 80, 0.9) 0%, 
        rgba(60, 30, 120, 0.7) 100%);
    border-color: rgba(168, 85, 247, 0.6);
    box-shadow: 
        0 8px 30px rgba(124, 58, 237, 0.3),
        0 0 40px rgba(168, 85, 247, 0.2) inset;
}

/* Cosmic building cards */
body[data-universe="2"] .building-card {
    background: linear-gradient(135deg, 
        rgba(20, 10, 40, 0.8) 0%, 
        rgba(40, 20, 80, 0.6) 100%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    box-shadow: 
        0 4px 20px rgba(124, 58, 237, 0.15),
        0 0 20px rgba(168, 85, 247, 0.08) inset;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-universe="2"] .building-card:hover {
    background: linear-gradient(135deg, 
        rgba(30, 15, 60, 0.9) 0%, 
        rgba(50, 25, 100, 0.7) 100%);
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 
        0 8px 40px rgba(124, 58, 237, 0.3),
        0 0 40px rgba(168, 85, 247, 0.15) inset;
    transform: translateX(4px) scale(1.02);
}

/* Cosmic upgrade cards */
body[data-universe="2"] .upgrade-card {
    background: linear-gradient(135deg, 
        rgba(20, 10, 40, 0.8) 0%, 
        rgba(40, 20, 80, 0.6) 100%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    box-shadow: 
        0 4px 20px rgba(124, 58, 237, 0.15),
        0 0 20px rgba(168, 85, 247, 0.08) inset;
}

body[data-universe="2"] .upgrade-card:hover {
    background: linear-gradient(135deg, 
        rgba(30, 15, 60, 0.9) 0%, 
        rgba(50, 25, 100, 0.7) 100%);
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 
        0 8px 40px rgba(124, 58, 237, 0.3),
        0 0 40px rgba(168, 85, 247, 0.15) inset;
}

/* Cosmic toast notifications */
body[data-universe="2"] .toast-msg {
    background: linear-gradient(135deg, 
        rgba(30, 15, 60, 0.95) 0%, 
        rgba(50, 25, 100, 0.9) 100%);
    border: 1px solid rgba(168, 85, 247, 0.5);
    box-shadow: 
        0 10px 40px rgba(124, 58, 237, 0.4),
        0 0 30px rgba(168, 85, 247, 0.2) inset;
}

/* Cosmic tabs */
body[data-universe="2"] .glass-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-universe="2"] .glass-btn:hover {
    background: rgba(40, 20, 80, 0.8) !important;
    box-shadow: 
        0 0 30px rgba(168, 85, 247, 0.3),
        0 0 20px rgba(124, 58, 237, 0.2) inset;
}

/* Cosmic progress bars */
body[data-universe="2"] .bg-blue-500 {
    background: linear-gradient(90deg, 
        rgba(124, 58, 237, 0.8) 0%, 
        rgba(168, 85, 247, 1) 100%) !important;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

/* Particle trails on hover */
body[data-universe="2"] .glass-btn::after,
body[data-universe="2"] .building-card::after,
body[data-universe="2"] .achievement-card::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.4), transparent);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
    opacity: 0;
    pointer-events: none;
}

body[data-universe="2"] .glass-btn:hover::after,
body[data-universe="2"] .building-card:hover::after,
body[data-universe="2"] .achievement-card:hover::after {
    width: 100%;
    height: 100%;
    opacity: 1;
}

/* Cosmic energy particles floating around the screen */
@keyframes cosmic-particle-1 {
    0% { transform: translate(0, 0) scale(1); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translate(-100vw, -100vh) scale(0.3); opacity: 0; }
}

@keyframes cosmic-particle-2 {
    0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { transform: translate(120vw, -80vh) scale(0.2); opacity: 0; }
}

@keyframes cosmic-particle-3 {
    0% { transform: translate(0, 0) scale(0.8); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { transform: translate(-80vw, 100vh) scale(0.4); opacity: 0; }
}

/* Energy field effect for HD levels in Universe 2 */
html[data-hd-level="1"] body[data-universe="2"]::before,
html[data-hd-level="2"] body[data-universe="2"]::before,
html[data-hd-level="3"] body[data-universe="2"]::before {
    opacity: 0.5;
    animation: starfield-drift 80s linear infinite, starfield-intensity 6s ease-in-out infinite;
}

@keyframes starfield-intensity {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.7; }
}

/* HD Level 1+ adds cosmic rays */
html[data-hd-level="1"] body[data-universe="2"]::after {
    background: 
        radial-gradient(ellipse at 30% 40%, rgba(168, 85, 247, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 70% 60%, rgba(124, 58, 237, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(88, 28, 135, 0.15) 0%, transparent 45%),
        linear-gradient(90deg, transparent 0%, rgba(168, 85, 247, 0.05) 50%, transparent 100%);
    animation: nebula-drift 120s ease-in-out infinite alternate;
}

/* HD Level 2+ adds aurora effect */

/* Cosmic Lite removed — accessibility-mode still handled separately */
html[data-hd-level="2"] body[data-universe="2"]::after {
    background: 
        radial-gradient(ellipse at 30% 40%, rgba(168, 85, 247, 0.25) 0%, transparent 40%),
        radial-gradient(ellipse at 70% 60%, rgba(124, 58, 237, 0.22) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(88, 28, 135, 0.18) 0%, transparent 45%),
        linear-gradient(120deg, 
            transparent 0%, 
            rgba(168, 85, 247, 0.08) 20%, 
            rgba(124, 58, 237, 0.08) 40%,
            transparent 60%);
    animation: nebula-drift 40s ease-in-out infinite alternate, aurora-wave 15s ease-in-out infinite;
}

@keyframes aurora-wave {
    0%, 100% { 
        background-position: 0% 50%, 100% 50%, 50% 100%, 0% 0%;
    }
    50% { 
        background-position: 100% 50%, 0% 50%, 50% 0%, 100% 100%;
    }
}

/* HD Level 3+ adds energy vortex */
html[data-hd-level="3"] body[data-universe="2"]::after {
    background: 
        radial-gradient(ellipse at 30% 40%, rgba(168, 85, 247, 0.3) 0%, transparent 40%),
        radial-gradient(ellipse at 70% 60%, rgba(124, 58, 237, 0.28) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(88, 28, 135, 0.22) 0%, transparent 45%),
        repeating-conic-gradient(
            from 0deg at 50% 50%,
            transparent 0deg,
            rgba(168, 85, 247, 0.1) 30deg,
            transparent 60deg
        );
    animation: nebula-drift 30s ease-in-out infinite alternate, vortex-spin 60s linear infinite;
}

@keyframes vortex-spin {
    from { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    to { transform: translate(-50%, -50%) rotate(360deg) scale(1.2); }
}

/* Enhanced foam effects for Universe 2 */
body[data-universe="2"] .foam-head {
    background: radial-gradient(ellipse at center, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(200, 150, 255, 0.7) 50%, 
        rgba(168, 85, 247, 0.5) 100%);
    box-shadow: 
        0 -5px 15px rgba(168, 85, 247, 0.3),
        inset 0 -3px 10px rgba(124, 58, 237, 0.2);
    animation: cosmic-foam-shimmer 3s ease-in-out infinite;
}

@keyframes cosmic-foam-shimmer {
    0%, 100% { 
        filter: brightness(1); 
        box-shadow: 
            0 -5px 15px rgba(168, 85, 247, 0.3),
            inset 0 -3px 10px rgba(124, 58, 237, 0.2);
    }
    50% { 
        filter: brightness(1.3); 
        box-shadow: 
            0 -5px 25px rgba(168, 85, 247, 0.5),
            inset 0 -3px 15px rgba(124, 58, 237, 0.4);
    }
}

/* Holographic effect on buttons in HD modes */
html[data-hd-level="2"] body[data-universe="2"] .glass-btn::before,
html[data-hd-level="3"] body[data-universe="2"] .glass-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: hologram-sweep 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes hologram-sweep {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

/* Cosmic scan lines for ultimate HD effect */
html[data-hd-level="3"] body[data-universe="2"] #game-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(168, 85, 247, 0.03) 2px,
        rgba(168, 85, 247, 0.03) 4px
    );
    pointer-events: none;
    z-index: 1000;
    animation: scanline-move 8s linear infinite;
}

@keyframes scanline-move {
    from { transform: translateY(0); }
    to { transform: translateY(4px); }
}

/* Reduced-motion / accessibility overrides: disables heavy animations and effects */
@media (prefers-reduced-motion: reduce) {
    body[data-universe="2"] *,
    body.mode-accessibility * {
        animation: none !important;
        transition: none !important;
    }
    body[data-universe="2"]::before,
    body[data-universe="2"]::after {
        opacity: 0.06 !important;
    }
}

/* Also respect explicit accessibility mode toggle */
body.mode-accessibility body[data-universe="2"]::before,
body.mode-accessibility body[data-universe="2"]::after {
    opacity: 0.06 !important;
}

/* Quantum blur effect on glass in HD3 */
html[data-hd-level="3"] body[data-universe="2"] .glass-panel {
    backdrop-filter: blur(30px) saturate(200%) contrast(120%);
    -webkit-backdrop-filter: blur(30px) saturate(200%) contrast(120%);
}

html[data-hd-level="3"] body[data-universe="2"] .beer-glass-container {
    filter: 
        drop-shadow(0 0 60px rgba(124, 58, 237, 0.8))
        drop-shadow(0 0 30px rgba(168, 85, 247, 0.6))
        drop-shadow(0 20px 40px rgba(0, 0, 0, 0.5));
}

/* Ultra chrome reflections on the glass */
html[data-hd-level="3"] body[data-universe="2"] .beer-glass-container::before {
    content: '';
    position: absolute;
    top: 5%;
    left: 10%;
    width: 30%;
    height: 40%;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.4) 0%,
        transparent 50%
    );
    border-radius: 50% 20% 50% 20%;
    pointer-events: none;
    z-index: 10;
    animation: glass-reflection-shimmer 4s ease-in-out infinite;
}

@keyframes glass-reflection-shimmer {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.1); }
}
