/* Gallery styles are deliberately isolated from other page and admin components. */
.hv-public .hv-gallery-page { padding-bottom: clamp(4rem, 8vw, 7rem) !important; }
.hv-public .hv-gallery-title {
    color: var(--hv-navy); font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.65rem, 3vw, 2.45rem); letter-spacing: -.035em;
}
.hv-public .hv-gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.hv-public .hv-gallery-item { min-width: 0; }
.hv-public .hv-gallery-item a {
    display: block; position: relative; overflow: hidden; border-radius: 18px;
    background: #e8edf3; aspect-ratio: 4 / 3;
    box-shadow: 0 7px 26px rgba(21, 46, 80, .09);
}
.hv-public .hv-gallery-item img {
    display: block; width: 100%; height: 100%; object-fit: cover;
    transition: transform .25s ease;
}
/* The JavaScript-enhanced gallery gives every photograph its natural ratio.
   The original CSS grid above remains the no-JavaScript fallback. */
.hv-public .hv-gallery-grid.hv-gallery-grid--masonry {
    position: relative;
    display: block;
}
.hv-public .hv-gallery-grid.hv-gallery-grid--masonry .hv-gallery-item {
    position: absolute;
    top: 0;
    left: 0;
}
.hv-public .hv-gallery-grid.hv-gallery-grid--masonry .hv-gallery-item a {
    aspect-ratio: var(--hv-photo-ratio, 4 / 3);
}
/* Fit the picture to its own (not a forced landscape) frame. */
.hv-public .hv-gallery-grid.hv-gallery-grid--masonry .hv-gallery-item img {
    object-fit: contain;
}

@media (hover:hover) {
    .hv-public .hv-gallery-item a:hover img { transform: scale(1.045); }
    .hv-public .hv-gallery-item a:hover .hv-gallery-zoom { opacity: 1; }
}
.hv-public .hv-gallery-zoom {
    position: absolute; right: 12px; bottom: 12px;
    border-radius: 50%; background: rgba(21,46,80,.8); color: white;
    width: 37px; height: 37px; display: grid; place-items: center;
    opacity: 0; transition: opacity .2s ease; font-size: 1.25rem;
}
.hv-public .hv-gallery-thumb-caption {
    color: #56677b; font-size: .89rem; line-height: 1.5; margin-top: 11px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.hv-public .hv-gallery-empty { max-width: 680px; }
.hv-gallery-lightbox {
    width: min(96vw, 1180px); max-width: none; max-height: 95vh;
    overflow: visible; border: 0; border-radius: 22px;
    background: rgba(20, 32, 50, .96); color: #fff;
    padding: 0; box-shadow: 0 28px 95px rgba(0,0,0,.5);
}
.hv-gallery-lightbox::backdrop {
    background: rgba(10, 20, 35, .77);
    -webkit-backdrop-filter: blur(9px);
    backdrop-filter: blur(9px);
}
.hv-gallery-lightbox-panel { padding: 52px 18px 17px; position: relative; }
.hv-gallery-close {
    position: absolute; top: 11px; right: 18px; z-index: 3;
    border: 0; background: transparent; color: #fff; line-height: 1;
    font-size: 2.25rem; width: 38px; height: 38px; border-radius: 9px;
}
.hv-gallery-close:hover, .hv-gallery-arrow:hover { background: rgba(255,255,255,.14); }
.hv-gallery-lightbox-stage {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    min-height: 150px;
}
.hv-gallery-lightbox-stage img {
    display: block; max-width: calc(100% - 100px); max-height: min(72vh, 840px);
    object-fit: contain; width: auto; height: auto; border-radius: 12px;
}
.hv-gallery-arrow {
    border: none; background: rgba(255,255,255,.075); color: #fff;
    border-radius: 50%; width: 42px; height: 42px; flex: 0 0 42px;
    font-size: 1.45rem; display: grid; place-items: center; cursor: pointer;
}
.hv-gallery-arrow[hidden], .hv-gallery-lightbox-description[hidden] { display: none; }
.hv-gallery-lightbox-footer {
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    text-align: center; gap: 7px; min-height: 48px; margin: 12px auto 0;
    max-width: 800px; padding: 0 12px;
}
.hv-gallery-lightbox-description { overflow-wrap: anywhere; white-space: pre-line; color: #eef3fa; }
.hv-gallery-lightbox-counter { color: #aebed1; font-size: .8rem; }
@media (max-width: 991.98px) { .hv-public .hv-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } }
@media (max-width: 575.98px) {
    .hv-public .hv-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .hv-public .hv-gallery-item a { border-radius: 12px; }
    .hv-public .hv-gallery-thumb-caption { font-size: .77rem; margin-top: 6px; }
    .hv-gallery-lightbox { width: 100vw; max-height: 100vh; border-radius: 0; }
    .hv-gallery-lightbox-panel { padding: 49px 8px 14px; }
    .hv-gallery-lightbox-stage { gap: 4px; }
    .hv-gallery-lightbox-stage img { max-width: calc(100% - 72px); max-height: 75vh; }
    .hv-gallery-arrow { width: 32px; height: 40px; flex-basis: 32px; border-radius: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .hv-public .hv-gallery-item img { transition: none; }
}

/* Mixed photo/video viewer: keep both media types within the same stage. */
.hv-gallery-lightbox-stage img[hidden],
.hv-gallery-lightbox-stage video[hidden] { display: none !important; }
.hv-gallery-lightbox-stage video {
    display: block;
    width: auto;
    height: auto;
    max-width: calc(100% - 108px);
    max-height: min(72vh, 840px);
    min-width: 0;
    object-fit: contain;
    background: #080b13;
    border-radius: 12px;
}
@media (max-width: 575.98px) {
    .hv-gallery-lightbox-stage video {
        max-width: calc(100% - 72px);
        max-height: min(68dvh, 75vh);
    }
}
