/*
 * Riyadah Co. Ltd - Animations & Interactions
 * Performance-optimized animations for enterprise website
 */

/* ========================================
   KEYFRAME ANIMATIONS
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes marquee {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* ========================================
   SCROLL ANIMATIONS
   ======================================== */

.animate-on-scroll {
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
  opacity: 1;
}

.fade-up {
  animation: fadeUp 0.8s ease forwards;
}

.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.scale-in {
  animation: scaleIn 0.6s ease forwards;
}

.slide-in-left {
  animation: slideInLeft 0.8s ease forwards;
}

.slide-in-right {
  animation: slideInRight 0.8s ease forwards;
}

/* Staggered Animations */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }

/* ========================================
   HERO ANIMATIONS
   ======================================== */

.hero-content h1 {
  animation: fadeUp 1s ease 0.2s both;
}

.hero-content p {
  animation: fadeUp 1s ease 0.4s both;
}

.hero-content .button {
  animation: fadeUp 1s ease 0.6s both;
}

/* Parallax Background */
.hero-background {
  transition: transform 0.5s ease-out;
  will-change: transform;
}

/* ========================================
   CARD HOVER EFFECTS
   ======================================== */

.card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  box-shadow: 0 20px 40px rgba(11, 79, 108, 0.2);
}

.card:hover::before {
  opacity: 1;
}

.card:hover {
  transform: translateY(-8px);
}

.card-service:hover .icon {
  animation: pulse 0.6s ease;
}

/* ========================================
   BUTTON INTERACTIONS
   ======================================== */

.button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.button:hover::before {
  width: 300px;
  height: 300px;
}

.button:active {
  transform: translateY(-1px) scale(0.98);
}

/* ========================================
   LOGO SLIDER / MARQUEE
   ======================================== */

.logo-slider {
  overflow: hidden;
  position: relative;
  width: 100%;
  padding: var(--space-xl) 0;
}

.logo-slider-track {
  display: flex;
  gap: var(--space-2xl);
  animation: marquee 30s linear infinite;
  width: fit-content;
}

.logo-slider-track:hover {
  animation-play-state: paused;
}

.logo-slider .logo-item {
  flex-shrink: 0;
  width: 180px;
}

/* Duplicate logos for seamless loop */
.logo-slider-track::after {
  content: '';
  display: flex;
  gap: var(--space-2xl);
}

/* ========================================
   NAVIGATION ANIMATIONS
   ======================================== */

.navbar {
  transform: translateY(0);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.navbar.hidden {
  transform: translateY(-100%);
}

.navbar-menu a {
  position: relative;
  transition: color 0.2s ease;
}

.navbar-menu a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-primary-blue);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-menu a:hover::after,
.navbar-menu a.active::after {
  width: 100%;
}

/* Mobile Menu Animation */
.navbar-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.navbar-toggle.active span:nth-child(2) {
  opacity: 0;
}

.navbar-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* ========================================
   FORM INTERACTIONS
   ======================================== */

.form-input,
.form-textarea,
.form-select {
  transition: all 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  transform: translateY(-2px);
}

.form-group {
  position: relative;
}

.form-label {
  transition: all 0.2s ease;
}

.form-input:focus + .form-label,
.form-textarea:focus + .form-label {
  color: var(--color-primary-blue);
}

/* ========================================
   LOADING STATES
   ======================================== */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-light-gray);
  border-top-color: var(--color-primary-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========================================
   PAGE TRANSITIONS
   ======================================== */

.page-transition {
  animation: fadeIn 0.4s ease;
}

/* ========================================
   ICON ANIMATIONS
   ======================================== */

.icon {
  transition: all 0.3s ease;
}

.icon:hover {
  transform: scale(1.1);
  color: var(--color-teal-accent);
}

.icon-rotate:hover {
  transform: rotate(360deg);
}

/* ========================================
   IMAGE HOVER EFFECTS
   ======================================== */

.image-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.image-wrapper img {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
  width: 100%;
}

.image-wrapper:hover img {
  transform: scale(1.05);
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.6) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: flex-end;
  padding: var(--space-md);
  color: white;
}

.image-wrapper:hover .image-overlay {
  opacity: 1;
}

/* ========================================
   SCROLL PROGRESS INDICATOR
   ======================================== */

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(to right, var(--color-primary-blue), var(--color-teal-accent));
  transform-origin: left;
  z-index: var(--z-fixed);
  transition: transform 0.1s ease;
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .hero-background {
    transform: none !important;
  }
  
  .logo-slider-track {
    animation: none;
  }
}

/* GPU acceleration for smooth animations */
.card,
.button,
.hero-background,
.navbar {
  will-change: transform;
}

/* Remove will-change after animation completes */
.animated {
  will-change: auto;
}
