/* ==========================================================================
   Memorial popup - In ricordo di Roberto Giamagli
   Isolato con prefisso .memorial-popup (nessuna dipendenza da Bootstrap).
   Breakpoint: < 768px mobile (immagine sopra) / >= 768px due colonne.
   ========================================================================== */

.memorial-popup {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100000;
    padding: 16px;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.memorial-popup.is-open {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

.memorial-popup *,
.memorial-popup *:before,
.memorial-popup *:after {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.memorial-popup__overlay {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    -webkit-transition: opacity .3s ease;
    transition: opacity .3s ease;
}

/* --- Dialog ------------------------------------------------------------- */

.memorial-popup__dialog {
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -ms-flex-direction: column;
    flex-direction: column;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    margin: 0;
    background: #12202B;
    color: #B8C8D0;
    overflow: hidden;
    -webkit-box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    outline: none;
    opacity: 0;
    -webkit-transform: translateY(16px);
    transform: translateY(16px);
    -webkit-transition: opacity .3s ease, -webkit-transform .3s ease;
    transition: opacity .3s ease, transform .3s ease;
}

.memorial-popup.is-visible .memorial-popup__overlay,
.memorial-popup.is-visible .memorial-popup__dialog {
    opacity: 1;
}

.memorial-popup.is-visible .memorial-popup__dialog {
    -webkit-transform: none;
    transform: none;
}

/* Mobile: scorre tutto il contenuto (immagine + testo) */
.memorial-popup__scroll {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* --- Close button ------------------------------------------------------- */

.memorial-popup .memorial-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(18, 32, 43, 0.65);
    font-size: 0;
    line-height: 0;
    text-shadow: none;
    opacity: 1;
    cursor: pointer;
    -webkit-transition: background-color .2s ease;
    transition: background-color .2s ease;
}

/* X disegnata in CSS: indipendente dal font */
.memorial-popup .memorial-popup__close:before,
.memorial-popup .memorial-popup__close:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    margin: -1px 0 0 -10px;
    background: #FFFFFF;
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
}

.memorial-popup .memorial-popup__close:after {
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);
}

.memorial-popup .memorial-popup__close:hover {
    background: #006C9C;
}

.memorial-popup .memorial-popup__close:focus {
    outline: 2px solid #006C9C;
    outline-offset: 2px;
}

.memorial-popup .memorial-popup__close:focus:not(:focus-visible) {
    outline: none;
}

/* --- Media (mobile: immagine sopra, nome/ruolo sotto la foto) ------------ */

.memorial-popup__media {
    position: relative;
    margin: 0;
    padding: 0;
}

.memorial-popup__picture {
    display: block;
}

.memorial-popup .memorial-popup__img {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0;
    border: 0;
}

.memorial-popup__caption {
    display: block;
    padding: 24px 24px 0;
}

.memorial-popup__name,
.memorial-popup__role {
    display: block;
}

.memorial-popup__name {
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.3;
}

.memorial-popup__role {
    margin-top: 4px;
    color: #B8C8D0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: .04em;
}

/* --- Content ------------------------------------------------------------ */

.memorial-popup__content {
    padding: 24px 24px 32px;
}

.memorial-popup__date {
    display: block;
    margin: 0 0 12px;
    color: #B8C8D0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: .08em;
}

.memorial-popup .memorial-popup__title {
    margin: 0 0 16px;
    padding: 0;
    color: #F4F8FA;
    font-family: 'Montserrat', sans-serif;
    font-size: 30px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -.01em;
    text-transform: none;
    border: 0;
}

.memorial-popup__title-line {
    display: block;
}

/* Barretta di accento sotto il titolo */
.memorial-popup .memorial-popup__title:after {
    content: '';
    display: block;
    width: 32px;
    height: 2px;
    margin-top: 20px;
    background: #006C9C;
}

.memorial-popup .memorial-popup__subtitle {
    margin: 0 0 16px;
    padding: 0;
    color: #DCE6EB;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.5;
}

.memorial-popup .memorial-popup__body p {
    margin: 0 0 16px;
    padding: 0;
    color: #B8C8D0;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.7;
}

.memorial-popup .memorial-popup__body p:last-child {
    margin-bottom: 0;
}

/* --- Tablet / Desktop: due colonne ------------------------------------- */

@media (min-width: 768px) {
    .memorial-popup {
        padding: 24px;
    }

    .memorial-popup__dialog {
        max-width: 1200px;
        max-height: calc(100vh - 48px);
        max-height: calc(100dvh - 48px);
    }

    .memorial-popup__scroll {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        overflow: hidden;
        /* altezza minima = foto 2:3 a piena colonna (come Figma), entro il viewport */
        min-height: min(648px, calc((100vw - 48px) * 0.54), calc(100vh - 48px));
    }

    /* Colonna immagine ~36% */
    .memorial-popup__media {
        -webkit-box-flex: 0;
        -ms-flex: 0 0 36%;
        flex: 0 0 36%;
        max-width: 36%;
        overflow: hidden;
    }

    .memorial-popup__picture {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }

    /* cover necessario: la colonna si adatta all'altezza del testo */
    .memorial-popup .memorial-popup__img {
        width: 100%;
        height: 100%;
        -o-object-fit: cover;
        object-fit: cover;
        -o-object-position: 50% 20%;
        object-position: 50% 20%;
    }

    /* Nome e ruolo sovrapposti in basso alla foto */
    .memorial-popup__caption {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1;
        padding: 96px 32px 28px;
        background: -webkit-linear-gradient(top, rgba(18, 32, 43, 0) 0%, rgba(18, 32, 43, 0.85) 100%);
        background: linear-gradient(to bottom, rgba(18, 32, 43, 0) 0%, rgba(18, 32, 43, 0.85) 100%);
    }

    .memorial-popup__name {
        font-size: 20px;
    }

    .memorial-popup__role {
        color: #DCE6EB;
    }

    /* Colonna testo ~65%: scroll interno se il viewport è basso */
    .memorial-popup__content {
        -webkit-box-flex: 1;
        -ms-flex: 1 1 64%;
        flex: 1 1 64%;
        min-width: 0;
        max-height: calc(100vh - 48px);
        max-height: calc(100dvh - 48px);
        padding: 44px 48px 44px 48px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .memorial-popup .memorial-popup__close {
        top: 24px;
        right: 24px;
        background: transparent;
    }

    .memorial-popup .memorial-popup__close:before,
    .memorial-popup .memorial-popup__close:after {
        width: 18px;
        height: 1.5px;
        margin: -0.75px 0 0 -9px;
        background: #B8C8D0;
    }

    .memorial-popup .memorial-popup__close:hover {
        background: rgba(0, 108, 156, 0.35);
    }

    .memorial-popup .memorial-popup__title {
        font-size: 32px;
    }

    .memorial-popup .memorial-popup__subtitle {
        font-size: 17px;
    }

    .memorial-popup .memorial-popup__body p {
        margin-bottom: 14px;
        font-size: 14px;
        line-height: 1.65;
    }
}

@media (min-width: 992px) {
    .memorial-popup__content {
        padding: 48px 52px 48px 56px;
    }

    .memorial-popup__date {
        margin-bottom: 16px;
        font-size: 12px;
    }

    .memorial-popup .memorial-popup__title {
        margin-bottom: 18px;
        font-size: 38px;
        line-height: 1.2;
    }

    .memorial-popup .memorial-popup__subtitle {
        margin-bottom: 16px;
        font-size: 19px;
    }
}

/* Scrollbar sottile: contenitore mobile e colonna testo desktop.
   scrollbar-width solo per Firefox: in Chrome disattiverebbe gli stili ::-webkit-scrollbar */
@-moz-document url-prefix() {
    .memorial-popup__scroll,
    .memorial-popup__content {
        scrollbar-width: thin;
        scrollbar-color: rgba(184, 200, 208, 0.35) transparent;
    }
}

.memorial-popup__scroll::-webkit-scrollbar,
.memorial-popup__content::-webkit-scrollbar {
    width: 4px;
}

.memorial-popup__scroll::-webkit-scrollbar-track,
.memorial-popup__content::-webkit-scrollbar-track {
    background: transparent;
}

.memorial-popup__scroll::-webkit-scrollbar-thumb,
.memorial-popup__content::-webkit-scrollbar-thumb {
    background: rgba(184, 200, 208, 0.35);
    border-radius: 2px;
}

/* --- Blocco scroll pagina ---------------------------------------------- */

html.memorial-popup-open,
html.memorial-popup-open body {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .memorial-popup__overlay,
    .memorial-popup__dialog {
        -webkit-transition: none;
        transition: none;
    }
}
