/* gallery / modal — 이미지 라이트박스 + 영상 임베드 공용 모달 */

.gallery-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}
.gallery-modal.is-open {
    display: flex;
}

.gallery-modal__stage {
    position: relative;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* 닫기 버튼 */
.gallery-modal__close {
    position: absolute;
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}
.gallery-modal__close:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* 좌우 네비 */
.gallery-modal__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    z-index: 2;
    transition: background 0.15s;
}
.gallery-modal__nav:hover {
    background: rgba(255, 255, 255, 0.22);
}
.gallery-modal__nav--prev { left: -56px; }
.gallery-modal__nav--next { right: -56px; }
.gallery-modal__nav[disabled] { opacity: 0.3; cursor: default; }
.gallery-modal__nav[disabled]:hover { background: rgba(255, 255, 255, 0.12); }

/* 콘텐츠 영역 */
.gallery-modal__content {
    position: relative;
    width: 100%;
    max-height: 78vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

/* 이미지 */
.gallery-modal__image {
    display: block;
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* 고정 비율 박스 (이미지여러장 슬라이드 모달) — 설정 비율로 cover 크롭.
   가로폭을 min(뷰포트폭, 78vh×비율)로 지정 → 높이는 aspect-ratio로 파생되어
   78vh를 넘지 않으므로, 어떤 비율을 골라도 화면 안에서 비율이 정확히 유지된다.
   (예전엔 width:100% + max-height:78vh라 세로가 잘리며 비율이 깨졌음) */
.gallery-modal__ratio {
    max-width: 1000px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}
.gallery-modal__ratio--16-9 { aspect-ratio: 16 / 9; width: min(92vw, calc(78vh * 16 / 9)); }
.gallery-modal__ratio--4-3  { aspect-ratio: 4 / 3;  width: min(92vw, calc(78vh * 4 / 3));  }
.gallery-modal__ratio--1-1  { aspect-ratio: 1 / 1;  width: min(92vw, 78vh); }
.gallery-modal__ratio--3-4  { aspect-ratio: 3 / 4;  width: min(92vw, calc(78vh * 3 / 4));  }
.gallery-modal__image--cover {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
}

/* 영상 (iframe/video) */
.gallery-modal__video-wrap {
    position: relative;
    width: 100%;
    max-width: 960px;
    aspect-ratio: 16 / 9;
    background: #000;
}
.gallery-modal__video-wrap--portrait {
    aspect-ratio: 9 / 16;
    max-width: 380px;
    margin: 0 auto;
}
.gallery-modal__video-wrap iframe,
.gallery-modal__video-wrap video {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* 캡션 */
.gallery-modal__caption {
    margin-top: 12px;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    max-width: 100%;
    word-break: keep-all;
}

/* 카운터 */
.gallery-modal__counter {
    position: absolute;
    top: -36px;
    left: 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    letter-spacing: 0.5px;
}

/* 인라인 플레이어 */
.gallery-inline-player {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #000;
    border-radius: inherit;
}
.gallery-inline-player iframe,
.gallery-inline-player video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* 반응형 */
@media (max-width: 767px) {
    .gallery-modal {
        padding: 56px 12px 12px;
    }
    .gallery-modal__close {
        top: 12px;
        right: 12px;
    }
    .gallery-modal__counter {
        top: 16px;
        left: 16px;
    }
    .gallery-modal__nav {
        width: 38px;
        height: 38px;
    }
    .gallery-modal__nav--prev { left: 8px; }
    .gallery-modal__nav--next { right: 8px; }
}
