/* Mental Health House - Advanced Animations */
/* Smooth transitions, morphing layouts, and particle effects */

/* Room Transition Animations */
.room-transition-enter {
    animation: roomEnter 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.room-transition-exit {
    animation: roomExit 0.6s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

@keyframes roomEnter {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        filter: blur(5px);
    }
    50% {
        opacity: 0.7;
        transform: translateY(10px) scale(0.98);
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes roomExit {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(1.05);
        filter: blur(3px);
    }
}

/* Morphing Layout Animations */
.morphing-container {
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.morphing-container.morph-active {
    animation: morphTransform 2s ease-in-out;
}

@keyframes morphTransform {
    0% { transform: perspective(1000px) rotateY(0deg) scale(1); }
    25% { transform: perspective(1000px) rotateY(90deg) scale(0.8); }
    50% { transform: perspective(1000px) rotateY(180deg) scale(0.9); }
    75% { transform: perspective(1000px) rotateY(270deg) scale(0.8); }
    100% { transform: perspective(1000px) rotateY(360deg) scale(1); }
}

/* Particle System Base Animations */
.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    animation: particleFloat 8s linear infinite;
}

.particle.small {
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, var(--sage-green), transparent);
}

.particle.medium {
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, var(--french-blue), transparent);
}

.particle.large {
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, rgba(156, 175, 136, 0.6), transparent);
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) translateX(0px) rotate(0deg);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) translateX(50px) rotate(360deg);
    }
}

/* Depression-specific particle animation */
.particle.depression {
    animation: depressionParticle 15s ease-in-out infinite;
    background: radial-gradient(circle, rgba(156, 175, 136, 0.4), transparent);
}

@keyframes depressionParticle {
    0% {
        opacity: 0;
        transform: translateY(100vh) translateX(0px) scale(1);
    }
    20% {
        opacity: 0.6;
        transform: translateY(80vh) translateX(10px) scale(1.1);
    }
    80% {
        opacity: 0.3;
        transform: translateY(20vh) translateX(-10px) scale(0.9);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) translateX(0px) scale(0.8);
    }
}

/* Anxiety-specific particle animation */
.particle.anxiety {
    animation: anxietyParticle 3s ease-in-out infinite;
    background: radial-gradient(circle, rgba(102, 153, 204, 0.5), transparent);
}

@keyframes anxietyParticle {
    0% {
        opacity: 0;
        transform: translateX(0px) translateY(0px) scale(1);
    }
    25% {
        opacity: 1;
        transform: translateX(20px) translateY(-10px) scale(1.2);
    }
    50% {
        opacity: 0.7;
        transform: translateX(-15px) translateY(15px) scale(0.8);
    }
    75% {
        opacity: 1;
        transform: translateX(10px) translateY(-5px) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translateX(0px) translateY(0px) scale(1);
    }
}

/* OCD-specific particle animation */
.particle.ocd {
    animation: ocdParticle 4s linear infinite;
    background: linear-gradient(45deg, var(--sage-green), var(--french-blue));
}

@keyframes ocdParticle {
    0% {
        opacity: 1;
        transform: translateX(0px) translateY(0px) rotate(0deg);
    }
    25% {
        opacity: 1;
        transform: translateX(50px) translateY(0px) rotate(90deg);
    }
    50% {
        opacity: 1;
        transform: translateX(50px) translateY(50px) rotate(180deg);
    }
    75% {
        opacity: 1;
        transform: translateX(0px) translateY(50px) rotate(270deg);
    }
    100% {
        opacity: 1;
        transform: translateX(0px) translateY(0px) rotate(360deg);
    }
}

/* Bipolar-specific particle animation */
.particle.bipolar {
    animation: bipolarParticle 6s ease-in-out infinite;
}

@keyframes bipolarParticle {
    0% {
        opacity: 0.3;
        transform: scale(0.5);
        background: radial-gradient(circle, rgba(70, 130, 180, 0.6), transparent);
    }
    25% {
        opacity: 1;
        transform: scale(1.5);
        background: radial-gradient(circle, rgba(255, 215, 0, 0.8), transparent);
    }
    50% {
        opacity: 0.7;
        transform: scale(1);
        background: radial-gradient(circle, rgba(156, 175, 136, 0.6), transparent);
    }
    75% {
        opacity: 0.4;
        transform: scale(0.8);
        background: radial-gradient(circle, rgba(25, 25, 112, 0.5), transparent);
    }
    100% {
        opacity: 0.3;
        transform: scale(0.5);
        background: radial-gradient(circle, rgba(70, 130, 180, 0.6), transparent);
    }
}

/* PTSD-specific particle animation */
.particle.ptsd {
    animation: ptsdParticle 8s ease-in-out infinite;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.7), transparent);
}

@keyframes ptsdParticle {
    0%, 90% {
        opacity: 0;
        transform: scale(1) translateX(0px) translateY(0px);
    }
    91% {
        opacity: 1;
        transform: scale(2) translateX(20px) translateY(-20px);
    }
    93% {
        opacity: 0.8;
        transform: scale(1.5) translateX(-10px) translateY(10px);
    }
    95% {
        opacity: 0.6;
        transform: scale(1.2) translateX(5px) translateY(-5px);
    }
    100% {
        opacity: 0;
        transform: scale(1) translateX(0px) translateY(0px);
    }
}

/* ADHD-specific particle animation */
.particle.adhd {
    animation: adhdParticle 2s linear infinite;
    background: linear-gradient(45deg, var(--sage-green), var(--french-blue), var(--sage-green));
}

