/**
 * Abstract Visual Elements
 * Mesh gradients, aurora effects, geometric shapes, glassmorphism, wave dividers
 * Performance-optimized with reduced motion support
 */

/* ============================================
   1. MESH GRADIENT BACKGROUNDS
   ============================================ */

.mesh-gradient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(56, 189, 248, 0.15), transparent 50%),
    radial-gradient(ellipse 60% 80% at 80% 60%, rgba(99, 102, 241, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 60% at 50% 20%, rgba(168, 85, 247, 0.1), transparent 50%);
  background-size: 200% 200%, 200% 200%, 200% 200%;
}

@media (prefers-reduced-motion: no-preference) {
  .mesh-gradient {
    animation: meshMorph 20s ease-in-out infinite;
  }
}

@keyframes meshMorph {
  0%, 100% { 
    background-position: 0% 0%, 100% 100%, 50% 0%; 
  }
  33% { 
    background-position: 100% 50%, 0% 50%, 100% 50%; 
  }
  66% { 
    background-position: 50% 100%, 50% 0%, 0% 100%; 
  }
}

/* Simplified mesh for mobile */
@media (max-width: 768px) {
  .mesh-gradient {
    background: 
      radial-gradient(ellipse 100% 60% at 30% 30%, rgba(56, 189, 248, 0.12), transparent 50%),
      radial-gradient(ellipse 80% 100% at 70% 70%, rgba(99, 102, 241, 0.1), transparent 50%);
  }
}

/* ============================================
   2. AURORA / NORTHERN LIGHTS EFFECT
   ============================================ */

.aurora-effect {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.08) 0%,
    rgba(99, 102, 241, 0.06) 25%,
    rgba(168, 85, 247, 0.08) 50%,
    rgba(56, 189, 248, 0.06) 75%,
    rgba(99, 102, 241, 0.08) 100%
  );
  background-size: 400% 400%;
  opacity: 0.8;
}

@media (prefers-reduced-motion: no-preference) {
  .aurora-effect {
    animation: auroraFlow 15s ease-in-out infinite;
  }
}

@keyframes auroraFlow {
  0%, 100% {
    background-position: 0% 50%;
  }
  25% {
    background-position: 50% 0%;
  }
  50% {
    background-position: 100% 50%;
  }
  75% {
    background-position: 50% 100%;
  }
}

/* Aurora waves - secondary layer */
.aurora-waves {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: 
    linear-gradient(180deg, transparent 0%, rgba(56, 189, 248, 0.04) 30%, transparent 60%),
    linear-gradient(180deg, transparent 40%, rgba(168, 85, 247, 0.03) 70%, transparent 100%);
  filter: blur(40px);
}

@media (prefers-reduced-motion: no-preference) {
  .aurora-waves {
    animation: auroraWaveFloat 25s ease-in-out infinite;
  }
}

@keyframes auroraWaveFloat {
  0%, 100% {
    transform: translateY(0) scaleY(1);
    opacity: 0.8;
  }
  50% {
    transform: translateY(-5%) scaleY(1.1);
    opacity: 1;
  }
}

/* ============================================
   3. GEOMETRIC SHAPES
   ============================================ */

.geometric-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Base shape styles */
.geo-shape {
  position: absolute;
  opacity: 0.15;
  will-change: transform;
}

/* Hollow circle */
.geo-circle {
  width: 120px;
  height: 120px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 50%;
}

.geo-circle--lg {
  width: 200px;
  height: 200px;
  border-color: rgba(99, 102, 241, 0.3);
}

.geo-circle--sm {
  width: 60px;
  height: 60px;
  border-color: rgba(168, 85, 247, 0.35);
}

/* Triangle using borders */
.geo-triangle {
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 86px solid transparent;
  position: relative;
}

.geo-triangle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: -47px;
  width: 0;
  height: 0;
  border-left: 47px solid transparent;
  border-right: 47px solid transparent;
  border-bottom: 80px solid var(--color-bg, #05070a);
}

.geo-triangle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -50px;
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 86px solid rgba(56, 189, 248, 0.3);
}

