/* ============================================
   AsilMedia v2 — Animations & Transitions
   ============================================ */

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

/* Slide up */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp var(--duration-normal) var(--ease-out);
}

/* Scale in */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.scale-in {
  animation: scaleIn var(--duration-normal) var(--ease-spring);
}

/* Pulse for loading states */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

/* Spin for loading icon */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* Ripple effect on buttons */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10);
  opacity: 0;
  transition: transform 0.5s, opacity 0.8s;
}

.ripple:active::after {
  transform: scale(0);
  opacity: 1;
  transition: 0s;
}

/* Shimmer loading for images */
@keyframes shimmer-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Content visibility for below-fold optimization */
.lazy-section {
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}

/* ── SPA Navigation ── */

/* Progress bar */
.spa-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.spa-progress.is-active {
  opacity: 1;
}

.spa-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--clr-accent, #6c5ce7);
  box-shadow: 0 0 8px var(--clr-accent, #6c5ce7), 0 0 2px var(--clr-accent, #6c5ce7);
  transition: width 0.15s linear, opacity 0.3s;
  border-radius: 0 2px 2px 0;
}

/* Circular spinner companion — top-right corner, mirrors .spa-progress.
   `right` offset clears the vertical scrollbar on Windows (~16px). */
.spa-spinner {
  position: fixed;
  top: 12px;
  right: 24px;
  width: 22px;
  height: 22px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.25s ease, transform 0.25s ease;
  filter: drop-shadow(0 0 6px var(--clr-accent, #6c5ce7));
}

.spa-spinner.is-active {
  opacity: 1;
  transform: scale(1);
}

.spa-spinner svg {
  width: 100%;
  height: 100%;
  animation: spaSpinnerRotate 1.1s linear infinite;
  transform-origin: center;
}

.spa-spinner__track {
  fill: none;
  stroke: var(--clr-accent, #6c5ce7);
  stroke-width: 3;
  opacity: 0.18;
}

.spa-spinner__head {
  fill: none;
  stroke: var(--clr-accent, #6c5ce7);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 94.248; /* 2*PI*15 */
  stroke-dashoffset: 70;
  animation: spaSpinnerDash 1.4s ease-in-out infinite;
  transform-origin: center;
}

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

@keyframes spaSpinnerDash {
  0%   { stroke-dashoffset: 85; transform: rotate(0deg); }
  50%  { stroke-dashoffset: 25; transform: rotate(135deg); }
  100% { stroke-dashoffset: 85; transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spa-spinner svg,
  .spa-spinner__head {
    animation-duration: 2.5s;
  }
}

/* Page content transitions */
.spa-fade-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

.spa-fade-in {
  animation: spaFadeIn 0.3s ease-out forwards;
}

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

/* ── SPA Exit Animation — staggered scale+fade for sections ── */
@keyframes spaExitScale {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
}

.spa-exit-animate {
  animation: spaExitScale 0.35s cubic-bezier(0.4, 0, 0.7, 0.2) forwards;
}

/* ── SPA Enter Animation — staggered scale+fade for sections ── */
@keyframes spaEnterScale {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.spa-enter-animate {
  animation: spaEnterScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0; /* start hidden */
}

/* Scroll hint — pulse glow on target section */
@keyframes scrollHintPulse {
  0%   { box-shadow: inset 0 0 0 2px var(--accent, #00b4d8); }
  50%  { box-shadow: inset 0 0 0 2px transparent; }
  100% { box-shadow: inset 0 0 0 2px var(--accent, #00b4d8); }
}

.scroll-hint {
  animation: scrollHintPulse 0.5s ease 5;
  border-radius: var(--radius-lg, 12px);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
