/* ADVENT CALENDAR PRO V4 - Toutes améliorations */

:root {
    --acp-primary: #c41e3a;
    --acp-secondary: #165b33;
    --acp-gold: #d4af37;
    --acp-door-size: 180px;
    --acp-gap: 15px;
    --acp-modal-width: 900px;
    --acp-border-radius: 8px;
}

/* Container principal */
.advent-calendar {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Bannière mode test */
.acp-test-mode-banner {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: var(--acp-border-radius);
    padding: 15px 20px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
    color: #856404;
}

/* Grille */
.advent-grid {
    display: grid;
    gap: var(--acp-gap);
    margin: 0 auto;
    perspective: 1000px;
}

.advent-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.advent-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.advent-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.advent-grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.advent-grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* ========================================
   PORTE - Système CSS Automatique
   ======================================== */

.advent-door {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--acp-border-radius);
    overflow: visible;
    transform-style: preserve-3d;
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.advent-door:hover {
    transform: scale(1.02);
}

/* Contenu de la porte */
.advent-door-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: var(--acp-border-radius);
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Animation ouverture SUBTILE : Léger mouvement vers le haut */
.advent-door.opening .advent-door-inner {
    transform: translateY(-5px); /* Mouvement léger vers le haut, uniforme pour toutes les cases */
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15); /* Ombre légèrement plus prononcée */
}

/* Suppression du fond sombre - animation simple et propre */

.advent-door-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    backface-visibility: hidden;
}

/* Porte verrouillée */
.advent-door-locked {
    opacity: 0.4;
    filter: grayscale(70%);
    cursor: not-allowed;
}

.advent-door-locked:hover {
    transform: none;
}

/* Porte active */
.advent-door-active {
    cursor: pointer;
    opacity: 1;
}

/* Porte du jour */
.advent-door-today .advent-door-inner {
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 8px 20px rgba(212, 175, 55, 0.5), 0 0 30px rgba(212, 175, 55, 0.3);
    }
}

/* Placeholder - Génération CSS automatique */
.advent-door-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--door-bg-color, linear-gradient(135deg, var(--acp-primary), var(--acp-secondary)));
    color: white;
}

/* Numéro du jour */
.advent-door-number {
    font-size: 72px;
    font-weight: bold;
    font-family: inherit; /* Utilise la police du body/texte */
    color: var(--number-color, #000000); /* Couleur personnalisable par case, défaut noir */
    transition: opacity 0.3s ease;
}

/* Logo partenaire - Carré blanc */
.advent-door-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%; /* Augmenté de 60% à 85% pour occuper plus de place */
    height: 85%;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    /* box-shadow supprimée */
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Afficher logo sur porte active */
.advent-door-active .advent-door-logo {
    opacity: 1;
}

/* Masquer numéro sur porte active avec logo */
.advent-door-active.has-logo .advent-door-number {
    opacity: 0;
}

.advent-door-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Modal - Positionné pour éviter header sticky */
.advent-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999990 !important;
    display: none;
    align-items: flex-start !important; /* Alignement en haut au lieu de center */
    justify-content: center;
    overflow-y: auto;
    padding-top: var(--modal-top-offset, 150px); /* Variable CSS personnalisable pour header sticky */
    padding-bottom: 20px;
}

.advent-modal.show {
    display: flex !important;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Overlay */
.advent-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(5px);
    z-index: 999999990 !important; /* Fond noir en arrière */
}

/* FLOCONS - Entre l'overlay et le contenu du modal */
#acp-snow-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 999999992 !important; /* Au-dessus de l'overlay (990), sous le modal content (995) */
    overflow: hidden;
}

.acp-snowflake {
    position: absolute;
    pointer-events: none;
    will-change: transform, opacity;
}

/* AMÉLIORATION 1 : Tailles BEAUCOUP plus marquées */
.acp-snowflake.size-small {
    width: 12px !important;  /* Plus petit */
    height: 12px !important;
    opacity: 0.5;
    font-size: 12px;
}

.acp-snowflake.size-medium {
    width: 28px !important;  /* Moyen bien visible */
    height: 28px !important;
    opacity: 0.75;
    font-size: 28px;
}

