/*==================================================
 * PAGE TRANSITIONS & MODERN LOADER SYSTEM
 * 
 * Professional page transition system with custom SVG loader
 * Features smooth blur effects, backdrop filtering, and seamless
 * navigation between pages without white flashes.
 * 
 * @author: Naery Development Team
 * @version: 1.0
 * @dependencies: Custom loader.svg, cubic-bezier transitions
 *==================================================*/

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
    /* Transition timing - plus rapide et plus fluide */
    --transition-duration: 0.6s;
    
    /* Brand colors for loader overlay - aligner avec les couleurs du site */
    --loader-primary: #7b1fa2;    /* Primary violet du site */
    --loader-secondary: #4527a0;  /* Secondary violet foncé du site */
    --loader-accent: #ae52d4;     /* Light accent violet du site */
    --loader-glass-bg: rgba(25, 25, 45, 0.2); /* Glass background ultra-transparent */
    --loader-glass-border: rgba(230, 230, 255, 0.1); /* Glass border with léger halo */
}

/* ===== MAIN TRANSITION OVERLAY ===== */
/**
 * Full-screen overlay that appears during page transitions
 * Features gradient background with backdrop blur for modern glass effect
 * Uses high z-index to ensure it appears above all other content
 */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* Fond ultra-transparent basé sur les couleurs du site Naery */
    background: radial-gradient(circle at center, rgba(123, 31, 162, 0.08) 0%, rgba(69, 39, 160, 0.1) 40%, rgba(69, 39, 160, 0.08) 80%);
    box-shadow: inset 0 0 250px rgba(123, 31, 162, 0.08);
    
    /* Enhanced modern glass effect with subtle blur */
    backdrop-filter: blur(12px) saturate(110%);
    -webkit-backdrop-filter: blur(12px) saturate(110%); /* Safari support */
    
    /* Ensure overlay appears above all content */
    z-index: 9999;
    
    /* Center the loader content */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    
    /* Smooth transitions with custom easing curve */
    transition: all var(--transition-duration) cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity var(--transition-duration) cubic-bezier(0.25, 0.46, 0.45, 0.94),
                visibility var(--transition-duration) cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/**
 * Active state - overlay becomes visible during transitions
 */
.page-transition-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== MODERN LOADER CONTAINER ===== */
/**
 * Main container for the loading animation elements
 * Includes smooth scaling transition for exit animation
 */
.modern-loader {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    
    /* Default state */
    transform: scale(1);
    
    /* Smooth transitions for entry/exit animations */
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/**
 * Exit animation for loader - subtle scale down and fade
 * Triggered when overlay is no longer active
 */
.page-transition-overlay:not(.active) .modern-loader {
    transform: scale(0.9);
    opacity: 0.7;
}

/* ===== CUSTOM SVG LOADER ===== */
/**
 * Container for the custom SVG loader with rotating border effect
 * Provides consistent sizing and centering for the loader animation
 */
.loader-svg-container {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Modern glass card effect */
    background: var(--loader-glass-bg);
    border-radius: 50%;
}

/**
 * Custom SVG loader element
 * Uses brand's custom loader.svg with white filter and pulse animation
 */
.loader-svg {
    width: 60px;
    height: 60px;
    
    /* Enhanced shadow effect */
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
    
    /* Animation combinée de rotation et pulsation pour effet plus engageant */
    animation: svgPulseRotate 6s ease-in-out infinite;
    transform-origin: center center;
}

/**
 * SVG Pulse Animation
 * Creates a subtle breathing effect for the loader SVG
 * Combines scale and opacity changes for organic feel
 */
@keyframes svgPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/**
 * Animation combinée de rotation et pulsation pour le cercle central
 * Rend l'animation plus engageante et évite l'impression de freeze
 */
@keyframes svgPulseRotate {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: scale(1.05) rotate(90deg);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.1) rotate(180deg);
        opacity: 0.8;
    }
    75% {
        transform: scale(1.05) rotate(270deg);
        opacity: 0.9;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

/**
 * Rotating border effect around SVG loader
 * Creates a subtle spinning ring to enhance the loading animation
 * Uses pseudo-element for clean markup separation
 */
/* Removed the ::before border animation in favor of the new SVG animation */

/**
 * Continuous rotation keyframes
 * Used for the rotating border effect around the loader
 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/**
 * Animation de zoom pour l'apparition du logo
 */
@keyframes zoom-in {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/**
 * Animation de pulsation pour le logo pendant le chargement
 */
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 30px rgba(230, 230, 255, 0.1); }
    50% { transform: scale(1.03); box-shadow: 0 0 35px rgba(230, 230, 255, 0.2); }
    100% { transform: scale(1); box-shadow: 0 0 30px rgba(230, 230, 255, 0.1); }
}