/* Hexagon using clip-path */
.geo-hexagon {
  width: 100px;
  height: 86px;
  background: transparent;
  position: relative;
}

.geo-hexagon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(99, 102, 241, 0.3);
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.geo-hexagon::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--color-bg, #05070a);
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

/* Diamond */
.geo-diamond {
  width: 60px;
  height: 60px;
  border: 1px solid rgba(168, 85, 247, 0.35);
  transform: rotate(45deg);
}

/* Plus/Cross */
.geo-plus {
  width: 40px;
  height: 40px;
  position: relative;
}

.geo-plus::before,
.geo-plus::after {
  content: '';
  position: absolute;
  background: rgba(56, 189, 248, 0.3);
}

.geo-plus::before {
  width: 1px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

.geo-plus::after {
  width: 100%;
  height: 1px;
  top: 50%;
  transform: translateY(-50%);
}

/* Shape positioning */
.geo-shape--1 { top: 10%; left: 5%; }
.geo-shape--2 { top: 25%; right: 8%; }
.geo-shape--3 { top: 60%; left: 12%; }
.geo-shape--4 { bottom: 15%; right: 15%; }
.geo-shape--5 { top: 40%; right: 25%; }
.geo-shape--6 { bottom: 30%; left: 8%; }
.geo-shape--7 { top: 5%; right: 30%; }
.geo-shape--8 { bottom: 10%; right: 5%; }

/* Shape animations */
@media (prefers-reduced-motion: no-preference) {
  .geo-shape--1 { animation: geoFloat1 35s ease-in-out infinite, geoRotate 60s linear infinite; }
  .geo-shape--2 { animation: geoFloat2 40s ease-in-out infinite, geoRotate 45s linear infinite reverse; }
  .geo-shape--3 { animation: geoFloat3 30s ease-in-out infinite; }
  .geo-shape--4 { animation: geoFloat1 45s ease-in-out infinite 5s, geoRotate 50s linear infinite; }
  .geo-shape--5 { animation: geoFloat2 38s ease-in-out infinite 2s; }
  .geo-shape--6 { animation: geoFloat3 42s ease-in-out infinite 3s, geoRotate 55s linear infinite reverse; }
  .geo-shape--7 { animation: geoFloat1 32s ease-in-out infinite 1s; }
  .geo-shape--8 { animation: geoFloat2 36s ease-in-out infinite 4s, geoRotate 40s linear infinite; }
}

@keyframes geoFloat1 {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(15px, -20px); }
  50% { transform: translate(-10px, -35px); }
  75% { transform: translate(20px, -15px); }
}

@keyframes geoFloat2 {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(-20px, 15px); }
  66% { transform: translate(10px, -25px); }
}

@keyframes geoFloat3 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(25px, 20px); }
}

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

/* ============================================
   4. GLASSMORPHISM ENHANCEMENTS
   ============================================ */

