﻿:root {
    --radius: 18px;
    --gap: 16px;
}

* {
    box-sizing: border-box;
}


.intro {
    max-width: 420px;
    margin: 0;
    color: var(--muted);
    line-height: 1.9;
}

.gallery {
    columns: 4 260px;
    column-gap: var(--gap);
}

.gallery-item {
    position: relative;
    display: block;
    width: 100%;
    margin: 0 0 var(--gap);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius);
    background: #ddd;
    box-shadow: 0 8px 28px rgba(17, 17, 17, .07);
    cursor: zoom-in;
    break-inside: avoid;
    isolation: isolate;
}

    .gallery-item img {
        display: block;
        width: 100%;
        height: auto;
        transition: transform .55s cubic-bezier(.2,.7,.2,1), filter .4s ease;
    }

    .gallery-item::after {
        content: "مشاهده تصویر";
        position: absolute;
        inset: auto 12px 12px;
        padding: 11px 14px;
        color: #fff;
        border: 1px solid rgba(255,255,255,.25);
        border-radius: 12px;
        background: rgba(10,10,10,.48);
        backdrop-filter: blur(10px);
        opacity: 0;
        transform: translateY(8px);
        transition: .3s ease;
        z-index: 2;
    }

    .gallery-item:hover img,
    .gallery-item:focus-visible img {
        transform: scale(1.035);
        filter: brightness(.88);
    }

    .gallery-item:hover::after,
    .gallery-item:focus-visible::after {
        opacity: 1;
        transform: translateY(0);
    }

    .gallery-item:focus-visible {
        outline: 3px solid #171717;
        outline-offset: 4px;
    }

.lightbox {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 76px 80px 70px;
    background: rgba(5,5,5,.92);
    backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    z-index: 1000;
}

    .lightbox.is-open {
        opacity: 1;
        visibility: visible;
    }

.lightbox-stage {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
}

.lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(0,0,0,.5);
    user-select: none;
    cursor: zoom-in;
    transition: transform .18s ease;
    will-change: transform;
}

    .lightbox-image.zoomed {
        cursor: grab;
    }

    .lightbox-image.dragging {
        cursor: grabbing;
        transition: none;
    }

.icon-btn {
    position: absolute;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    color: #fff;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 50%;
    background: var(--panel);
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: transform .2s ease, background .2s ease;
    z-index: 3;
}

    .icon-btn:hover {
        transform: scale(1.07);
        background: rgba(30,30,30,.95);
    }

    .icon-btn:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 3px;
    }

    .icon-btn svg {
        width: 21px;
        height: 21px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
    }

.close {
    top: 18px;
    left: 18px;
}

.zoom {
    top: 18px;
    left: 76px;
}

.previous {
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
}

.next {
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
}

    .previous:hover, .next:hover {
        transform: translateY(-50%) scale(1.07);
    }

.counter {
    position: absolute;
    right: 20px;
    top: 22px;
    color: rgba(255,255,255,.8);
    font-size: .9rem;
    direction: ltr;
    z-index: 3;
}

.caption {
    position: absolute;
    bottom: 18px;
    left: 50%;
    margin: 0;
    padding: 9px 14px;
    color: rgba(255,255,255,.88);
    border-radius: 999px;
    background: var(--panel);
    backdrop-filter: blur(10px);
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 3;
}

@media (max-width: 760px) {
    .page {
        width: min(100% - 22px, 1320px);
        padding-top: 34px;
    }

    .hero {
        display: block;
        margin-bottom: 22px;
    }

    .intro {
        margin-top: 14px;
        font-size: .9rem;
    }

    .gallery {
        columns: 2 145px;
        column-gap: 10px;
    }

    .gallery-item {
        margin-bottom: 10px;
        border-radius: 12px;
    }

        .gallery-item::after {
            display: none;
        }

    .lightbox {
        padding: 66px 12px 64px;
    }

    .previous {
        right: 10px;
    }

    .next {
        left: 10px;
    }

    .close {
        top: 12px;
        left: 12px;
    }

    .zoom {
        top: 12px;
        left: 68px;
    }

    .counter {
        top: 18px;
        right: 14px;
    }

    .caption {
        bottom: 12px;
        max-width: calc(100% - 24px);
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
