﻿/**
 * Animations CSS file for Blankemeier Website
 * 
 * This file contains all animations and transitions using 
 * a modern, performance-optimized approach:
 * - Fade and transform effects for sections
 * - Staggered animations for lists of elements
 * - Timeline-specific animations
 * - Interactive element animations (hover, active states)
 */

/* ===== Core Animation Variables ===== */
:root {
    --animation-duration: 0.8s;
    --animation-easing: cubic-bezier(0.25, 0.1, 0.25, 1);
    --animation-distance: 30px;
    --stagger-delay: 0.15s;
  }
  
  /* ===== Base Animation Classes ===== */
  
  /* Universal fade animation base */
  .fade-in,
  [data-animate] {
    opacity: 0;
    transform: translateY(var(--animation-distance));
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
    will-change: opacity, transform;
  }
  
  /* Animation active states */
  .fade-in.visible,
  [data-animate].animate-visible {
    opacity: 1;
    transform: translateY(0);
  }
  
  /* ===== Section Header Animation ===== */
  .section-header {
    opacity: 0;
    transform: translateY(var(--animation-distance));
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
  }
  
  .section-header.animate {
    opacity: 1;
    transform: translateY(0);
  }
  
  /* Section header underline animation */
  .section-header h2::after {
    transform: translateX(-50%) scaleX(0);
    transform-origin: center;
    transition: transform 0.6s var(--animation-easing);
    will-change: transform;
  }
  
  .section-header.animate h2::after {
    transform: translateX(-50%) scaleX(1);
    transition-delay: 0.3s;
  }
  
  /* ===== Direction Variations ===== */
  
  /* Upward animation */
  [data-animate="fade-up"] {
    transform: translateY(var(--animation-distance));
  }
  
  /* Downward animation */
  [data-animate="fade-down"] {
    transform: translateY(calc(var(--animation-distance) * -1));
  }
  
  /* Rightward animation */
  [data-animate="fade-left"] {
    transform: translateX(var(--animation-distance));
  }
  
  /* Leftward animation */
  [data-animate="fade-right"] {
    transform: translateX(calc(var(--animation-distance) * -1));
  }
  
  /* ===== Staggered Delays ===== */
  
  /* Service items and other lists use staggered delays */
  [data-animate-delay="100"],
  .service-item:nth-child(1) {
    transition-delay: calc(var(--stagger-delay) * 0);
  }
  
  [data-animate-delay="200"],
  .service-item:nth-child(2) {
    transition-delay: calc(var(--stagger-delay) * 1);
  }
  
  [data-animate-delay="300"],
  .service-item:nth-child(3) {
    transition-delay: calc(var(--stagger-delay) * 2);
  }
  
  [data-animate-delay="400"],
  .service-item:nth-child(4) {
    transition-delay: calc(var(--stagger-delay) * 3);
  }
  
  [data-animate-delay="500"],
  .service-item:nth-child(5) {
    transition-delay: calc(var(--stagger-delay) * 4);
  }
  
  [data-animate-delay="600"],
  .service-item:nth-child(6) {
    transition-delay: calc(var(--stagger-delay) * 5);
  }
  
  [data-animate-delay="700"],
  .service-item:nth-child(7) {
    transition-delay: calc(var(--stagger-delay) * 6);
  }
  
  [data-animate-delay="800"],
  .service-item:nth-child(8) {
    transition-delay: calc(var(--stagger-delay) * 7);
  }
  
  [data-animate-delay="900"],
  .service-item:nth-child(9) {
    transition-delay: calc(var(--stagger-delay) * 8);
  }
  
  /* ===== Timeline Animation ===== */
  
  .timeline-item {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
  }
  
  .timeline-item:nth-child(even) {
    transform: translateX(30px);
  }
  
  .timeline-item.visible,
  .timeline-item.fade-in.visible {
    opacity: 1;
    transform: translateX(0);
  }
  
  /* Staggered timeline items */
  .timeline-item:nth-child(1) {
    transition-delay: 0s;
  }
  
  .timeline-item:nth-child(2) {
    transition-delay: 0.1s;
  }
  
  .timeline-item:nth-child(3) {
    transition-delay: 0.2s;
  }
  
  .timeline-item:nth-child(4) {
    transition-delay: 0.3s;
  }
  
  /* Timeline image hover effect */
  .timeline-image img {
    transition: transform 0.5s ease;
  }
  
  .timeline-item:hover .timeline-image img {
    transform: scale(1.05);
  }
  
  /* ===== Service Items Animation ===== */
  
  .service-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .service-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  }
  
  .service-icon {
    transition: transform 0.3s ease, color 0.3s ease;
  }
  
  .service-item:hover .service-icon {
    transform: scale(1.25);
    color: var(--secondary-color, #E67E22);
  }

  .service-link:hover, 
  .service-link:focus {
    transform: translateY(-2px);
  }
  
  /* ===== Gallery Items Animation ===== */
  
  .gallery-item {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease,
                transform 0.6s ease,
                box-shadow 0.3s ease;
  }
  
  .gallery-item.visible {
    opacity: 1;
    transform: scale(1);
  }
  
  .gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  }
  
  /* ===== Hero Section Animation ===== */

  .hero h1 {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    transition-delay: 0.3s;
  }
  
  .hero h2 {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    transition-delay: 0.6s;
  }
  
  .hero .cta-buttons {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    transition-delay: 0.9s;
  }
  
  .hero.visible h1,
  .hero.visible h2,
  .hero.visible .cta-buttons {
    opacity: 1;
    transform: translateY(0);
  }
  
  /* ===== Back to Top Button ===== */
  
  .back-to-top {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease,
                transform 0.3s ease,
                background-color 0.3s ease;
  }
  
  .back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
  }
  
  .back-to-top:hover {
    background-color: var(--secondary-color-dark, #d35400);
    transform: translateY(-3px);
  }
  
  /* ===== Partner Items Animation ===== */
  
  .partner-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .partner-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  }
  
  .partner-item img {
    transition: opacity 0.3s ease;
  }
  
  .partner-item:hover img {
    transform: scale(1.1);
  }
  
  .partner-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .partner-item:hover .partner-overlay {
    opacity: 1;
  }
  
  /* ===== Form Interactions ===== */
  
  .form-group input,
  .form-group textarea {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
  }
  
  .form-group input:focus,
  .form-group textarea:focus {
    border-color: var(--secondary-color, #E67E22);
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.2);
  }
  
  /* Form validation animations */
  @keyframes shake {
    0%, 100% {transform: translateX(0);}
    10%, 30%, 50%, 70%, 90% {transform: translateX(-5px);}
    20%, 40%, 60%, 80% {transform: translateX(5px);}
  }
  
  .form-error {
    animation: shake 0.6s ease;
  }
  
  /* Submit button ripple effect */
  .btn {
    position: relative;
    overflow: hidden;
  }
  
  .btn:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
  }
  
  .btn:focus-visible:not(:active)::after {
    animation: ripple 0.8s ease-out;
  }
  
  @keyframes ripple {
    0% {
      transform: scale(0, 0);
      opacity: 0.5;
    }
    20% {
      transform: scale(25, 25);
      opacity: 0.3;
    }
    100% {
      opacity: 0;
      transform: scale(40, 40);
    }
  }
  
  /* ===== Loading Animation ===== */
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  .loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
  }
  
  /* ===== Mobile Menu Animation ===== */
  
  .mobile-menu-toggle {
    transition: transform 0.3s ease;
  }
  
  .mobile-menu-toggle .bar {
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  
  .mobile-menu-toggle.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  
  .mobile-menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
  }
  
  .mobile-menu-toggle.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }
  
  /* ===== Media Queries for Animation Adjustments ===== */
  
  @media (max-width: 768px) {
    :root {
      --animation-distance: 20px;
      --animation-duration: 0.6s;
    }
    
    /* Simplify animations on mobile for better performance */
    .partner-item:hover {
      transform: translateY(-3px);
    }
    
    .service-item:hover {
      transform: translateY(-3px);
    }
  }
  
  @media (prefers-reduced-motion: reduce) {
    /* Respect user preferences for reduced motion */
    *,
    *::before,
    *::after {
      animation-duration: 0.001ms !important;
      animation-delay: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
      transition-delay: 0.001ms !important;
      scroll-behavior: auto !important;
    }

    .fade-in,
    [data-animate],
    .timeline-item,
    .section-header {
      opacity: 1;
      transform: none;
    }
  }
