/*-----------------------------------------------------------
Memorial Popup
------------------------------------------------------------*/

.custom-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(15, 18, 22, 0.65);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

/* hidden = never show (dismissed or not yet triggered) */
.custom-popup.hidden {
    display: none;
}

/* is-open = fade the dimmed backdrop in */
.custom-popup.is-open {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: #181818;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    text-align: center;
    transform: translateY(24px) scale(0.96);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
}

.custom-popup.is-open .popup-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.popup-media {
    width: 100%;
    line-height: 0;
}

.popup-media img {
    width: 100%;
    height: auto;
    display: block;
}

.popup-body {
    padding: 1rem 1.35rem 1.25rem 1.35rem;
}

.popup-title {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.3;
    color: #ffffff;
}

.popup-subtitle {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.4;
    color: #ffffff;
}

.popup-divider {
    display: block;
    width: 80%;
    max-width: 280px;
    height: auto;
    margin: 0 auto 1.0rem;
}

.popup-text {
    margin: 0 0 0.6rem;
    font-size: 0.95rem;
    line-height: 1.65;
    color: #ffffff;
}

.popup-dismiss {
    appearance: none;
    cursor: pointer;
    padding: 0.7rem 2.25rem;
    border: 1px solid #ffffff;
    border-radius: 0;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #ffffff;
    transition: background 0.25s ease, color 0.25s ease;
}

.popup-dismiss:hover {
    background: #ffffff;
    color: #181818;
}

.popup-dismiss:active {
    transform: translateY(1px);
}

.popup-close {
    position: absolute;
    top: 0.75rem;
    right: 0.9rem;
    z-index: 2;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
    transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.popup-close:hover {
    background: rgba(0, 0, 0, 0.75);
    transform: scale(1.12);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.popup-close:active {
    transform: scale(1.05);
}

.popup-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55);
}

@media (prefers-reduced-motion: reduce) {
    .custom-popup,
    .popup-content {
        transition: opacity 0.2s ease, visibility 0.2s ease;
        transform: none;
    }
}

/* Narrow phones: tighten side padding so text isn't cramped. */
@media (max-width: 480px) {
    .custom-popup {
        padding: 1rem;
    }
    .popup-body {
        padding: 0.6rem 1.5rem 1.75rem;
    }
}

/* Short screens: shrink the portrait and text so the whole popup
   always fits without scrolling. The capped image stays centered on
   the dark card, so no side gaps appear. */
@media (max-height: 820px) {
    .popup-media img {
        width: auto;
        max-width: 100%;
        max-height: 40vh;
        margin: 0 auto;
    }
    .popup-title { font-size: 1.2rem; }
    .popup-subtitle { font-size: 0.95rem; margin-bottom: 0.75rem; }
    .popup-text { font-size: 0.9rem; margin-bottom: 1rem; line-height: 1.55; }
    .popup-divider { margin-bottom: 1.1rem; }
    .popup-dismiss { padding: 0.6rem 2rem; }
}

@media (max-height: 680px) {
    .popup-media img {
        max-height: 32vh;
    }
    .popup-body {
        padding: 0.5rem 1rem 1.5rem;
    }
    .popup-title { font-size: 1.05rem; }
    .popup-subtitle { font-size: 0.85rem; margin-bottom: 0.6rem; }
    .popup-text { font-size: 0.82rem; margin-bottom: 0.9rem; }
    .popup-divider { margin-bottom: 0.9rem; max-width: 220px; }
}
