/* Elegant Animation System - v2 Refined */

/* Animation Variables - Slower, More Sophisticated */
:root {
  --ease-elegant: cubic-bezier(0.24, 0.1, 0.25, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.24, 0.1, 0.25, 1);
  --duration-fast: 0.28s;
  --duration-normal: 0.38s;
  --duration-slow: 0.5s;
  --duration-slower: 0.65s;
}

/* Page Transition - Subtle Fade */
.page-transition {
  opacity: 0;
  animation: pageEnter 0.65s var(--ease-elegant) forwards;
}

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

/* Fade Animations - Subtle Movement */
.animate-fade-up {
  opacity: 0;
  transform: translateY(15px);
  animation: fadeUp 0.6s var(--ease-elegant) forwards;
}

.animate-fade-down {
  opacity: 0;
  transform: translateY(-15px);
  animation: fadeDown 0.6s var(--ease-elegant) forwards;
}

.animate-fade-left {
  opacity: 0;
  transform: translateX(-15px);
  animation: fadeLeft 0.6s var(--ease-elegant) forwards;
}

.animate-fade-right {
  opacity: 0;
  transform: translateX(15px);
  animation: fadeRight 0.6s var(--ease-elegant) forwards;
}

.animate-fade-in {
  opacity: 0;
  animation: fadeIn 0.5s var(--ease-smooth) forwards;
}

.animate-scale-in {
  opacity: 0;
  transform: scale(0.97);
  animation: scaleIn 0.5s var(--ease-elegant) forwards;
}

/* Stagger Delays - Slightly Longer */
.stagger-1 { animation-delay: 0.12s; }
.stagger-2 { animation-delay: 0.24s; }
.stagger-3 { animation-delay: 0.36s; }
.stagger-4 { animation-delay: 0.48s; }
.stagger-5 { animation-delay: 0.6s; }
.stagger-6 { animation-delay: 0.72s; }
.stagger-7 { animation-delay: 0.84s; }
.stagger-8 { animation-delay: 0.96s; }

