/* 뷰어(사진·문서·파일 보기) - 동작은 viewer.js, 규칙은 claude_common/ui/viewer.md
   uk-lint: fixed-dark - 테마와 상관없이 늘 어두운 몰입 화면이라 흰색 반투명 값은 일부러 고정한다.
   어두운 바탕에 화면을 꽉 채우고, 머리·아래 줄은 반투명 띠로 위에 뜬다. 테마와 상관없이 어둡다(사진 몰입형).
   1280px 이상에서 옆 칸으로 열면(.is-side) 화면 오른쪽 절반에 붙고 왼쪽 목록은 계속 누를 수 있다. */
.viewer {
  --viewer-bg: rgba(16, 16, 24, .97);
  --viewer-bar: rgba(10, 12, 18, .55);
  --viewer-fg: #fff;
  --viewer-muted: rgba(255, 255, 255, .7);
  --viewer-head-h: 56px;
  --viewer-foot-h: 0px;          /* 아래 줄 높이 - 스크립트가 채운다 */
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: var(--viewer-bg); color: var(--viewer-fg);
  overflow: hidden; overscroll-behavior: contain;
}
.viewer::backdrop { background: transparent; }
.viewer:not([open]) { display: none; }

/* 머리 - ← 닫기 · 제목 · ⋮ */
.viewer-head { position: absolute; top: 0; left: 0; right: 0; z-index: 3; height: var(--viewer-head-h); display: flex; align-items: center; gap: var(--uk-hd-gap, 4px); padding: 0 var(--uk-hd-edge, 12px) 0 var(--uk-hd-start, 4px); padding-top: env(safe-area-inset-top, 0px); /* 사이 4·왼쪽 4·오른쪽 끝 12 = 공통 머리줄(navigation.md), 끝은 X(2026-10-24) */ background: var(--viewer-bar); transition: transform .2s ease, opacity .2s ease; }
.viewer-title { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-icon { flex: none; width: var(--uk-hd-btn, 44px); height: var(--uk-hd-btn, 44px); padding: 0; border: 0; border-radius: 50%; background: none; color: var(--viewer-fg); cursor: pointer; display: grid; place-items: center; }
/* 머리 단추 = 공통 머리줄 단추 44 · 그림 28 · 선 1.3(modal.md 닫기 X 크기 표 "뷰어", 2026-10-23). ⋮는 점 세 개라 선을 굵게 */
.viewer-icon svg { display: block; width: var(--uk-hd-icon, 28px); height: var(--uk-hd-icon, 28px); stroke-width: var(--uk-hd-stroke, 1.3); }
.viewer-menu svg { stroke-width: 2.6; }
.viewer-icon:hover { background: rgba(255, 255, 255, .12); }
.viewer-icon[hidden] { display: none; } /* 위 display: grid가 hidden(메뉴 없을 때 ⋮)을 이기지 않게 */

/* 슬라이드 줄 - 한 장 = 화면 폭, 좌우로 밀면 붙어 넘어간다 */
.viewer-track { position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.viewer-track::-webkit-scrollbar { display: none; }
.viewer-track.is-locked { overflow: hidden; }
.viewer-slide { flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: grid; place-items: center; overflow: hidden; position: relative; }
.viewer-slide.is-image img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; touch-action: pan-x; transform-origin: center center; transition: transform .18s ease; }
.viewer-slide.is-image.is-zoomed img { touch-action: none; transition: none; cursor: grab; }
.viewer-slide video, .viewer-slide audio { max-width: 100%; max-height: calc(100% - var(--viewer-head-h) - var(--viewer-foot-h)); }
/* 사진이 아닌 장은 머리와 아래 줄 사이에만 깔린다 - 내용이 띠 밑으로 들어가 가려지지 않게 */
.viewer-slide.is-doc, .viewer-slide.is-file { align-self: stretch; height: auto; margin: var(--viewer-head-h) 0 var(--viewer-foot-h); }
.viewer-doc { align-self: stretch; justify-self: stretch; overflow-y: auto; overscroll-behavior: contain; background: var(--uk-surface); color: var(--uk-fg); padding: 20px clamp(16px, 4vw, 40px); font-size: 15px; line-height: 1.7; word-break: keep-all; }
.viewer-doc > :first-child { margin-top: 0; }
.viewer-file { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 24px; max-width: 360px; }
.viewer-file-kind { width: 72px; height: 88px; border-radius: var(--uk-r-md); background: rgba(255, 255, 255, .1); display: grid; place-items: center; font-size: 14px; font-weight: 700; letter-spacing: .04em; }
.viewer-file-name { font-weight: 600; overflow-wrap: anywhere; }
.viewer-file-note { color: var(--viewer-muted); font-size: 13.5px; white-space: pre-line; }
.viewer-btn { border: 0; border-radius: var(--uk-r-md); padding: 9px 16px; background: rgba(255, 255, 255, .14); color: var(--viewer-fg); font: inherit; font-size: 14px; cursor: pointer; }
.viewer-btn:hover { background: rgba(255, 255, 255, .24); }
.viewer-btn.is-primary { background: var(--uk-brand); }

/* 좌우 이동 - 반투명 어두운 원, 처음·끝에서는 숨는다 */
.viewer-nav { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; border: 0; border-radius: 50%; background: var(--viewer-bar); color: var(--viewer-fg); cursor: pointer; padding: 0; display: grid; place-items: center; transition: opacity .2s ease; }
/* 넘기기 그림 = 머리줄 그림과 같은 28 · 1.3(--uk-hd-icon·--uk-hd-stroke) - 대시보드 뷰슬라이드 .dash-gallery-nav도 이 값 */
.viewer-nav svg { display: block; width: var(--uk-hd-icon, 28px); height: var(--uk-hd-icon, 28px); stroke-width: var(--uk-hd-stroke, 1.3); }
.viewer-nav:hover { background: rgba(10, 12, 18, .8); }
.viewer-prev { left: 12px; }
.viewer-next { right: 12px; }

/* 아래 줄 - 필름스트립(2장 이상) + 위치 N/M + 동작 버튼 */
.viewer-foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; flex-direction: column; background: var(--viewer-bar); padding-bottom: env(safe-area-inset-bottom, 0px); transition: transform .2s ease, opacity .2s ease; }
.viewer-strip-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px 4px; min-width: 0; }
.viewer-strip { flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; justify-content: safe center; }
.viewer-strip::-webkit-scrollbar { display: none; }
.viewer-thumb { flex: none; width: 48px; height: 48px; border: 0; border-radius: var(--uk-r-sm); padding: 0; overflow: hidden; background: rgba(255, 255, 255, .12); color: var(--viewer-muted); font-size: 10px; font-weight: 700; cursor: pointer; opacity: .6; }
.viewer-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewer-thumb.is-current { opacity: 1; box-shadow: inset 0 0 0 2px #fff; }
.viewer-thumb.is-current img { outline: 2px solid #fff; outline-offset: -2px; }
.viewer-count { flex: none; font-size: 12.5px; color: var(--viewer-muted); font-variant-numeric: tabular-nums; }
.viewer-actions { display: flex; justify-content: center; gap: 4px; padding: 6px 8px 8px; flex-wrap: wrap; }
.viewer-action { border: 0; background: none; color: var(--viewer-fg); font: inherit; font-size: 13px; padding: 8px 14px; border-radius: var(--uk-r-sm); cursor: pointer; }
.viewer-action:hover { background: rgba(255, 255, 255, .12); }
.viewer-icon:focus-visible, .viewer-nav:focus-visible, .viewer-thumb:focus-visible, .viewer-action:focus-visible, .viewer-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* 몰입 모드 - 사진 장에서 누르면 띠·이동 버튼이 사라진다 */
.viewer.is-controls-hidden .viewer-head { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.viewer.is-controls-hidden .viewer-foot { transform: translateY(100%); opacity: 0; pointer-events: none; }
.viewer.is-controls-hidden .viewer-nav { opacity: 0; pointer-events: none; }

/* 옆 칸(1280px 이상) - 오른쪽 절반, 뒤 화면은 그대로 눌린다 */
@media (min-width: 1280px) {
  /* 옆 칸은 뒤 화면을 막지 않는다 - 열린 <dialog>마다 뒤 스크롤을 잠그는 공용 규칙을 풀어 준다 */
  html:has(dialog.viewer.is-side[open]):not(:has(dialog:modal)) { overflow: auto; padding-right: 0; }
  .viewer.is-side { left: auto; right: 0; width: 50%; box-shadow: -8px 0 24px rgba(0, 0, 0, .25); z-index: 100; }
}
@media (max-width: 767px) {
  .viewer-nav { display: none; } /* 휴대폰은 밀어서 넘긴다 */
  .viewer-action { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .viewer-head, .viewer-foot, .viewer-nav, .viewer-slide.is-image img { transition: none; }
  .viewer-track { scroll-behavior: auto; }
}
