/* =============================================
   aulnayfacade - STYLES GLOBAUX & ANIMATIONS
   ============================================= */

/* ----------------------------------------
   1. VARIABLES CSS PERSONNALISÉES
   ---------------------------------------- */
:root {
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    --accent-500: #0ea5e9;
    --accent-600: #0284c7;
}

/* ----------------------------------------
   2. ANIMATIONS AU SCROLL (AOS-like)
   ---------------------------------------- */
[data-aos] {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
    will-change: opacity, transform; /* Optimisation GPU */
}

[data-aos="fade-up"] { transform: translateY(30px); }
[data-aos="fade-down"] { transform: translateY(-30px); }
[data-aos="fade-left"] { transform: translateX(30px); }
[data-aos="fade-right"] { transform: translateX(-30px); }
[data-aos="zoom-in"] { transform: scale(0.9); }

[data-aos].aos-animate {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

/* Réduire les animations si l'utilisateur préfère moins de mouvement */
@media (prefers-reduced-motion: reduce) {
    [data-aos] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

[data-aos-delay="100"] { transition-delay: 100ms; }
[data-aos-delay="200"] { transition-delay: 200ms; }
[data-aos-delay="300"] { transition-delay: 300ms; }
[data-aos-delay="400"] { transition-delay: 400ms; }
[data-aos-delay="500"] { transition-delay: 500ms; }

/* ----------------------------------------
   3. BOUTONS AVEC EFFETS
   ---------------------------------------- */
.btn-hover-lift {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    will-change: transform; /* Optimisation GPU */
}

.btn-hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.btn-hover-lift:active {
    transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
    .btn-hover-lift {
        transition: none;
    }
    .btn-hover-lift:hover {
        transform: none;
    }
}

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ----------------------------------------
   4. CARTES AVEC EFFETS
   ---------------------------------------- */
.card-hover-grow {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-grow:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.card-hover-glow:hover {
    box-shadow: 0 0 30px rgba(232, 93, 42, 0.15);
}

/* ----------------------------------------
   5. IMAGE COMPARISON SLIDER
   ---------------------------------------- */
.image-comparison {
    position: relative;
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
}

.image-comparison .img-before {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    overflow: hidden;
    z-index: 2;
}

.image-comparison .img-before img {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: auto;
    max-width: none;
}

.image-comparison .img-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.image-comparison .img-after img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-comparison .comparison-slider {
    position: absolute;
    top: 0;
    width: 4px;
    height: 100%;
    background: white;
    z-index: 10;
    cursor: ew-resize;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* ----------------------------------------
   6. FORMULAIRES STYLISÉS
   ---------------------------------------- */
.form-input-modern {
    transition: all 0.2s ease;
    border: 2px solid #e5e7eb;
}

.form-input-modern:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(232, 93, 42, 0.1);
    outline: none;
}

.form-input-modern:hover:not(:focus) {
    border-color: #d1d5db;
}

/* ----------------------------------------
   7. SKELETON LOADERS
   ---------------------------------------- */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----------------------------------------
   8. FAQ ACCORDION
   ---------------------------------------- */
.faq-item {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:hover {
    border-color: var(--primary-500);
}

.faq-question {
    padding: 1.25rem;
    background: #f9fafb;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #1f2937;
    transition: all 0.3s ease;
}

.faq-question:hover {
    background: #f3f4f6;
}

.faq-question .icon {
    transition: transform 0.3s ease;
}

.faq-item.active .faq-question .icon {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
    padding: 0 1.25rem;
}

.faq-item.active .faq-answer {
    max-height: 500px;
    padding: 0 1.25rem 1.25rem;
}

/* ----------------------------------------
   9. TOAST NOTIFICATIONS
   ---------------------------------------- */
.toast-container {
    position: fixed;
    top: 100px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    transition: transform 0.4s ease;
    max-width: 350px;
}

.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--primary-500); }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid var(--accent-500); }

/* ----------------------------------------
   10. LOADING SPINNER
   ---------------------------------------- */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ----------------------------------------
   11. GRADIENT TEXT
   ---------------------------------------- */
.gradient-text {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--accent-500) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ----------------------------------------
   12. GLASS EFFECT
   ---------------------------------------- */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ----------------------------------------
   13. PULSE ANIMATION
   ---------------------------------------- */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ----------------------------------------
   14. SHAKE ANIMATION
   ---------------------------------------- */
.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* ----------------------------------------
   15. LINE CLAMP UTILITIES
   ---------------------------------------- */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ----------------------------------------
   16. SMOOTH SCROLL
   ---------------------------------------- */
html {
    scroll-behavior: smooth;
}

/* ----------------------------------------
   17. SELECTION STYLE
   ---------------------------------------- */
::selection {
    background: var(--primary-200);
    color: var(--primary-900);
}

/* ----------------------------------------
   18. FOCUS VISIBLE
   ---------------------------------------- */
:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* ----------------------------------------
   19. CUSTOM SCROLLBAR
   ---------------------------------------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ----------------------------------------
   20. RESPONSIVE HELPERS
   ---------------------------------------- */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }

    /* Ajustement des boutons flottants sur mobile - position en bas à GAUCHE */
    .whatsapp-float {
        bottom: 1rem !important;
        right: auto !important;
        left: 1rem !important;
        width: 3rem !important;
        height: 3rem !important;
        opacity: 0.9 !important;
    }

    #scrollToTop {
        bottom: 1rem !important;
        right: 1rem !important;
        left: auto !important;
        width: 2.75rem !important;
        height: 2.75rem !important;
    }

    .whatsapp-float svg {
        width: 1.5rem !important;
        height: 1.5rem !important;
    }

    #scrollToTop svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}

