/* ─── Image Zoom Overlay ─── */
.image-zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.image-zoom-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Header bar */
.image-zoom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    flex-shrink: 0;
}

.image-zoom-name {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 48px);
}

.image-zoom-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.image-zoom-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Image container */
.image-zoom-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
    position: relative;
    padding-bottom: env(safe-area-inset-bottom);
}

.image-zoom-img {
    max-width: 92vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 6px;
    transition: transform 0.1s ease, opacity 0.2s ease;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
}

/* Loading spinner — reuses qa-thinking-wave */
.image-zoom-spinner {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-zoom-spinner .qa-thinking-wave {
    height: 32px;
}

.image-zoom-spinner.hidden {
    display: none;
}

/* Swipe-down hint indicator */
.image-zoom-body::after {
    content: '';
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.image-zoom-overlay.zoomed .image-zoom-body::after {
    opacity: 0;
}

/* ─── Carousel: prev/next chevrons + counter ─── */
.image-zoom-counter {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    margin-left: 10px;
    flex-shrink: 0;
    display: none;
}

/* Only show counter when carousel is active */
.image-zoom-overlay.has-carousel .image-zoom-counter {
    display: inline-block;
}

/* Carousel header layout needs the name to flex and counter to push close */
.image-zoom-overlay.has-carousel .image-zoom-name {
    flex: 1;
    min-width: 0;
    max-width: none;
}

.image-zoom-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: none; /* hidden until .has-carousel */
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.15s ease, opacity 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.image-zoom-overlay.has-carousel .image-zoom-nav {
    display: flex;
}

.image-zoom-nav-prev { left: 16px; }
.image-zoom-nav-next { right: 16px; }

.image-zoom-nav:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-50%) scale(1.06);
}

.image-zoom-nav:active {
    transform: translateY(-50%) scale(0.96);
}

.image-zoom-nav:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* Hide nav while zoomed-in (panning should own the gesture) */
.image-zoom-overlay.zoomed .image-zoom-nav {
    opacity: 0;
    pointer-events: none;
}

/* Mobile: tuck chevrons closer + slightly smaller so they don't crowd the image */
@media (max-width: 640px) {
    .image-zoom-nav {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
    .image-zoom-nav-prev { left: 8px; }
    .image-zoom-nav-next { right: 8px; }
}

/* Header positions counter between name and close button */
.image-zoom-header {
    gap: 8px;
}

/* Header header: keep the layout (name/counter/close). Counter sits just
   before the close button; when non-carousel, counter is display:none so
   the layout falls back to the original name + close. */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .image-zoom-overlay { transition: none; }
    .image-zoom-img { transition: none; }
    .image-zoom-nav { transition: none; }
}
