/* ==========================================
   ANIMATIONS AVANCÉES - SCROLLING & 3D EFFECTS
   ========================================== */

/* Variables d'animation */
:root {
    --easing-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --easing-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --animation-duration: 0.6s;
}

/* ========== KEYFRAME - TEXT CHAR REVEAL ==========*/
@keyframes textCharReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 3D TEXT EFFECTS - HERO TITLE ==========*/

.hero-title-3d-wrapper {
    perspective: 1000px;
    overflow: visible;
    display: inline-block;
    position: relative;
}

.hero-title-3d {
    transform-style: preserve-3d;
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    position: relative;
    flex-wrap: wrap;
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
}

.hero-title-3d span {
    display: inline-block;
    color: white;
    filter: drop-shadow(0 2px 8px rgba(33, 92, 202, 0.3));
    text-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.3);
    font-weight: 800;
    letter-spacing: 2px;
}

.hero-title-3d:after {
    display: none !important;
}

.hero-title-3d:hover span {
    filter: drop-shadow(0 2px 12px rgba(33, 92, 202, 0.5));
    text-shadow: 
        0 2px 15px rgba(33, 92, 202, 0.5),
        0 0 20px rgba(255, 255, 255, 0.3);
}

.text-3d {
    display: block;
    perspective: 1000px;
    transform-style: preserve-3d;
    transition: all 0.3s ease;
    position: relative;
    letter-spacing: 2px;
    font-weight: 800;
    color: #ffffff;
    filter: drop-shadow(0 0 20px rgba(33, 92, 202, 0.4)) drop-shadow(0 0 10px rgba(108, 99, 255, 0.2));
    text-shadow: 
        0 0 15px rgba(33, 92, 202, 0.4),
        0 0 25px rgba(108, 99, 255, 0.3),
        2px 2px 10px rgba(0, 0, 0, 0.2);
    -webkit-text-stroke: 0.5px rgba(33, 92, 202, 0.2);
}

.text-3d::before {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    color: rgba(255, 255, 255, 0.8);
    transform: translateZ(-20px) translateX(2px) translateY(2px);
    filter: blur(1px);
    opacity: 0.9;
    font-weight: 800;
    letter-spacing: 2px;
}

.text-3d::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    color: rgba(255, 255, 255, 0.5);
    transform: translateZ(-40px) translateX(4px) translateY(4px);
    filter: blur(2px);
    opacity: 0.7;
    font-weight: 800;
    letter-spacing: 2px;
}

@keyframes hero3DFloat {
    0%, 100% {
        transform: translateY(0px) rotateX(0deg) rotateY(0deg);
    }
    25% {
        transform: translateY(-15px) rotateX(5deg) rotateY(-5deg);
    }
    50% {
        transform: translateY(-30px) rotateX(0deg) rotateY(0deg);
    }
    75% {
        transform: translateY(-15px) rotateX(-5deg) rotateY(5deg);
    }
}

.hero-title-3d:hover .text-3d {
    filter: drop-shadow(0 0 50px rgba(33, 92, 202, 0.9)) drop-shadow(0 0 80px rgba(108, 99, 255, 0.6)) drop-shadow(0 0 100px rgba(33, 92, 202, 0.4));
    text-shadow: 
        0 0 40px rgba(33, 92, 202, 0.9),
        0 0 80px rgba(108, 99, 255, 0.6),
        0 10px 40px rgba(33, 92, 202, 0.4),
        0 0 20px rgba(255, 255, 255, 0.5);
}

/* ========== ANIMATIONS GÉNÉRALES ==========*/

/* Scroll Indicator Progress Bar */
.scroll-indicator {
    background: linear-gradient(90deg, #215cca, #6c63ff, #f31212) !important;
    background-size: 200% 100%;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% center; }
    50% { background-position: 100% center; }
    100% { background-position: 0% center; }
}

/* ========== ANIMATIONS AU SCROLLING ==========*/

/* Style visible pour data-aos */
[data-aos] {
    opacity: 0;
    animation: fadeInUp var(--animation-duration) ease-out forwards;
}

[data-aos].visible {
    opacity: 1 !important;
}

/* Différentes animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleInUp {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(40px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ========== ANIMATIONS DES SECTIONS ==========*/

/* Hero Section Enhancements */
.hero-section {
    position: relative;
    isolation: isolate;
}

.hero-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(33, 92, 202, 0.1), transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(108, 99, 255, 0.1), transparent 50%);
    animation: gradientPulse 8s ease-in-out infinite;
    z-index: 0;
}

@keyframes gradientPulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

.hero-badge {
    animation: badgeFloat 3s ease-in-out infinite !important;
}

@keyframes badgeFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.hero-title {
    animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        text-shadow: 0 2px 10px rgba(0,0,0,0.3);
        letter-spacing: 0px;
    }
    50% {
        text-shadow: 0 0 20px rgba(33, 92, 202, 0.4);
        letter-spacing: 2px;
    }
}