.glass {
  background: rgba(12, 15, 20, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass--light {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass--strong {
  background: rgba(12, 15, 20, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Glassmorphism card enhancement */
.theme-dark .card.glass-card {
  background: rgba(12, 15, 20, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.theme-dark .card.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* ============================================
   5. WAVE DIVIDERS
   ============================================ */

.wave-divider {
  position: relative;
  width: 100%;
  height: 80px;
  overflow: hidden;
  pointer-events: none;
}

.wave-divider svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 100%;
  fill: var(--color-bg, #05070a);
}

.wave-divider--top {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: no-preference) {
  .wave-divider svg {
    animation: waveFlow 12s linear infinite;
  }
}

@keyframes waveFlow {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Wave SVG inline - use as background */
.wave-divider--inline {
  height: 60px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'%3E%3Cpath d='M0,60 C200,120 400,0 600,60 C800,120 1000,0 1200,60 L1200,120 L0,120 Z' fill='%2305070a'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 1200px 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .wave-divider--inline {
    animation: waveFlowBg 15s linear infinite;
  }
}

@keyframes waveFlowBg {
  from { background-position-x: 0; }
  to { background-position-x: 1200px; }
}

/* ============================================
   6. PARTICLE CANVAS CONTAINER
   ============================================ */

.particle-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}

.particle-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================
   7. GLOW TRAIL CONTAINER
   ============================================ */

.glow-trail-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
  opacity: 0.6;
}

.glow-trail-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================
   8. SPOTLIGHT OVERLAY
   ============================================ */

.spotlight-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(
    circle 150px at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(56, 189, 248, 0.08) 0%,
    transparent 100%
  );
}

.card:hover .spotlight-overlay,
.has-spotlight:hover .spotlight-overlay {
  opacity: 1;
}

/* ============================================
   9. SCROLL PROGRESS BAR
   ============================================ */

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #22d3ee, #6366f1, #a855f7);
  transform-origin: left;
  transform: scaleX(var(--scroll-progress, 0));
  z-index: 9999;
  pointer-events: none;
}

/* ============================================
   10. RIPPLE EFFECT
   ============================================ */

.ripple-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.3);
  transform: scale(0);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .ripple {
    animation: rippleExpand 0.6s ease-out forwards;
  }
}

@keyframes rippleExpand {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ============================================
   11. GLOWING BORDER ANIMATION
   ============================================ */

/* CSS Houdini for angle animation - with fallback */
@property --border-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.glow-border {
  position: relative;
  z-index: 0;
}

.glow-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(
    from var(--border-angle, 0deg),
    #22d3ee,
    #6366f1,
    #a855f7,
    #22d3ee
  );
  border-radius: inherit;
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
}

.glow-border::after {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  border-radius: inherit;
  z-index: -1;
}

.glow-border:hover::before {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .glow-border:hover::before {
    animation: borderRotate 3s linear infinite;
  }
}

@keyframes borderRotate {
  to {
    --border-angle: 360deg;
  }
}

/* Fallback for browsers without @property support */
@supports not (background: conic-gradient(from 0deg, red, blue)) {
  .glow-border:hover::before {
    background: linear-gradient(135deg, #22d3ee, #6366f1, #a855f7);
    animation: none;
  }
}

/* ============================================
   12. CONNECTION LINES CONTAINER
   ============================================ */

.connection-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

.connection-lines svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.connection-line {
  fill: none;
  stroke: rgba(56, 189, 248, 0.15);
  stroke-width: 1;
  stroke-dasharray: 8 4;
}

@media (prefers-reduced-motion: no-preference) {
  .connection-line {
    animation: connectionFlow 20s linear infinite;
  }
}

@keyframes connectionFlow {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -100; }
}

/* ============================================
   13. GENERATIVE BLOB CONTAINER
   ============================================ */

.blob-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  filter: blur(60px);
  opacity: 0.4;
  will-change: transform;
}

.blob--cyan {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.4) 0%, transparent 70%);
}

.blob--indigo {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%);
}

.blob--purple {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.3) 0%, transparent 70%);
}

@media (prefers-reduced-motion: no-preference) {
  .blob {
    animation: blobMorph 20s ease-in-out infinite;
  }
  
  .blob:nth-child(2) {
    animation-delay: -5s;
    animation-duration: 25s;
  }
  
  .blob:nth-child(3) {
    animation-delay: -10s;
    animation-duration: 22s;
  }
}

