/**
 * Subtle selection / focus animations + hero + section fade-up
 * Respects prefers-reduced-motion
 */

/* Page load fade – subtle */
@keyframes pageFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  body {
    animation: pageFadeIn 0.55s ease-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }
}

/* Hero grid overlay – very subtle pulse */
@keyframes hero-circuit-pulse {
  0%, 100% { opacity: 0.18; }
  50% { opacity: 0.26; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero::after {
    animation: hero-circuit-pulse 6s ease-in-out infinite;
  }
}

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

/* Data-flow line keyframes – background position shift */
@keyframes data-flow-shift {
  from { background-position: 0% 50%; }
  to { background-position: 200% 50%; }
}

/* Abstract orbs – gentle float and soft pulse */
@keyframes orb-float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(8px, -12px) scale(1.02); }
  66% { transform: translate(-6px, 8px) scale(0.98); }
}
@keyframes orb-float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-10px, -8px) scale(1.03); }
}
@keyframes orb-float-3 {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(12px, 6px); }
  75% { transform: translate(-8px, -10px); }
}
@keyframes orb-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.55; }
}
@keyframes mesh-drift {
  0%, 100% { opacity: 0.9; transform: scale(1) translate(0, 0); }
  50% { opacity: 1; transform: scale(1.05) translate(2%, 1%); }
}
@media (prefers-reduced-motion: no-preference) {
  .hero .abstract-orb--1 { animation: orb-float-1 14s ease-in-out infinite; }
  .hero .abstract-orb--2 { animation: orb-float-2 18s ease-in-out infinite; }
  .hero .abstract-orb--3 { animation: orb-float-3 16s ease-in-out infinite; }
  .hero .abstract-orb--4 { animation: orb-float-1 12s ease-in-out infinite 1s; }
  .hero .abstract-orb--5 { animation: orb-float-2 15s ease-in-out infinite 0.5s; }
  .abstract-orbs--section .abstract-orb--1,
  .abstract-orbs--cta .abstract-orb--1 { animation: orb-float-1 16s ease-in-out infinite; }
  .abstract-orbs--section .abstract-orb--2,
  .abstract-orbs--cta .abstract-orb--2 { animation: orb-float-2 14s ease-in-out infinite 0.8s; }
  .abstract-orbs--section .abstract-orb--3,
  .abstract-orbs--cta .abstract-orb--3 { animation: orb-float-3 18s ease-in-out infinite 0.3s; }
  .abstract-orbs--cta .abstract-orb--4 { animation: orb-pulse 6s ease-in-out infinite; }
  .page-circuit-bg::before { animation: mesh-drift 20s ease-in-out infinite; }
}
@media (prefers-reduced-motion: reduce) {
  .abstract-orb { animation: none !important; }
  .page-circuit-bg::before { animation: none; }
}

/* Circuit nodes – subtle pulse (SVG circles in circuit background) */
@keyframes circuit-node-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}
@media (prefers-reduced-motion: no-preference) {
  .circuit-nodes circle {
    transform-origin: center;
    animation: circuit-node-pulse 3s ease-in-out infinite;
  }
  .circuit-nodes circle:nth-child(1) { animation-delay: 0s; }
  .circuit-nodes circle:nth-child(2) { animation-delay: 0.4s; }
  .circuit-nodes circle:nth-child(3) { animation-delay: 0.8s; }
  .circuit-nodes circle:nth-child(4) { animation-delay: 0.2s; }
  .circuit-nodes circle:nth-child(5) { animation-delay: 0.6s; }
  .circuit-nodes circle:nth-child(6) { animation-delay: 1s; }
  .circuit-nodes circle:nth-child(7) { animation-delay: 0.3s; }
  .circuit-nodes circle:nth-child(8) { animation-delay: 0.7s; }
  .circuit-nodes circle:nth-child(9) { animation-delay: 0.5s; }
}
@media (prefers-reduced-motion: reduce) {
  .circuit-nodes circle { animation: none; }
}

/* Section fade-up on enter – subtle lift */
.animate-section {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  will-change: transform, opacity;
}

.animate-section.animate-in {
  opacity: 1;
  transform: translateY(0);
  will-change: auto;
}

/* Staggered card fade-in when section enters view */
.animate-section .cards .card {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}
.animate-section.animate-in .cards .card {
  opacity: 1;
  transform: translateY(0);
}
.animate-section.animate-in .cards .card:nth-child(1) { transition-delay: 0.06s; }
.animate-section.animate-in .cards .card:nth-child(2) { transition-delay: 0.14s; }
.animate-section.animate-in .cards .card:nth-child(3) { transition-delay: 0.22s; }
.animate-section.animate-in .cards .card:nth-child(4) { transition-delay: 0.3s; }
.animate-section.animate-in .cards .card:nth-child(5) { transition-delay: 0.38s; }
.animate-section.animate-in .cards .card:nth-child(6) { transition-delay: 0.46s; }