.stats-card {
    transition: all 0.4s var(--easing-bounce);
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
    z-index: 1;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.stats-card:hover {
    transform: translateY(-15px) rotateY(5deg);
    box-shadow: 0 25px 50px rgba(33, 92, 202, 0.2);
}

.stats-icon {
    font-size: 2.5rem;
    animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

.stats-number {
    animation: countUp 1s ease-out;
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== ANIMATIONS DES ENTITÉS ==========*/

.entity-content {
    animation: slideInLeft 0.8s var(--easing-smooth) forwards;
}

.entity-image {
    animation: slideInRight 0.8s var(--easing-smooth) forwards;
    position: relative;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-60px) skewX(10deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) skewX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(60px) skewX(-10deg);
    }
    to {
        opacity: 1;
        transform: translateX(0) skewX(0);
    }
}

.entity-image img {
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: brightness(1);
}

.entity-image img:hover {
    filter: brightness(1.15) drop-shadow(0 0 20px rgba(33, 92, 202, 0.4));
    transform: scale(1.08) perspective(1000px) rotateY(8deg);
}

/* ========== ANIMATIONS DES FEATURES ==========*/

.feature-icon {
    animation: featureIconAppear 0.6s var(--easing-smooth) backwards;
    transition: all 0.4s var(--easing-bounce);
}

.feature-icon:nth-child(1) { animation-delay: 0.1s; }
.feature-icon:nth-child(2) { animation-delay: 0.2s; }
.feature-icon:nth-child(3) { animation-delay: 0.3s; }
.feature-icon:nth-child(4) { animation-delay: 0.4s; }

@keyframes featureIconAppear {
    from {
        opacity: 0;
        transform: scale(0.3) rotate(-180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.feature-icon:hover {
    animation: featureIconHover 0.6s ease;
    color: #6c63ff !important;
}

@keyframes featureIconHover {
    0%, 100% {
        transform: rotateY(0deg) scale(1);
    }
    50% {
        transform: rotateY(360deg) scale(1.2);
    }
}

/* ========== ANIMATIONS DES BOUTONS ==========*/

.btn {
    transition: all 0.4s var(--easing-bounce);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    z-index: -1;
}

.btn:hover::before {
    width: 400px;
    height: 400px;
}

.btn:hover {
    transform: translateY(-5px);
    letter-spacing: 1px;
}

.btn:active {
    transform: translateY(-2px);
}

/* ========== ANIMATIONS DES ONGLETS ==========*/

.nav-pills .nav-link {
    transition: all 0.4s var(--easing-bounce);
    position: relative;
    overflow: hidden;
}

.nav-pills .nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -100%;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: left 0.4s var(--easing-bounce);
    z-index: 1;
}

.nav-pills .nav-link:hover::before,
.nav-pills .nav-link.active::before {
    left: 0;
}

.tab-pane {
    animation: tabFadeIn 0.5s var(--easing-smooth) forwards;
}

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== PARALLAX EFFECT SUPPORT ==========*/

[data-parallax] {
    position: relative;
    z-index: 1;
    will-change: transform;
}

/* ========== ANIMATIONS D'ENTRÉE EN CASCADES ==========*/

.animate-up {
    animation: animateUp 0.7s var(--easing-smooth) backwards;
}

.animate-up:nth-child(1) { animation-delay: 0.1s; }
.animate-up:nth-child(2) { animation-delay: 0.2s; }
.animate-up:nth-child(3) { animation-delay: 0.3s; }
.animate-up:nth-child(4) { animation-delay: 0.4s; }
.animate-up:nth-child(5) { animation-delay: 0.5s; }
.animate-up:nth-child(6) { animation-delay: 0.6s; }
.animate-up:nth-child(7) { animation-delay: 0.7s; }
.animate-up:nth-child(8) { animation-delay: 0.8s; }

@keyframes animateUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========== ANIMATIONS DE TEXTE ==========*/

h1, h2, h3 {
    position: relative;
}

h1::after, h2::after, h3::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s var(--easing-smooth);
}

h1:hover::after, h2:hover::after, h3:hover::after {
    width: 100%;
}

/* ========== ANIMATIONS RESPONSIVES ==========*/

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ========== ANIMATIONS POUR PETITS ÉCRANS ==========*/

@media (max-width: 768px) {
    .entity-content,
    .entity-image {
        animation: fadeInUp 0.6s var(--easing-smooth) forwards;
    }
    
    .stats-card {
        animation: fadeInUp 0.6s var(--easing-smooth) backwards;
    }
    
    .btn {
        animation: fadeInUp 0.6s var(--easing-smooth) backwards;
    }
}

/* ========== ANIMATIONS POUR 3D EFFECTS ==========*/

.three-js-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* Amélioration du rendu WebGL */
canvas {
    display: block;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ========== STATE-BASED ANIMATIONS ==========*/

body.scrolling-down .hero-badge {
    animation-play-state: running;
}

/* Performance optimizations */
.animate-up,
[data-aos],
.hero-badge,
.stats-card,
.btn {
    transform: translateZ(0);
    will-change: auto;
}

.stats-card:hover,
.btn:hover,
.entity-image img:hover {
    will-change: transform;
}
