/* 燈箱開啟時鎖住背景捲動，由 lightbox.js 開/關燈箱時加上、拿掉這個 class */
html.lightbox-open {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
}

.lightbox:not([open]) {
    display: none;
}

.lightbox::backdrop {
    background-color: rgba(0, 0, 0, 0.85);
}

.lightbox__figure {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 80px 120px;
    box-sizing: border-box;
}

.lightbox__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.6);
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.lightbox__close:focus-visible,
.lightbox__prev:focus-visible,
.lightbox__next:focus-visible {
    outline: 4px solid #2563eb;
    outline-offset: 2px;
}

/* 關閉鍵 */
.lightbox__close {
    top: 24px;
    right: 44px;
    width: 40px;
    height: 40px;
    color: #a3a3a3;
}

.lightbox__close:hover {
    color: #00683e;
}

/* 上一頁/下一頁 */
.lightbox__prev,
.lightbox__next {
    width: 40px;
    height: 40px;
    background-color: #fff;
    color: #000;
}

.lightbox__prev:hover,
.lightbox__next:hover {
    background-color: #006f3e;
    color: #fff;
}

.lightbox__prev {
    top: 50%;
    left: 40px;
    transform: translateY(-50%);
}

.lightbox__next {
    top: 50%;
    right: 40px;
    transform: translateY(-50%);
}

.lightbox__counter {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    margin: 0;
    padding: 4px 12px;
    border-radius: 9999px;
    background-color: rgba(0, 0, 0, 0.6);
    font-size: 0.875rem;
}

/* 平板 */
@media (max-width: 1024px) {
    .lightbox__figure {
        padding: 64px 112px;
    }

    .lightbox__close {
        right: 24px;
        width: 40px;
        height: 40px;
    }

    .lightbox__prev,
    .lightbox__next {
        width: 40px;
        height: 40px;
    }

    .lightbox__prev {
        left: 40px;
    }

    .lightbox__next {
        right: 40px;
    }
}

/* 手機：圖片、上一張/下一張、頁數整組置中顯示 */
@media (max-width: 640px) {
    .lightbox {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "image  image"
            "prev   next"
            "counter counter";
        align-content: center;
        justify-items: center;
        gap: 16px;
        padding: 72px 16px 24px;
        box-sizing: border-box;
    }

    .lightbox__close {
        position: absolute;
        top: 16px;
        right: 12px;
        width: 36px;
        height: 36px;
    }

    .lightbox__figure {
        grid-area: image;
        position: static;
        width: 100%;
        height: auto;
        padding: 0;
    }

    .lightbox__image {
        max-height: 55vh;
    }

    .lightbox__prev,
    .lightbox__next {
        width: 36px;
        height: 36px;
    }

    .lightbox__prev {
        grid-area: prev;
        position: static;
        justify-self: end;
        transform: none;
    }

    .lightbox__next {
        grid-area: next;
        position: static;
        justify-self: start;
        transform: none;
    }

    .lightbox__counter {
        grid-area: counter;
        position: static;
        transform: none;
    }
}
