/**
 * OSHAC USA - Animation Keyframes
 * CSS animations for micro-interactions and effects
 */

/* ========================================
   FADE 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 fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* ========================================
   SLIDE ANIMATIONS
   ======================================== */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   SCALE ANIMATIONS
   ======================================== */
@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes scaleUp {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.05);
    }
}

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

/* ========================================
   ROTATE ANIMATIONS
   ======================================== */
@keyframes rotate360 {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes swing {
    0%, 100% {
        transform: rotate(0deg);
    }
    20% {
        transform: rotate(15deg);
    }
    40% {
        transform: rotate(-10deg);
    }
    60% {
        transform: rotate(5deg);
    }
    80% {
        transform: rotate(-5deg);
    }
}

/* ========================================
   BOUNCE ANIMATIONS
   ======================================== */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* ========================================
   SHAKE ANIMATION (For Error States)
   ======================================== */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

/* ========================================
   FLOATING ANIMATIONS
   ======================================== */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes floatSlow {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(10px, -10px);
    }
    50% {
        transform: translate(0, -20px);
    }
    75% {
        transform: translate(-10px, -10px);
    }
}

/* ========================================
   GLOW ANIMATION
   ======================================== */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(0, 0, 128, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 0, 255, 0.8);
    }
}

@keyframes textGlow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(0, 0, 128, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(0, 0, 255, 1);
    }
}

/* ========================================
   GRADIENT ANIMATION
   ======================================== */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* ========================================
   LOADING ANIMATIONS
   ======================================== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* ========================================
   WAVE ANIMATION
   ======================================== */
@keyframes wave {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ========================================
   REVEAL ANIMATIONS
   ======================================== */
@keyframes reveal {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

@keyframes revealUp {
    from {
        clip-path: inset(100% 0 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

/* ========================================
   UTILITY ANIMATION CLASSES
   ======================================== */

/* Fade Utilities */
.animate-fade-in {
    animation: fadeIn 0.6s var(--ease-out) forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.8s var(--ease-out) forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.8s var(--ease-out) forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.8s var(--ease-out) forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.8s var(--ease-out) forwards;
}

/* Slide Utilities */
.animate-slide-in-up {
    animation: slideInUp 0.6s var(--ease-out) forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.6s var(--ease-out) forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.6s var(--ease-out) forwards;
}

/* Scale Utilities */
.animate-scale-in {
    animation: scaleIn 0.5s var(--ease-spring) forwards;
}

.animate-bounce-in {
    animation: bounceIn 0.8s var(--ease-out) forwards;
}

/* Continuous Animations */
.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

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

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

/* Hover Animations */
.hover-bounce:hover {
    animation: bounce 0.6s;
}

.hover-shake:hover {
    animation: shake 0.5s;
}

.hover-rotate:hover {
    animation: rotate360 0.6s var(--ease-out);
}

.hover-swing:hover {
    animation: swing 0.6s;
}

/* ========================================
   STAGGER DELAYS (For Sequential 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; }
.stagger-7 { animation-delay: 0.7s; }
.stagger-8 { animation-delay: 0.8s; }

/* ========================================
   BACKGROUND ANIMATIONS
   ======================================== */
.bg-gradient-animated {
    background: linear-gradient(270deg, #000080, #0000FF, #00BFFF);
    background-size: 600% 600%;
    animation: gradientShift 15s ease infinite;
}

/* Floating Shapes Background */
.floating-shapes {
    position: relative;
    overflow: hidden;
}

.floating-shapes::before,
.floating-shapes::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(0, 0, 128, 0.05);
    animation: floatSlow 20s ease-in-out infinite;
}

.floating-shapes::before {
    top: 10%;
    left: 10%;
}

.floating-shapes::after {
    bottom: 10%;
    right: 10%;
    animation-delay: 10s;
    animation-duration: 25s;
}

/* ========================================
   SCROLL-TRIGGERED ANIMATIONS
   (Used with JavaScript IntersectionObserver)
   ======================================== */
.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s var(--ease-out),
                transform 0.8s var(--ease-out);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.8s var(--ease-out),
                transform 0.8s var(--ease-out);
}

.scroll-reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.8s var(--ease-out),
                transform 0.8s var(--ease-out);
}

.scroll-reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.8s var(--ease-out),
                transform 0.8s var(--ease-spring);
}

.scroll-reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* ========================================
   BUTTON HOVER EFFECTS
   ======================================== */
.btn-hover-slide {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-hover-slide::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: white;
    transition: left 0.4s var(--ease-out);
    z-index: -1;
}

.btn-hover-slide:hover::before {
    left: 0;
}

.btn-hover-glow:hover {
    animation: glow 1.5s ease-in-out infinite;
}

/* ========================================
   TEXT ANIMATIONS
   ======================================== */
.typing-effect {
    overflow: hidden;
    border-right: 0.15em solid var(--navy-primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end),
               blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--navy-primary);
    }
}

/* ========================================
   PAGE TRANSITIONS
   ======================================== */
.page-transition-enter {
    animation: fadeIn 0.5s var(--ease-out);
}

.page-transition-exit {
    animation: fadeIn 0.5s var(--ease-in) reverse;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {
    /* Reduce animation intensity on mobile */
    .animate-float {
        animation: float 4s ease-in-out infinite;
    }

    .floating-shapes::before,
    .floating-shapes::after {
        width: 200px;
        height: 200px;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Disable animations for users who prefer reduced motion */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
