/**
 * Animations
 * CSS animations and transitions
 *
 * @package Baffled_Architect
 * @since 1.0.0
 */

/* ========================================================================
   Keyframe Animations
   ======================================================================== */

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

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

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

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

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

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

/* ========================================================================
   Scroll Animation Classes
   ======================================================================== */

.animate-on-scroll {
  opacity: 0;
  transition: none;
}

.animate-on-scroll.animated {
  animation-duration: 0.6s;
  animation-fill-mode: both;
  animation-timing-function: ease-out;
}

/* Animation Variants */
.animate-fade-in.animated {
  animation-name: fadeIn;
}

.animate-fade-in-up.animated {
  animation-name: fadeInUp;
}

.animate-fade-in-down.animated {
  animation-name: fadeInDown;
}

.animate-slide-in-right.animated {
  animation-name: slideInRight;
}

.animate-slide-in-left.animated {
  animation-name: slideInLeft;
}

.animate-scale-in.animated {
  animation-name: scaleIn;
}

/* ========================================================================
   Stagger Delays for Multiple Items
   ======================================================================== */

.animate-on-scroll:nth-child(1).animated { animation-delay: 0s; }
.animate-on-scroll:nth-child(2).animated { animation-delay: 0.1s; }
.animate-on-scroll:nth-child(3).animated { animation-delay: 0.2s; }
.animate-on-scroll:nth-child(4).animated { animation-delay: 0.3s; }
.animate-on-scroll:nth-child(5).animated { animation-delay: 0.4s; }
.animate-on-scroll:nth-child(6).animated { animation-delay: 0.5s; }
.animate-on-scroll:nth-child(7).animated { animation-delay: 0.6s; }
.animate-on-scroll:nth-child(8).animated { animation-delay: 0.7s; }
.animate-on-scroll:nth-child(9).animated { animation-delay: 0.8s; }
.animate-on-scroll:nth-child(10).animated { animation-delay: 0.9s; }

/* ========================================================================
   Hover Animations
   ======================================================================== */

/* Hover Lift Effect */
.hover-lift {
  transition: transform var(--hover-transition), box-shadow var(--hover-transition);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Hover Glow Effect (underline animation) */
.hover-glow {
  position: relative;
  transition: color var(--hover-transition);
}

.hover-glow::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.hover-glow:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Hover Scale */
.hover-scale {
  transition: transform var(--hover-transition);
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* Hover Brightness */
.hover-brightness {
  transition: filter var(--hover-transition);
}

.hover-brightness:hover {
  filter: brightness(1.1);
}

/* ========================================================================
   Page Load Animations
   ======================================================================== */

body {
  animation: fadeIn 0.4s ease-in;
}

/* ========================================================================
   Button Animations
   ======================================================================== */

button,
input[type="submit"],
input[type="button"],
a.button,
.wp-block-button__link {
  position: relative;
  overflow: hidden;
  transition: all var(--hover-transition);
}

button::before,
input[type="submit"]::before,
input[type="button"]::before,
a.button::before,
.wp-block-button__link::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

button:hover::before,
input[type="submit"]:hover::before,
input[type="button"]:hover::before,
a.button:hover::before,
.wp-block-button__link:hover::before {
  width: 300px;
  height: 300px;
}

/* ========================================================================
   Loading Spinner (for future use)
   ======================================================================== */

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spinner {
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
}

/* ========================================================================
   Pulse Animation (for notifications/badges)
   ======================================================================== */

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

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

/* ========================================================================
   Accessibility - Reduce Motion
   ======================================================================== */

@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;
  }

  .animate-on-scroll {
    opacity: 1;
  }

  body {
    animation: none;
  }
}

/* ========================================================================
   Smooth Scroll Behavior
   ======================================================================== */

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ========================================================================
   Focus Visible (for keyboard navigation)
   ======================================================================== */

*:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ========================================================================
   Theme Transition (smooth theme switching)
   ======================================================================== */

body,
.site-header,
.post-card,
.widget,
.site-footer,
button,
input,
textarea,
select,
a {
  transition: background-color var(--theme-transition),
              color var(--theme-transition),
              border-color var(--theme-transition);
}
