/* WP Gallery — public site styles: the image grid (both new Gallery
   blocks and WordPress-imported galleries) and the lightbox. */

/* ---------------------------------------------------------------
   Grid — shared by .bh-gallery (new blocks) and .wp-block-gallery
   (WordPress-imported content, which has no per-instance override,
   so it uses the :root defaults set by App::rootStyle()).
   --------------------------------------------------------------- */
.bh-gallery,
figure.wp-block-gallery {
    display: grid !important;
    grid-template-columns: repeat(var(--bh-gallery-columns, 3), 1fr);
    gap: var(--bh-gallery-gap, 8px);
    margin: 1.5em 0;
    padding: 0;
    list-style: none;
}

.bh-gallery__item,
figure.wp-block-gallery figure.wp-block-image {
    margin: 0;
    position: relative;
}

.bh-gallery__item img,
figure.wp-block-gallery figure.wp-block-image img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: var(--bh-gallery-fit, cover);
    border-radius: 6px;
}

.bh-gallery__caption,
figure.wp-block-gallery figure.wp-block-image figcaption {
    font-size: 0.8em;
    color: #64748b;
    margin-top: 4px;
    text-align: center;
}

/* The caption-visibility setting only controls the grid; legacy WordPress
   captions are long image-description text meant for the lightbox, not
   under every thumbnail, so they're hidden in the grid unconditionally
   and still appear in the lightbox via the figcaption read at click time. */
figure.wp-block-gallery figure.wp-block-image figcaption { display: none; }

@media (max-width: 640px) {
    .bh-gallery,
    figure.wp-block-gallery {
        grid-template-columns: repeat(min(2, var(--bh-gallery-columns, 3)), 1fr) !important;
    }
}

.bh-gallery-empty {
    color: #94a3b8;
    font-style: italic;
}

/* ---------------------------------------------------------------
   Lightbox
   --------------------------------------------------------------- */
.bhg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.bhg-lightbox[hidden] { display: none; }

body.bhg-lightbox-open { overflow: hidden; }

.bhg-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.88);
}

.bhg-lightbox__dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-wrap: wrap;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.bhg-lightbox__media {
    flex: 1 1 65%;
    min-width: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    max-height: 90vh;
}
.bhg-lightbox__img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}
.bhg-lightbox__counter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
}

.bhg-lightbox__info {
    flex: 1 1 280px;
    max-width: 340px;
    padding: 22px 20px;
    overflow-y: auto;
    color: #e2e8f0;
    background: #111827;
}
.bhg-lightbox__title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 8px;
    color: #fff;
}
.bhg-lightbox__caption {
    font-size: 13.5px;
    line-height: 1.5;
    color: #cbd5e1;
    margin: 0 0 14px;
}
.bhg-lightbox__meta {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 14px;
}
.bhg-lightbox__sizes {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.8;
    margin-bottom: 18px;
}
.bhg-lightbox__sizes-label { color: #64748b; }
.bhg-lightbox__sizes a,
.bhg-lightbox__download {
    color: #60a5fa;
    text-decoration: none;
}
.bhg-lightbox__sizes a:hover { text-decoration: underline; }

.bhg-lightbox__download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
}
.bhg-lightbox__download:hover { background: #1e293b; }
.bhg-lightbox__download[hidden] { display: none; }

.bhg-lightbox__close,
.bhg-lightbox__nav {
    position: absolute;
    z-index: 2;
    border: none;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.bhg-lightbox__close {
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    font-size: 22px;
}
.bhg-lightbox__close:hover { background: rgba(220, 38, 38, 0.85); }

.bhg-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 999px;
    font-size: 26px;
}
.bhg-lightbox__prev { left: 14px; }
.bhg-lightbox__next { right: 14px; }
.bhg-lightbox__nav:hover { background: rgba(37, 99, 235, 0.85); }
.bhg-lightbox--single .bhg-lightbox__nav { display: none; }

@media (max-width: 760px) {
    .bhg-lightbox { padding: 0; }
    .bhg-lightbox__dialog { max-height: 100vh; border-radius: 0; flex-direction: column; }
    .bhg-lightbox__media { max-height: 55vh; }
    .bhg-lightbox__img { max-height: 55vh; }
    .bhg-lightbox__info { max-width: none; max-height: 45vh; }
}
