/*
 * 보드팩토리 이미지 뷰어 (assets/js/bf-viewer.js). 사이트 라이트 · 다크 모드와 관계없이 늘 어두운 화면
 * 모든 선택자는 .bfv 안에서만 쓴다 (줄어 보이는 본문 그림의 돋보기 커서 .bfv-zoomable 만 밖)
 */
.bfv-zoomable { cursor: zoom-in; }
html.bfv-open, html.bfv-open body { overflow: hidden !important; }

.bfv {
    --bfv-bg: rgba(8, 10, 14, .96);
    --bfv-ink: #f1f4f8;
    --bfv-muted: #a9b2bf;
    --bfv-btn: rgba(255, 255, 255, .1);
    --bfv-btn-hover: rgba(255, 255, 255, .2);
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    background: var(--bfv-bg);
    color: var(--bfv-ink);
    font: 14px/1.5 var(--bf-font, Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif);
    opacity: 0;
    transition: opacity .18s ease;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}
.bfv[hidden] { display: none; }
.bfv.is-open { opacity: 1; }
.bfv *, .bfv *::before, .bfv *::after { box-sizing: border-box; }
.bfv svg { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* 그림 자리 */
.bfv__stage { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: default; }
.bfv.is-zoomed .bfv__stage { cursor: grab; }
.bfv.is-zoomed .bfv__stage:active { cursor: grabbing; }
.bfv__img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none !important;
    max-height: none !important;
    margin: 0;
    border: 0;
    transform-origin: 0 0;
    will-change: transform;
    -webkit-user-drag: none;
    image-rendering: auto;
}
.bfv__img.is-anim { transition: transform .24s cubic-bezier(.2, .8, .2, 1); }
.bfv__img:not([src]) { visibility: hidden; }

.bfv__spin {
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 26px;
    height: 26px;
    border: 3px solid rgba(255, 255, 255, .2);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    animation: bfv-spin .8s linear infinite;
}
.bfv.is-loading .bfv__spin { opacity: 1; transition-delay: .25s; }
@keyframes bfv-spin { to { transform: rotate(360deg); } }

/* 위 줄: 몇 번째 · 설명 · 단추 */
.bfv__top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 24px 18px;
    background: linear-gradient(180deg, rgba(0, 0, 0, .55), transparent);
    pointer-events: none;
}
.bfv__count { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.bfv__cap { flex: 1; min-width: 0; overflow: hidden; color: var(--bfv-muted); text-overflow: ellipsis; white-space: nowrap; }
.bfv__tools { display: flex; gap: 6px; margin-left: auto; pointer-events: auto; }

.bfv__btn, .bfv__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--bfv-btn);
    color: var(--bfv-ink) !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color .15s;
}
.bfv__btn:hover, .bfv__nav:hover { background: var(--bfv-btn-hover); }
.bfv__btn:focus-visible, .bfv__nav:focus-visible, .bfv__thumb:focus-visible { outline: 2px solid #8fd0ff; outline-offset: 2px; }
.bfv__btn[hidden], .bfv__nav[hidden] { display: none; }
.bfv__btn span, .bfv__nav span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* 이전 · 다음 */
.bfv__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 48px;
    height: 48px;
    margin-top: -24px;
    background: rgba(0, 0, 0, .35);
}
.bfv.has-strip .bfv__nav { margin-top: -60px; }
.bfv__nav svg { width: 26px; height: 26px; }
.bfv__nav--prev { left: 14px; }
.bfv__nav--next { right: 14px; }

/* 아래 작은 그림 줄 */
.bfv__strip {
    display: flex;
    flex: none;
    gap: 8px;
    justify-content: center;
    padding: 10px 14px 14px;
    overflow-x: auto;
    scrollbar-width: thin;
}
.bfv__strip[hidden] { display: none; }
.bfv__thumb {
    flex: none;
    width: 58px;
    height: 58px;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #1d222b;
    opacity: .55;
    cursor: pointer;
    transition: opacity .15s, border-color .15s;
}
.bfv__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bfv__thumb:hover { opacity: .85; }
.bfv__thumb.is-on { border-color: #fff; opacity: 1; }

/* 휴대폰: 단추를 줄이고 이전 · 다음은 밀어서 넘기기와 함께 */
@media (max-width: 640px) {
    .bfv__top { padding: 8px 8px 20px 14px; gap: 8px; }
    .bfv__cap { display: none; }
    .bfv__btn { width: 38px; height: 38px; }
    .bfv__btn[data-act="out"], .bfv__btn[data-act="in"] { display: none; }
    .bfv__nav { width: 40px; height: 40px; margin-top: -20px; background: rgba(0, 0, 0, .25); }
    .bfv__nav--prev { left: 6px; }
    .bfv__nav--next { right: 6px; }
    .bfv__thumb { width: 46px; height: 46px; }
    .bfv__strip { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    .bfv, .bfv__img.is-anim { transition: none; }
}

/* 테마 · 모듈이 뷰어로 열도록 표시한 그림 (줄어 보일 때만 여는 것은 위 .bfv-zoomable 로) */
[data-bf-viewer]:not([data-bf-viewer="off"]):not([data-bf-viewer-when]),
[data-bf-viewer]:not([data-bf-viewer="off"]):not([data-bf-viewer-when]) img { cursor: zoom-in; }
