/**
 * Chemistry Hub - Animations & Utilities
 */

/* =====================================================
   Animations
   ===================================================== */
@keyframes ch-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ch-fade-in-right {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes ch-scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes ch-float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(5deg);
    }
}

@keyframes ch-pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes ch-pulse-glow {
    0%, 100% {
        opacity: 0.6;
        box-shadow: var(--ch-molecule-glow);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 40px hsl(152 76% 40% / 0.6);
    }
}

@keyframes ch-spin-slow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes ch-bounce-subtle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Animation Classes */
.ch-animate-fade-in {
    animation: ch-fade-in 0.6s ease-out forwards;
}

.ch-animate-fade-in-right {
    animation: ch-fade-in-right 0.6s ease-out forwards;
}

.ch-animate-scale-in {
    animation: ch-scale-in 0.4s ease-out forwards;
}

.ch-animate-float {
    animation: ch-float 6s ease-in-out infinite;
}

.ch-animate-float-delayed {
    animation: ch-float 6s ease-in-out infinite 2s;
}

.ch-animate-pulse-glow {
    animation: ch-pulse-glow 3s ease-in-out infinite;
}

.ch-animate-spin-slow {
    animation: ch-spin-slow 20s linear infinite;
}

.ch-animate-bounce-subtle {
    animation: ch-bounce-subtle 2s ease-in-out infinite;
}

/* Staggered Animation Delays */
.ch-animation-delay-100 { animation-delay: 0.1s; }
.ch-animation-delay-200 { animation-delay: 0.2s; }
.ch-animation-delay-300 { animation-delay: 0.3s; }
.ch-animation-delay-400 { animation-delay: 0.4s; }
.ch-animation-delay-500 { animation-delay: 0.5s; }
.ch-animation-delay-600 { animation-delay: 0.6s; }

/* Scroll Animation */
.ch-scroll-animate {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

/* Initial hidden state - only applied when JS is ready */
.ch-scroll-animate.ch-hidden {
    opacity: 0;
    transform: translateY(30px);
}

.ch-scroll-animate.ch-animated,
.ch-scroll-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =====================================================
   Responsive Utilities
   ===================================================== */
.ch-hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .ch-hide-mobile {
        display: block;
    }
}

.ch-hide-desktop {
    display: block;
}

@media (min-width: 768px) {
    .ch-hide-desktop {
        display: none;
    }
}

/* =====================================================
   Text Utilities
   ===================================================== */
.ch-text-center { text-align: center; }
.ch-text-right { text-align: right; }
.ch-text-left { text-align: left; }

.ch-line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ch-line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ch-line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =====================================================
   Spacing Utilities
   ===================================================== */
.ch-mb-0 { margin-bottom: 0; }
.ch-mb-1 { margin-bottom: 0.25rem; }
.ch-mb-2 { margin-bottom: 0.5rem; }
.ch-mb-3 { margin-bottom: 0.75rem; }
.ch-mb-4 { margin-bottom: 1rem; }
.ch-mb-6 { margin-bottom: 1.5rem; }
.ch-mb-8 { margin-bottom: 2rem; }

.ch-mt-0 { margin-top: 0; }
.ch-mt-4 { margin-top: 1rem; }
.ch-mt-6 { margin-top: 1.5rem; }
.ch-mt-8 { margin-top: 2rem; }

/* =====================================================
   Elementor Editor Styles
   ===================================================== */
.elementor-editor-active .ch-widget {
    min-height: 100px;
}

.elementor-editor-active .ch-navbar {
    position: relative;
}

/* Ensure all content is visible in Elementor editor */
.elementor-editor-active .ch-scroll-animate,
.elementor-editor-active .ch-hero-content,
.elementor-editor-active .ch-categories-header,
.elementor-editor-active .ch-courses-header,
.elementor-editor-active .ch-why-us-content,
.elementor-editor-active .ch-about-hero-content {
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* Ensure hero content is visible above molecules */
.elementor-editor-active .ch-hero-grid,
.elementor-editor-active .ch-container {
    position: relative;
    z-index: 10;
}

/* Full width widgets in Elementor */
.elementor-widget-wrap > .elementor-element {
    width: 100%;
}

/* Fix Elementor Icon Rendering in Buttons */
.ch-btn-primary .elementor-icon,
.ch-btn-secondary .elementor-icon,
.ch-hero-buttons .elementor-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
}

.ch-btn-primary .elementor-icon svg,
.ch-btn-secondary .elementor-icon svg,
.ch-hero-buttons .elementor-icon svg,
.ch-hero-buttons a svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    max-width: 1.25rem !important;
    max-height: 1.25rem !important;
}

.ch-btn-primary .elementor-icon i,
.ch-btn-secondary .elementor-icon i,
.ch-hero-buttons .elementor-icon i,
.ch-hero-buttons a i {
    font-size: 1.25rem !important;
    line-height: 1 !important;
}

/* Global Customization Variables */
.ch-global-custom {
    --ch-primary: var(--ch-custom-primary, hsl(222 60% 22%));
    --ch-secondary: var(--ch-custom-secondary, hsl(152 76% 40%));
    --ch-accent: var(--ch-custom-accent, hsl(152 76% 40%));
    --ch-background: var(--ch-custom-background, hsl(210 40% 98%));
    --ch-foreground: var(--ch-custom-text, hsl(222 47% 11%));
    --ch-muted-foreground: var(--ch-custom-muted, hsl(215 16% 47%));
    font-family: var(--ch-custom-font-family, 'Cairo', sans-serif);
}

.ch-global-custom .ch-custom-heading-font {
    font-family: var(--ch-custom-heading-font-family, 'Cairo', sans-serif) !important;
}

/* Custom Font Classes */
.ch-font-primary {
    font-family: var(--ch-custom-font-family, 'Cairo', sans-serif) !important;
}

.ch-font-heading {
    font-family: var(--ch-custom-heading-font-family, 'Cairo', sans-serif) !important;
}

/* Custom Color Classes */
.ch-color-primary {
    color: var(--ch-custom-primary, hsl(222 60% 22%)) !important;
}

.ch-color-secondary {
    color: var(--ch-custom-secondary, hsl(152 76% 40%)) !important;
}

.ch-color-accent {
    color: var(--ch-custom-accent, hsl(152 76% 40%)) !important;
}

.ch-color-background {
    background-color: var(--ch-custom-background, hsl(210 40% 98%)) !important;
}

.ch-color-text {
    color: var(--ch-custom-text, hsl(222 47% 11%)) !important;
}

.ch-color-muted {
    color: var(--ch-custom-muted, hsl(215 16% 47%)) !important;
}
