:root {
    --gold: #c5a059;
    --cream: #faf7f2;
    --dark: #1a1a1a;
    --card-height: 450px; /* Taille fixe pour harmoniser toute la grille */
}

* { box-sizing: border-box; } /* Sécurité pour que les paddings ne cassent pas la grille */
img {
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    margin: 0;
    background: var(--cream);
    font-family: 'Montserrat', sans-serif;
    color: var(--dark);
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* --- LOGO & HEADER --- */
#main-header { 
    padding: 20px 0; background: white; text-align: center; 
    border-bottom: 1px solid #f0f0f0; position: relative; z-index: 100;
}
#logo-block { transition: opacity 0.4s ease, transform 0.4s ease; padding: 0 20px; }
#main-logo-img { max-width: 100%; width: 450px; height: auto; display: block; margin: 0 auto; }
#main-subtitle {
    font-style: italic;
    color: #888;
    margin-top: 10px;
    letter-spacing: 2px;
    font-size: 0.9rem;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    #main-subtitle {
        background: repeating-linear-gradient(
            110deg,
            rgba(18, 18, 18, 0.98) 0px,
            rgba(18, 18, 18, 0.98) 130px,
            rgba(255, 255, 255, 0.98) 170px,
            rgba(18, 18, 18, 0.98) 210px,
            rgba(18, 18, 18, 0.98) 340px
        );
        background-size: 340px 100%;
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        animation: subtitle-shimmer 7.3s linear infinite;
        will-change: background-position;
    }
}

/* --- NAVIGATION --- */
#nav-header { 
    max-width: 1200px; margin: 0 auto; display: flex; 
    justify-content: space-between; align-items: center; padding: 10px 20px; 
    opacity: 0; transition: opacity 0.5s ease;
}
#nav-header.visible { opacity: 1; }
#back-btn { 
    background: white; border: 1px solid var(--gold); color: var(--gold); 
    padding: 8px 15px; cursor: pointer; font-weight: 600; transition: 0.3s; font-size: 0.8rem;
}
#back-btn:hover { background: var(--gold); color: white; }
#category-title { font-family: 'Playfair Display', serif; color: var(--gold); text-transform: uppercase; letter-spacing: 2px; font-size: 1.1rem; margin: 0; }

/* --- ANIMATIONS TRANSITION --- */
#main-wrapper { transition: transform 0.8s cubic-bezier(0.7, 0, 0.3, 1), opacity 0.8s ease; }
.zoom-in { transform: scale(3); opacity: 0; pointer-events: none; }
.zoom-out { transform: scale(0.8); opacity: 0; pointer-events: none; }

@keyframes subtitle-shimmer {
    from { background-position: -340px 50%; }
    to { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    #main-subtitle {
        animation: none;
    }
}

/* --- GRILLES (Mise à jour pour éviter chevauchement) --- */
.category-grid { 
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    padding: 40px 5%;
    max-width: 1400px;
    margin: 0 auto;
}

.memory-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 30px; 
    padding: 20px 5%; 
    max-width: 1400px;
    margin: 0 auto;
}

/* --- CARDS CATÉGORIES --- */
.category-card {
    position: relative; width: 100%; height: var(--card-height);
    cursor: pointer; overflow: hidden; background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.category-img { width: 100%; height: 100%; object-fit: cover; transition: 0.8s; }
.category-card:hover .category-img { transform: scale(1.1); }

/* Animation Scan */
.category-card:hover::after {
    content: ''; position: absolute; inset: 0; border: 2px solid var(--gold);
    animation: scan 1.5s linear infinite; z-index: 5;
}
@keyframes scan {
    0% { clip-path: inset(0 0 98% 0); }
    25% { clip-path: inset(0 98% 0 0); }
    50% { clip-path: inset(98% 0 0 0); }
    75% { clip-path: inset(0 0 0 98%); }
    100% { clip-path: inset(0 0 98% 0); }
}
.category-overlay { position: absolute; bottom: 0; width: 100%; padding: 20px; background: linear-gradient(transparent, rgba(0,0,0,0.8)); color: white; text-align: center; }

/* --- CARDS SOUVENIRS (FLIP OPTIMISÉ) --- */
.card { 
    height: var(--card-height); 
    perspective: 2000px; /* Perspective augmentée pour éviter l'effet de "sortie" de grille */
    cursor: pointer; 
}
.card-inner { 
    position: relative; width: 100%; height: 100%; 
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1); 
    transform-style: preserve-3d; 
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back { 
    position: absolute; inset: 0; 
    backface-visibility: hidden; 
    border-radius: 4px; overflow: hidden; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); 
}

.card-front { 
    background: white; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    padding: 30px; text-align: center; font-family: 'Playfair Display'; font-style: italic; font-size: 1.1rem; 
    border: 1px solid #f0f0f0; transition: 0.4s ease;
}

.flip-hint {
    position: absolute; bottom: 30px; font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 3px;
    color: var(--gold); font-weight: 600; font-style: normal;
    opacity: 0.6; transition: 0.4s ease;
}

.card:hover .card-front { border-color: var(--gold); transform: translateY(-5px); box-shadow: 0 15px 35px rgba(0,0,0,0.1); }
.card:hover .flip-hint { opacity: 1; letter-spacing: 5px; }

.card-back { transform: rotateY(180deg); position: relative; background: #eee; }
.card-back img { width: 100%; height: 100%; object-fit: cover; display: block; }

.expand-icon {
    position: absolute; top: 15px; right: 15px;
    width: 35px; height: 35px; background: rgba(255,255,255,0.95);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 10;
}
.expand-icon img { width: 50%; height: 50%; }

/* --- LIGHTBOX --- */
#lightbox { 
    position: fixed; inset: 0; z-index: 9999; 
    display: none; align-items: center; justify-content: center; 
    opacity: 0; transition: opacity 0.4s ease;
}
#lightbox.active { display: flex; opacity: 1; }
.lightbox-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px); }
.lightbox-content { position: relative; z-index: 10000; width: 95vw; height: 95vh; display: flex; align-items: center; justify-content: center; }
#lightbox-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.close-lightbox { position: absolute; top: 10px; right: 20px; font-size: 3rem; background: none; border: none; cursor: pointer; color: white; z-index: 10001; }

/* --- RESPONSIVITÉ --- */
@media (max-width: 768px) {
    #main-logo-img { width: 280px; }
    #main-subtitle { font-size: 0.75rem; }
    .memory-grid, .category-grid { 
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); 
        padding: 15px; 
        gap: 20px;
    }
    .card, .category-card { height: 400px; }
    #category-title { font-size: 0.9rem; letter-spacing: 1px; }
    .close-lightbox { top: 5px; right: 15px; font-size: 2.5rem; }
}
