/* =========================================================
   Reusable Gallery + Lightbox
========================================================= */
.gallery-section {
    padding: 48px 0;
    background: var(--bg-color);
}

.gallery-head {
    margin-bottom: 24px;
}

.gallery-head h2 {
    margin: 0 0 12px;
}

.gallery-intro {
    max-width: 760px;
    margin: 0;
    color: var(--muted-text);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.gallery-item {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    background: var(--surface);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.gallery-item:hover,
.gallery-item:focus-visible {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.14);
    outline: none;
}

.gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
    transform: scale(1.04);
}

/* =========================================================
   Shared Lightbox
========================================================= */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.92);
}

.lightbox[hidden] {
    display: none;
}

.lightbox__inner {
    position: relative;
    width: min(100%, 1100px);
    max-height: 100%;
    text-align: center;
    touch-action: pan-y;
    cursor: grab;
    user-select: none;
}

.lightbox__inner.is-dragging {
    cursor: grabbing;
}

.lightbox__img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 80vh;
    margin: 0 auto;
    border-radius: 16px;
    object-fit: contain;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox__caption,
.lightbox__count {
    margin: 12px 0 0;
    color: #f5f5f5;
}

.lightbox__caption {
    font-size: 0.98rem;
    line-height: 1.5;
}

.lightbox__count {
    font-size: 0.88rem;
    opacity: 0.8;
}

.lightbox__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox__close:hover,
.lightbox__close:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.04);
    outline: none;
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1100px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 767px) {
    .gallery-section {
        padding: 36px 0;
    }

    .gallery-grid {
        gap: 10px;
    }

    .gallery-item {
        border-radius: 14px;
    }

    .lightbox {
        padding: 16px;
    }

    .lightbox__img {
        max-height: 72vh;
    }

    .lightbox__close {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
        font-size: 1.8rem;
    }
}





/* =========================================
   Gallery image polish with accent
========================================= */
.gallery-item {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    background: var(--surface);
    cursor: pointer;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 1;
    transition: transform 0.35s ease, filter 0.25s ease;
    filter: saturate(1.04) contrast(1.05) brightness(0.97);
}

/* Accent wash */
.gallery-item::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    border-radius: inherit;
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--accent-color) 22%, transparent) 0%,
            color-mix(in srgb, var(--accent-color) 10%, transparent) 22%,
            transparent 48%),
        linear-gradient(to top,
            color-mix(in srgb, var(--accent-color) 16%, transparent) 0%,
            transparent 30%);
    opacity: 0.95;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Dark polish layer */
.gallery-item::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    border-radius: inherit;
    background:
        linear-gradient(to bottom,
            rgba(255, 255, 255, 0.08) 0%,
            rgba(255, 255, 255, 0.02) 28%,
            rgba(0, 0, 0, 0.28) 100%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 -26px 40px rgba(0, 0, 0, 0.10);
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.gallery-item:hover,
.gallery-item:focus-visible {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow:
        0 14px 28px rgba(0, 0, 0, 0.14),
        0 0 0 1px color-mix(in srgb, var(--accent-color) 30%, transparent);
    outline: none;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
    transform: scale(1.04);
    filter: saturate(1.08) contrast(1.06) brightness(0.96);
}

.gallery-item:hover::before,
.gallery-item:focus-visible::before {
    opacity: 1;
}

.gallery-item:hover::after,
.gallery-item:focus-visible::after {
    background:
        linear-gradient(to bottom,
            rgba(255, 255, 255, 0.06) 0%,
            rgba(255, 255, 255, 0.01) 24%,
            rgba(0, 0, 0, 0.34) 100%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 -30px 46px rgba(0, 0, 0, 0.16);
}

/* Dark mode */
[data-theme="dark"] .gallery-item img {
    filter: saturate(1.06) contrast(1.07) brightness(0.93);
}

[data-theme="dark"] .gallery-item::before {
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--accent-color) 26%, transparent) 0%,
            color-mix(in srgb, var(--accent-color) 12%, transparent) 22%,
            transparent 48%),
        linear-gradient(to top,
            color-mix(in srgb, var(--accent-color) 18%, transparent) 0%,
            transparent 30%);
    opacity: 1;
}

[data-theme="dark"] .gallery-item::after {
    background:
        linear-gradient(to bottom,
            rgba(255, 255, 255, 0.04) 0%,
            rgba(255, 255, 255, 0.01) 22%,
            rgba(0, 0, 0, 0.38) 100%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.04),
        inset 0 -30px 50px rgba(0, 0, 0, 0.20);
}

[data-theme="dark"] .gallery-item:hover img,
[data-theme="dark"] .gallery-item:focus-visible img {
    filter: saturate(1.10) contrast(1.08) brightness(0.92);
}