/* TH Popup Gallery v1.0
   Reutiliza el overlay de th-lightbox-button (thlb-overlay, thlb-close, thlb-overlay-bg).
   Solo añade lo necesario para el cuerpo con múltiples imágenes.
*/

/* ── Trigger ── */
.thpg-trigger-wrap {
    display: flex;
}

.thpg-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: filter .18s;
}
.thpg-btn:active { filter: brightness(.88); }

/* ── Overlay (autocontenido por si th-lightbox-button no está en la página) ── */
.thlb-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility .28s ease;
}
.thlb-overlay.is-open  { opacity: 1; visibility: visible; }
.thlb-overlay.is-closing { opacity: 0; }

.thlb-overlay-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.thlb-overlay .thlb-close {
    position: absolute !important;
    top: 16px !important;
    right: 16px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: unset !important;
    min-height: unset !important;
    padding: 0 !important;
    margin: 0 !important;
    background: rgba(255,255,255,.12) !important;
    border: 1px solid rgba(255,255,255,.2) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #fff !important;
    z-index: 2 !important;
    line-height: 1 !important;
    font-size: 0 !important;
    box-shadow: none !important;
    transition: background .18s ease, transform .18s ease !important;
}
.thlb-overlay .thlb-close:hover {
    background: rgba(255,255,255,.26) !important;
    transform: scale(1.08) !important;
}
.thlb-overlay .thlb-close svg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    pointer-events: none !important;
    display: block !important;
    fill: none !important;
}

/* ── Caja del popup (dentro del thlb-overlay) ── */
.thpg-box {
    position: relative;
    z-index: 1;
    background: #fff;
    width: 100%;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;

    transform: scale(.96) translateY(12px);
    opacity: 0;
    transition:
        transform .34s cubic-bezier(.34,1.3,.64,1),
        opacity   .28s ease;
}
.thlb-overlay.is-open .thpg-box {
    transform: none;
    opacity: 1;
}
.thlb-overlay.is-closing .thpg-box {
    transform: scale(.96) translateY(12px);
    opacity: 0;
}

/* ── Header ── */
.thpg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.thpg-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #1A1A1A;
    margin: 0;
}

/* ── Body scrollable ── */
.thpg-body {
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overscroll-behavior: contain;
}

/* ── Figura ── */
.thpg-figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thpg-figure img {
    display: block;
    width: 100%;
    height: auto;
}

/* ── Leyenda ── */
.thpg-legend {
    font-family: 'Open Sans', sans-serif;
    font-size: .85rem;
    color: #555;
    line-height: 1.5;
    text-align: center;
}

/* ── Responsive — sheet desde abajo en móvil ── */
@media (max-width: 600px) {
    .thlb-overlay:has(.thpg-box) {
        align-items: flex-end;
        padding: 0;
    }
    .thpg-box {
        max-height: 92vh;
        border-radius: 12px 12px 0 0;
        transform: translateY(30px);
        opacity: 1;
    }
    .thlb-overlay.is-open .thpg-box {
        transform: none;
    }
    .thlb-overlay.is-closing .thpg-box {
        transform: translateY(30px);
    }
}
