/* Galería pública — rejilla foto primero */

.gallery-page {
    padding-top: 2rem;
    padding-bottom: 4rem;
}

.gallery-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    margin-bottom: 1.75rem;
}

.gallery-toolbar .public-share {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.gallery-search {
    display: block;
    flex: 0 1 16rem;
    width: min(100%, 16rem);
    margin: 0;
    margin-left: auto;
}

.gallery-search .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.gallery-search__input {
    width: 100%;
    height: 2.5rem;
    border-radius: 0.75rem;
    border-color: rgba(11, 24, 51, 0.14);
    color: #0b1833;
}

.gallery-search__input:focus {
    border-color: #0052CC;
    box-shadow: 0 0 0 0.2rem rgba(0, 82, 204, 0.15);
}

@media (max-width: 575.98px) {
    .gallery-search {
        flex: 1 1 100%;
        width: 100%;
        max-width: none;
        margin-left: 0;
    }
}

.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.gallery-filter {
    appearance: none;
    border: 1px solid rgba(11, 24, 51, 0.14);
    background: #fff;
    color: #0b1833;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-filter:hover {
    border-color: #0052CC;
    color: #0052CC;
}

.gallery-filter.is-active {
    background: #0b1833;
    border-color: #0b1833;
    color: #fff;
    box-shadow: 0 6px 16px rgba(11, 24, 51, 0.18);
}

.gallery-filter:focus-visible {
    outline: 2px solid #0052CC;
    outline-offset: 2px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 576px) {
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.5rem;
    }
}

@media (min-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.gallery-tile {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    border-radius: 1rem;
    overflow: hidden;
    background: #0b1833;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 10px 28px rgba(11, 24, 51, 0.12);
    isolation: isolate;
}

.gallery-tile__media {
    position: absolute;
    inset: 0;
}

.gallery-tile__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: scale(1);
    transition: transform 0.45s ease;
}

.gallery-tile__shade {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(11, 24, 51, 0.08) 0%, rgba(11, 24, 51, 0.15) 42%, rgba(11, 24, 51, 0.82) 100%);
    z-index: 1;
    pointer-events: none;
}

.gallery-tile__chip {
    position: absolute;
    top: 0.85rem;
    left: 0.85rem;
    z-index: 2;
    max-width: calc(100% - 1.7rem);
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0b1833;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-tile__meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 1rem 1rem 1.1rem;
    color: #fff;
}

.gallery-tile__title {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-tile__count {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.88;
    font-weight: 500;
}

.gallery-tile__cta {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    transform: translate(-50%, -40%);
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    background: #0052CC;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 8px 20px rgba(0, 82, 204, 0.35);
}

.gallery-tile:hover .gallery-tile__media img,
.gallery-tile:focus-visible .gallery-tile__media img {
    transform: scale(1.06);
}

.gallery-tile:hover .gallery-tile__cta,
.gallery-tile:focus-visible .gallery-tile__cta {
    opacity: 1;
    transform: translate(-50%, -50%);
}

.gallery-tile:focus-visible {
    outline: 3px solid #0052CC;
    outline-offset: 3px;
}

.gallery-tile.is-hidden {
    display: none;
}

.gallery-empty {
    margin: 2.5rem 0 0;
    text-align: center;
    color: #64748b;
    font-size: 1rem;
}

.gallery-sentinel {
    width: 100%;
    height: 1px;
    margin-top: 1.5rem;
    pointer-events: none;
}

.gallery-restore-spacer {
    width: 100%;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            180deg,
            rgba(219, 228, 243, 0.35) 0,
            rgba(219, 228, 243, 0.35) 12px,
            transparent 12px,
            transparent 28px
        );
}

.gallery-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.75rem;
}

.gallery-load-more {
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: #0052CC;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.7rem 1.4rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 82, 204, 0.28);
    transition: background 0.2s ease, transform 0.2s ease;
}

.gallery-load-more:hover:not(:disabled) {
    background: #0047B3;
}

