/* 영상, 자막, 손짓 안내, 알림, 프롬프트, 컨트롤 막대.
   크기(--video-w, --video-h, --prompt-w)는 js/layout/layout.js가 정한다.
   영상 칸의 높이는 프롬프트를 켜도 그대로라서 컨트롤 막대 자리가 움직이지 않는다. */
.stage { padding-bottom: 8px; }

/* 영상 틀: 오른쪽 폭 가득. 영상 | (프롬프트를 켜면) 폭 조절 손잡이 12px | 프롬프트(틀 오른쪽 끝).
   영상은 칸 안 가운데에 비율대로 들어가고 남는 곳은 검은 여백이다. */
.stage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: var(--video-h);
}

.app.prompt-on .stage-row { grid-template-columns: minmax(0, 1fr) 12px var(--prompt-w); }

.screen {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000;
  touch-action: manipulation;   /* 두 번 두드리기 확대를 막는다(두 번 누르기는 10초 이동) */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}

/* 프롬프트 폭 조절 손잡이(영상과 프롬프트 사이 12px). 두 번 누르면 기본 폭 */
.prompt-resizer {
  display: none;
  cursor: col-resize;
  touch-action: none;
}

.app.prompt-on[data-device="desktop"]:not([data-layout="overlay"]) .prompt-resizer { display: block; }

.prompt-resizer:hover,
.prompt-resizer:focus-visible,
body.resizing .prompt-resizer:active {
  outline: none;
  background: linear-gradient(90deg, transparent 5px, var(--accent) 5px, var(--accent) 7px, transparent 7px);
}

/* 자막층: 실제 영상 영역(cap-area)에 맞춰 놓고, 크기는 영상 높이 기준(cqh)으로 정한다.
   숫자는 녹화 영상에 박힌 Vimeo 자막을 1920x1080 기준으로 잰 값이다:
   글자 크기 약 48px(4.465cqh), 한 줄 바탕 y 978~1054, 두 줄 바탕 y 920~1054 */
/* 재생 엔진(player/soft)이 그리는 캔버스: video와 같은 자리·같은 맞춤. 쓰는 동안 video는 감춘다. */
.screen .soft-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}
/* 아이폰(기기 전체 화면용으로 캔버스를 video로 흘려보낼 때)은 video를 보이는 채로 캔버스 아래에 둔다(보이지 않으면 기기가 재생을 멈춘다) */
.screen[data-engine="soft"]:not([data-mirror]) video { visibility: hidden; }

