/*
 * Crowdfunding-Popup
 * Markup: inc/crowdfunding-popup.php, Logik: js/crowdfunding-popup.js
 */

.crp-popup[hidden] {
    display: none;
}

.crp-popup {
    position: fixed;
    inset: 0;
    z-index: 1000; /* höchster z-index in style.css ist 25 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    font-family: aller, sans-serif;
}

.crp-popup__overlay {
    position: absolute;
    inset: 0;
    background: rgba(28, 110, 134, 0.75); /* Petrol #1C6E86 */
    cursor: pointer;
}

.crp-popup__dialog {
    position: relative;
    width: 100%;
    /* Breite an 4:5 der verfügbaren Höhe koppeln, damit nie weiße Ränder entstehen */
    max-width: 440px;
    max-width: min(440px, calc((100vh - 32px) * 0.8));
    max-width: min(440px, calc((100dvh - 32px) * 0.8));
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    animation: crp-popup-in 0.25s ease-out;
}

.crp-popup__link {
    display: block;
    line-height: 0;
    border-radius: 6px;
    overflow: hidden;
}

/* Bild im 4:5-Format; auf kleinen Displays an die Viewport-Höhe gebunden,
   damit es inkl. Schließen-Button komplett sichtbar bleibt. */
.crp-popup__image {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    object-fit: contain;
    background: #ffffff;
}

.crp-popup__close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #00CFE3;
    color: #ffffff;
    font-size: 28px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.crp-popup__close:hover,
.crp-popup__close:focus {
    background: #1C6E86;
    outline: none;
}

.crp-popup__close:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

/* Seite dahinter nicht scrollen lassen, solange das Popup offen ist */
html.crp-popup-open,
html.crp-popup-open body {
    overflow: hidden;
}

@media (max-width: 480px) {
    .crp-popup__close {
        top: -8px;
        right: -8px;
    }
}

@keyframes crp-popup-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .crp-popup__dialog {
        animation: none;
    }
}