/* ----------------------------------------
   21. FLOATING BUTTONS RESPONSIVE POSITIONING
   ---------------------------------------- */
.whatsapp-float {
    isolation: isolate;
    /* Le bouton n'interfère plus avec le scroll */
    pointer-events: auto;
}

/* Sur mobile, réduire encore plus l'opacité au défilement */
@media (max-width: 768px) {
    .whatsapp-float {
        transition: all 0.3s ease, opacity 0.3s ease;
    }

    /* Ajouter une classe pour cacher temporairement pendant le scroll */
    .whatsapp-float.scrolling {
        opacity: 0.4 !important;
        transform: scale(0.85);
    }
}

/* ----------------------------------------
   22. LAZY LOADING IMAGES
   ---------------------------------------- */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

img[loading="lazy"].loaded {
    animation: none;
    background: transparent;
}

/* Image fade-in effect */
img {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img.loaded,
img[src] {
    opacity: 1;
}

/* ----------------------------------------
   23. ASPECT RATIO CONTAINERS
   ---------------------------------------- */
.aspect-ratio-16-9 {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    overflow: hidden;
}

.aspect-ratio-4-3 {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 */
    overflow: hidden;
}

.aspect-ratio-1-1 {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 1:1 */
    overflow: hidden;
}

.aspect-ratio-16-9 > *,
.aspect-ratio-4-3 > *,
.aspect-ratio-1-1 > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   24. ASYMMETRICAL & CREATIVE LAYOUTS
   ======================================== */

/* Asymmetrical Grid - 2 large + 3 small */
.asymmetric-grid-2-3 {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto;
}

.asymmetric-grid-2-3 > :nth-child(1) {
    grid-column: span 2;
    grid-row: span 2;
}

.asymmetric-grid-2-3 > :nth-child(2) {
    grid-column: span 1;
    grid-row: span 1;
}

.asymmetric-grid-2-3 > :nth-child(3) {
    grid-column: span 1;
}

.asymmetric-grid-2-3 > :nth-child(4) {
    grid-column: span 1;
}

/* Pinterest-style Masonry */
.asymmetric-grid-masonry {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-auto-rows: auto;
    grid-auto-flow: dense;
}

.asymmetric-grid-masonry > :nth-child(3n+1) {
    grid-column: span 2;
    grid-row: span 2;
}

@media (max-width: 768px) {
    .asymmetric-grid-masonry {
        grid-template-columns: repeat(2, 1fr);
    }
    .asymmetric-grid-masonry > :nth-child(3n+1) {
        grid-column: span 1;
        grid-row: span 1;
    }
}

/* Staggered/Offset Effect */
.stagger-offset > :nth-child(odd) {
    transform: translateY(20px);
}

.stagger-offset > :nth-child(even) {
    transform: translateY(-20px);
}

/* Diagonal Clip-Path for Sections */
.diagonal-clip {
    clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
}

.diagonal-clip-reverse {
    clip-path: polygon(0 15%, 100% 0, 100% 100%, 0 100%);
}

/* Angled Section Borders */
.angled-section {
    position: relative;
    transform: skewY(-1deg);
}

.angled-section > * {
    transform: skewY(1deg);
}

/* Overlapping Cards */
.overlap-cards {
    position: relative;
}

.overlap-cards > :not(:last-child) {
    margin-bottom: -40px;
    position: relative;
    z-index: calc(10 - var(--index, 0));
}

/* Floating Animation */
@keyframes floating {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

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

.floating-animation-slower {
    animation: floating 4s ease-in-out infinite;
}

.floating-animation-faster {
    animation: floating 2.5s ease-in-out infinite;
}

/* Blob Shape with CSS */
.blob-shape {
    border-radius: 42% 58% 65% 35% / 58% 42% 58% 42%;
    animation: blob-morph 8s infinite;
}

@keyframes blob-morph {
    0%, 100% { border-radius: 42% 58% 65% 35% / 58% 42% 58% 42%; }
    25% { border-radius: 65% 35% 42% 58% / 42% 58% 35% 65%; }
    50% { border-radius: 35% 65% 58% 42% / 65% 35% 42% 58%; }
    75% { border-radius: 58% 42% 35% 65% / 35% 65% 65% 35%; }
}

/* Color Block Behind Text */
.color-block-bg {
    position: relative;
    display: inline-block;
    z-index: 1;
}

.color-block-bg::before {
    content: '';
    position: absolute;
    inset: -8px -12px;
    background: var(--color-block, var(--primary-100));
    z-index: -1;
    border-radius: 8px;
    transform: skewY(-2deg);
}

/* Gradient Mesh Background */
.gradient-mesh {
    position: relative;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 50%, #eff6ff 100%);
}

.gradient-mesh::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(14, 165, 233, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

/* Tilted Cards on Scroll */
.tilt-effect {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tilt-effect:hover {
    transform: perspective(1000px) rotateY(5deg) rotateX(-5deg);
}

/* Text Stroke Effect */
.text-stroke {
    -webkit-text-stroke: 1px var(--primary-600);
    -webkit-text-fill-color: transparent;
    paint-order: stroke fill;
}

/* Glitch Text Effect */
.glitch-effect {
    position: relative;
}

.glitch-effect::before,
.glitch-effect::after {
    content: attr(data-glitch);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-effect::before {
    animation: glitch-anim 0.3s infinite;
    color: #3b82f6;
    z-index: -1;
    text-shadow: -2px 0 #0ea5e9;
    clip: rect(0, 900px, 0, 0);
}

.glitch-effect::after {
    animation: glitch-anim 0.3s infinite reverse;
    color: #0ea5e9;
    z-index: -2;
    text-shadow: -2px 0 #3b82f6;
    clip: rect(0, 900px, 0, 0);
}

@keyframes glitch-anim {
    0% { clip: rect(0, 0, 0, 0); }
    20% { clip: rect(0, 9999px, 100%, 0); }
    40% { clip: rect(0, 0, 0, 0); }
    60% { clip: rect(0, 0, 100%, 0); }
    80% { clip: rect(0, 9999px, 100%, 0); }
    100% { clip: rect(0, 0, 0, 0); }
}

/* Wave Divider */
.wave-divider {
    position: relative;
    height: 100px;
    background: inherit;
}

.wave-divider svg {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Skewed Cards */
.card-skew {
    transform: skewY(-2deg);
    transition: transform 0.3s ease;
}

.card-skew:hover {
    transform: skewY(-2deg) scale(1.02);
}

/* Staggered Animation on Multiple Items */
.stagger-animation-1 { animation-delay: 0.1s; }
.stagger-animation-2 { animation-delay: 0.2s; }
.stagger-animation-3 { animation-delay: 0.3s; }
.stagger-animation-4 { animation-delay: 0.4s; }
.stagger-animation-5 { animation-delay: 0.5s; }
.stagger-animation-6 { animation-delay: 0.6s; }

/* Enhanced Gradient Variations */
.gradient-primary-accent {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--accent-500) 100%);
}

.gradient-primary-accent-reverse {
    background: linear-gradient(-135deg, var(--primary-500) 0%, var(--accent-500) 100%);
}

.gradient-mesh-primary {
    background: linear-gradient(45deg, #eff6ff 0%, #f0f9ff 100%);
}

/* Responsive Asymmetric Layouts */
@media (max-width: 1024px) {
    .asymmetric-grid-2-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .asymmetric-grid-2-3 > :nth-child(1) {
        grid-column: span 2;
        grid-row: span 1;
    }
}

@media (max-width: 768px) {
    .asymmetric-grid-2-3,
    .asymmetric-grid-masonry {
        grid-template-columns: 1fr;
    }

    .asymmetric-grid-2-3 > :nth-child(1),
    .asymmetric-grid-2-3 > :nth-child(2),
    .asymmetric-grid-2-3 > :nth-child(3),
    .asymmetric-grid-2-3 > :nth-child(4),
    .asymmetric-grid-masonry > * {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }

    .stagger-offset > * {
        transform: translateY(0) !important;
    }

    .angled-section {
        transform: skewY(0);
    }

    .angled-section > * {
        transform: skewY(0);
    }
}

/* Reduce motion respect */
@media (prefers-reduced-motion: reduce) {
    .floating-animation,
    .floating-animation-slower,
    .floating-animation-faster,
    .blob-shape,
    .tilt-effect,
    .card-skew,
    .glitch-effect::before,
    .glitch-effect::after {
        animation: none !important;
        transform: none !important;
    }
}
