/* gallery.css */
.product-gallery {
    max-width: 720px;
    margin: 0 auto;
}

/* 大圖區：寬度滿版；高度由「最高的那張圖」決定（不再用 1:1 裁切） */
.gallery-main {
    position: relative;
    display: grid;                 /* 所有 slide 疊在同一格 → 容器高度 = 最高的一張 */
    grid-template-columns: 1fr;
    overflow: hidden;
    border-radius: 0; /* 大圖取消圓角 */
    cursor: zoom-in;
    background: #fff;
}

.gallery-main__slide {
    grid-area: 1 / 1;              /* 取代原本的 position:absolute; inset:0 */
    display: flex;
    align-items: center;           /* 較矮的圖上下居中 */
    justify-content: center;
    width: 100%;
    transform: translateX(100%);
    transition: transform 0.8s ease-out; /* 滑動速度 0.8s */
}

.gallery-main__slide { background: #fff; }

.gallery-main__slide.active {
    transform: translateX(0);
    z-index: 2;
}

.gallery-main__slide.off-left {
    transform: translateX(-100%);
}

.gallery-main__slide img {
    width: 100%;                   /* 滿寬 */
    height: auto;                  /* 依原圖實際比例 */
    max-height: none;
    object-fit: contain;           /* 不裁切 */
    display: block;
    border-radius: 0; /* 大圖圖片取消圓角 */
}

/* 縮略圖區：左右居中；高度拉齊到該列最高，較矮的圖上下居中 */
.gallery-thumbs {
    display: flex;
    align-items: stretch;          /* 每格高度 = 該列最高的縮圖 */
    justify-content: center; /* 整條縮略圖左右居中 */
    gap: 8px;
    margin-top: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.gallery-thumb-item {
    flex: 0 0 84px;
    display: flex;
    align-items: center;           /* 較矮的縮圖上下居中 */
    justify-content: center;
    cursor: pointer;
}

.gallery-thumb-item img {
    width: 100%;                   /* 滿寬 */
    height: auto;                  /* 依原圖實際比例 */
    max-height: none;
    object-fit: contain;           /* 不裁切 */
    border: 2px solid transparent;
    border-radius: 0; /* 縮圖取消圓角 */
    transition: border-color 0.2s ease, filter 0.2s ease;
    /* 預設：不變色，維持原本樣子 */
    filter: none;
}

/* 選中狀態 → 變淺（變淡） */
.gallery-thumb-item.active img {
    border-color: #087860;
    filter: brightness(0.75);
}

.gallery-thumb-item:hover img {
    border-color: #999;
}

/* ===== Lightbox 彈窗 ===== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox-overlay.open {
    display: flex;
}

.lightbox-wrap {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: #fff;
    padding: 12px;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* 彈窗大圖：完整顯示，不裁切也不變形 */
.lightbox-img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 82vh;
    display: block;
    object-fit: contain;
    border-radius: 0; /* 彈窗大圖也取消圓角 */
}

.lightbox-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 30px;
    height: 30px;
    color: #111;
    background: #fff;
    border: none;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    padding: 10px;
}

.lightbox-close:hover {
    background: #f9f9f9;
}
