/* 백팩 — 스크린샷·영상 갤러리 (media-gallery.js) v19
   원칙(docs/design-research.md): 무채색 바탕, 장식 없음, 모서리 2~4px. 메인은 16:9 가로 스크롤 + scroll-snap, 아래 썸네일 줄.
   움직임 줄이기(prefers-reduced-motion)면 부드러운 스크롤·전환을 끈다. */
.mg { --mg-th-w: 112px; position: relative; min-width: 0; }
.mg.mg-c { --mg-th-w: 84px; }
.mg-wait { aspect-ratio: 16 / 9; display: grid; place-items: center; background: var(--bg3); border-radius: 4px; color: var(--tx3); font-size: 12px; }
.mg-wait span { animation: mg-pulse 1.4s ease-in-out infinite; }
@keyframes mg-pulse { 50% { opacity: .45; } }
.mg-empty { margin: 0; padding: 10px 12px; font-size: 12.5px; color: var(--tx3); background: var(--bg1); border-radius: 4px; }
.mg-empty a { color: var(--steam); }

/* 메인 */
.mg-stage { position: relative; border-radius: 4px; overflow: hidden; background: #000; outline: none; }
.mg-track { display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-behavior: smooth; overscroll-behavior-x: contain;
  scrollbar-width: none; aspect-ratio: 16 / 9; outline: none; }
.mg-track::-webkit-scrollbar { display: none; }
.mg-track:focus-visible { box-shadow: inset 0 0 0 2px var(--acc); }
.mg-slide { position: relative; flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; background: #000; overflow: hidden; }
.mg-img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.mg-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: block; cursor: pointer; }
.mg-slide.has-video .mg-img { visibility: hidden; }

/* 영상 포스터: 재생 표시(누르면 재생). 영상이 붙으면 숨긴다 */
.mg-play { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(10, 12, 16, .62); border: 1px solid rgba(255, 255, 255, .28); color: #fff; z-index: 2; transition: background .15s, transform .15s; }
.mg-play svg { width: 28px; height: 28px; fill: currentColor; stroke: none; margin-left: 3px; }
.mg-play:hover { background: rgba(10, 12, 16, .82); transform: scale(1.05); }
.mg-slide.has-video .mg-play { display: none; }
.mg-slide.has-video:not(.is-playing) .mg-play { display: grid; }
.mg-vname { position: absolute; left: 10px; bottom: 40px; max-width: calc(100% - 20px); padding: 2px 7px; border-radius: 2px; background: rgba(10, 12, 16, .7);
  font-size: 11.5px; color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 2; pointer-events: none; }
.mg-slide.is-playing .mg-vname { opacity: 0; transition: opacity .3s .8s; }
.mg-c .mg-play { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
.mg-c .mg-vname { display: none; }

/* 위에 겹치는 표시(미리보기의 위시·보유·관심 배지) */
.mg-over { position: absolute; left: 8px; top: 8px; display: flex; flex-wrap: wrap; gap: 4px; z-index: 3; pointer-events: none; }
.mg-over:empty { display: none; }

/* 좌우 화살표 · 아래 막대(번호 · 영상 도구) */
.mg-arrow { position: absolute; top: 50%; width: 34px; height: 54px; margin-top: -27px; display: grid; place-items: center; z-index: 3; color: #fff;
  background: rgba(10, 12, 16, .55); opacity: 0; transition: opacity .15s; }
.mg-arrow svg { width: 20px; height: 20px; }
.mg-arrow.prev { left: 0; border-radius: 0 4px 4px 0; }
.mg-arrow.next { right: 0; border-radius: 4px 0 0 4px; }
.mg-stage:hover .mg-arrow, .mg-arrow:focus-visible { opacity: 1; }
.mg-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; z-index: 3; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent); }
.mg-count { font-size: 11.5px; color: rgba(255, 255, 255, .85); }
.mg-tools { margin-left: auto; display: flex; align-items: center; gap: 4px; pointer-events: auto; }
.mg-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 4px; color: #fff; background: rgba(10, 12, 16, .55); }
.mg-btn:hover { background: rgba(10, 12, 16, .85); }
.mg-btn svg { width: 17px; height: 17px; }
.mg-btn[data-mg-toggle] svg { fill: currentColor; stroke: none; }
.mg-steam { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 4px; background: rgba(10, 12, 16, .7); color: var(--steam);
  font-size: 11.5px; text-decoration: none; white-space: nowrap; }
.mg-steam svg { width: 13px; height: 13px; }

/* 썸네일 줄 */
.mg-thumbs { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 4px; scrollbar-width: thin; }
.mg-th { position: relative; flex: 0 0 var(--mg-th-w); aspect-ratio: 16 / 9; border-radius: 2px; overflow: hidden; background: var(--bg3); opacity: .55;
  outline: 2px solid transparent; outline-offset: -2px; transition: opacity .15s, outline-color .15s; }
.mg-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-th:hover { opacity: .85; }
.mg-th.is-on, .mg-th[aria-selected="true"] { opacity: 1; outline-color: var(--acc); }
.mg-th:focus-visible { outline-color: var(--acc); opacity: 1; }
.mg-thv { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .25); color: #fff; }
.mg-thv svg { width: 18px; height: 18px; fill: currentColor; stroke: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.mg-note { margin: 4px 0 0; font-size: 11.5px; color: var(--tx3); }

/* 전체 화면: 무대가 화면을 채운다 */
.mg-stage:fullscreen { display: flex; align-items: center; background: #000; }
.mg-stage:fullscreen .mg-track { width: 100%; height: 100%; aspect-ratio: auto; }
.mg-stage:fullscreen .mg-arrow { opacity: 1; }

/* 터치 기기: 화살표는 늘 보이게(작게) */
@media (hover: none) {
  .mg-arrow { opacity: .85; width: 28px; height: 44px; margin-top: -22px; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-track, .mg-thumbs { scroll-behavior: auto; }
  .mg-play, .mg-th, .mg-arrow, .mg-slide.is-playing .mg-vname { transition: none; }
  .mg-wait span { animation: none; }
}

/* 오른쪽 미리보기: 위쪽 그림 자리를 갤러리가 대신한다 */
.i-media { position: relative; margin: 0 0 2px; }
.i-media .mg-stage { border: 1px solid var(--line); }
.i-media.is-reached .mg-stage { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(61, 220, 151, .15); }
.i-mflags { position: absolute; left: 8px; top: 8px; z-index: 4; display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none; }
.i-mflags:empty { display: none; }
.i-media .mg-thumbs { margin-top: 5px; gap: 5px; }
/* 상세 페이지 절 */
.gv-media .mg-thumbs { gap: 8px; margin-top: 8px; }
