/**
 * 🎨 EMOCARD - Portfolio Carousel CSS
 * 
 * Carrousel élégant avec animation droite→gauche (inverse des témoignages)
 * 
 * Fonctionnalités :
 * - Animation continue GPU-optimized (transform translateX)
 * - Format portrait 3:4 pour cohérence design EMOCARD
 * - Hover effects premium (scale + pause animation)
 * - Loop infini seamless avec duplication images
 * - Responsive multi-device (desktop/tablet/mobile)
 * - Design system EMOCARD (border-radius, shadows, spacing)
 * 
 * @author EMOCARD Team
 * @version 1.0.0
 * @date 2025-10-02
 */

/* ÉCRASEMENT CONTAINER PARENT - Force pleine largeur */
.portfolio-section .container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* CONTENEUR PRINCIPAL DU CARROUSEL - Pleine largeur */
.portfolio-carousel-wrapper {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow: hidden;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    padding: 3rem 0;
    background: linear-gradient(135deg, #fefcf5 0%, #f8f5f0 100%);
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* 🎬 PISTE D'ANIMATION - Défilement GAUCHE→DROITE (INVERSÉ) */
.portfolio-carousel-track {
    display: flex;
    gap: 20px;
    /* animation: scrollLeftToRight 20s linear infinite; */ /* ❌ DÉSACTIVÉ - emocard-animations-unified.js contrôle via emocardportfolioMove */
    will-change: transform;
}

/* 🆕 ACCÉLÉRATION MOBILE SPÉCIFIQUE */
@media (max-width: 768px) {
    .portfolio-carousel-track {
        /* animation-duration: 10s !important; */ /* ❌ DÉSACTIVÉ - JS unified contrôle */
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .portfolio-carousel-track {
        /* animation-duration: 15s !important; */ /* ❌ DÉSACTIVÉ - JS unified contrôle */
    }
}

/* ⏸️ PAUSE AU HOVER avec INERTIE DOUCE - UX Premium */
.portfolio-carousel-wrapper:hover .portfolio-carousel-track {
    animation-play-state: paused;
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.portfolio-carousel-wrapper:not(:hover) .portfolio-carousel-track {
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

/* 🖼️ ITEM INDIVIDUEL DU CARROUSEL */
.portfolio-carousel-item {
    position: relative;
    flex-shrink: 0;
    width: clamp(280px, 22vw, 360px);
    aspect-ratio: 3/4;
    border-radius: 16px !important;
    overflow: hidden;
    box-shadow: 
        0 4px 12px rgba(170, 123, 76, 0.12),
        0 2px 6px rgba(0, 0, 0, 0.08);
    /* ✨ EFFET REBOND SMOOTH - cubic-bezier ease-out-back */
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: #fff;
}

/* ✨ HOVER EFFECT PREMIUM - Scale encart + Ombre dramatique + Rebond */
.portfolio-carousel-item:hover {
    transform: scale(1.08) translateY(-10px);
    box-shadow: 
        0 20px 48px rgba(170, 123, 76, 0.35),
        0 10px 24px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(170, 123, 76, 0.1);
    z-index: 10;
    border-radius: 16px !important;
}

/* 📸 IMAGE - Format portrait optimisé SANS ZOOM AU HOVER */
.portfolio-carousel-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    /* ✅ FIX CRITIQUE : Image visible par défaut (pas opacity: 0) */
    /* Progressive enhancement : blur initial puis net après chargement */
    opacity: 1;
    filter: blur(4px);  /* Légère blur pour indiquer "en cours de chargement" */
    transition: opacity 0.3s ease-in-out, filter 0.3s ease-in-out;
}

/* ✨ IMAGE CHARGÉE - Supprime blur, conserve opacité */
.portfolio-carousel-image.loaded {
    opacity: 1;
    filter: blur(0);  /* Net = chargé */
}

/* 🔴 IMAGE EN ERREUR - Placeholder visible avec pattern */
.portfolio-carousel-image.error {
    opacity: 0.3;
    filter: blur(0);
    background: linear-gradient(135deg, #f0f0f0 25%, #e0e0e0 25%, #e0e0e0 50%, #f0f0f0 50%, #f0f0f0 75%, #e0e0e0 75%, #e0e0e0);
    background-size: 40px 40px;
}

/* SUPPRESSION DU ZOOM IMAGE AU HOVER */
.portfolio-carousel-item:hover .portfolio-carousel-image {
    /* L'image ne bouge plus - seul l'encart scale */
    transform: none;
}

/* 🎭 ANIMATION PRINCIPALE - Défilement GAUCHE→DROITE (INVERSÉ) */
@keyframes scrollLeftToRight {
    0% {
        transform: translateX(-50%);
    }
    100% {
        transform: translateX(0);
    }
}

/* 🎯 OPTIMISATION PERFORMANCE - GPU Acceleration */
.portfolio-carousel-track,
.portfolio-carousel-item {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}

/* 📱 RESPONSIVE - TABLET (768px - 1024px) */
@media (max-width: 1024px) {
    .portfolio-carousel-wrapper {
        padding: 2.5rem 0;
        border-radius: 12px;
    }
    
    .portfolio-carousel-track {
        gap: 2vw;
        /* animation-duration: 35s; ← NEUTRALISÉ : Le système unifié gère les vitesses */
    }
    
    .portfolio-carousel-item {
        width: clamp(240px, 28vw, 320px);
        border-radius: 14px;
    }
}

/* 📱 RESPONSIVE - MOBILE (max 768px) */
@media (max-width: 768px) {
    .portfolio-carousel-wrapper {
        padding: 2rem 0;
        border-radius: 0; /* Pas d'arrondi sur mobile pour effet bord à bord */
        margin: 1.5rem 0;
        /* 🎯 Pleine largeur garantie car hors du .container */
    }
    
    .portfolio-carousel-track {
        gap: 3vw;
        /* animation-duration: 30s; ← NEUTRALISÉ : Le système unifié gère les vitesses */
        padding: 0 3vw;
    }
    
    .portfolio-carousel-item {
        width: clamp(200px, 45vw, 280px);
        border-radius: 12px;
    }
    
    /* Hover désactivé sur mobile pour performance */
    .portfolio-carousel-item:hover {
        transform: none;
    }
    
    .portfolio-carousel-item:hover .portfolio-carousel-image {
        transform: none;
    }
}

/* 📱 RESPONSIVE - SMALL MOBILE (max 480px) */
@media (max-width: 480px) {
    .portfolio-carousel-wrapper {
        padding: 1.5rem 0;
        border-radius: 0; /* Pas d'arrondi sur très petit écran */
        /* 🎯 Pleine largeur garantie car hors du .container */
    }
    
    .portfolio-carousel-track {
        gap: 4vw;
        /* animation-duration: 25s; ← NEUTRALISÉ : Le système unifié gère les vitesses */
        padding: 0 4vw;
    }
    
    .portfolio-carousel-item {
        width: clamp(180px, 60vw, 240px);
        border-radius: 10px;
        box-shadow: 
            0 3px 8px rgba(170, 123, 76, 0.10),
            0 1px 4px rgba(0, 0, 0, 0.06);
    }
}

/* 🎯 COHÉRENCE DESIGN SYSTEM EMOCARD */
.portfolio-section .portfolio-carousel-wrapper {
    margin-top: 3rem;
}

/* 🌟 ANIMATION D'ENTRÉE - Fade in au scroll */
.portfolio-carousel-wrapper {
    opacity: 0;
    animation: fadeInCarousel 0.8s ease-out forwards;
}

@keyframes fadeInCarousel {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 🎨 COULEURS EMOCARD - Variables pour cohérence */
:root {
    --emocard-primary: #aa7b4c;
    --emocard-primary-light: #d4af37;
    --emocard-bg-light: #fefcf5;
    --emocard-bg-alt: #f8f5f0;
    --emocard-shadow-light: rgba(170, 123, 76, 0.12);
    --emocard-shadow-medium: rgba(170, 123, 76, 0.24);
    --emocard-radius-medium: 16px;
    --emocard-radius-small: 12px;
}

/* 🔄 ACCESSIBILITÉ - Respect des préférences motion */
@media (prefers-reduced-motion: reduce) {
    .portfolio-carousel-track {
        animation: none;
    }
    
    .portfolio-carousel-item:hover {
        transform: scale(1.02);
    }
    
    .portfolio-carousel-item:hover .portfolio-carousel-image {
        transform: scale(1.03);
    }
}

/* 🎯 ÉTAT CHARGEMENT - Skeleton loader pour lazy loading */
.portfolio-carousel-item.loading {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s ease-in-out infinite;
}

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

/* 🎨 OVERLAY SUBTIL - Apparaît au hover pour info */
.portfolio-carousel-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent 0%,
        transparent 60%,
        rgba(0, 0, 0, 0.3) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.portfolio-carousel-item:hover::after {
    opacity: 1;
}

/* 🎯 OPTIMISATION - Lazy loading support */
.portfolio-carousel-image[loading="lazy"] {
    background: #f0f0f0;
}

/* ✨ SMOOTH SCROLLING pour navigation touch */
.portfolio-carousel-wrapper {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* 🎬 ALTERNATIVE - Mode manuel pour accessibilité */
.portfolio-carousel-wrapper.manual-mode .portfolio-carousel-track {
    animation: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 1rem;
}

.portfolio-carousel-wrapper.manual-mode .portfolio-carousel-item {
    scroll-snap-align: start;
}

/* 📊 DEBUG MODE - Visible uniquement en développement */
.portfolio-carousel-wrapper[data-debug="true"] {
    border: 2px dashed var(--emocard-primary);
}

.portfolio-carousel-wrapper[data-debug="true"]::before {
    content: '🎨 Portfolio Carousel Debug Mode';
    position: absolute;
    top: 0;
    left: 0;
    background: var(--emocard-primary);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    z-index: 100;
}