.gallery-load-more:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Skeleton placeholders — ocupan el hueco mientras llega el lote */
.gallery-skeleton {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 1rem;
    overflow: hidden;
    background: linear-gradient(135deg, #dbe4f3 0%, #eef2f8 55%, #d5deee 100%);
    box-shadow: 0 8px 20px rgba(11, 24, 51, 0.08);
}

.gallery-skeleton__shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        transparent 20%,
        rgba(255, 255, 255, 0.55) 45%,
        transparent 70%
    );
    transform: translateX(-100%);
    animation: gallery-shimmer 1.25s ease-in-out infinite;
}

.gallery-skeleton__chip {
    position: absolute;
    top: 0.85rem;
    left: 0.85rem;
    width: 4.5rem;
    height: 1.15rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
}

.gallery-skeleton__meta {
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
}

.gallery-skeleton__line {
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.72);
}

.gallery-skeleton__line--title {
    width: 72%;
    height: 0.95rem;
    margin-bottom: 0.45rem;
}

.gallery-skeleton__line--count {
    width: 38%;
    height: 0.7rem;
}

@keyframes gallery-shimmer {
    100% { transform: translateX(100%); }
}

.gallery-tile--enter {
    animation: gallery-tile-in 0.38s ease both;
    animation-delay: var(--gallery-tile-delay, 0ms);
}

@keyframes gallery-tile-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-tile__media img,
    .gallery-tile__cta,
    .gallery-photo__media,
    .gallery-photo__cta {
        transition: none;
    }

    .gallery-skeleton__shine,
    .gallery-tile--enter {
        animation: none;
    }
}

/* ——— Álbum: rejilla de fotos (mismo lenguaje visual) ——— */

.gallery-album-page {
    -webkit-user-select: none;
    user-select: none;
}

.gallery-photo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

@media (min-width: 768px) {
    .gallery-photo-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.15rem;
    }
}

@media (min-width: 1200px) {
    .gallery-photo-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1.35rem;
    }
}

.gallery-photo {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    border-radius: 1rem;
    overflow: hidden;
    background: linear-gradient(135deg, #dbe4f3 0%, #eef2f8 55%, #d5deee 100%);
    cursor: zoom-in;
    box-shadow: 0 10px 28px rgba(11, 24, 51, 0.12);
    isolation: isolate;
}

.gallery-photo--pending .gallery-photo__media {
    opacity: 0;
}

.gallery-photo.is-loading .gallery-photo__media,
.gallery-photo.is-loaded .gallery-photo__media {
    opacity: 1;
    transition: opacity 0.35s ease, transform 0.45s ease;
}

.gallery-photo-skeleton {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 1rem;
    overflow: hidden;
    background: linear-gradient(135deg, #dbe4f3 0%, #eef2f8 55%, #d5deee 100%);
    box-shadow: 0 8px 20px rgba(11, 24, 51, 0.08);
}

.gallery-photo-skeleton__shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        transparent 20%,
        rgba(255, 255, 255, 0.55) 45%,
        transparent 70%
    );
    transform: translateX(-100%);
    animation: gallery-shimmer 1.25s ease-in-out infinite;
}

.gallery-photo__media {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    transform: scale(1);
    transition: transform 0.45s ease;
    pointer-events: none;
    -webkit-user-drag: none;
}

.gallery-photo__shield {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
}

.gallery-photo__meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: 0.75rem 0.85rem;
    background: linear-gradient(180deg, transparent 0%, rgba(11, 24, 51, 0.72) 100%);
    color: #fff;
    pointer-events: none;
}

.gallery-photo__hits {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
}

.gallery-photo__cta {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    transform: translate(-50%, -40%);
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    background: #0052CC;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 8px 20px rgba(0, 82, 204, 0.35);
}

.gallery-photo:hover .gallery-photo__media,
.gallery-photo:focus-visible .gallery-photo__media {
    transform: scale(1.05);
}

.gallery-photo:hover .gallery-photo__cta,
.gallery-photo:focus-visible .gallery-photo__cta {
    opacity: 1;
    transform: translate(-50%, -50%);
}

