/* === Thumbnail Gallery === */

.bkbg-tgal-wrap {
    box-sizing: border-box;
    width: 100%;
}

.bkbg-tgal-inner {
    margin: 0 auto;
}

/* ── container flex layouts ── */
.bkbg-tgal-container {
    display: flex;
    gap: 12px;
}

.bkbg-tgal-container.pos-bottom,
.bkbg-tgal-container.pos-top {
    flex-direction: column;
}

.bkbg-tgal-container.pos-top {
    flex-direction: column-reverse;
}

.bkbg-tgal-container.pos-left {
    flex-direction: row;
}

.bkbg-tgal-container.pos-right {
    flex-direction: row-reverse;
}

/* ── main image area ── */
.bkbg-tgal-main {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.bkbg-tgal-main img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.bkbg-tgal-main img.is-fade-out {
    opacity: 0;
}

.bkbg-tgal-main img.is-fade-in {
    opacity: 1;
}

/* ── caption overlay ── */
.bkbg-tgal-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    font-family:      var(--bktg-cp-font-family, inherit);
    font-size:        var(--bktg-cp-font-size-d, 13px);
    line-height:      var(--bktg-cp-line-height-d, 1.4);
    font-weight:      var(--bktg-cp-font-weight, normal);
    font-style:       var(--bktg-cp-font-style, normal);
    text-decoration:  var(--bktg-cp-text-decoration, none);
    text-transform:   var(--bktg-cp-text-transform, none);
    letter-spacing:   var(--bktg-cp-letter-spacing-d, normal);
    word-spacing:     var(--bktg-cp-word-spacing-d, normal);
    pointer-events: none;
}

/* ── counter badge ── */
.bkbg-tgal-counter {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 11px;
    border-radius: 20px;
    font-family:      var(--bktg-ct-font-family, inherit);
    font-size:        var(--bktg-ct-font-size-d, 12px);
    line-height:      var(--bktg-ct-line-height-d, normal);
    font-weight:      var(--bktg-ct-font-weight, 600);
    font-style:       var(--bktg-ct-font-style, normal);
    text-decoration:  var(--bktg-ct-text-decoration, none);
    text-transform:   var(--bktg-ct-text-transform, none);
    letter-spacing:   var(--bktg-ct-letter-spacing-d, 0.03em);
    word-spacing:     var(--bktg-ct-word-spacing-d, normal);
    pointer-events: none;
}

/* ── zoom button ── */
.bkbg-tgal-zoom {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: zoom-in;
    transition: opacity 0.2s;
    opacity: 0.85;
}

.bkbg-tgal-zoom:hover {
    opacity: 1;
}

/* ── arrows ── */
.bkbg-tgal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    opacity: 0.85;
    border: none;
    background: none;
    z-index: 3;
}

.bkbg-tgal-arrow:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.08);
}

.bkbg-tgal-arrow.prev { left: 10px; }
.bkbg-tgal-arrow.next { right: 10px; }

/* ── thumbnail strip ── */
.bkbg-tgal-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    padding: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}

.bkbg-tgal-strip::-webkit-scrollbar {
    height: 4px;
}

.bkbg-tgal-strip::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}

.bkbg-tgal-container.pos-left .bkbg-tgal-strip,
.bkbg-tgal-container.pos-right .bkbg-tgal-strip {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.bkbg-tgal-container.pos-left .bkbg-tgal-strip::-webkit-scrollbar,
.bkbg-tgal-container.pos-right .bkbg-tgal-strip::-webkit-scrollbar {
    width: 4px;
    height: auto;
}

/* ── thumbnail item ── */
.bkbg-tgal-thumb {
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: border-color 0.15s, opacity 0.15s;
    box-sizing: border-box;
    opacity: 0.72;
}

.bkbg-tgal-thumb:hover {
    opacity: 0.9;
}

.bkbg-tgal-thumb.is-active {
    opacity: 1;
}

/* ── lightbox overlay ── */
.bkbg-tgal-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.9);
    animation: bkbg-tgal-lb-in 0.2s ease;
}

@keyframes bkbg-tgal-lb-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.bkbg-tgal-lightbox img {
    max-width: 92vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.bkbg-tgal-lb-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
    background: none;
    border: none;
}

.bkbg-tgal-lb-close:hover {
    opacity: 1;
}

.bkbg-tgal-lb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s;
    background: none;
    border: none;
    padding: 0 16px;
}

.bkbg-tgal-lb-arrow:hover { opacity: 1; }
.bkbg-tgal-lb-arrow.prev { left: 0; }
.bkbg-tgal-lb-arrow.next { right: 0; }

/* ── responsive ── */
@media (max-width: 1024px) {
    .bkbg-tgal-caption {
        font-size:        var(--bktg-cp-font-size-t, var(--bktg-cp-font-size-d, 13px));
        line-height:      var(--bktg-cp-line-height-t, var(--bktg-cp-line-height-d, 1.4));
        letter-spacing:   var(--bktg-cp-letter-spacing-t, var(--bktg-cp-letter-spacing-d, normal));
        word-spacing:     var(--bktg-cp-word-spacing-t, var(--bktg-cp-word-spacing-d, normal));
    }
    .bkbg-tgal-counter {
        font-size:        var(--bktg-ct-font-size-t, var(--bktg-ct-font-size-d, 12px));
        line-height:      var(--bktg-ct-line-height-t, var(--bktg-ct-line-height-d, normal));
        letter-spacing:   var(--bktg-ct-letter-spacing-t, var(--bktg-ct-letter-spacing-d, 0.03em));
        word-spacing:     var(--bktg-ct-word-spacing-t, var(--bktg-ct-word-spacing-d, normal));
    }
}

@media (max-width: 767px) {
    .bkbg-tgal-caption {
        font-size:        var(--bktg-cp-font-size-m, var(--bktg-cp-font-size-t, var(--bktg-cp-font-size-d, 13px)));
        line-height:      var(--bktg-cp-line-height-m, var(--bktg-cp-line-height-t, var(--bktg-cp-line-height-d, 1.4)));
        letter-spacing:   var(--bktg-cp-letter-spacing-m, var(--bktg-cp-letter-spacing-t, var(--bktg-cp-letter-spacing-d, normal)));
        word-spacing:     var(--bktg-cp-word-spacing-m, var(--bktg-cp-word-spacing-t, var(--bktg-cp-word-spacing-d, normal)));
    }
    .bkbg-tgal-counter {
        font-size:        var(--bktg-ct-font-size-m, var(--bktg-ct-font-size-t, var(--bktg-ct-font-size-d, 12px)));
        line-height:      var(--bktg-ct-line-height-m, var(--bktg-ct-line-height-t, var(--bktg-ct-line-height-d, normal)));
        letter-spacing:   var(--bktg-ct-letter-spacing-m, var(--bktg-ct-letter-spacing-t, var(--bktg-ct-letter-spacing-d, 0.03em)));
        word-spacing:     var(--bktg-ct-word-spacing-m, var(--bktg-ct-word-spacing-t, var(--bktg-ct-word-spacing-d, normal)));
    }
}

@media (max-width: 600px) {
    .bkbg-tgal-container.pos-left,
    .bkbg-tgal-container.pos-right {
        flex-direction: column;
    }

    .bkbg-tgal-container.pos-left .bkbg-tgal-strip,
    .bkbg-tgal-container.pos-right .bkbg-tgal-strip {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
}