@keyframes blobMorph {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  25% {
    transform: translate(5%, -5%) scale(1.05);
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
  50% {
    transform: translate(-5%, 5%) scale(0.95);
    border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%;
  }
  75% {
    transform: translate(3%, 3%) scale(1.02);
    border-radius: 60% 40% 60% 40% / 70% 30% 50% 60%;
  }
}

/* ============================================
   HERO CIRCUIT NETWORK (draw-on-load)
   ============================================ */

.hero-circuit-network {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  contain: layout paint;
}

.hero-circuit-network svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-circuit-network .hero-circuit-line {
  fill: none;
  stroke: var(--accent, #22d3ee);
  stroke-width: 1;
  stroke-linecap: round;
  opacity: 0.3;
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
}

.hero-circuit-network .hero-circuit-nodes circle {
  fill: var(--accent, #22d3ee);
  opacity: 0.3;
}

@media (prefers-reduced-motion: no-preference) {
  .hero-circuit-network .hero-circuit-line {
    animation: hero-circuit-draw 1.5s ease-out forwards;
  }
  .hero-circuit-network .hero-circuit-line:nth-child(2) { animation-delay: 0s; }
  .hero-circuit-network .hero-circuit-line:nth-child(3) { animation-delay: 0.08s; }
  .hero-circuit-network .hero-circuit-line:nth-child(4) { animation-delay: 0.16s; }
  .hero-circuit-network .hero-circuit-line:nth-child(5) { animation-delay: 0.24s; }
  .hero-circuit-network .hero-circuit-line:nth-child(6) { animation-delay: 0.32s; }
  .hero-circuit-network .hero-circuit-line:nth-child(7) { animation-delay: 0.4s; }
  .hero-circuit-network .hero-circuit-line:nth-child(8) { animation-delay: 0.48s; }
}

@keyframes hero-circuit-draw {
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-circuit-network .hero-circuit-line {
    animation: none;
    stroke-dashoffset: 0;
  }
}

/* ============================================
   METRICS STRIP
   ============================================ */

.metrics-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-lg);
  background: rgba(5, 7, 10, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
  contain: layout paint;
}

.metrics-strip__text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-shadow: 0 0 20px rgba(34, 211, 238, 0.2);
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .metrics-strip__text {
    animation: metrics-strip-fade 1s ease-out;
  }
}

@keyframes metrics-strip-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .metrics-strip__text {
    animation: none;
  }
}

/* ============================================
   GLOBAL DELIVERY MAP
   ============================================ */

.container--relative {
  position: relative;
}

.global-delivery-map {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  contain: layout paint;
}

.global-delivery-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.global-delivery-map__land {
  fill: var(--color-bg, #05070a);
  opacity: 0.1;
}

.global-delivery-map .map-dot {
  fill: var(--accent, #22d3ee);
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.4));
  opacity: 0.6;
  transform-origin: center;
}

@media (prefers-reduced-motion: no-preference) {
  .global-delivery-map .map-dot {
    animation: map-dot-pulse 3s ease-in-out infinite;
  }
}

@keyframes map-dot-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  .global-delivery-map .map-dot {
    animation: none;
  }
}

/* Optional: boost dot opacity when region card is hovered */
#impact[data-hover-region="apac"] .map-dot[data-region="apac"],
#impact[data-hover-region="mena"] .map-dot[data-region="mena"],
#impact[data-hover-region="europe"] .map-dot[data-region="europe"],
#impact[data-hover-region="nam"] .map-dot[data-region="nam"] {
  opacity: 0.95;
}

/* ============================================
   SECTION LIGHTING DEPTH
   ============================================ */

.section-glow-tl,
.section-glow-br {
  position: relative;
}

.section-glow-tl::before,
.section-glow-br::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.section-glow-tl::before {
  background: radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.06), transparent 60%);
}

.section-glow-br::before {
  background: radial-gradient(circle at 80% 80%, rgba(34, 211, 238, 0.06), transparent 60%);
}

.section-glow-tl .container,
.section-glow-br .container,
.section-glow-tl .container--relative,
.section-glow-br .container--relative {
  position: relative;
  z-index: 1;
}

/* ============================================
   REDUCED MOTION FALLBACKS
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .mesh-gradient,
  .aurora-effect,
  .aurora-waves,
  .geo-shape,
  .wave-divider svg,
  .wave-divider--inline,
  .ripple,
  .glow-border::before,
  .connection-line,
  .blob {
    animation: none !important;
  }
  .hero-circuit-network .hero-circuit-line {
    stroke-dashoffset: 0;
  }
  
  /* Static fallbacks */
  .mesh-gradient {
    background-position: 50% 50%;
  }
  
  .aurora-effect {
    background-position: 50% 50%;
  }
}
