/* Heart Pottery Studios Gallery Manager */

.hpsgm-gallery {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
    margin: 0;
}

.hpsgm-gallery-item {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: zoom-in;
}

.hpsgm-gallery-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background-color 180ms ease;
}

.hpsgm-gallery-item:hover::after,
.hpsgm-gallery-item:focus-visible::after {
    background: rgba(0, 0, 0, 0.12);
}

.hpsgm-gallery-item:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

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

.hpsgm-gallery-item:hover img {
    transform: scale(1.025);
}

.hpsgm-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.9);
}

.hpsgm-lightbox[hidden] {
    display: none;
}

.hpsgm-lightbox-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(1200px, 94vw);
    max-height: 92vh;
}

.hpsgm-lightbox-image {
    display: block;
    max-width: 100%;
    max-height: calc(92vh - 70px);
    object-fit: contain;
}

.hpsgm-lightbox-caption {
    max-width: 900px;
    margin: 14px 60px 0;
    color: #fff;
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
}

.hpsgm-lightbox-close,
.hpsgm-lightbox-prev,
.hpsgm-lightbox-next {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    color: #fff;
    background: rgba(0, 0, 0, 0.48);
    cursor: pointer;
}

.hpsgm-lightbox-close {
    top: -18px;
    right: -18px;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    font-size: 30px;
    line-height: 1;
}

.hpsgm-lightbox-prev,
.hpsgm-lightbox-next {
    top: 50%;
    width: 48px;
    height: 58px;
    transform: translateY(-50%);
    font-size: 36px;
}

.hpsgm-lightbox-prev {
    left: -64px;
}

.hpsgm-lightbox-next {
    right: -64px;
}

.hpsgm-lightbox-close:hover,
.hpsgm-lightbox-prev:hover,
.hpsgm-lightbox-next:hover,
.hpsgm-lightbox-close:focus-visible,
.hpsgm-lightbox-prev:focus-visible,
.hpsgm-lightbox-next:focus-visible {
    background: rgba(0, 0, 0, 0.75);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

body.hpsgm-lightbox-open {
    overflow: hidden;
}

@media (max-width: 1024px) {
    .hpsgm-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (max-width: 640px) {
    .hpsgm-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .hpsgm-lightbox {
        padding: 16px;
    }

    .hpsgm-lightbox-dialog {
        max-width: 100%;
    }

    .hpsgm-lightbox-close {
        top: 8px;
        right: 8px;
    }

    .hpsgm-lightbox-prev {
        left: 8px;
    }

    .hpsgm-lightbox-next {
        right: 8px;
    }

    .hpsgm-lightbox-caption {
        margin-left: 12px;
        margin-right: 12px;
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hpsgm-gallery-item img,
    .hpsgm-gallery-item::after {
        transition: none;
    }
}