/**
 * Animation de fondu pour le texte presque terminé
 */
@keyframes text-glow {
    0% { opacity: 0.8; }
    50% { opacity: 1; text-shadow: 0 0 8px rgba(255, 255, 255, 0.3); }
    100% { opacity: 0.8; }
}

/* Loader Text */
.loader-text {
    color: #fff; /* Blanc pur pour un meilleur contraste */
    margin-top: 15px;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 600; /* Légèrement plus gras pour meilleure lisibilité */
    text-align: center;
    opacity: 0;
    animation: fadeInText 0.5s ease forwards 0.3s;
    letter-spacing: 1px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 4px rgba(0, 0, 0, 0.3); /* Ombre portée plus visible */
    
    /* Modern glass card effect for text container */
    background: var(--loader-glass-bg);
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--loader-glass-border);
    transition: all 0.3s ease;
}

/* Animation pour le texte quand le chargement est presque terminé */
.loader-text.loading-almost-complete {
    animation: text-glow 1s ease-in-out infinite;
    color: #ffffff;
    letter-spacing: 1.2px;
}

@keyframes fadeInText {
    to {
        opacity: 1;
    }
}

/* Progress Bar */
.loader-progress {
    width: 280px;
    height: 18px;
    background: rgba(20, 10, 30, 0.5);
    border-radius: 25px;
    overflow: hidden;
    position: relative;
    
    /* Enhanced glass effect for progress bar */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2), inset 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 15px;
    padding: 3px;
}

.loader-progress-bar {
    height: 100%;
    /* Utilisation du violet principal du site Naery */
    background: var(--color-primary); /* #7b1fa2 */
    border-radius: 30px; /* Coins plus arrondis pour un style plus friendly */
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    
    /* Elegant shine effect */
    overflow: hidden;
    /* Add 3D effect with inner shadow and glow using site's primary color */
    box-shadow: 0 0 25px rgba(123, 31, 162, 0.4), inset 0px -2px 4px rgba(0, 0, 0, 0.1);
}

.loader-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
    animation: shimmer 1.8s infinite;
    transform: skewX(-20deg);
    width: 50%;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Animation du dégradé pour la barre de progression */
@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Modern Blur Page Transitions */
.page-content {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-content.blur-out {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
    filter: blur(10px);
}

.page-content.blur-in {
    opacity: 0;
    transform: translateY(30px) scale(1.05);
    filter: blur(15px);
    animation: modernPageEnter 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes modernPageEnter {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(1.05);
        filter: blur(15px);
    }
    60% {
        opacity: 0.7;
        transform: translateY(10px) scale(1.02);
        filter: blur(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0px);
    }
}

/* Animation styles for the page content */

/* Modern Mesh Gradient Background */
.transition-bg-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.05; /* Fortement réduit pour assurer la transparence */
    
    /* Multi-layered effect with enhanced violet tones */
    background: 
        linear-gradient(135deg, rgba(124, 58, 237, 0.07) 0%, transparent 25%, rgba(94, 53, 177, 0.05) 50%, transparent 75%, rgba(124, 58, 237, 0.07) 100%),
        radial-gradient(circle at 20% 20%, rgba(216, 180, 254, 0.04) 0%, transparent 30%),
        radial-gradient(circle at 80% 80%, rgba(196, 181, 253, 0.04) 0%, transparent 30%),
        /* Subtle mesh pattern */
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.01) 0, rgba(255, 255, 255, 0.01) 1px, transparent 1px, transparent 2px),
        /* Elegant cosmic particles */
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        radial-gradient(circle at 40% 70%, rgba(255, 255, 255, 0.15) 1px, transparent 1px),
        radial-gradient(circle at 60% 30%, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.15) 1px, transparent 1px),
        radial-gradient(circle at 10% 90%, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
    background-size: 100% 100%, 60% 60%, 60% 60%, 10px 10px, 300px 300px;
    animation: subtleMeshMove 100s linear infinite;
}