/* Keyframes - Refined Movement */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeLeft {
  from {
    opacity: 0;
    transform: translateX(-15px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeRight {
  from {
    opacity: 0;
    transform: translateX(15px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

/* Pulse Animation - Subtle Breathing */
.animate-pulse {
  animation: pulse 4s var(--ease-smooth) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

/* Glow Pulse - Subtle Gold */
.animate-glow-pulse {
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 15px rgba(201, 162, 39, 0.15);
  }
  50% {
    box-shadow: 0 0 25px rgba(201, 162, 39, 0.25);
  }
}

/* Float Animation - Minimal */
.animate-float {
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* Hover Lift Effect - Subtle */
.hover-lift {
  transition: transform var(--duration-slow) var(--ease-elegant);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

/* Button Ripple Animation */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::after {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}

.btn-ripple:active::after {
  transform: scale(0, 0);
  opacity: 0.4;
  transition: 0s;
}

/* Glass Effect */
.glass-effect {
  background: rgba(15, 17, 41, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all var(--duration-normal) var(--ease-spring);
}

.glass-effect:hover {
  background: rgba(20, 20, 20, 0.8);
  border-color: rgba(212, 175, 55, 0.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.15);
  transform: translateY(-4px);
}

/* Particles container */
.particles-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* Loading Orb - Elegant, Minimal */
.loading-orb-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.loading-orb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--charcoal, #111111);
  border: 2px solid rgba(201, 162, 39, 0.4);
  animation: orbPulseElegant 3s var(--ease-elegant) infinite;
  box-shadow: 0 0 20px rgba(201, 162, 39, 0.15);
  position: relative;
}

.loading-orb::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: inherit;
  background: rgba(201, 162, 39, 0.6);
  transform: translate(-50%, -50%);
}

.loading-orb::after {
  display: none;
}

@keyframes orbPulseElegant {
  0%, 100% { 
    opacity: 0.6;
    border-color: rgba(201, 162, 39, 0.3);
  }
  50% { 
    opacity: 1;
    border-color: rgba(201, 162, 39, 0.5);
  }
}

/* Legal scale loading animation - Subtle */
.legal-scale-loader {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto;
}

.legal-scale-loader:before,
.legal-scale-loader:after {
  content: "";
  display: block;
  position: absolute;
  border-radius: 50%;
  animation: scaleBalanceElegant 2.5s infinite var(--ease-elegant);
}

.legal-scale-loader:before {
  width: 20px;
  height: 20px;
  background: rgba(201, 162, 39, 0.4);
  left: 8px;
  top: 20px;
}

.legal-scale-loader:after {
  width: 20px;
  height: 20px;
  background: rgba(201, 162, 39, 0.3);
  right: 8px;
  top: 20px;
  animation-delay: -1.25s;
}

@keyframes scaleBalanceElegant {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-6px);
    opacity: 0.7;
  }
}

/* Typing indicator - Elegant */
.typing-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
  gap: 6px;
}

.typing-indicator span {
  height: 6px;
  width: 6px;
  border-radius: 50%;
  background: rgba(201, 162, 39, 0.5);
  display: block;
}

.typing-indicator span:nth-child(1) {
  animation: typingFade 1.8s infinite 0s;
}

.typing-indicator span:nth-child(2) {
  animation: typingFade 1.8s infinite 0.3s;
}

.typing-indicator span:nth-child(3) {
  animation: typingFade 1.8s infinite 0.6s;
}

@keyframes typingFade {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.8;
  }
}

/* Input animation container */
.input-animation-container {
  position: relative;
}

.input-animation-container::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #d4af37, #ffd700);
  transition: all var(--duration-normal) var(--ease-spring);
  transform: translateX(-50%);
}

.input-animation-container:focus-within::after {
  width: 100%;
}

/* FAB (Floating Action Button) - Elegant */
.fab-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
}

.fab-button {
  width: 52px;
  height: 52px;
  background: var(--charcoal, #111111);
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(201, 162, 39, 0.8);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-elegant);
}

.fab-button:hover {
  border-color: rgba(201, 162, 39, 0.5);
  color: rgba(201, 162, 39, 1);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.fab-button svg {
  transition: transform var(--duration-slow) var(--ease-elegant);
}

.fab-container.active .fab-button svg {
  transform: rotate(45deg);
}

.fab-actions {
  position: absolute;
  bottom: 100%;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 1rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all var(--duration-slow) var(--ease-elegant);
}

.fab-container.active .fab-actions {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.fab-action-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--charcoal, #111111);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-elegant);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.fab-action-button:hover {
  background: var(--slate, #1a1a1a);
  color: rgba(201, 162, 39, 0.9);
  border-color: rgba(201, 162, 39, 0.3);
}

/* Defense Reveal Animation - Elegant */
.defense-reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: defenseRevealElegant 0.5s var(--ease-elegant) forwards;
}

@keyframes defenseRevealElegant {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered Defense Sections */
.defense-section-animate {
  opacity: 0;
  transform: translateX(-20px);
  animation: sectionSlide 0.5s var(--ease-spring) forwards;
}

.defense-section-animate:nth-child(1) { animation-delay: 0.1s; }
.defense-section-animate:nth-child(2) { animation-delay: 0.2s; }
.defense-section-animate:nth-child(3) { animation-delay: 0.3s; }
.defense-section-animate:nth-child(4) { animation-delay: 0.4s; }
.defense-section-animate:nth-child(5) { animation-delay: 0.5s; }

@keyframes sectionSlide {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Shimmer Effect */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Waveform Animation for TTS */
.waveform-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 20px;
}

.waveform-bar {
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #d4af37, #ffd700);
  border-radius: 4px;
  transform-origin: center;
}

.waveform-bar.animating {
  animation: waveformBar 0.6s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { animation-delay: 0s; }
.waveform-bar:nth-child(2) { animation-delay: 0.1s; }
.waveform-bar:nth-child(3) { animation-delay: 0.2s; }
.waveform-bar:nth-child(4) { animation-delay: 0.3s; }
.waveform-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveformBar {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

/* Particle Burst for Verdict */
.particle-burst {
  position: fixed;
  top: 50%;
  left: 50%;
  pointer-events: none;
  z-index: 9999;
}

/* Success Checkmark Animation */
.success-checkmark {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: block;
  stroke-width: 3;
  stroke: #d4af37;
  stroke-miterlimit: 10;
  animation: checkFill 0.4s ease-in-out 0.4s forwards, checkScale 0.3s ease-in-out 0.9s both;
  position: relative;
}

.success-checkmark .checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 3;
  stroke-miterlimit: 10;
  stroke: #d4af37;
  fill: none;
  animation: checkStroke 0.6s var(--ease-smooth) forwards;
}

.success-checkmark .checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkStroke 0.3s var(--ease-smooth) 0.8s forwards;
}

@keyframes checkStroke {
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes checkScale {
  0%, 100% {
    transform: none;
  }
  50% {
    transform: scale3d(1.1, 1.1, 1);
  }
}

@keyframes checkFill {
  100% {
    box-shadow: inset 0 0 0 40px rgba(212, 175, 55, 0.15);
  }
}

/* Hover Lift Effect */
.hover-lift {
  transition: all var(--duration-normal) var(--ease-spring);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(212, 175, 55, 0.2);
}

/* Border Glow Animation */
@keyframes borderGlow {
  0%, 100% {
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
  }
  50% {
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
  }
}

.animate-border-glow {
  animation: borderGlow 3s ease-in-out infinite;
}

/* Rotate Animation */
.animate-rotate {
  animation: rotate 8s linear infinite;
}

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

/* Bounce Animation */
.animate-bounce {
  animation: bounce 1s var(--ease-bounce) infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Text Reveal Animation */
.text-reveal {
  overflow: hidden;
}

.text-reveal span {
  display: inline-block;
  opacity: 0;
  transform: translateY(100%);
  animation: textReveal 0.6s var(--ease-spring) forwards;
}

@keyframes textReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Animations - Reduce motion for mobile */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 768px) {
  .loading-orb {
    width: 60px;
    height: 60px;
  }
  
  .fab-container {
    bottom: calc(80px + 1rem);
  }
}