.acp-snowflake.size-large {
    width: 50px !important;  /* GROS et bien visible */
    height: 50px !important;
    opacity: 1;
    font-size: 50px;
}

.acp-snowflake.blur-near {
    filter: blur(0px);
    z-index: 3;
}

.acp-snowflake.blur-mid {
    filter: blur(1px);
    z-index: 2;
}

.acp-snowflake.blur-far {
    filter: blur(2px);
    z-index: 1;
}

.acp-snowflake img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* AMÉLIORATION 2 : Animation avec rotation aléatoire (gérée en JS) */
@keyframes snowfall {
    0% {
        transform: translateY(-50px) translateX(0) rotate(var(--start-rotation, 0deg));
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) translateX(var(--drift)) rotate(var(--end-rotation, 360deg));
        opacity: 0;
    }
}

/* Contenu Modal */
.advent-modal-content {
    position: relative !important;
    width: 90%;
    max-width: var(--acp-modal-width);
    max-height: 85vh;
    background: white !important;
    border-radius: var(--acp-border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: slideUp 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 999999999 !important;
    margin: auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.advent-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.advent-modal-close:hover {
    background: var(--acp-primary);
    transform: rotate(90deg);
}

.advent-modal-body {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow-y: auto;
}

.advent-prize-image {
    width: 100%;
    max-height: 400px;
    overflow: hidden;
    background: #f8f9fa;
}

.advent-prize-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* AMÉLIORATION 4 : Couleurs personnalisables via CSS variables */
.advent-prize-info {
    padding: 30px;
    background: var(--modal-bg-color, #ffffff);
}

.advent-prize-title {
    margin: 0 0 20px 0;
    font-size: 28px;
    color: var(--modal-title-color, var(--acp-primary)) !important; /* AMÉLIORATION 5 : Force couleur */
    font-weight: bold;
}

.advent-prize-description {
    margin: 0 0 20px 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--modal-text-color, #333);
}

.advent-prize-brand {
    margin: 0 0 15px 0;
    padding: 12px 20px;
    background: var(--modal-brand-bg, linear-gradient(135deg, var(--acp-secondary), #1a7a4a));
    color: var(--modal-brand-color, white);
    border-radius: var(--acp-border-radius);
    font-size: 14px;
}

.advent-prize-brand strong {
    font-size: 18px;
}

.advent-prize-winner {
    margin: 0;
    padding: 15px 20px;
    background: var(--modal-winner-bg, linear-gradient(135deg, var(--acp-gold), #f4d03f));
    color: var(--modal-winner-color, #333);
    border-radius: var(--acp-border-radius);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

/* Force headers en-dessous */
header, .header, .site-header, #header, #masthead,
.main-header, .top-bar, .navbar, nav,
.mobile-header, #mobile-header, .sticky-header,
.zeen-header, .tipi-header, #tipi-header {
    z-index: 999 !important;
}

/* Responsive */
@media screen and (max-width: 1024px) {
    .advent-grid-cols-4,
    .advent-grid-cols-5,
    .advent-grid-cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .advent-calendar {
        padding: 15px;
    }
    
    .advent-grid-cols-3,
    .advent-grid-cols-4,
    .advent-grid-cols-5,
    .advent-grid-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Modal : ajustement pour header mobile sticky */
    .advent-modal {
        padding-top: var(--modal-top-offset-mobile, 120px) !important; /* Variable CSS pour header mobile */
    }
    
    .advent-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .advent-prize-info {
        padding: 20px;
    }
    
    .advent-door-number {
        font-size: 48px;
    }
    
    .advent-door-logo {
        width: 80%; /* Légèrement réduit en mobile mais toujours grand */
        height: 80%;
    }
}

/* 
 * PERSONNALISATION POUR HEADER STICKY
 * Si ton header sticky a une hauteur spécifique, ajoute dans ton thème :
 * 
 * :root {
 *     --modal-top-offset: 180px;        // Desktop (hauteur header + marge)
 *     --modal-top-offset-mobile: 140px; // Mobile (hauteur header + marge)
 * }
 * 
 * Ou calcul automatique avec JS (voir documentation)
 */
