/* Discovery Pure 3D Wall - Clean Text & Safe Flip */

#discovery-grid {
    position: absolute;
    inset: 0;
    overflow: hidden !important;
    perspective: 2000px;
    pointer-events: none;
    z-index: 30;
}

#discovery-grid.is-on-top {
    z-index: 100 !important;
}

/* Fog of War Precision */
#discovery-fog {
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    z-index: 50;
    pointer-events: none;
    background: radial-gradient(
        800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(249, 115, 22, 0.1) 0%,
        rgba(0, 0, 0, 0.1) 40%,
        rgba(0, 0, 0, 0.8) 100%
    );
}

#discovery-particles {
    position: absolute;
    inset: 0;
    z-index: 40;
    pointer-events: none;
}

.mosaic-container-3d {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    transform: translate(-50%, -50%) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
    transition: transform 0.4s ease-out;
}

.discovery-card-3d {
    position: absolute;
    width: var(--card-width, 320px);
    aspect-ratio: 16 / 10;
    perspective: 1500px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 10;
    transition: all 0.5s cubic-bezier(0.2, 1, 0.3, 1);
}

.card-inner-3d {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.discovery-card-3d.is-flipped .card-inner-3d {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden; /* Réactivé pour supprimer les fantômes de texte */
    background: #0a0a0c;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    transform-style: preserve-3d; 
}

.card-back {
    transform: rotateY(180deg);
    border-color: rgba(249, 115, 22, 0.6);
}

/* Back Light Glow */
.discovery-card-3d::before {
    content: '';
    position: absolute;
    inset: -40px;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.5) 0%, transparent 70%);
    opacity: 0;
    z-index: -1;
    transform: translateZ(-100px) scale(0.8);
    transition: all 0.6s ease;
    filter: blur(30px);
}

.discovery-card-3d:hover::before,
.discovery-card-3d.is-expanded::before {
    opacity: 1;
    transform: translateZ(-120px) scale(1.1);
}

.discovery-card-3d:hover {
    z-index: 100;
}

.discovery-card-3d.is-expanded {
    z-index: 1000 !important;
    transform: translate(-50%, -50%) 
               translate(calc(var(--base-x) + var(--expand-offset-x, 0px)), calc(var(--base-y) + var(--expand-offset-y, 0px))) 
               translateZ(450px) scale(1.45) !important;
}

.discovery-preview-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(1.0) contrast(1.1);
    transition: all 0.6s ease;
    z-index: 1;
}

.discovery-card-3d:hover .discovery-preview-img {
    filter: brightness(1.3) contrast(1.2);
}

.discovery-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 24px;
    background: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0.7) 60%, transparent 100%);
    color: white;
    z-index: 10;
    text-align: left;
    transform: translateZ(8px); /* Relief subtil pour éviter le clipping */
    pointer-events: none;
    backface-visibility: hidden;
}

.discovery-content h3 {
    font-size: 13.5px;
    font-weight: 950;
    text-transform: uppercase;
    color: #f97316;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0,0,0,1), 0 0 5px rgba(249, 115, 22, 0.3);
    line-height: 1.2;
    max-height: 2.4em; /* 2 lines max */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.discovery-content p {
    font-size: 11px;
    margin: 6px 0 0 0;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
    text-shadow: 0 2px 5px rgba(0,0,0,1);
    color: rgba(255, 255, 255, 0.9);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
    line-height: 1.4;
}

.discovery-card-3d:hover p {
    opacity: 1;
    transform: translateY(0);
}

/* Brouillard sur inactifs */
.drop-zone.vignette-focused .discovery-card-3d:not(:hover):not(.is-expanded) {
    filter: blur(2px) brightness(0.5);
    opacity: 0.6;
}
