/* Gallery — frontend styles. */

/* Grid layout */
.b-galgrid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(6px, 1.2vw, 12px);
}

.b-galgrid .photo {
    overflow: hidden;
    border-radius: var(--radius-sm, 10px);
    background: var(--surface2, #f5f1ea);
}

@media (max-width: 900px) {
    .b-galgrid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
    .b-galgrid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
}

/* Masonry layout */
.b-masonry {
    columns: 3 140px;
    column-gap: clamp(6px, 1.2vw, 12px);
}

.b-masonry .photo {
    margin-bottom: clamp(6px, 1.2vw, 12px);
    break-inside: avoid;
    overflow: hidden;
    border-radius: var(--radius-sm, 10px);
    background: var(--surface2, #f5f1ea);
}

@media (max-width: 500px) {
    .b-masonry { columns: 2 100px; column-gap: 6px; }
    .b-masonry .photo { margin-bottom: 6px; }
}

/* Lightbox trigger cursor on gallery images */
.b-galgrid .photo img[role="button"],
.b-masonry .photo img[role="button"] {
    cursor: zoom-in;
    transition: transform 0.22s var(--ease-out, cubic-bezier(.2,.7,.2,1)),
                filter 0.22s ease;
}

@media (hover: hover) {
    .b-galgrid .photo img[role="button"]:hover,
    .b-masonry .photo img[role="button"]:hover {
        transform: scale(1.03);
        filter: brightness(1.04);
    }
}

/* ===================================================================
   KabLightbox overlay (inlined here — scoped to #kab-lb so duplicate
   enqueues by other blocks are idempotent).
   =================================================================== */

#kab-lb {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
#kab-lb[hidden] { display: none; }
#kab-lb .kab-lb__bd {
    position: absolute; inset: 0;
    background: var(--overlay, rgba(12, 18, 26, 0.78));
    opacity: 0;
    transition: opacity 0.22s ease;
}
#kab-lb.kab-lb--visible .kab-lb__bd { opacity: 1; }
#kab-lb .kab-lb__frame {
    position: relative; z-index: 1;
    display: flex; align-items: center; gap: 10px;
    max-width: min(96vw, 1200px);
    max-height: 96dvh;
    padding: 0 6px;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.22s ease, transform 0.22s var(--ease-out, cubic-bezier(.2,.7,.2,1));
    pointer-events: none;
}
#kab-lb.kab-lb--visible .kab-lb__frame {
    opacity: 1; transform: scale(1); pointer-events: auto;
}
#kab-lb .kab-lb__media {
    position: relative; display: flex; flex-direction: column;
    align-items: center; gap: 10px;
    max-width: min(88vw, 1060px); max-height: 90dvh;
}
#kab-lb .kab-lb__img {
    display: block;
    max-width: 100%; max-height: 82dvh;
    width: auto; height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm, 10px);
    box-shadow: var(--shadow-pop, 0 30px 70px -20px rgba(12,18,26,.55));
}
#kab-lb .kab-lb__cap {
    margin: 0; font-size: 0.82rem; line-height: 1.4;
    color: rgba(255, 255, 255, 0.75);
    text-align: center; max-width: 56ch;
}
#kab-lb .kab-lb__counter {
    position: absolute; bottom: -28px; left: 50%; transform: translateX(-50%);
    font-size: 0.72rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap; pointer-events: none;
}
#kab-lb .kab-lb__close {
    position: absolute; top: -14px; right: -14px; z-index: 2;
    width: 36px; height: 36px; border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(20, 16, 12, 0.7); color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0;
    transition: background 0.14s ease, border-color 0.14s ease;
}
#kab-lb .kab-lb__close:hover {
    background: rgba(30, 24, 18, 0.9);
    border-color: rgba(255, 255, 255, 0.45);
}
#kab-lb .kab-lb__close:focus-visible {
    outline: 2px solid var(--accent, #9c3a52); outline-offset: 3px;
}
#kab-lb .kab-lb__nav {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    background: rgba(20, 16, 12, 0.55); color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0;
    transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}
#kab-lb .kab-lb__nav:hover {
    background: rgba(30, 24, 18, 0.85); border-color: rgba(255, 255, 255, 0.45);
}
#kab-lb .kab-lb__nav:active { transform: scale(0.93); }
#kab-lb .kab-lb__nav:focus-visible {
    outline: 2px solid var(--accent, #9c3a52); outline-offset: 3px;
}
@media (max-width: 600px) {
    #kab-lb .kab-lb__frame {
        flex-direction: column; padding: 0; gap: 14px; max-width: 100vw;
    }
    #kab-lb .kab-lb__nav { width: 40px; height: 40px; }
    #kab-lb .kab-lb__img { max-height: 72dvh; }
}
@media (prefers-reduced-motion: reduce) {
    #kab-lb .kab-lb__bd,
    #kab-lb .kab-lb__frame { transition: none; }
}
