/* =========================================================
   AGRITEX — TRACTOR GALLERY LIGHTBOX
   Fullscreen image viewer with top bar, navigation, thumbs.
   Independent stylesheet — does not touch style.css.
   ========================================================= */

.gallery__main {
    cursor: zoom-in;
}

.gallery__main:focus-visible {
    outline: 3px solid var(--color-primary, #7CB342);
    outline-offset: 4px;
}

/* Hover zoom-hint badge */
.gallery__zoom-hint {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #1f2a1a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
    z-index: 2;
}

.gallery__main:hover .gallery__zoom-hint,
.gallery__main:focus-visible .gallery__zoom-hint {
    opacity: 1;
    transform: translateY(0);
}

/* ───────────────────────── Lightbox shell ───────────────────────── */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: stretch;
    justify-content: center;
    color: #fff;
    font-family: inherit;
}

.lightbox.is-open {
    display: flex;
    animation: lightboxFadeIn 220ms ease both;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 8, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.lightbox__shell {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 0;
}

/* ───────────────────────── Top bar ───────────────────────── */

.lightbox__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
    min-height: 72px;
}

.lightbox__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    max-width: 60%;
}

.lightbox__title strong {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.25;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lightbox__title small {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.lightbox__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.lightbox__action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.lightbox__action:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.lightbox__action--call {
    background: var(--color-primary, #7CB342);
    border-color: transparent;
}

.lightbox__action--call:hover {
    background: var(--color-primary-dark, #558B2F);
}

.lightbox__action--fav.is-active {
    background: #e53935;
    border-color: transparent;
}

.lightbox__action--fav.is-active i {
    font-weight: 900;
}

.lightbox__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

.lightbox__close:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: rotate(90deg);
}

/* ───────────────────────── Stage ───────────────────────── */

.lightbox__stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 80px;
    min-height: 0;
    overflow: hidden;
}

.lightbox__image-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.lightbox__image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transition: opacity 200ms ease;
    image-rendering: -webkit-optimize-contrast;
}

.lightbox__image.is-loading {
    opacity: 0.35;
}

.lightbox__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: #fff;
    animation: lightboxSpin 0.8s linear infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}

.lightbox__spinner.is-visible {
    opacity: 1;
}

@keyframes lightboxSpin {
    to { transform: rotate(360deg); }
}

.lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
    z-index: 3;
}

.lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.24);
}

.lightbox__nav--prev { left: 16px; }
.lightbox__nav--next { right: 16px; }

.lightbox__counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* ───────────────────────── Thumb strip ───────────────────────── */

.lightbox__thumbs {
    display: flex;
    align-items: center;
    /* safe center — thumb-lar ekrana sığırsa ortalanır, sığmırsa start-dan
       başlayır və scroll edilə bilir (köhnə flex-start bug-ı yoxdur). */
    justify-content: safe center;
    gap: 10px;
    padding: 16px 24px 20px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.45), transparent);
    overscroll-behavior-x: contain;
}

.lightbox__thumbs::-webkit-scrollbar { height: 6px; }
.lightbox__thumbs::-webkit-scrollbar-track { background: transparent; }
.lightbox__thumbs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
}

.lightbox__thumb {
    flex: 0 0 auto;
    width: 92px;
    height: 70px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    padding: 0;
    transition: border-color 160ms ease, transform 160ms ease, opacity 160ms ease;
    opacity: 0.7;
}

.lightbox__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
    display: block;
    pointer-events: none;
}

.lightbox__thumb:hover {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.4);
}

.lightbox__thumb.active {
    border-color: var(--color-primary, #7CB342);
    opacity: 1;
    transform: translateY(-2px);
}

/* ───────────────────────── Body lock ───────────────────────── */

body.lightbox-open {
    overflow: hidden;
}

/* ───────────────────────── Responsive ───────────────────────── */

@media (max-width: 768px) {
    .lightbox__topbar {
        padding: 12px 14px;
        min-height: 60px;
    }

    .lightbox__title strong { font-size: 15px; }
    .lightbox__title small  { font-size: 11px; letter-spacing: 0.6px; }

    .lightbox__action {
        padding: 8px 12px;
        font-size: 13px;
        gap: 6px;
    }

    .lightbox__action span {
        display: none;
    }

    .lightbox__action--call,
    .lightbox__action--fav {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }

    .lightbox__close {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .lightbox__stage {
        padding: 10px 14px;
    }

    .lightbox__nav {
        width: 44px;
        height: 44px;
        font-size: 15px;
    }

    .lightbox__nav--prev { left: 8px; }
    .lightbox__nav--next { right: 8px; }

    .lightbox__counter {
        font-size: 12px;
        padding: 5px 11px;
    }

    .lightbox__thumbs {
        padding: 10px 14px 14px;
        gap: 8px;
    }

    .lightbox__thumb {
        width: 70px;
        height: 56px;
    }
}

@media (max-width: 480px) {
    .lightbox__title {
        max-width: 50%;
    }

    .lightbox__title strong { font-size: 14px; }

    .lightbox__nav {
        width: 40px;
        height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lightbox.is-open,
    .lightbox__image,
    .lightbox__nav,
    .lightbox__close,
    .lightbox__action,
    .lightbox__thumb,
    .lightbox__spinner {
        animation: none !important;
        transition: none !important;
    }
}
