/* ============================================
   WARM LOOM ANIMATIONS
   SVG Path Animations & Micro-interactions
   ============================================ */

/* ----------------------------------------
   SVG Path Animation (Logo Draw Effect)
   ---------------------------------------- */
.svg-path-draw {
  fill: none;
  stroke: var(--color-charcoal);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Main brand mark animation */
.logo-animated .svg-path-draw {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawPath 1.8s ease-in-out forwards;
}

/* Staggered animation for multiple paths */
.logo-animated .svg-path-draw:nth-child(1) {
  animation-delay: 0s;
}

.logo-animated .svg-path-draw:nth-child(2) {
  animation-delay: 0.2s;
}

.logo-animated .svg-path-draw:nth-child(3) {
  animation-delay: 0.4s;
}

.logo-animated .svg-path-draw:nth-child(4) {
  animation-delay: 0.6s;
}

.logo-animated .svg-path-draw:nth-child(5) {
  animation-delay: 0.8s;
}

@keyframes drawPath {
  0% {
    stroke-dashoffset: 1000;
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

/* Fill reveal after stroke animation */
.logo-animated .svg-fill-reveal {
  fill: var(--color-charcoal);
  fill-opacity: 0;
  animation: revealFill 0.6s ease forwards;
  animation-delay: 1.6s;
}

@keyframes revealFill {
  0% {
    fill-opacity: 0;
  }
  100% {
    fill-opacity: 1;
  }
}

/* Knit texture reveal overlay */
.knit-texture-reveal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('../images/knit-texture.svg') repeat;
  background-size: 20px 20px;
  opacity: 0;
  animation: revealTexture 0.8s ease forwards;
  animation-delay: 1.8s;
  mix-blend-mode: multiply;
}

@keyframes revealTexture {
  0% {
    opacity: 0;
    transform: scale(1.1);
  }
  100% {
    opacity: 0.1;
    transform: scale(1);
  }
}

/* ----------------------------------------
   Hero Animations
   ---------------------------------------- */

/* Content fade and slide up */
.hero-animate-in {
  opacity: 0;
  transform: translateY(30px);
}

.hero-animate-in.animate {
  animation: heroFadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes heroFadeUp {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered hero content */
.hero-content .hero-animate-in:nth-child(1) { animation-delay: 2s; }
.hero-content .hero-animate-in:nth-child(2) { animation-delay: 2.15s; }
.hero-content .hero-animate-in:nth-child(3) { animation-delay: 2.3s; }
.hero-content .hero-animate-in:nth-child(4) { animation-delay: 2.45s; }

/* Parallax scroll effect */
.parallax-element {
  will-change: transform;
  transition: transform 0.1s linear;
}

[data-parallax-speed="slow"] {
  --parallax-speed: 0.3;
}

[data-parallax-speed="medium"] {
  --parallax-speed: 0.5;
}

[data-parallax-speed="fast"] {
  --parallax-speed: 0.7;
}

/* ----------------------------------------
   Button Hover States
   ---------------------------------------- */

/* Primary button ripple */
.btn-primary {
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

/* Secondary button fill */
.btn-secondary {
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.btn-secondary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-taupe);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
  z-index: -1;
}

.btn-secondary:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}

/* Icon button bounce */
.btn-icon:hover {
  animation: iconBounce 0.4s ease;
}

@keyframes iconBounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

/* ----------------------------------------
   Card Interactions
   ---------------------------------------- */

/* Card hover lift */
.card-hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card-hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
}

/* Image zoom on hover */
.image-zoom-hover {
  overflow: hidden;
}

.image-zoom-hover img {
  transition: transform var(--transition-slow);
}

.image-zoom-hover:hover img {
  transform: scale(1.08);
}

/* ----------------------------------------
   Page Transitions
   ---------------------------------------- */

/* Fade transition */
.page-transition-fade {
  animation: pageFadeIn 0.4s ease;
}

@keyframes pageFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Slide up transition */
.page-transition-slide {
  animation: pageSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageSlideUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------------------------------
   Image Reveal Animations
   ---------------------------------------- */

/* Curtain reveal from left */
.reveal-curtain-left {
  position: relative;
  overflow: hidden;
}

.reveal-curtain-left::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-cream);
  transform: scaleX(1);
  transform-origin: right;
  z-index: 1;
}

.reveal-curtain-left.revealed::before {
  animation: curtainRevealLeft 0.8s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes curtainRevealLeft {
  0% {
    transform: scaleX(1);
    transform-origin: right;
  }
  100% {
    transform: scaleX(0);
    transform-origin: right;
  }
}

/* Curtain reveal from bottom */
.reveal-curtain-bottom {
  position: relative;
  overflow: hidden;
}

.reveal-curtain-bottom::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-taupe-light);
  transform: scaleY(1);
  transform-origin: top;
  z-index: 1;
}