/* Staggered region cards (Global Delivery Footprint) */
.animate-section .region-cards .card {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}
.animate-section.animate-in .region-cards .card {
  opacity: 1;
  transform: translateY(0);
}
.animate-section.animate-in .region-cards .card:nth-child(1) { transition-delay: 0.06s; }
.animate-section.animate-in .region-cards .card:nth-child(2) { transition-delay: 0.14s; }
.animate-section.animate-in .region-cards .card:nth-child(3) { transition-delay: 0.22s; }
.animate-section.animate-in .region-cards .card:nth-child(4) { transition-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .animate-section {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .animate-section.animate-in {
    opacity: 1;
    transform: none;
  }
  .animate-section .cards .card,
  .animate-section.animate-in .cards .card,
  .animate-section .region-cards .card,
  .animate-section.animate-in .region-cards .card {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Buttons - smooth focus ring */
.btn {
  transition: box-shadow var(--transition-base), outline-offset var(--transition-fast);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-primary);
}

/* Cards - subtle focus state when tabbing to links inside */
.card,
.case-study-card {
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}
.card:focus-within,
.case-study-card:focus-within {
  box-shadow: 0 0 0 1px rgba(19, 109, 236, 0.3);
}

/* Nav links - focus underline */
.nav-links a {
  transition: color var(--transition-base), box-shadow var(--transition-base);
}
.nav-links a:focus-visible {
  box-shadow: 0 2px 0 0 var(--color-primary);
  outline: none;
}

/* Capability list - focus left border */
.capability-list li {
  transition: background-color var(--transition-base), padding-left var(--transition-fast);
}
.capability-list li:focus-visible {
  outline: none;
  background-color: rgba(19, 109, 236, 0.08);
  padding-left: var(--space-sm);
}
.capability-list li:focus-visible::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}
.capability-list li {
  position: relative;
}

/* Form controls - focus border transition (components.css has border-color; ensure smooth) */
.form-group input,
.form-group textarea {
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.form-group input:focus,
.form-group textarea:focus {
  box-shadow: 0 0 0 2px rgba(19, 109, 236, 0.2);
}

/* Reduced motion - disable focus animations */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .card,
  .case-study-card,
  .nav-links a,
  .capability-list li,
  .form-group input,
  .form-group textarea {
    transition: none;
  }
}

/* Dark theme: enterprise hover glow – border 0.08 → cyan 0.35, subtle shadow, optional lift. 250ms ease. */
.theme-dark .card,
.theme-dark .btn-primary,
.theme-dark .btn-accent,
.theme-dark .hero-btns a,
.theme-dark .nav-links a,
.theme-dark .card a.btn {
  transition: border-color 250ms ease, box-shadow 250ms ease, transform 250ms ease;
  border-color: rgba(255, 255, 255, 0.08);
}
.theme-dark .card:hover,
.theme-dark .btn-primary:hover,
.theme-dark .btn-accent:hover,
.theme-dark .hero-btns a:hover,
.theme-dark .nav-links a:hover,
.theme-dark .card a.btn:hover {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25), 0 0 24px rgba(56, 189, 248, 0.1);
  transform: translateY(-2px);
}
.theme-dark .card a:not(.btn) {
  transition: border-color 250ms ease, box-shadow 250ms ease;
}
.theme-dark .card a:not(.btn):hover {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25), 0 0 24px rgba(56, 189, 248, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  .theme-dark .card:hover,
  .theme-dark .btn-primary:hover,
  .theme-dark .btn-accent:hover,
  .theme-dark .hero-btns a:hover,
  .theme-dark .nav-links a:hover,
  .theme-dark .card a:hover {
    transform: none;
  }
  .theme-dark .card,
  .theme-dark .btn-primary,
  .theme-dark .btn-accent,
  .theme-dark .hero-btns a,
  .theme-dark .nav-links a,
  .theme-dark .card a {
    transition-duration: 0.12s;
  }
}

/* ============================================
   TEXT REVEAL ANIMATIONS
   ============================================ */

/* Word-by-word reveal */
.reveal-text {
  overflow: hidden;
}

