/* ================================================
   미디어 뷰어 — 풀스크린 오버레이
   ================================================ */

/* 오버레이 */
.media-viewer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.95);
    flex-direction: column;
}

.media-viewer.is-visible {
    display: flex;
}

/* 열기/닫기 애니메이션 */
.media-viewer.is-opening {
    animation: mv-fade-in 0.2s ease forwards;
}

.media-viewer.is-closing {
    animation: mv-fade-out 0.2s ease forwards;
}

@keyframes mv-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mv-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}


/* ---- 상단 헤더 ---- */
.media-viewer__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.media-viewer__filename {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-viewer__filesize {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
}

.media-viewer__dl {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.media-viewer__dl:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.media-viewer__dl[hidden] {
    display: none !important;
}

.media-viewer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.media-viewer__close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}


/* ---- 메인 미디어 영역 ---- */
.media-viewer__stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    padding: 16px 60px;
    overflow: hidden;
}

.media-viewer__media {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
}

/* 이미지 로딩 */
img.media-viewer__media.is-loading {
    opacity: 0.3;
}

img.media-viewer__media {
    cursor: zoom-in;
}

/* 확대 — 가운데 정렬을 margin: auto로 옮겨야 넘친 쪽이 잘리지 않고 스크롤된다 */
.media-viewer__wrap.is-zoomed {
    overflow: auto;
    overscroll-behavior: contain;
    align-items: flex-start;
    justify-content: flex-start;
}

.media-viewer__wrap.is-zoomed > img.media-viewer__media {
    flex: none;
    max-width: none;
    max-height: none;
    margin: auto;
    cursor: zoom-out;
}

/* 영상 — 고해상도 영상이 화면을 꽉 채우지 않도록 제한, 중앙 정렬 */
video.media-viewer__media {
    outline: none;
    background: #000;
    max-width: min(100%, 1120px);
    max-height: min(100%, 680px);
    margin: auto;
}

/* 이미지 max-width/max-height 100%가 스테이지 기준이 되도록 래퍼가 스테이지를 채운다 — 없으면 긴 사진이 잘린다. */
.media-viewer__wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.media-viewer__pdf {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 6px;
    background: #fff;
}

/* 미리보기 불가 파일 — 다운로드 안내 카드 */
.media-viewer__fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 420px;
    padding: 48px 56px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.media-viewer__fallback > i {
    font-size: 56px;
    color: rgba(255, 255, 255, 0.45);
}

.media-viewer__fallback strong {
    color: #fff;
    font-size: 15px;
    overflow-wrap: anywhere;
}

.media-viewer__fallback p {
    margin: 0;
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
    line-height: 1.5;
}


/* ---- 좌우 네비게이션 ---- */
.media-viewer__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.media-viewer__nav:hover {
    background: rgba(0, 0, 0, 0.75);
}

.media-viewer__nav--prev {
    left: 12px;
}

.media-viewer__nav--next {
    right: 12px;
}

.media-viewer__nav[hidden] {
    display: none !important;
}


/* ---- 하단 썸네일 스트립 ---- */
.media-viewer__strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px 16px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.media-viewer__strip[hidden] {
    display: none !important;
}

.media-viewer__thumb {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s ease, border-color 0.15s ease;
    background: rgba(255, 255, 255, 0.06);
    padding: 0;
}

.media-viewer__thumb:hover {
    opacity: 0.8;
}

.media-viewer__thumb.is-active {
    border-color: var(--action-blue, #4a8cff);
    opacity: 1;
}

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

.media-viewer__thumb-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
}

.media-viewer__thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 12px;
}

.media-viewer__counter {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 8px;
    flex-shrink: 0;
}


/* ---- 모바일 ---- */
@media (max-width: 640px) {
    .media-viewer__stage {
        padding: 8px 12px;
    }

    .media-viewer__nav {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .media-viewer__nav--prev {
        left: 4px;
    }

    .media-viewer__nav--next {
        right: 4px;
    }

    .media-viewer__thumb {
        width: 36px;
        height: 36px;
    }
}