.reveal-curtain-bottom.revealed::before {
  animation: curtainRevealBottom 0.8s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes curtainRevealBottom {
  0% {
    transform: scaleY(1);
    transform-origin: top;
  }
  100% {
    transform: scaleY(0);
    transform-origin: top;
  }
}

/* Scale and fade in */
.reveal-scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* ----------------------------------------
   Scroll Animations
   ---------------------------------------- */

/* Fade up on scroll */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered grid items */
.stagger-children > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.1s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.2s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.3s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.4s; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.5s; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 0.6s; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 0.7s; }

.stagger-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ----------------------------------------
   Loading Animations
   ---------------------------------------- */

/* Pulse loading */
.loading-pulse {
  animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

/* Dots loading */
.loading-dots {
  display: flex;
  gap: var(--space-2);
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background-color: var(--color-taupe);
  border-radius: 50%;
  animation: dotsLoading 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotsLoading {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ----------------------------------------
   Form Interactions
   ---------------------------------------- */

/* Input focus animation */
.input-animated {
  position: relative;
}

.input-animated::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background-color: var(--color-forest);
  transition: width 0.3s ease, left 0.3s ease;
}

.input-animated:focus-within::after {
  width: 100%;
  left: 0;
}

/* Checkbox check animation */
.checkbox-animated {
  position: relative;
}

.checkbox-animated input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.checkbox-animated input[type="checkbox"]:checked {
  background-color: var(--color-charcoal);
  border-color: var(--color-charcoal);
}

.checkbox-animated .checkmark {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  pointer-events: none;
}

.checkbox-animated .checkmark path {
  stroke: var(--color-cream);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.2s ease;
}

.checkbox-animated input[type="checkbox"]:checked + .checkmark path {
  stroke-dashoffset: 0;
}

/* ----------------------------------------
   Toast Animations
   ---------------------------------------- */

/* Toast enter */
.toast-enter {
  animation: toastEnter 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes toastEnter {
  0% {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Toast exit */
.toast-exit {
  animation: toastExit 0.3s ease forwards;
}

@keyframes toastExit {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ----------------------------------------
   Modal Animations
   ---------------------------------------- */

/* Backdrop fade */
.modal-backdrop-animate {
  animation: backdropFade 0.3s ease;
}

@keyframes backdropFade {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Modal scale in */
.modal-animate {
  animation: modalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ----------------------------------------
   Micro-interactions
   ---------------------------------------- */

/* Heart favorite animation */
.heart-animate {
  transition: transform 0.2s ease;
}

.heart-animate:active {
  transform: scale(0.85);
}

.heart-animate.favorited {
  animation: heartPop 0.4s ease;
}

@keyframes heartPop {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(0.95);
  }
  75% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Add to cart animation */
.add-to-cart-animate {
  position: relative;
}

.add-to-cart-animate.added::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background-color: var(--color-forest);
  border-radius: 50%;
  animation: cartPulse 0.6s ease forwards;
}

@keyframes cartPulse {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

/* Count increment animation */
.count-animate {
  display: inline-block;
}

.count-animate.increment {
  animation: countBump 0.3s ease;
}

@keyframes countBump {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

/* ----------------------------------------
   Reduced Motion Override
   ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }

  .svg-path-draw {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }

  .svg-fill-reveal {
    fill-opacity: 1;
  }

  .hero-animate-in,
  .animate-on-scroll,
  .stagger-children > *,
  .reveal-scale {
    opacity: 1;
    transform: none;
  }

  .parallax-element {
    transform: none !important;
  }
}
