/**
 * Copy-Media Shortcodes CSS
 * 
 * Styles pour les shortcodes personnalisés
 * - Galeries premium
 * - Spacers responsives
 * 
 * @package Copy_Media
 * @version 1.0.0
 * @since 2025-01-29
 */

/* ===========================================
   GALERIES COPY-MEDIA - BASE
   =========================================== */

.cm-gallery {
    margin: 1.5rem 0;
    clear: both;
}

.cm-gallery-grid {
    display: grid;
    gap: 0.75rem;
    align-items: start;
}

.cm-gallery-item {
    position: relative;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cm-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(161, 13, 89, 0.12);
}

.cm-image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.cm-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.cm-gallery-item:hover img {
    transform: scale(1.05);
}

.cm-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(161, 13, 89, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cm-gallery-item:hover .cm-image-overlay {
    opacity: 1;
}

.cm-zoom-icon {
    color: white;
    font-size: 1.5rem;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.cm-gallery-item:hover .cm-zoom-icon {
    transform: scale(1);
}

.cm-gallery-link {
    display: block;
    text-decoration: none;
}

/* ===========================================
   ALIGNEMENTS GALERIE
   =========================================== */

.cm-gallery-left {
    float: left;
    margin: 0 2rem 1rem 0;
}

.cm-gallery-right {
    float: right;
    margin: 0 0 1rem 2rem;
}

.cm-gallery-center {
    margin: 2rem auto;
}

/* ===========================================
   RESPONSIVE GALERIES
   =========================================== */

/* Desktop - 4 colonnes max */
@media (min-width: 1025px) {
    .cm-gallery-grid[data-count="1"] { grid-template-columns: 1fr; }
    .cm-gallery-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
    .cm-gallery-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
    .cm-gallery-grid[data-count="4"], 
    .cm-gallery-grid[data-count="5"],
    .cm-gallery-grid[data-count="6"] { grid-template-columns: repeat(4, 1fr); }
}

/* Laptop - 3 colonnes max */
@media (max-width: 1024px) and (min-width: 769px) {
    .cm-gallery-grid[data-count="1"] { grid-template-columns: 1fr; }
    .cm-gallery-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
    .cm-gallery-grid[data-count="3"],
    .cm-gallery-grid[data-count="4"],
    .cm-gallery-grid[data-count="5"],
    .cm-gallery-grid[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet - 2 colonnes max */
@media (max-width: 768px) and (min-width: 481px) {
    .cm-gallery-left,
    .cm-gallery-right {
        float: none;
        margin: 1.5rem 0;
        max-width: 100%;
    }
    
    .cm-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }
    
    .cm-image-container {
        height: 0;
        padding-bottom: 75%; /* Ratio tablet optimisé */
    }
}

/* Mobile - 1 colonne */
@media (max-width: 480px) {
    .cm-gallery-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .cm-image-container {
        height: 0;
        padding-bottom: 60%; /* Ratio mobile compact */
    }
    
    .cm-gallery {
        margin: 1rem 0;
    }
}

/* ===========================================
   ANIMATIONS GALERIES
   =========================================== */

.cm-gallery-item {
    opacity: 0;
    animation: cmFadeInUp 0.6s ease-out forwards;
}

.cm-gallery-item[data-index="0"] { animation-delay: 0s; }
.cm-gallery-item[data-index="1"] { animation-delay: 0.1s; }
.cm-gallery-item[data-index="2"] { animation-delay: 0.2s; }
.cm-gallery-item[data-index="3"] { animation-delay: 0.3s; }
.cm-gallery-item[data-index="4"] { animation-delay: 0.4s; }
.cm-gallery-item[data-index="5"] { animation-delay: 0.5s; }

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

/* ===========================================
   SPACERS COPY-MEDIA
   =========================================== */

.cm-spacer {
    clear: both;
    width: 100%;
    position: relative;
    display: block;
    /* Height définie inline via PHP */
}

/* Debug mode - Décommenter pour voir les spacers */
/*
.cm-spacer::before {
    content: "Spacer";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(161, 13, 89, 0.1);
    color: #a10d59;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 3px;
    font-family: monospace;
    white-space: nowrap;
}
*/

/* ===========================================
   UTILITAIRES
   =========================================== */

/* Clear fixes */
.cm-gallery::after,
.cm-spacer::after {
    content: "";
    display: table;
    clear: both;
}

/* Performance optimizations */
.cm-gallery-item,
.cm-image-container {
    will-change: transform;
}

.cm-gallery-item:hover {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    .cm-gallery-item,
    .cm-image-container img,
    .cm-zoom-icon {
        transition: none !important;
        animation: none !important;
    }
    
    .cm-gallery-item {
        opacity: 1;
    }
}
