/* --- Start: Adventskalender Styling v3.6 (object-fit: contain) --- */

/* --- 0. NEUE KEYFRAMES --- */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}


/* --- 1. Schnee-Effekt Styling --- */
#snow-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none; 
}


/* --- 2. Grid-Layout (6 Spalten) --- */
.adventskalender-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    max-width: 1000px; 
    margin: 20px auto;
    padding: 0;
    perspective: 1000px;
}

@media (max-width: 900px) {
    .adventskalender-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .adventskalender-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}


/* --- 3. 3D-Flip-Struktur --- */

.tuerchen-container {
    aspect-ratio: 1 / 1; 
    height: auto;
    cursor: pointer;
    background-color: transparent;
    border: none;
    padding: 0;
    
    opacity: 0; 
    animation: slideInUp 0.5s ease-out forwards;
    animation-delay: calc(var(--animation-order) * 40ms); 
}

.tuerchen-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s, box-shadow 0.3s ease-out;
    transform-style: preserve-3d;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    border-radius: 8px;
}

.tuerchen-container.is-flipped .tuerchen-inner {
    transform: rotateY(180deg);
}

.tuerchen-container.geschlossen {
    cursor: pointer; 
    opacity: 0.8;
}
.tuerchen-container.geschlossen:focus {
    outline: none; 
}

.tuerchen-container:focus {
    outline: 3px solid #0099dd;
    outline-offset: 3px;
    border-radius: 8px;
}
.tuerchen-container.is-flipped:focus {
    outline: none;
}


/* --- 4. Vorder- und Rückseite Styling (ANGEPASST) --- */

.tuerchen-front,
.tuerchen-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
    padding: 10px;
    box-sizing: border-box;
}

.tuerchen-front {
    background-color: #f4f4f4;
    border: 2px solid #ccc;
    color: #333;
}

.tuerchen-logo {
    max-width: 60%;
    height: auto;
    opacity: 0.7;
}

.tuerchen-nummer {
    font-size: 2.2em;
    font-weight: bold;
    position: absolute;
    bottom: 5px;
    right: 12px;
    color: #888;
}

.tuerchen-back {
    background-color: #333; 
    border: 2px solid #0073aa;
    color: #fff; 
    transform: rotateY(180deg); 
    padding: 0;
    justify-content: flex-end; 
}

.tuerchen-back a.tuerchen-link-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: flex-end; 
    align-items: center;
    text-decoration: none;
    color: inherit;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2; 
}

.tuerchen-bild {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* *** NEU v3.6: Zeigt das ganze Bild, füllt Ränder mit Hintergrundfarbe *** */
    object-fit: contain; 
    z-index: 0; 
    margin-bottom: 0;
    border-radius: 0;
}

.tuerchen-back::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%; 
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 40%, transparent 100%);
    z-index: 1; 
    border-radius: 0 0 6px 6px; 
}

.tuerchen-titel {
    font-size: 0.9em;
    font-weight: bold;
    text-align: center;
    line-height: 1.3; 
    color: #FFFFFF;
    width: 100%;
    padding: 0 10px 10px 10px; 
    box-sizing: border-box;
    margin-top: 0;
    position: relative;
    z-index: 3; 
    
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.6em; 
}

.tuerchen-bild-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* *** NEU v3.6: Zeigt das ganze Bild, füllt Ränder mit Hintergrundfarbe *** */
    object-fit: contain; 
    z-index: 1; 
    border-radius: 6px; 
}

/* --- 5. Hover-Effekt für geschlossene Türen --- */
.tuerchen-container:not(.geschlossen):not(.is-flipped):hover .tuerchen-inner {
    transform: scale(1.05); 
    box-shadow: 0 8px 30px rgba(0, 115, 170, 0.3); 
}


/* --- 6. Styling für spezielle Türchen (Vorder- & Rückseite) --- */
.tuerchen-container.special-day .tuerchen-front {
    border: 3px solid #FFD700; 
    background-color: #fffbeb; 
}
.tuerchen-container.special-day .tuerchen-back {
    border: 3px solid #FFD700; 
}
.tuerchen-container.special-day .tuerchen-logo {
    opacity: 1;
    filter: drop-shadow(0 0 5px #FFD700); 
}
.tuerchen-container.special-day .tuerchen-nummer {
    color: #DAA520; 
    font-weight: bold;
}

/* --- 7. Shake-Animation --- */
.tuerchen-container.is-shaking .tuerchen-inner {
    animation: shake 0.4s ease-in-out;
}