.captions { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.cap-area { position: absolute; container-type: size; }

/* 자막 상자: 아래 가운데의 짙은 회색 상자. 박힌 자막이 보이는 순간에는 captions.js가 최소 폭·높이를 정해
   그 바탕까지 덮는다(한 줄이면 y 975~1056). */
.cap-box {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.2cqh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: fit-content;
  max-width: 99cqw;
  margin: 0 auto;
  padding: 0.24em 0.456em;
  border-radius: 0.08em;
  background: #202020;
  color: #fff;
  font-family: "Helvetica Neue", "Apple SD Gothic Neo", var(--font);
  font-size: 4.465cqh;
  line-height: 1.2;
  text-align: center;
  white-space: pre-line;
}

/* 손짓 안내: 2배속(위 가운데), 10초 이동(왼쪽·오른쪽) */
.hint {
  position: absolute;
  z-index: 3;
  padding: 6px 14px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}

.hint[data-at="top"] { top: 14px; left: 50%; transform: translateX(-50%); }
.hint[data-at="left"] { top: 50%; left: 12%; transform: translateY(-50%); }
.hint[data-at="right"] { top: 50%; right: 12%; transform: translateY(-50%); }

/* 영상 위 작은 알림(이어보기 안내 등) */
.notice {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  padding: 5px 6px 5px 12px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 13px;
}

.notice button {
  flex: none;
  border: 0;
  border-radius: 99px;
  padding: 2px 10px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

.notice .notice-close {
  width: 22px;
  height: 22px;
  padding: 0;
  background: none;
  font-size: 16px;
  line-height: 1;
}

.app[data-layout="overlay"] .notice { top: calc(var(--now-h) + 8px); }

/* 프롬프트(대본) */
.prompt {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.prompt-inner {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 8px;
}

.pp { margin-bottom: 2px; padding: 6px 8px; border-radius: 6px; }
.pp.on { background: var(--accent-bg); }

.pp-time {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.pp-text { margin: 2px 0 0; color: var(--sub); font-size: 13.5px; line-height: 1.65; }
.pp.on .pp-text { color: var(--text); }
.pp-text span { border-radius: 3px; cursor: pointer; }
.pp-text span:hover { background: var(--hover); }
.pp-text span.on { background: rgba(47, 111, 219, 0.2); color: var(--text); }
.prompt-empty { margin: 8px; color: var(--sub); font-size: 13px; }


/* 컨트롤 막대: 영상 틀 바로 아래, 틀과 같은 폭 */
.controls {
  display: flex;
  flex-wrap: wrap;   /* 창이 좁으면 버튼이 다음 줄로 넘어간다 */
  align-items: center;
  gap: 6px;
  padding: 10px 0 2px;
}

.cb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  white-space: nowrap;
}

.cb:hover { background: var(--hover); }
.cb.on { background: var(--accent-bg); color: var(--accent-text); border-color: transparent; }
.cb.na { opacity: 0.45; }
.cb svg { width: 18px; height: 18px; fill: currentColor; }
.cb svg .line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.cb[data-act="mute"] { padding: 0 8px; }

.time {
  padding: 0 4px;
  color: var(--sub);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.seek {
  flex: 1;
  min-width: 80px;
  accent-color: var(--accent);
  cursor: pointer;
}

.rate { position: relative; }

.rate-menu {
  position: absolute;
  right: 0;
  bottom: 42px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  min-width: 76px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.rate-menu button {
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.rate-menu button:hover { background: var(--hover); }
.rate-menu button.on { color: var(--accent-text); font-weight: 600; }

/* 좁은 화면(휴대폰 세로): 영상 틀은 화면 폭 가득(모서리 없음). 프롬프트는 틀 오른쪽 끝(폭 조절 손잡이 없음) */
.app[data-device="compact"] .screen { border-radius: 0; }
.app[data-device="compact"].prompt-on .stage-row { grid-template-columns: minmax(0, 1fr) var(--prompt-w); }
.app[data-device="compact"] .prompt { border-width: 0 0 0 1px; border-radius: 0; }
.app[data-device="compact"][data-orient="landscape"] [data-mode="max"] { display: none; }   /* 휴대폰 가로는 늘 최대 */
.app[data-device="compact"] .prompt-inner { padding: 4px; }
.app[data-device="compact"] .pp { padding: 4px 6px; }
.app[data-device="compact"] .pp-time { font-size: 11px; }
.app[data-device="compact"] .pp-text { font-size: 12.5px; line-height: 1.55; }
.app[data-device="compact"] .controls { width: 100%; padding: 8px 10px 2px; gap: 4px; }
.app[data-device="compact"] .cb { height: 32px; min-width: 32px; padding: 0 8px; font-size: 13px; }

/* 영상만 크게(전체, 휴대폰 가로): 영상이 화면을 채우고, 제목줄·컨트롤은 영상 위에 떠 있다가 자동으로 숨는다.
   제목줄과 컨트롤 막대는 프롬프트를 켜도 늘 화면 폭 가득이다(자리가 바뀌지 않게). 프롬프트는 그 사이에 들어간다. */
.app[data-layout="overlay"] .stage {
  position: absolute;
  inset: 0;
  padding: 0;
}

.app[data-layout="overlay"] .stage-row {
  height: 100%;
  grid-template-columns: minmax(0, 1fr);
}

.app[data-layout="overlay"].prompt-on .stage-row { grid-template-columns: minmax(0, 1fr) var(--prompt-w); }
.app[data-layout="overlay"].prompt-on .prompt { margin: var(--now-h) 0 var(--controls-h); }
.app[data-layout="overlay"] .prompt-resizer { display: none; }
.app[data-layout="overlay"] .screen { border-radius: 0; }

.app[data-layout="overlay"] .controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  width: auto;
  padding: 28px 16px 12px;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75));
  color: #fff;
  transition: opacity 0.25s;
}


/* 휴대폰 가로: 컨트롤을 한 줄에 들어가게 줄인다 */
.app[data-layout="overlay"][data-device="compact"] .controls { gap: 4px; padding: 20px 8px 6px; }
.app[data-layout="overlay"][data-device="compact"] .cb { height: 30px; min-width: 30px; padding: 0 6px; font-size: 12.5px; }
.app[data-layout="overlay"][data-device="compact"] .time { padding: 0 2px; font-size: 12px; }
.app[data-layout="overlay"][data-device="compact"] .seek { min-width: 50px; }
.app[data-layout="overlay"] .cb { border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.1); color: #fff; }
.app[data-layout="overlay"] .cb:hover { background: rgba(255, 255, 255, 0.2); }
.app[data-layout="overlay"] .cb.on { background: rgba(255, 255, 255, 0.3); }
.app[data-layout="overlay"] .time { color: #ddd; }
.app[data-layout="overlay"] .rate-menu { background: #222; border-color: #444; }
.app[data-layout="overlay"] .rate-menu button:hover { background: #333; }
.app[data-layout="overlay"] .rate-menu button.on { color: #a8c6ff; }
.app[data-layout="overlay"] [data-mode="max"] { display: none; }   /* 영상만 크게 볼 때는 최대가 의미 없다 */

.app[data-layout="overlay"] .prompt {
  border: 0;
  border-left: 1px solid #333;
  border-radius: 0;
  background: #161616;
}

.app[data-layout="overlay"] .pp-text { color: #9a9a9a; }
.app[data-layout="overlay"] .pp.on { background: #1f2c45; }
.app[data-layout="overlay"] .pp.on .pp-text,
.app[data-layout="overlay"] .pp-text span.on { color: #f2f2f2; }
.app[data-layout="overlay"] .pp-text span:hover { background: #2a2a2a; }
.app[data-layout="overlay"] .pp-time { color: #a8c6ff; }

/* 자동 숨김: 제목줄·컨트롤을 감추고, 영상 위 마우스 표시도 숨긴다 */
.app[data-layout="overlay"].idle .controls,
.app[data-layout="overlay"].idle .now { opacity: 0; pointer-events: none; }
.app[data-layout="overlay"].idle .screen,
.app[data-layout="overlay"].idle video { cursor: none; }

/* 영상 자리 가운데 안내: 아직 재생할 수 없는 형식, 소리 파일 이름 */
.screen-msg {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: #e6e6e6;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  pointer-events: none;
}

.screen-msg svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }
.screen-msg b { font-weight: 600; }
.screen-msg small { color: #a8a8a8; font-size: 12.5px; }
