/* ================================================
   SYSTÈME DE POPUPS
   ================================================ */

/* Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 27, 22, 0.62);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.popup-overlay.active {
    display: block;
    opacity: 1;
}

/* Container Principal */
.popup-container {
    position: fixed;
    z-index: 9999;
    display: none;
}

.popup-container.active,
.popup-container.closing {
    display: block;
}

/* Positions */
.popup-container.position-center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.popup-container.position-top { top: 20px; left: 50%; transform: translateX(-50%); }
.popup-container.position-bottom { bottom: 20px; left: 50%; transform: translateX(-50%); }

/* Entrée : le popup glisse du haut vers sa place ; sortie : il remonte */
.popup-container.position-center.active { animation: popupDropCenter .6s cubic-bezier(.22, 1, .36, 1) both; }
.popup-container.position-top.active { animation: popupDropTop .6s cubic-bezier(.22, 1, .36, 1) both; }
.popup-container.position-bottom.active { animation: popupDropBottom .6s cubic-bezier(.22, 1, .36, 1) both; }

.popup-container.position-center.closing { animation: popupLiftCenter .35s ease-in both; }
.popup-container.position-top.closing { animation: popupLiftTop .35s ease-in both; }
.popup-container.position-bottom.closing { animation: popupLiftBottom .35s ease-in both; }

@keyframes popupDropCenter {
    from { opacity: 0; transform: translate(-50%, calc(-50% - 40vh)); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes popupDropTop {
    from { opacity: 0; transform: translate(-50%, -120%); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes popupDropBottom {
    from { opacity: 0; transform: translate(-50%, -60px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes popupLiftCenter {
    from { opacity: 1; transform: translate(-50%, -50%); }
    to { opacity: 0; transform: translate(-50%, calc(-50% - 40vh)); }
}

@keyframes popupLiftTop {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -120%); }
}

@keyframes popupLiftBottom {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -60px); }
}

/* Mouvements réduits demandés par le système : simple apparition */
@media (prefers-reduced-motion: reduce) {
    .popup-container.active,
    .popup-container.closing { animation-duration: .01s; }
}

/* Tailles */
.popup-container.size-small {
    max-width: 400px;
    width: 90%;
}

.popup-container.size-medium {
    max-width: 600px;
    width: 90%;
}

.popup-container.size-large {
    max-width: 800px;
    width: 90%;
}

/* Popup Content */
.popup-content {
    background: var(--surface, #fff);
    border-radius: var(--radius-lg, 16px);
    box-shadow: 0 24px 60px -20px rgba(31, 27, 22, 0.45);
    overflow: hidden;
    position: relative;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

/* Bouton de fermeture */
.popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    background: rgba(31, 27, 22, 0.55);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.popup-close:hover {
    background: rgba(31, 27, 22, 0.85);
}

/* Image */
.popup-image {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    max-height: 300px;
    object-fit: cover;
}

/* Body */
.popup-body {
    padding: 24px 28px 28px;
}

/* Mention « Publicité » (annonceur) */
.popup-sponsor {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted, #776e63);
}

/* Title */
.popup-title {
    font-family: var(--font-display, inherit);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.15;
    margin-bottom: 10px;
    color: var(--ink, #1f1b16);
}

/* Content */
.popup-text {
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink-2, #4d463d);
    margin-bottom: 20px;
}

/* Button */
.popup-button {
    display: inline-block;
    padding: 12px 26px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

.popup-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Types de Popup : un liseré et un bouton aux couleurs du site */
.popup-content { border-top: 5px solid var(--green, #0e7f41); }
.popup-content .popup-button { background: var(--green, #0e7f41); color: #fff; }
.popup-content .popup-button:hover { background: var(--green-700, #08552b); color: #fff; }

.popup-content.type-info { border-top-color: var(--ink, #1f1b16); }
.popup-content.type-info .popup-button { background: var(--ink, #1f1b16); }
.popup-content.type-info .popup-button:hover { background: #000; }

.popup-content.type-warning { border-top-color: var(--red, #c4242d); }
.popup-content.type-warning .popup-button { background: var(--red, #c4242d); }
.popup-content.type-warning .popup-button:hover { background: #9e1c24; }

.popup-content.type-promotion,
.popup-content.type-announcement { border-top-color: var(--yellow, #f2b705); }
.popup-content.type-promotion .popup-button,
.popup-content.type-announcement .popup-button { background: var(--yellow, #f2b705); color: var(--ink, #1f1b16); }
.popup-content.type-promotion .popup-button:hover,
.popup-content.type-announcement .popup-button:hover { background: #d9a404; color: var(--ink, #1f1b16); }

/* Avec une image, le liseré passe sous l'image */
.popup-content.has-image { border-top: 0; }
.popup-content.has-image .popup-body { border-top: 5px solid var(--green, #0e7f41); }
.popup-content.has-image.type-info .popup-body { border-top-color: var(--ink, #1f1b16); }
.popup-content.has-image.type-warning .popup-body { border-top-color: var(--red, #c4242d); }
.popup-content.has-image.type-promotion .popup-body,
.popup-content.has-image.type-announcement .popup-body { border-top-color: var(--yellow, #f2b705); }

/* Responsive */
@media (max-width: 768px) {
    .popup-container {
        width: 95% !important;
        max-width: none !important;
    }

    .popup-container.position-top {
        top: 10px;
    }

    .popup-container.position-bottom {
        bottom: 10px;
    }

    .popup-body {
        padding: 20px;
    }

    .popup-title {
        font-size: 20px;
    }

    .popup-text {
        font-size: 14px;
    }

    .popup-image {
        max-height: 200px;
    }
}

/* Animation d'entrée pour l'overlay */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.popup-overlay.active {
    animation: fadeIn 0.3s ease;
}

/* Performance */
.popup-container,
.popup-overlay {
    will-change: opacity, transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
