/* Custom CSS for MathTime by Alka Ma'am */

/* Inter Font (already linked in HTML, but good to have here for reference) */
body {
    font-family: 'Inter', sans-serif;
}

/* Background pattern for Hero Section */
.bg-pattern {
    background-image: url('data:image/svg+xml,%3Csvg width="6" height="6" viewBox="0 0 6 6" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="%23ffffff" fill-opacity="0.1" fill-rule="evenodd"%3E%3Cpath d="M5 0h1L0 6V5zm1 6v-1L1 0h1L6 5z"/%3E%3C/g%3E%3C/svg%3E');
}

/* --- Animation Keyframes --- */

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide In Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide In Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* --- Animation Classes (applied by JS on scroll or directly on load) --- */

/* Base class for elements that will be animated */
.animate-on-scroll {
    opacity: 0; /* Start hidden */
    transition: opacity 0.6s ease-out, transform 0.6s ease-out; /* Smooth transition for non-animated state */
}

/* When 'is-visible' class is added, apply the animation */
.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1); /* Reset transform */
}

/* Specific animation types */
.fade-in-up.is-visible {
    animation: fadeInUp 0.8s ease-out forwards;
}

.slide-in-left.is-visible {
    animation: slideInLeft 0.8s ease-out forwards;
}

.slide-in-right.is-visible {
    animation: slideInRight 0.8s ease-out forwards;
}

.scale-in.is-visible {
    animation: scaleIn 0.8s ease-out forwards;
}

.fade-in.is-visible {
    animation: fadeIn 0.8s ease-out forwards;
}

/* Initial load animations for Hero Section */
.hero-animate-text {
    animation: slideInLeft 1s ease-out forwards;
    animation-delay: 0.2s; /* Delay for text */
    opacity: 0; /* Start hidden */
}

.hero-animate-image {
    animation: slideInRight 1s ease-out forwards;
    animation-delay: 0.4s; /* Delay for image */
    opacity: 0; /* Start hidden */
}

.hero-animate-buttons a,
.hero-animate-buttons button {
    animation: fadeInUp 0.8s ease-out forwards;
    opacity: 0; /* Start hidden */
}

.hero-animate-buttons a:nth-child(1) { animation-delay: 0.6s; }
.hero-animate-buttons a:nth-child(2) { animation-delay: 0.8s; }
.hero-animate-buttons button:nth-child(3) { animation-delay: 1s; }

/* Staggered delays for cards/items */
.grid > div.animate-on-scroll.is-visible:nth-child(1) { animation-delay: 0.1s; }
.grid > div.animate-on-scroll.is-visible:nth-child(2) { animation-delay: 0.2s; }
.grid > div.animate-on-scroll.is-visible:nth-child(3) { animation-delay: 0.3s; }
.grid > div.animate-on-scroll.is-visible:nth-child(4) { animation-delay: 0.4s; }
.grid > div.animate-on-scroll.is-visible:nth-child(5) { animation-delay: 0.5s; }
.grid > div.animate-on-scroll.is-visible:nth-child(6) { animation-delay: 0.6s; }
/* Add more as needed for larger grids */

/* For section titles */
.section-title.is-visible {
    animation: fadeInUp 1s ease-out forwards;
}

/* Responsive Video Embeds */
.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio (height / width = 9 / 16 = 0.5625) */
    height: 0;
    overflow: hidden;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Performance Optimizations */
img {
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
}

/* Reduce CLS (Cumulative Layout Shift) */
.hero-section {
    min-height: 100vh;
    contain: layout size;
}

/* Optimize animations for performance */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Improve First Contentful Paint */
.critical-content {
    display: block;
    content-visibility: auto;
}