/* ══════════════════════════════════════════════════
   Jenga Gallery – Frontend Styles
   ══════════════════════════════════════════════════ */

/* ── Carousel ───────────────────────────────────── */
.jenga-gallery {
    --jg-gap: 16px;
    --jg-per-view: 3;
    position: relative;
    max-width: 1200px;
    margin: 2em auto;
}

.jenga-gallery.alignwide {
    max-width: 1400px;
}

.jenga-gallery.alignfull {
    max-width: 100%;
    padding: 0 24px;
}

.jenga-track {
    display: flex;
    gap: var(--jg-gap);
    overflow: hidden;
    scroll-behavior: smooth;
    border-radius: 10px;
}

.jenga-slide {
    flex: 0 0 calc((100% - var(--jg-gap) * (var(--jg-per-view) - 1)) / var(--jg-per-view));
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.35s ease;
}

.jenga-slide:hover {
    transform: scale(1.025);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.16);
}

.jenga-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.jenga-slide:hover img {
    transform: scale(1.06);
}

/* ── Nav arrows ─────────────────────────────────── */
.jenga-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    transition: all 0.25s ease;
    color: #1a1a1a;
    padding: 0;
    line-height: 1;
}

.jenga-arrow:hover {
    background: #fff;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.16);
    transform: translateY(-50%) scale(1.08);
}

.jenga-arrow--prev { left: 12px; }
.jenga-arrow--next { right: 12px; }

/* ── Dots ───────────────────────────────────────── */
.jenga-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.jenga-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.jenga-dot.is-active {
    background: #333;
    transform: scale(1.35);
}

/* ══════════════════════════════════════════════════
   Lightbox
   ══════════════════════════════════════════════════ */
.jenga-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);

    display: grid;
    grid-template-rows: 1fr auto auto;
    grid-template-columns: 1fr;
    justify-items: center;
    height: 100dvh;
    height: 100vh;
    /* Push content up so Android/iOS nav bars don't overlap */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 48px);

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    overflow: hidden;
}

.jenga-lightbox[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

/* Close */
.jenga-lb-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s, border-color 0.2s;
    padding: 0;
}

.jenga-lb-close:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

/* ── Row 1: Image stage ─────────────────────────── */
.jenga-lb-stage {
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    padding: 56px 24px 8px;
    box-sizing: border-box;
    overflow: hidden;
}

.jenga-lb-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.45);
    user-select: none;
    -webkit-user-drag: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.jenga-lb-img.is-loaded {
    opacity: 1;
}

/* ── Row 2: Controls bar (← caption/counter →) ── */
.jenga-lb-controls {
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 800px;
    padding: 10px 20px 6px;
    box-sizing: border-box;
}

.jenga-lb-arrow {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.jenga-lb-arrow:hover {
    background: rgba(255, 255, 255, 0.18);
}

.jenga-lb-info {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.jenga-lb-caption {
    color: #fff;
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jenga-lb-counter {
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
    font-weight: 400;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

/* ── Row 3: Thumbnails ──────────────────────────── */
.jenga-lb-thumbs {
    grid-row: 3;
    display: flex;
    gap: 8px;
    padding: 6px 16px 4px;
    overflow-x: auto;
    max-width: 88vw;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
    justify-self: center;
}

.jenga-lb-thumb {
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.4;
    transition: all 0.25s ease;
    padding: 0;
    background: none;
}

.jenga-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.jenga-lb-thumb:hover {
    opacity: 0.7;
}

.jenga-lb-thumb.is-active {
    opacity: 1;
    border-color: #fff;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
    .jenga-gallery { --jg-per-view: 2 !important; }
    .jenga-arrow--prev { left: 6px; }
    .jenga-arrow--next { right: 6px; }
    .jenga-lb-stage { padding: 48px 12px 4px; }
    .jenga-lb-controls { gap: 10px; padding: 6px 12px 2px; }
    .jenga-lb-caption { font-size: 1.6rem; }
    .jenga-lb-counter { font-size: 0.9rem; }
    .jenga-lb-arrow { width: 40px; height: 40px; }
    .jenga-lb-thumb { width: 44px; height: 44px; }
    .jenga-lb-thumbs { padding: 4px 10px 2px; }
}

@media (max-width: 480px) {
    .jenga-gallery { --jg-per-view: 1 !important; }
    .jenga-arrow { width: 36px; height: 36px; }
    .jenga-lb-stage { padding: 40px 8px 2px; }
    .jenga-lb-controls { gap: 6px; padding: 4px 8px 0; }
    .jenga-lb-arrow { width: 34px; height: 34px; }
    .jenga-lb-caption { font-size: 1.4rem; }
    .jenga-lb-counter { font-size: 0.85rem; }
    .jenga-lb-thumb { width: 36px; height: 36px; }
    .jenga-lb-thumbs { padding: 4px 8px 0; gap: 5px; }
}
