/*
 * CarBlitz Premium Gallery
 * Theme-agnostic. Override via CSS variables in your theme:
 *   --cb-gallery-bg       backdrop color (lightbox)
 *   --cb-gallery-accent   active thumb border + counter
 *   --cb-gallery-text     UI text color in lightbox
 */

:root {
    --cb-gallery-bg: rgba(8, 12, 24, 0.96);
    --cb-gallery-accent: #0060BF;
    --cb-gallery-text: #ffffff;
    --cb-gallery-radius: 16px;
    --cb-gallery-radius-sm: 8px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* HERO VIEWER (inline pe pagina anunț)        */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.cb-gallery {
    position: relative;
    width: 100%;
}

.cb-gallery__hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--cb-gallery-radius);
    background: #0a0e1a;
    aspect-ratio: 4 / 3;
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
    .cb-gallery__hero { aspect-ratio: 16 / 10; }
}

.cb-gallery__viewport {
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.cb-gallery__container {
    display: flex;
    height: 100%;
    touch-action: pan-y pinch-zoom;
}

.cb-gallery__slide {
    position: relative;
    flex: 0 0 100%;
    min-width: 0;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.cb-gallery__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

@media (min-width: 640px) {
    .cb-gallery__img { object-fit: cover; }
}

/* Counter + open-fullscreen badge */
.cb-gallery__counter {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    pointer-events: none;
    z-index: 2;
    letter-spacing: 0.02em;
}

.cb-gallery__expand {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    border-radius: 12px;
    z-index: 2;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.cb-gallery__expand:hover { background: rgba(0, 0, 0, 0.75); }
.cb-gallery__expand svg { width: 18px; height: 18px; }

/* Arrows hero (desktop only) */
.cb-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    color: #0b1220;
    border-radius: 999px;
    cursor: pointer;
    border: none;
    z-index: 2;
    transition: transform 0.2s ease, background 0.2s ease;
}
.cb-gallery__nav:hover { transform: translateY(-50%) scale(1.06); background: #fff; }
.cb-gallery__nav--prev { left: 12px; }
.cb-gallery__nav--next { right: 12px; }
.cb-gallery__nav svg { width: 20px; height: 20px; }
@media (min-width: 768px) {
    .cb-gallery__nav { display: flex; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* THUMBNAIL STRIP                              */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.cb-gallery__thumbs {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cb-gallery__thumbs::-webkit-scrollbar { display: none; }

.cb-gallery__thumb {
    flex: 0 0 auto;
    width: 80px;
    height: 60px;
    border-radius: var(--cb-gallery-radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.18s ease, opacity 0.18s ease;
    background: #0a0e1a;
    opacity: 0.65;
    padding: 0;
}
.cb-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cb-gallery__thumb--active {
    border-color: var(--cb-gallery-accent);
    opacity: 1;
}
.cb-gallery__thumb:hover { opacity: 0.95; }

@media (min-width: 768px) {
    .cb-gallery__thumb { width: 96px; height: 72px; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* FULLSCREEN LIGHTBOX                          */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.cb-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--cb-gallery-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.cb-lightbox--open {
    opacity: 1;
    visibility: visible;
}

.cb-lightbox--closing {
    opacity: 0;
}

/* Top bar (close X + counter) */
.cb-lightbox__top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    color: var(--cb-gallery-text);
    z-index: 10;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cb-lightbox__counter {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 14px;
    border-radius: 999px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.cb-lightbox__close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--cb-gallery-text);
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.cb-lightbox__close:hover { background: rgba(255, 255, 255, 0.16); transform: scale(1.05); }
.cb-lightbox__close svg { width: 22px; height: 22px; }

/* Main viewport */
.cb-lightbox__main {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cb-lightbox__viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.cb-lightbox__track {
    display: flex;
    height: 100%;
    will-change: transform;
}

.cb-lightbox__slide {
    flex: 0 0 100%;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.cb-lightbox__img-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}

.cb-lightbox__img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.cb-lightbox__img--zoomed { transition: none; cursor: grab; }
.cb-lightbox__img--zoomed:active { cursor: grabbing; }

/* Lightbox arrows (desktop) */
.cb-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--cb-gallery-text);
    border-radius: 999px;
    cursor: pointer;
    border: none;
    z-index: 10;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.2s ease, transform 0.2s ease;
}
.cb-lightbox__nav:hover { background: rgba(255, 255, 255, 0.22); transform: translateY(-50%) scale(1.05); }
.cb-lightbox__nav--prev { left: 20px; }
.cb-lightbox__nav--next { right: 20px; }
.cb-lightbox__nav svg { width: 26px; height: 26px; }
@media (min-width: 768px) { .cb-lightbox__nav { display: flex; } }

/* Bottom thumb strip */
.cb-lightbox__thumbs {
    display: flex;
    gap: 6px;
    padding: 12px 16px 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.cb-lightbox__thumbs::-webkit-scrollbar { display: none; }

.cb-lightbox__thumb {
    flex: 0 0 auto;
    width: 56px;
    height: 42px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.45;
    transition: border-color 0.18s ease, opacity 0.18s ease;
    padding: 0;
    background: rgba(0, 0, 0, 0.4);
}
.cb-lightbox__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cb-lightbox__thumb--active {
    opacity: 1;
    border-color: var(--cb-gallery-accent);
}

/* Auto-hide UI on mobile after inactivity */
.cb-lightbox--ui-hidden .cb-lightbox__top,
.cb-lightbox--ui-hidden .cb-lightbox__thumbs {
    opacity: 0;
    pointer-events: none;
}

/* Drag-to-close offset */
.cb-lightbox__main--dragging .cb-lightbox__track { transition: none; }
