/* --- Gallery Container --- */
.gallery-container-new {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

/* gallery-section 가로 스크롤 방지 */
.gallery-section {
    overflow-x: hidden;
}

/* --- Coverflow Gallery --- */
.gallery-coverflow {
    position: relative;
    margin-left: calc(-50vw + 50%);
    width: 100vw;
    height: 660px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.coverflow-wrapper {
    position: relative;
    width: 600px;
    height: 600px;
    touch-action: pan-y;
}

/* Dynamic Aspect Ratio Classes (Desktop) */

.coverflow-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.45s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coverflow-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    pointer-events: none;
    background-color: transparent;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.85), 0 6px 24px rgba(0,0,0,0.18);
}

/* 2D States */
.coverflow-item.center {
    transform: translateX(0) scale(1);
    z-index: 5;
    opacity: 1;
}

.coverflow-item.left1 {
    transform: translateX(-240px) scale(0.75);
    z-index: 4;
    opacity: 0.85;
}

.coverflow-item.right1 {
    transform: translateX(240px) scale(0.75);
    z-index: 4;
    opacity: 0.85;
}

.coverflow-item.left2 {
    transform: translateX(-400px) scale(0.55);
    z-index: 3;
    opacity: 0.5;
}

.coverflow-item.right2 {
    transform: translateX(400px) scale(0.55);
    z-index: 3;
    opacity: 0.5;
}

.coverflow-item.hidden {
    transform: translateX(0) scale(0.4);
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

.coverflow-item.hidden-left {
    transform: translateX(-480px) scale(0.4);
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

.coverflow-item.hidden-right {
    transform: translateX(480px) scale(0.4);
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

/* ── Wide desktop (1100px+): 5장 커버플로우 ── */
@media (min-width: 1100px) {
    .gallery-coverflow {
        height: 700px;
    }


    .coverflow-wrapper {
        width: 700px;
        height: 680px;
    }

    .coverflow-item.left1  { transform: translateX(-360px) scale(0.73); }
    .coverflow-item.right1 { transform: translateX(360px)  scale(0.73); }

    .coverflow-item.left2  { transform: translateX(-650px) scale(0.53); opacity: 0.55; }
    .coverflow-item.right2 { transform: translateX(650px)  scale(0.53); opacity: 0.55; }

    .coverflow-item.hidden-left  { transform: translateX(-900px) scale(0.38); }
    .coverflow-item.hidden-right { transform: translateX(900px)  scale(0.38); }

    /* 1100px+: wrapper가 더 넓어도 동일한 -56px 적용 */
}

/* Mobile Responsiveness for Coverflow */
@media (max-width: 768px) {
    .gallery-coverflow { margin-bottom: 5px; height: 460px; }

    .coverflow-wrapper { width: 320px; height: 420px; }

    .coverflow-item.left1 { transform: translateX(-120px) scale(0.75); }
    .coverflow-item.right1 { transform: translateX(120px) scale(0.75); }

    .coverflow-item.left2 { transform: translateX(-200px) scale(0.55); }
    .coverflow-item.right2 { transform: translateX(200px) scale(0.55); }
    .coverflow-item.hidden-left { transform: translateX(-280px) scale(0.4); }
    .coverflow-item.hidden-right { transform: translateX(280px) scale(0.4); }

    /* 모바일: 빈 공간 없으므로 wrapper 안쪽 가장자리에 배치 */
    .gallery-nav { width: 36px; height: 36px; font-size: 1rem; }
    .gallery-prev { left: 10px; }
    .gallery-next { right: 10px; }
}

/* --- Thumbnails Grid --- */
.gallery-thumbs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding-bottom: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.thumb-item {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease, opacity 0.2s ease;
    border: 2px solid transparent;
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-item:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.thumb-item.active {
    border-color: var(--color-accent);
    opacity: 0.6;
}

/* --- Navigation Arrows --- */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.5);
    backdrop-filter: blur(5px);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #333;
    z-index: 10;
    transition: background 0.2s;
}

.gallery-nav:hover {
    background: rgba(255,255,255,0.8);
}

/* wrapper 기준 음수 offset → 사진 가장자리에서 16px 바깥 */
.gallery-prev { left: -48px; }
.gallery-next { right: -48px; }

/* Responsive adjustments */
@media (max-width: 480px) {
    .gallery-thumbs {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* --- Lightbox --- */
.gallery-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.gallery-lightbox.active {
    display: flex;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    padding: 4px 8px;
    opacity: 0.8;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 1.4rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}

.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255, 255, 255, 0.3); }

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
