/* 
 * PC API Galleries - Stylesheet
 * A modern, responsive masonry gallery with pill navigation.
 */

:root {
    --pc-gallery-primary: #1a1a1a;
    --pc-gallery-bg: #f9fafb;
    --pc-gallery-text: #4b5563;
    --pc-gallery-accent: #3b82f6; /* Modern Blue */
    --pc-gallery-radius: 8px;
    --pc-gallery-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pc-gallery-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 2rem auto;
    width: 100%;
    max-width: 1400px;
    box-sizing: border-box;
}

/* Navigation Menu */
.pc-gallery-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.pc-gallery-nav-level {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.pc-gallery-nav-level-2 .pc-gallery-nav-btn {
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.pc-gallery-nav-level-2 .pc-gallery-nav-btn:hover,
.pc-gallery-nav-level-2 .pc-gallery-nav-btn.active {
    background-color: var(--pc-gallery-accent);
    color: #fff;
    border-color: var(--pc-gallery-accent);
}

.pc-gallery-nav-btn {
    background-color: #fff;
    color: var(--pc-gallery-text);
    border: 1px solid #e5e7eb;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px; /* Pill shape */
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--pc-gallery-transition);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pc-gallery-nav-btn:hover {
    border-color: var(--pc-gallery-primary);
    color: var(--pc-gallery-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.pc-gallery-nav-btn.active {
    background-color: var(--pc-gallery-primary);
    color: #fff;
    border-color: var(--pc-gallery-primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Gallery Grid */
.pc-gallery-masonry {
    display: grid;
    gap: 0.5rem;
    width: 100%;
}

.pc-gallery-photos-grid {
    grid-template-columns: repeat(3, 1fr);
}

.pc-gallery-folders-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* Default fallback */
#pc-gallery-grid:not(.pc-gallery-folders-grid):not(.pc-gallery-photos-grid) {
    grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 640px) {
    .pc-gallery-masonry {
        gap: 1.5rem;
    }
    .pc-gallery-photos-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .pc-gallery-folders-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    #pc-gallery-grid:not(.pc-gallery-folders-grid):not(.pc-gallery-photos-grid) {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Gallery Item */
.pc-gallery-item {
    aspect-ratio: 3 / 2;
    display: block;
    border-radius: var(--pc-gallery-radius);
    overflow: hidden;
    position: relative;
    background-color: #e5e7eb; /* Placeholder color before load */
    transform: translateZ(0); /* Hardware acceleration */
}

.pc-gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    will-change: transform;
}

/* Hover effect on images */
.pc-gallery-item:hover img {
    transform: scale(1.03);
}

/* Loading overlay effect for images */
.pc-gallery-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
    pointer-events: none;
}

.pc-gallery-item:hover::after {
    background: rgba(0,0,0,0.1);
}

/* Download button overlay */
.pc-gallery-download {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--pc-gallery-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--pc-gallery-transition);
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 10;
}

.pc-gallery-item:hover .pc-gallery-download {
    opacity: 1;
    transform: translateY(0);
}

.pc-gallery-download:hover {
    background: var(--pc-gallery-primary);
    color: #fff;
}

.pc-gallery-download svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Loader */
.pc-gallery-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
    color: var(--pc-gallery-text);
}

.pc-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--pc-gallery-primary);
    animation: pc-spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

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

/* Error message */
.pc-gallery-error {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 1rem;
    border-radius: var(--pc-gallery-radius);
    text-align: center;
    border: 1px solid #f87171;
    margin: 2rem 0;
}

/* Hide element utility */
.pc-hidden {
    display: none !important;
}

/* PhotoSwipe custom tweaks */
.pswp__button--download {
    display: flex;
    justify-content: center;
    align-items: center;
}
.pswp__button--download svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* Gallery Folders */
.pc-gallery-folder {
    cursor: pointer;
    background-color: #f3f4f6;
}

.pc-gallery-folder-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 1.5rem 1rem 1rem;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.pc-gallery-folder-overlay h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.pc-btn-discover {
    display: inline-block;
    padding: 0.4rem 1.25rem;
    background-color: var(--pc-gallery-accent);
    color: #fff;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    transition: var(--pc-gallery-transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pc-gallery-folder:hover .pc-btn-discover {
    background-color: #fff;
    color: var(--pc-gallery-accent);
}

.pc-gallery-folder-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.pc-gallery-folder-placeholder h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
}

.pc-gallery-folder:hover .pc-gallery-folder-placeholder {
    color: var(--pc-gallery-accent);
}

.pc-btn-back {
    background-color: transparent !important;
    border: 1px solid #d1d5db !important;
    color: var(--pc-gallery-text) !important;
    margin-bottom: 0.5rem;
}

.pc-btn-back:hover {
    background-color: #f3f4f6 !important;
    color: var(--pc-gallery-primary) !important;
}

/* --- Mobile Optimizations --- */
@media (max-width: 639px) {
    .pc-gallery-wrapper {
        margin: 1rem auto;
        padding: 0 0.5rem;
    }

    /* Scroll horizontal fluide pour les filtres (catégories) */
    .pc-gallery-nav-level-2 {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        scrollbar-width: none; /* Firefox */
    }
    
    .pc-gallery-nav-level-2::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Edge */
    }

    .pc-gallery-nav-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Ajustement des textes des dossiers pour 2 colonnes */
    .pc-gallery-folder-overlay {
        padding: 1rem 0.5rem 0.5rem;
    }

    .pc-gallery-folder-overlay h3 {
        font-size: 0.9rem;
    }
    
    .pc-gallery-folder-placeholder h3 {
        font-size: 0.9rem;
    }

    .pc-btn-discover {
        padding: 0.25rem 0.75rem;
        font-size: 0.7rem;
    }

    /* Masquer le bouton de téléchargement sur image pour mobile 
       car l'utilisateur va ouvrir la Lightbox qui possède son propre bouton */
    .pc-gallery-download {
        display: none;
    }
}
