/* 혼자 넘겨 보는 화면의 겉 — 불러오는 화면, 조작 띠, 장 목록, 따라가기 알림.
   주소 옵션 없이 연 화면(html.is-solo)에만 쓰인다. 요소는 js/viewer.js 가 만든다. */

:root {
  --v-glass: rgb(19 25 58 / 88%);
  --v-line: rgb(255 255 255 / 14%);
  --v-dim: #aab4d6;
  --v-blue: #3b82f6;
  --v-red: #ff5a5f;
}

/* ── 불러오는 화면 ───────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #eef0fb;
  color: #13193a;
  transition:
    opacity 0.45s ease,
    visibility 0s linear 0.45s;
}

html.is-solo #loading {
  display: flex;
}

html.ready #loading {
  opacity: 0;
  visibility: hidden;
}

#loading strong {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

#loading .bar {
  width: 176px;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: rgb(19 25 58 / 12%);
}

#loading .bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--v-blue);
  transform: scaleX(var(--load, 0.04));
  transform-origin: 0 50%;
  transition: transform 0.3s ease;
}

#loading p {
  margin: 0;
  color: #4b5563;
  font-size: 14px;
  font-weight: 600;
}

/* 혼자 보다가 실수로 검은 화면이 됐을 때 돌아오는 길을 알려 준다 */
html.is-solo #blackout {
  cursor: pointer;
}

html.is-solo #blackout::after {
  content: 'B 키를 누르거나 화면을 누르면 돌아옵니다';
  position: absolute;
  right: 0;
  bottom: 7vh;
  left: 0;
  color: #3d4257;
  font-size: 14px;
  text-align: center;
}

/* 두 번 누르기 확대는 막고(빨리 넘길 때 화면이 커진다) 두 손가락 확대는 둔다 */
html.is-solo #viewport {
  touch-action: manipulation;
}

/* ── 겉 ─────────────────────────────────────────────── */
#viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  color: #fff;
  font-size: 14px;
  pointer-events: none;
}

#viewer > * {
  pointer-events: auto;
}

#viewer [hidden] {
  display: none !important;
}

#viewer button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#viewer button:focus-visible,
#viewer a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.v-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.v-btn:hover {
  background: rgb(255 255 255 / 12%);
}

.v-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.v-btn:disabled:hover {
  background: none;
}

/* ── 조작 띠 ─────────────────────────────────────────── */
#v-bar {
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 2px;
  width: min(760px, calc(100% - 24px));
  padding: 4px 6px;
  border: 1px solid var(--v-line);
  border-radius: 14px;
  background: var(--v-glass);
  box-shadow: 0 10px 30px rgb(8 12 32 / 28%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0s linear 0.25s;
}

body.v-ui #v-bar,
body.v-room #v-bar {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0s;
}

#v-pos {
  flex: none;
  min-width: 52px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#v-pos b {
  font-size: 16px;
  font-weight: 800;
}

#v-pos i {
  color: var(--v-dim);
  font-style: normal;
}

/* 진행 막대: 장마다 한 칸. 지금 장은 단계만큼 찬다 */
#v-track {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  gap: 3px;
  min-width: 0;
  height: 40px;
  margin: 0 8px;
}

#v-track button {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
}

#v-track button::before,
#v-track button::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: rgb(255 255 255 / 22%);
}

#v-track button::after {
  background: var(--v-blue);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
  transition: transform 0.3s ease;
}

#v-track button:hover::before {
  background: rgb(255 255 255 / 48%);
}

#v-track button.current::before {
  background: rgb(255 255 255 / 34%);
}

/* ── 처음 한 번 뜨는 도움말 ──────────────────────────── */
#v-tip {
  position: absolute;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  left: 16px;
  width: fit-content;
  margin: 0 auto;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--v-glass);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  white-space: pre-line;
  word-break: keep-all;
  opacity: 0;
  pointer-events: none !important;
  transform: translateY(6px);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

#v-tip.on {
  opacity: 1;
  transform: none;
}

/* ── 따라가기 알림 ───────────────────────────────────── */
#v-live {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  padding: 6px 12px;
  border: 1px solid var(--v-line);
  border-radius: 999px;
  background: var(--v-glass);
  box-shadow: 0 6px 20px rgb(8 12 32 / 24%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

#v-live.free {
  padding-right: 5px;
}

#v-live .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--v-red);
  animation: v-pulse 1.4s ease-in-out infinite;
}

#v-live b {
  color: #ff8f93;
  font-weight: 800;
  letter-spacing: 0.05em;
}

#v-live .msg {
  overflow: hidden;
  text-overflow: ellipsis;
}

#viewer #v-live button {
  flex: none;
  padding: 5px 12px;
  color: #fff;
  border-radius: 999px;
  background: var(--v-blue);
  font-weight: 700;
}

#viewer #v-live button:hover {
  background: #2f6be5;
}

@keyframes v-pulse {
  50% {
    opacity: 0.35;
  }
}

/* 발표자가 시연 중이거나 화면을 가렸을 때 */
#v-note {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgb(11 16 32 / 84%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-align: center;
}

#v-note h2 {
  margin: 0;
  font-size: clamp(22px, 3.4vw, 40px);
  font-weight: 800;
}

#v-note p {
  max-width: 34em;
  margin: 0;
  color: var(--v-dim);
  font-size: clamp(14px, 1.5vw, 19px);
  line-height: 1.55;
}

#v-note a {
  margin-top: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--v-blue);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

/* ── 장 목록 ─────────────────────────────────────────── */
#v-grid {
  --v-side: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px), calc((100% - 1280px) / 2));

  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  background: #0b1020;
}

.v-grid-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--v-side) 10px;
  background: #0b1020;
}

.v-grid-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.v-grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  padding: 0 var(--v-side);
}

#viewer .v-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--v-line);
  border-radius: 10px;
  background: rgb(255 255 255 / 5%);
  text-align: left;
}

#viewer .v-card:hover {
  border-color: rgb(255 255 255 / 40%);
}

#viewer .v-card.current {
  border-color: var(--v-blue);
  box-shadow: 0 0 0 2px var(--v-blue);
}

.v-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #eef0fb;
}

.v-card .no {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgb(11 16 32 / 82%);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.v-card .title {
  display: -webkit-box;
  overflow: hidden;
  padding: 8px 10px 10px;
  color: #dde3f7;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* 발표자가 지금 있는 장 */
.v-card.presenter::after {
  content: 'LIVE';
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--v-red);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

/* ── 좁은 화면 · 터치 ────────────────────────────────── */
@media (pointer: coarse) {
  .v-btn {
    width: 44px;
    height: 44px;
  }

  #v-track {
    height: 44px;
  }
}

@media (max-width: 520px) {
  #v-bar {
    width: calc(100% - 16px);
    padding: 2px 4px;
  }

  #v-track {
    gap: 2px;
    margin: 0 4px;
  }

  #v-pos {
    min-width: 46px;
  }

  .v-grid-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #v-live {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #v-live .dot {
    animation: none;
  }

  #v-bar,
  #v-tip,
  #loading {
    transition-duration: 0.01s;
  }
}

/* ── 장 목록 아래의 질의응답 부록 ────────────────────── */
.v-grid-sub {
  margin: 28px 0 12px;
  padding: 0 var(--v-side);
  color: var(--v-dim);
  font-size: 14px;
  font-weight: 700;
}

#viewer .v-card.qa {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
}

.v-card.qa .no {
  position: static;
  flex: none;
  background: var(--v-blue);
}

.v-card.qa .title {
  padding: 1px 0 0;
}

.v-card.qa.presenter::after {
  top: auto;
  bottom: 6px;
}
