/* ---------- Grid ---------- */
.obd-gallery {
    display: grid;
    grid-template-columns: repeat(var(--obd-cols, 4), minmax(0, 1fr));
    gap: var(--obd-gap, 12px);
    width: 100%;
}
@media (max-width: 1024px) {
    .obd-gallery { grid-template-columns: repeat(var(--obd-cols-tablet, 3), minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .obd-gallery { grid-template-columns: repeat(var(--obd-cols-mobile, 2), minmax(0, 1fr)); }
}

.obd-gallery__item {
    position: relative;
    display: block;
    aspect-ratio: var(--obd-ratio, 4 / 3);
    overflow: hidden;
    border-radius: var(--obd-radius, 10px);
    background: #cdbdad;
    cursor: zoom-in;
    box-shadow: 0 4px 14px rgba(61, 32, 0, 0.12);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.obd-gallery__item[hidden] { display: none; }

.obd-gallery__item .obd-gallery__img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    border-radius: 0;
    transition: transform 0.45s ease, filter 0.45s ease;
}

.obd-gallery__item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(61, 32, 0, 0.55), rgba(61, 32, 0, 0) 60%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.obd-gallery__zoom {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(221, 218, 195, 0.92);
    color: #3d2000;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.obd-gallery__item:hover,
.obd-gallery__item:focus-visible {
    box-shadow: 0 10px 26px rgba(61, 32, 0, 0.25);
    transform: translateY(-2px);
}
.obd-gallery__item:hover .obd-gallery__img,
.obd-gallery__item:focus-visible .obd-gallery__img { transform: scale(1.05); }
.obd-gallery__item:hover::after,
.obd-gallery__item:focus-visible::after { opacity: 1; }
.obd-gallery__item:hover .obd-gallery__zoom,
.obd-gallery__item:focus-visible .obd-gallery__zoom { opacity: 1; transform: none; }
.obd-gallery__item:focus-visible { outline: 3px solid #3d2000; outline-offset: 3px; }

/* "+N more" badge on the last visible tile */
.obd-gallery__more {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    background: rgba(61, 32, 0, 0.55);
    color: #fff;
    font-size: clamp(1.5rem, 3vw, 2.4rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background 0.25s ease;
}
.obd-gallery__item:hover .obd-gallery__more { background: rgba(61, 32, 0, 0.7); }

.obd-gallery-empty {
    padding: 16px;
    border: 2px dashed #a99988;
    border-radius: 10px;
    text-align: center;
    color: #3d2000;
}

@media (prefers-reduced-motion: reduce) {
    .obd-gallery__item,
    .obd-gallery__item .obd-gallery__img,
    .obd-gallery__zoom { transition: none; }
}

/* ---------- Lightbox ---------- */
.obd-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    background: rgba(24, 14, 4, 0.95);
    color: #dddac3;
    opacity: 0;
    transition: opacity 0.25s ease;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
}
.obd-lightbox[hidden] { display: none; }
.obd-lightbox.is-open { opacity: 1; }

.obd-lightbox__stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 72px 8px;
}
.obd-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.25s ease, transform 0.25s ease;
    user-select: none;
    -webkit-user-drag: none;
}
.obd-lightbox__img.is-loaded { opacity: 1; transform: none; }

.obd-lightbox__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(221, 218, 195, 0.25);
    border-top-color: #dddac3;
    border-radius: 50%;
    animation: obd-lightbox-spin 0.8s linear infinite;
}
.obd-lightbox__spinner[hidden] { display: none; }
@keyframes obd-lightbox-spin { to { transform: rotate(360deg); } }

.obd-lightbox__bar {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 16px;
    padding: 12px 20px calc(18px + env(safe-area-inset-bottom, 0px));
    text-align: center;
    font-size: 15px;
    line-height: 1.4;
}
.obd-lightbox__counter {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}
.obd-lightbox__caption { max-width: 70ch; }
.obd-lightbox__caption:empty { display: none; }

.obd-lightbox__btn {
    position: absolute;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(221, 218, 195, 0.12);
    color: #dddac3;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.obd-lightbox__btn:hover,
.obd-lightbox__btn:focus-visible {
    background: #dddac3;
    color: #3d2000;
}
.obd-lightbox__btn:focus-visible { outline: 2px solid #dddac3; outline-offset: 3px; }
.obd-lightbox__btn[hidden] { display: none; }
.obd-lightbox__close { top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; }
.obd-lightbox__prev,
.obd-lightbox__next { top: 50%; margin-top: -24px; }
.obd-lightbox__prev { left: 12px; }
.obd-lightbox__next { right: 12px; }

@media (max-width: 767px) {
    .obd-lightbox__stage { padding: 64px 8px 8px; }
    .obd-lightbox__prev,
    .obd-lightbox__next {
        top: auto;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        margin-top: 0;
    }
    .obd-lightbox__bar { padding-left: 68px; padding-right: 68px; min-height: 68px; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
    .obd-lightbox,
    .obd-lightbox__img { transition: none; }
}