@keyframes adhdParticle {
    0% {
        opacity: 1;
        transform: translateX(0px) translateY(0px) rotate(0deg) scale(1);
    }
    20% {
        opacity: 0.8;
        transform: translateX(30px) translateY(-20px) rotate(72deg) scale(1.2);
    }
    40% {
        opacity: 1;
        transform: translateX(-20px) translateY(30px) rotate(144deg) scale(0.8);
    }
    60% {
        opacity: 0.9;
        transform: translateX(25px) translateY(15px) rotate(216deg) scale(1.1);
    }
    80% {
        opacity: 0.7;
        transform: translateX(-15px) translateY(-25px) rotate(288deg) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0px) translateY(0px) rotate(360deg) scale(1);
    }
}

/* Interactive Shadow Animations */
.interactive-shadow {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.interactive-shadow::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-radius: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.interactive-shadow:hover::after {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(-5px);
}

/* Canvas Loading Animation */
.canvas-loading {
    position: relative;
}

.canvas-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--sage-green);
    border-top-color: transparent;
    border-radius: 50%;
    animation: canvasSpinner 1s linear infinite;
    z-index: 10;
}

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

/* Gentle Breathing Animation */
.breathing-effect {
    animation: breathe 4s ease-in-out infinite;
}

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

/* Parallax Effect Base */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.parallax-layer.slow {
    animation: parallaxSlow 20s linear infinite;
}

.parallax-layer.medium {
    animation: parallaxMedium 15s linear infinite;
}

.parallax-layer.fast {
    animation: parallaxFast 10s linear infinite;
}

@keyframes parallaxSlow {
    0% { transform: translateX(0px) translateY(0px); }
    100% { transform: translateX(-50px) translateY(-30px); }
}

@keyframes parallaxMedium {
    0% { transform: translateX(0px) translateY(0px); }
    100% { transform: translateX(-100px) translateY(-60px); }
}

@keyframes parallaxFast {
    0% { transform: translateX(0px) translateY(0px); }
    100% { transform: translateX(-150px) translateY(-90px); }
}

/* Glitch Effect for Anxiety */
.glitch-effect {
    position: relative;
}

.glitch-effect::before,
.glitch-effect::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    clip: rect(0, 900px, 0, 0);
}

.glitch-effect::before {
    animation: glitch1 2s infinite linear alternate-reverse;
    color: #ff0000;
    z-index: -1;
}

.glitch-effect::after {
    animation: glitch2 3s infinite linear alternate-reverse;
    color: #00ff00;
    z-index: -2;
}

@keyframes glitch1 {
    0% { clip: rect(42px, 9999px, 44px, 0); }
    5% { clip: rect(12px, 9999px, 59px, 0); }
    10% { clip: rect(48px, 9999px, 29px, 0); }
    15% { clip: rect(42px, 9999px, 73px, 0); }
    20% { clip: rect(63px, 9999px, 27px, 0); }
    25% { clip: rect(34px, 9999px, 55px, 0); }
    30% { clip: rect(86px, 9999px, 73px, 0); }
    35% { clip: rect(20px, 9999px, 20px, 0); }
    40% { clip: rect(26px, 9999px, 60px, 0); }
    45% { clip: rect(25px, 9999px, 66px, 0); }
    50% { clip: rect(57px, 9999px, 98px, 0); }
    55% { clip: rect(5px, 9999px, 46px, 0); }
    60% { clip: rect(82px, 9999px, 31px, 0); }
    65% { clip: rect(54px, 9999px, 27px, 0); }
    70% { clip: rect(28px, 9999px, 99px, 0); }
    75% { clip: rect(45px, 9999px, 69px, 0); }
    80% { clip: rect(23px, 9999px, 85px, 0); }
    85% { clip: rect(54px, 9999px, 84px, 0); }
    90% { clip: rect(45px, 9999px, 47px, 0); }
    95% { clip: rect(37px, 9999px, 20px, 0); }
    100% { clip: rect(4px, 9999px, 91px, 0); }
}

@keyframes glitch2 {
    0% { clip: rect(65px, 9999px, 100px, 0); }
    5% { clip: rect(52px, 9999px, 74px, 0); }
    10% { clip: rect(79px, 9999px, 85px, 0); }
    15% { clip: rect(75px, 9999px, 5px, 0); }
    20% { clip: rect(67px, 9999px, 61px, 0); }
    25% { clip: rect(14px, 9999px, 79px, 0); }
    30% { clip: rect(1px, 9999px, 66px, 0); }
    35% { clip: rect(86px, 9999px, 30px, 0); }
    40% { clip: rect(23px, 9999px, 98px, 0); }
    45% { clip: rect(85px, 9999px, 72px, 0); }
    50% { clip: rect(71px, 9999px, 75px, 0); }
    55% { clip: rect(2px, 9999px, 48px, 0); }
    60% { clip: rect(30px, 9999px, 16px, 0); }
    65% { clip: rect(59px, 9999px, 50px, 0); }
    70% { clip: rect(41px, 9999px, 62px, 0); }
    75% { clip: rect(2px, 9999px, 82px, 0); }
    80% { clip: rect(47px, 9999px, 73px, 0); }
    85% { clip: rect(3px, 9999px, 27px, 0); }
    90% { clip: rect(26px, 9999px, 55px, 0); }
    95% { clip: rect(42px, 9999px, 97px, 0); }
    100% { clip: rect(38px, 9999px, 49px, 0); }
}

/* Fade In/Out Utilities */
.fade-in {
    animation: fadeIn 0.5s ease-in forwards;
}

.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Scale Animations */
.scale-in {
    animation: scaleIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.scale-out {
    animation: scaleOut 0.3s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* Performance Optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    .particle,
    .morphing-container,
    .interactive-shadow,
    .breathing-effect,
    .parallax-layer,
    .glitch-effect::before,
    .glitch-effect::after {
        animation: none !important;
        transition: none !important;
    }
    
    .room-transition-enter,
    .room-transition-exit {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}