.reveal-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal-text.animate-in .reveal-word {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays for words */
.reveal-word:nth-child(1) { transition-delay: 0.0s; }
.reveal-word:nth-child(2) { transition-delay: 0.05s; }
.reveal-word:nth-child(3) { transition-delay: 0.1s; }
.reveal-word:nth-child(4) { transition-delay: 0.15s; }
.reveal-word:nth-child(5) { transition-delay: 0.2s; }
.reveal-word:nth-child(6) { transition-delay: 0.25s; }
.reveal-word:nth-child(7) { transition-delay: 0.3s; }
.reveal-word:nth-child(8) { transition-delay: 0.35s; }
.reveal-word:nth-child(9) { transition-delay: 0.4s; }
.reveal-word:nth-child(10) { transition-delay: 0.45s; }

/* Character reveal (for special headlines) */
.reveal-char {
  display: inline-block;
  opacity: 0;
  transform: translateY(50%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.reveal-text.animate-in .reveal-char {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal-word,
  .reveal-char {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ============================================
   GRADIENT TEXT ANIMATION
   ============================================ */

.gradient-text {
  background: linear-gradient(135deg, #22d3ee 0%, #6366f1 50%, #a855f7 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  .gradient-text {
    animation: gradientShift 8s ease infinite;
  }
  
  .gradient-text--fast {
    animation: gradientShift 4s ease infinite;
  }
  
  .gradient-text--slow {
    animation: gradientShift 12s ease infinite;
  }
}

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

/* ============================================
   TEXT GLOW EFFECTS
   ============================================ */

.text-glow {
  transition: text-shadow 0.3s ease;
}

.text-glow:hover {
  text-shadow: 
    0 0 10px rgba(34, 211, 238, 0.5),
    0 0 20px rgba(34, 211, 238, 0.3),
    0 0 40px rgba(34, 211, 238, 0.1);
}

.text-glow--cyan:hover {
  text-shadow: 
    0 0 10px rgba(34, 211, 238, 0.6),
    0 0 20px rgba(34, 211, 238, 0.4),
    0 0 40px rgba(34, 211, 238, 0.2);
}

.text-glow--indigo:hover {
  text-shadow: 
    0 0 10px rgba(99, 102, 241, 0.6),
    0 0 20px rgba(99, 102, 241, 0.4),
    0 0 40px rgba(99, 102, 241, 0.2);
}

.text-glow--purple:hover {
  text-shadow: 
    0 0 10px rgba(168, 85, 247, 0.6),
    0 0 20px rgba(168, 85, 247, 0.4),
    0 0 40px rgba(168, 85, 247, 0.2);
}

/* Permanent subtle glow */
.text-glow--always {
  text-shadow: 
    0 0 10px rgba(34, 211, 238, 0.3),
    0 0 20px rgba(34, 211, 238, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  .text-glow,
  .text-glow--cyan,
  .text-glow--indigo,
  .text-glow--purple {
    transition: none;
  }
}

/* ============================================
   NUMBER COUNTER ANIMATION STYLES
   ============================================ */

.stat-value {
  display: inline-block;
}

.stat-value.counting {
  min-width: 3ch;
}

/* ============================================
   FADE-IN DIRECTION VARIATIONS
   ============================================ */

/* Fade from left */
.animate-fade-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-fade-left.animate-in {
  opacity: 1;
  transform: translateX(0);
}

/* Fade from right */
.animate-fade-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-fade-right.animate-in {
  opacity: 1;
  transform: translateX(0);
}

/* Scale up */
.animate-scale-up {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-scale-up.animate-in {
  opacity: 1;
  transform: scale(1);
}

/* Scale down (from larger) */
.animate-scale-down {
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-scale-down.animate-in {
  opacity: 1;
  transform: scale(1);
}

/* Rotate in */
.animate-rotate-in {
  opacity: 0;
  transform: rotate(-5deg) scale(0.95);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-rotate-in.animate-in {
  opacity: 1;
  transform: rotate(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .animate-fade-left,
  .animate-fade-right,
  .animate-scale-up,
  .animate-scale-down,
  .animate-rotate-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ============================================
   PARALLAX LAYER STYLES
   ============================================ */

.parallax-layer {
  will-change: transform;
}

.parallax-layer--slow {
  --parallax-speed: 0.2;
}

.parallax-layer--medium {
  --parallax-speed: 0.4;
}

.parallax-layer--fast {
  --parallax-speed: 0.6;
}

/* ============================================
   PULSE ANIMATIONS
   ============================================ */

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

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid currentColor;
  border-radius: inherit;
  animation: pulse-ring 1.5s ease-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .pulse,
  .pulse-ring::after {
    animation: none;
  }
}

/* ============================================
   SHIMMER / SKELETON LOADING
   ============================================ */

@keyframes shimmer {
  from {
    background-position: -200% 0;
  }
  to {
    background-position: 200% 0;
  }
}

.shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .shimmer {
    animation: none;
    background: rgba(255, 255, 255, 0.03);
  }
}

/* ============================================
   FLOAT ANIMATION (Generic)
   ============================================ */

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

@keyframes float-rotate {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(3deg);
  }
}

.float {
  animation: float 4s ease-in-out infinite;
}

.float-rotate {
  animation: float-rotate 5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .float,
  .float-rotate {
    animation: none;
  }
}

/* ============================================
   TYPEWRITER EFFECT
   ============================================ */

@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: var(--color-primary, #22d3ee); }
}

.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--color-primary, #22d3ee);
  animation: 
    typewriter 3s steps(40, end),
    blink-caret 0.75s step-end infinite;
}

@media (prefers-reduced-motion: reduce) {
  .typewriter {
    animation: none;
    width: auto;
    border-right: none;
  }
}

/* ============================================
   BOUNCE ANIMATION
   ============================================ */

@keyframes bounce {
  0%, 20%, 53%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    transform: translateY(0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    transform: translateY(-20px);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    transform: translateY(-10px);
  }
  80% {
    transform: translateY(0);
  }
  90% {
    transform: translateY(-4px);
  }
}

.bounce {
  animation: bounce 1s both;
}

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

/* ============================================
   SPIN ANIMATION
   ============================================ */

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

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

.spin {
  animation: spin 1s linear infinite;
}

.spin-slow {
  animation: spin-slow 8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spin,
  .spin-slow {
    animation: none;
  }
}
