/* Popup GRIM — Frontend */

/* Overlay de fond */
.grim-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.grim-popup-overlay.grim-popup--visible {
    opacity: 1;
    visibility: visible;
}

.grim-popup-overlay.grim-popup--closing {
    opacity: 0;
    visibility: hidden;
}

/* Conteneur de la popup */
.grim-popup-container {
    position: relative;
    max-width: 700px;
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.04),
        0 20px 60px rgba(0, 0, 0, 0.28);
    transform: translateY(28px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.grim-popup-overlay.grim-popup--visible .grim-popup-container {
    transform: translateY(0) scale(1);
}

.grim-popup-overlay.grim-popup--closing .grim-popup-container {
    transform: translateY(28px) scale(0.95);
    transition: transform 0.25s ease-in;
}

/* Bouton de fermeture */
.grim-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.52);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    padding: 0;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s ease;
    outline-offset: 3px;
}

.grim-popup-close:hover,
.grim-popup-close:focus-visible {
    background: rgba(0, 0, 0, 0.82);
    transform: scale(1.12);
}

.grim-popup-close svg {
    width: 18px;
    height: 18px;
    display: block;
    pointer-events: none;
}

/* Image */
.grim-popup__link {
    display: block;
    line-height: 0;
    cursor: pointer;
}

.grim-popup__link:focus-visible {
    outline: 3px solid #6646ff;
    outline-offset: -3px;
}

.grim-popup__picture {
    display: block;
    line-height: 0;
}

.grim-popup__img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 82vh;
    object-fit: contain;
}

/* Empêcher le scroll en arrière-plan */
body.grim-popup-open {
    overflow: hidden;
}

/* ── Responsive mobile ── */
@media (max-width: 767px) {
    .grim-popup-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .grim-popup-container {
        max-width: 100%;
        border-radius: 12px 12px 0 0;
        transform: translateY(100%);
        max-height: 92vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .grim-popup-overlay.grim-popup--visible .grim-popup-container {
        transform: translateY(0);
    }

    .grim-popup-overlay.grim-popup--closing .grim-popup-container {
        transform: translateY(100%);
    }

    .grim-popup-close {
        top: 10px;
        right: 10px;
        width: 34px;
        height: 34px;
    }

    .grim-popup-close svg {
        width: 16px;
        height: 16px;
    }

    .grim-popup__img {
        max-height: 75vh;
    }
}