.gallery-photo:focus-visible {
    outline: 3px solid #0052CC;
    outline-offset: 3px;
}

/* Lightbox protegido */
body.gallery-lightbox-open {
    overflow: hidden;
}

.gallery-lightbox[hidden] {
    display: none !important;
}

.gallery-lightbox {
    --gallery-lightbox-offset: 5.5rem;
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: stretch;
    justify-content: center;
    /* El menú público es fixed y queda por encima (z-index 10001):
       el diálogo empieza debajo para que título y compartir no se tapen. */
    padding: var(--gallery-lightbox-offset) 1rem 1rem;
    box-sizing: border-box;
}

.gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 14, 30, 0.88);
}

.gallery-lightbox__dialog {
    position: relative;
    z-index: 1;
    width: min(1100px, 100%);
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gallery-lightbox__top {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    color: #fff;
}

.gallery-lightbox__title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-lightbox__share {
    flex: 0 0 auto;
}

.gallery-lightbox__share .public-share {
    margin: 0;
}

.gallery-lightbox__share .public-share__btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
    box-shadow: none;
}

.gallery-lightbox__share .public-share__btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.gallery-lightbox__share .public-share__toast {
    left: auto;
    right: 0;
}

.gallery-lightbox__close {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    flex: 0 0 auto;
}

.gallery-lightbox__close svg {
    display: block;
    flex-shrink: 0;
}

.gallery-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.gallery-lightbox__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.gallery-lightbox__stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.gallery-lightbox__frame {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    align-self: stretch;
    border-radius: 1rem;
    overflow: hidden;
    background: #0b1833;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.gallery-lightbox__image {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    -webkit-user-drag: none;
}

.gallery-lightbox__shield {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
    cursor: default;
}

.gallery-lightbox__nav {
    appearance: none;
    border: 0;
    flex: 0 0 auto;
    align-self: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 999px;
    background: #0052CC;
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 82, 204, 0.35);
}

.gallery-lightbox__nav:hover {
    background: #0047B3;
}

.gallery-lightbox__counter {
    flex: 0 0 auto;
    margin: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    font-weight: 600;
}

@media (max-width: 575.98px) {
    .gallery-lightbox {
        --gallery-lightbox-offset: 4.75rem;
        padding-left: 0.65rem;
        padding-right: 0.65rem;
        padding-bottom: 0.75rem;
    }

    .gallery-lightbox__nav {
        position: absolute;
        top: 50%;
        z-index: 3;
        transform: translateY(-50%);
    }

    .gallery-lightbox__nav--prev {
        left: 0.35rem;
    }

    .gallery-lightbox__nav--next {
        right: 0.35rem;
    }

    .gallery-lightbox__frame {
        min-height: 0;
    }
}

/* Botón flotante: volver (arriba, alineado al contenedor de thumbs; WhatsApp abajo derecha) */
.gallery-album-fab {
    --gallery-album-fab-top: 5.5rem;
    --gallery-album-fab-left: 1.1rem;
    position: fixed;
    left: var(--gallery-album-fab-left);
    right: auto;
    top: var(--gallery-album-fab-top);
    bottom: auto;
    z-index: 1045;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.15rem;
    border-radius: 999px;
    background: #0052CC;
    color: #fff !important;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none !important;
    box-shadow: 0 10px 28px rgba(0, 82, 204, 0.35);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, top 0.15s ease, left 0.15s ease;
}

.gallery-album-fab.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.gallery-album-fab:hover {
    background: #0047B3;
    color: #fff !important;
}

body.gallery-lightbox-open .gallery-album-fab {
    opacity: 0 !important;
    pointer-events: none !important;
}

@media (max-width: 575.98px) {
    .gallery-album-fab {
        --gallery-album-fab-top: 4.75rem;
        --gallery-album-fab-left: 0.85rem;
        max-width: calc(100vw - 1.7rem);
        font-size: 0.85rem;
        padding: 0.65rem 1rem;
    }
}