/* Logo in the loading screen */
.loader-logo-container {
    position: relative;
    margin-bottom: 30px;
    padding: 15px 35px;
    border-radius: 20px;
    background-color: var(--loader-glass-bg);
    border: 1px solid var(--loader-glass-border);
    box-shadow: 0 0 30px rgba(230, 230, 255, 0.1);
    animation: zoom-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.loader-logo-container.pulse-animation {
    animation: pulse 1.2s ease-in-out infinite;
}

.loader-logo {
    max-width: 150px;
    height: auto;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

@keyframes deblurLogo {
    0% {
        opacity: 0;
        filter: blur(10px);
        transform: translateY(20px);
    }
    60% {
        opacity: 0.8;
        filter: blur(5px);
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

@keyframes patternMove {
    0% { transform: translateX(0) translateY(0); }
    100% { transform: translateX(100px) translateY(-100px); }
}

@keyframes subtleMeshMove {
    0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
    50% { background-position: 50px 50px, 30px -30px, -30px 30px, 0 0, 150px -150px; }
    100% { background-position: 100px 100px, 60px -60px, -60px 60px, 0 0, 300px -300px; }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .loader-svg-container {
        width: 80px;
        height: 80px;
    }
    
    .loader-svg {
        width: 60px;
        height: 60px;
    }
    
    /* Adjust logo size for mobile */
    .loader-logo-container {
        padding: 10px 20px;
    }    
    
    .loader-logo {
        max-width: 100px;
        max-height: 40px;
        height: auto;
        width: auto;
        object-fit: contain;
    }
    
    .loader-text {
        font-size: 1rem;
    }
    
    .loader-progress {
        width: 150px;
    }
    
    .modern-loader {
        gap: 20px;
    }
    
    /* Réduire l'intensité du blur sur mobile pour les performances */
    .page-content.blur-out {
        filter: blur(5px);
    }
    
    .page-content.blur-in {
        filter: blur(8px);
    }
    
    @keyframes modernPageEnter {
        0% {
            opacity: 0;
            transform: translateY(20px) scale(1.03);
            filter: blur(8px);
        }
        60% {
            opacity: 0.7;
            transform: translateY(8px) scale(1.01);
            filter: blur(3px);
        }
        100% {
            opacity: 1;
            transform: translateY(0) scale(1);
            filter: blur(0px);
        }
    }
}

/* Alternative Loader Styles */
.loader-dots {
    display: flex;
    gap: 8px;
}

.loader-dot {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out;
}

.loader-dot:nth-child(1) { animation-delay: -0.32s; }
.loader-dot:nth-child(2) { animation-delay: -0.16s; }
.loader-dot:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Smooth Page Transitions */
body {
    transition: opacity 0.3s ease;
    background-color: #f8f9fa; /* Couleur de fond pour éviter le blanc pur */
}

body.transitioning {
    overflow: hidden;
}

/* Prévenir le flash blanc pendant les transitions */
body.page-loading {
    background-color: var(--loader-primary);
}

/* Animation d'entrée plus fluide */
main {
    min-height: 100vh;
    background-color: white;
    transition: all 0.3s ease;
}

/* Overlay de transition amélioré */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--loader-primary) 0%, var(--loader-secondary) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-duration) cubic-bezier(0.4, 0, 0.2, 1), 
                visibility var(--transition-duration) cubic-bezier(0.4, 0, 0.2, 1),
                backdrop-filter 0.3s ease;
}

/* Link Hover Effects for Transition Links */
a[data-transition] {
    position: relative;
    transition: all 0.3s ease;
}

a[data-transition]:hover {
    transform: translateY(-2px);
}

a[data-transition]::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--loader-primary);
    transition: width 0.3s ease;
}

a[data-transition]:hover::after {
    width: 100%;
}
