/* ═══════════════════════════════════════════════════════
   BPTK Resize Gallery — Frontend Styles

   Layout is handled by JS: each .bptk-rg-item is positioned
   absolutely (top/left/width/height) computed from the stored
   cs/rs/cw/rh values and the container width.

   This file covers cosmetics, hover effects, captions, and
   the lightbox only.
═══════════════════════════════════════════════════════ */

/* ── Gallery wrapper ─────────────────────────────────── */

.bptk-rg {
    position  : relative;
    width     : 100%;
    /* height is set by JS to contain all absolutely-positioned items */

    /* Hide until JS has applied placement (prevents flash of unstyled content) */
    visibility: hidden;
}

/* ── Gallery items ───────────────────────────────────── */

.bptk-rg-item {
    position     : absolute;   /* top/left/width/height set by JS */
    overflow     : hidden;
    border-radius: var(--rg-radius, 0px);
    cursor       : pointer;
    /* position:absolute makes this a containing block for the child img */
}

/* Image fills its cell completely.
   Uses position:absolute + !important to override common WordPress theme
   rules like "img { height: auto }" that would otherwise collapse narrow
   cells to their natural aspect-ratio height. */
.bptk-rg-item img {
    position   : absolute !important;
    top        : 0 !important;
    left       : 0 !important;
    width      : 100% !important;
    height     : 100% !important;
    max-width  : none !important;
    max-height : none !important;
    object-fit : var(--rg-fit, cover) !important;
    object-position: center center !important;
    display    : block !important;
    transition : transform 0.38s ease;
    will-change: transform;
}

.bptk-rg-item:hover img {
    transform: scale(1.05);
}

/* ══════════════════════════════════════════════════════
   CAPTION SYSTEM
   Controlled by modifier classes on .bptk-rg:
     .bptk-rg--cap-bottom  (default)
     .bptk-rg--cap-top
     .bptk-rg--cap-middle
     .bptk-rg--cap-always   (skips hover requirement)
══════════════════════════════════════════════════════ */

.bptk-rg-caption {
    position  : absolute;
    left      : 0;
    right     : 0;
    background: var(--rg-cap-bg,  rgba(0,0,0,0.65));
    color     : var(--rg-cap-clr, #ffffff);
    font-size : 13px;
    line-height: 1.45;
    padding   : 10px 14px;
    z-index   : 3;  /* above the absolutely-positioned img (z-index:auto) */
    transition: transform 0.26s ease, opacity 0.26s ease;
    will-change: transform;
}

/* ── Bottom (default) ────────────────────────────────── */

.bptk-rg--cap-bottom .bptk-rg-caption {
    bottom       : 0;
    border-radius: 0 0 var(--rg-radius, 0px) var(--rg-radius, 0px);
    transform    : translateY(102%);
}

.bptk-rg--cap-bottom .bptk-rg-item:hover .bptk-rg-caption,
.bptk-rg--cap-bottom.bptk-rg--cap-always .bptk-rg-caption {
    transform: translateY(0);
}

/* ── Top ─────────────────────────────────────────────── */

.bptk-rg--cap-top .bptk-rg-caption {
    top          : 0;
    border-radius: var(--rg-radius, 0px) var(--rg-radius, 0px) 0 0;
    transform    : translateY(-102%);
}

.bptk-rg--cap-top .bptk-rg-item:hover .bptk-rg-caption,
.bptk-rg--cap-top.bptk-rg--cap-always .bptk-rg-caption {
    transform: translateY(0);
}

/* ── Middle ──────────────────────────────────────────── */

.bptk-rg--cap-middle .bptk-rg-caption {
    top      : 50%;
    transform: translateY(-50%);
    opacity  : 0;
    transition: opacity 0.26s ease;
}

.bptk-rg--cap-middle .bptk-rg-item:hover .bptk-rg-caption,
.bptk-rg--cap-middle.bptk-rg--cap-always .bptk-rg-caption {
    opacity: 1;
}

/* ══════════════════════════════════════════════════════
   LIGHTBOX
══════════════════════════════════════════════════════ */

.bptk-rg-lb {
    position  : fixed;
    inset     : 0;
    z-index   : 999999;
    background: rgba(0, 0, 0, 0.93);
    display   : none;
    align-items    : center;
    justify-content: center;
    animation : bptk-rg-lb-fadein 0.22s ease forwards;
}

.bptk-rg-lb.is-open {
    display: flex;
}

@keyframes bptk-rg-lb-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.bptk-rg-lb-inner {
    position      : relative;
    max-width     : 92vw;
    max-height    : 92vh;
    display       : flex;
    flex-direction: column;
    align-items   : center;
    gap           : 10px;
}

.bptk-rg-lb-img {
    max-width : 100%;
    max-height: calc(92vh - 50px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 24px 72px rgba(0,0,0,0.6);
    display   : block;
    transition: opacity 0.18s ease;
}

.bptk-rg-lb-img.is-loading {
    opacity: 0.4;
}

.bptk-rg-lb-caption {
    color      : rgba(255,255,255,0.82);
    font-size  : 13px;
    text-align : center;
    max-width  : 560px;
    line-height: 1.5;
    min-height : 1em;
}

.bptk-rg-lb-close {
    position  : fixed;
    top       : 18px;
    right     : 22px;
    width     : 38px;
    height    : 38px;
    border-radius: 50%;
    border    : none;
    background: rgba(255,255,255,0.12);
    color     : #fff;
    font-size : 20px;
    line-height: 1;
    cursor    : pointer;
    display   : flex;
    align-items    : center;
    justify-content: center;
    transition: background 0.15s;
    z-index   : 10;
}

.bptk-rg-lb-close:hover { background: rgba(255,255,255,0.24); }

.bptk-rg-lb-prev,
.bptk-rg-lb-next {
    position  : fixed;
    top       : 50%;
    transform : translateY(-50%);
    width     : 48px;
    height    : 48px;
    border-radius: 50%;
    border    : none;
    background: rgba(255,255,255,0.12);
    color     : #fff;
    font-size : 26px;
    line-height: 1;
    cursor    : pointer;
    display   : flex;
    align-items    : center;
    justify-content: center;
    transition: background 0.15s;
    z-index   : 10;
    user-select: none;
}

.bptk-rg-lb-prev { left:  18px; }
.bptk-rg-lb-next { right: 18px; }

.bptk-rg-lb-prev:hover,
.bptk-rg-lb-next:hover { background: rgba(255,255,255,0.26); }

.bptk-rg-lb-counter {
    position  : fixed;
    bottom    : 18px;
    left      : 50%;
    transform : translateX(-50%);
    color     : rgba(255,255,255,0.5);
    font-size : 12px;
    letter-spacing: .04em;
}

@media (max-width: 640px) {
    .bptk-rg-lb-prev  { left:  8px; width: 38px; height: 38px; font-size: 22px; }
    .bptk-rg-lb-next  { right: 8px; width: 38px; height: 38px; font-size: 22px; }
    .bptk-rg-lb-close { top: 10px; right: 12px; width: 32px; height: 32px; font-size: 16px; }
}
