/**
 * The Stoic Wire - Sacred Geometry Transition Animations
 * Philosophical transitions for Stoic Lens Challenge
 * Version: 1.1.0 - Production Ready with Fixes
 * 
 * This file contains the Sacred Geometry animation styles
 * to be included alongside stoicLensChallenge.css
 */

/* ========================================= */
/* CSS Variables Fallback                    */
/* ========================================= */

/* Define fallback for primary color if not set */
:root {
  --slc-primary-fallback: #9c6644;
}

/* ========================================= */
/* Sacred Geometry Transition Container      */
/* ========================================= */

.slc-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10000; /* Higher than modal overlay */
  opacity: 0;
  background: rgba(0, 0, 0, 0.85); /* Dark background for visibility */
  transition: opacity 0.5s ease;
}

.slc-transition-overlay.active {
  opacity: 1;
}

/* Darken background during transition */
.slc-modal-overlay.transitioning {
  z-index: 9997; /* Lower than transition overlay */
}

.slc-modal-overlay.transitioning .slc-modal-container {
  filter: brightness(0.5);
  transition: filter 1s ease;
}

/* ========================================= */
/* Sacred Geometry Pattern                   */
/* ========================================= */

.slc-sacred-pattern {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  z-index: 10001; /* Ensure pattern is on top */
}

/* Geometric lines radiating from center */
.slc-geometry-line {
  position: absolute;
  width: 2px; /* Slightly thicker for visibility */
  height: 200px;
  background: linear-gradient(to bottom, 
    transparent 0%, 
    var(--slc-primary, var(--slc-primary-fallback)) 20%, 
    var(--slc-primary, var(--slc-primary-fallback)) 80%, 
    transparent 100%);
  left: 50%;
  top: 50%;
  transform-origin: center bottom;
  opacity: 0;
  animation: slcLineAppear 0.8s ease-out forwards;
  box-shadow: 0 0 4px rgba(156, 102, 68, 0.5); /* Subtle glow */
}

@keyframes slcLineAppear {
  0% {
    opacity: 0;
    height: 0;
  }
  100% {
    opacity: 0.8; /* Increased visibility */
    height: 200px;
  }
}

/* Fibonacci spirals */
.slc-fibonacci-spiral {
  position: absolute;
  border: 2px solid var(--slc-primary, var(--slc-primary-fallback));
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0) rotate(0deg);
  animation: slcSpiralGrow 1.2s ease-out forwards;
  box-shadow: 0 0 8px rgba(156, 102, 68, 0.4); /* Subtle glow */
}

@keyframes slcSpiralGrow {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 0;
  }
  50% {
    opacity: 0.6;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(180deg);
    opacity: 0.4;
  }
}

/* Golden ratio rectangles */
.slc-golden-rect {
  position: absolute;
  border: 1px solid var(--slc-primary, var(--slc-primary-fallback));
  opacity: 0;
  animation: slcRectAppear 1s ease-out forwards;
  box-shadow: 0 0 6px rgba(156, 102, 68, 0.3); /* Subtle glow */
}

@keyframes slcRectAppear {
  0% {
    transform: scale(0.8) rotate(0deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(45deg);
    opacity: 0.5; /* Increased visibility */
  }
}

/* Central nexus point */
.slc-geometry-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
}

.slc-center-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid var(--slc-primary, var(--slc-primary-fallback));
  border-radius: 50%;
  opacity: 0;
  animation: slcRingPulse 2s ease-out infinite;
  box-shadow: 0 0 10px rgba(156, 102, 68, 0.6); /* Glow effect */
}

@keyframes slcRingPulse {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Archetype-specific center colors with fallback */
.slc-geometry-center.emotional {
  filter: hue-rotate(320deg) brightness(1.2);
}

.slc-geometry-center.stoic {
  filter: hue-rotate(0deg) brightness(1.2);
}

.slc-geometry-center.practical {
  filter: hue-rotate(120deg) brightness(1.2);
}

.slc-geometry-center.systemic {
  filter: hue-rotate(180deg) brightness(1.2);
}

.slc-geometry-center.protective {
  filter: hue-rotate(60deg) brightness(1.2);
}

/* Pattern rotation */
.slc-sacred-pattern.rotating {
  animation: slcPatternRotate 3s ease-in-out forwards;
}

@keyframes slcPatternRotate {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) rotate(180deg) scale(1.1);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg) scale(0);
    opacity: 0;
  }
}

/* ========================================= */
/* Response Card Sacred Geometry Effects     */
/* ========================================= */

/* Add subtle geometry on hover */
.slc-response-card {
  position: relative; /* Ensure positioning context */
}

.slc-response-card::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  height: 150%;
  transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle at center, 
    transparent 30%, 
    rgba(156, 102, 68, 0.05) 50%, 
    transparent 70%);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: -1; /* Behind content */
}

.slc-response-card:hover::before {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Sacred geometry accent for selected response */
.slc-response-card.selected::after {
  content: '';
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  background: var(--slc-primary, var(--slc-primary-fallback));
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  animation: slcDiamondSpin 4s linear infinite;
}

@keyframes slcDiamondSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ========================================= */
/* Wisdom Particles                          */
/* ========================================= */

.slc-wisdom-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--slc-primary, var(--slc-primary-fallback));
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: slcParticleFloat 3s ease-out forwards;
  box-shadow: 0 0 4px rgba(156, 102, 68, 0.8); /* Glow for visibility */
}

@keyframes slcParticleFloat {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

/* ========================================= */
/* Content Fade Transitions                  */
/* ========================================= */

.slc-sacred-fade-out {
  animation: slcContentFadeOut 0.8s ease-out forwards;
}

@keyframes slcContentFadeOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.95);
  }
}

.slc-sacred-fade-in {
  animation: slcContentFadeIn 0.8s ease-out forwards;
}

@keyframes slcContentFadeIn {
  0% {
    opacity: 0;
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================= */
/* Mobile Optimizations                      */
/* ========================================= */

@media (max-width: 768px) {
  .slc-sacred-pattern {
    width: 300px;
    height: 300px;
  }
  
  .slc-geometry-line {
    height: 150px;
  }
  
  .slc-geometry-center {
    width: 40px;
    height: 40px;
  }
  
  /* Simplify animations on mobile for performance */
  @media (hover: none) {
    .slc-fibonacci-spiral {
      animation-duration: 0.8s;
    }
    
    .slc-sacred-pattern.rotating {
      animation-duration: 2s;
    }
    
    /* Reduce particle count on mobile */
    .slc-wisdom-particle:nth-child(n+25) {
      display: none;
    }
  }
}

/* ========================================= */
/* Reduced Motion Support                    */
/* ========================================= */

@media (prefers-reduced-motion: reduce) {
  .slc-geometry-line,
  .slc-fibonacci-spiral,
  .slc-golden-rect,
  .slc-center-ring,
  .slc-sacred-pattern,
  .slc-wisdom-particle {
    animation: none !important;
    opacity: 0.5 !important;
  }
  
  .slc-sacred-fade-out,
  .slc-sacred-fade-in {
    animation: none !important;
    opacity: 1 !important;
  }
}
