/* screen — production UI */

:root {
  --accent: #4caf50;
  --accent-2: #6abf6e;
  --warn: #e0a000;
  --danger: #cc2e2e;
}

/* hidden 속성이 display:flex 같은 class 룰에 가려지지 않도록 강제 */
[hidden] { display: none !important; }

/* ---- 아이콘 ---- */
.icon { width: 20px; height: 20px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 56px; height: 56px; opacity: 0.4; }

/* ---- 화면 라우팅 ---- */
body[data-screen="loading"] .screen[data-screen="loading"],
body[data-screen="landing"] .screen[data-screen="landing"],
body[data-screen="join"] .screen[data-screen="join"],
body[data-screen="room"] .screen[data-screen="room"],
body[data-screen="fullscreen"] .screen[data-screen="fullscreen"] {
  display: flex;
  animation: screen-fade-in 0.18s ease-out;
}
.screen { display: none; }
@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---- Landing & Join & Loading ---- */
.screen[data-screen="landing"],
.screen[data-screen="join"],
.screen[data-screen="loading"] {
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ---- Loading splash ---- */
.loading-card {
  align-items: center;
  text-align: center;
}
.brand-pulse {
  font-size: 44px;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
  animation: brand-pulse 2.6s ease-in-out infinite;
  font-weight: 700;
}
@keyframes brand-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}
.dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 18px 0 10px;
}
.dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40%          { opacity: 1;    transform: scale(1.05); }
}
.loading-status {
  margin-top: 2px;
  opacity: 0.7;
  font-size: 14px;
  min-height: 1.2em;
  transition: opacity 0.25s ease-out;
}

.card {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.card h1 {
  font-size: 44px;
  letter-spacing: -0.03em;
  text-align: center;
  margin-bottom: 2px;
  font-weight: 700;
}
.tagline {
  color: var(--subtle);
  text-align: center;
  margin-bottom: 24px;
  font-size: 14px;
}

/* ---- Action buttons (large) ---- */
.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn-action:hover { background: #222; border-color: #3a3a3a; }
.btn-action:active { transform: scale(0.98); }
.btn-action.primary {
  background: #fff;
  color: #000;
  border-color: #fff;
}
.btn-action.primary:hover { background: #e8e8e8; border-color: #e8e8e8; }
.btn-action.primary.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-back {
  position: absolute;
  top: -4px;
  left: 0;
  background: transparent;
  border: none;
  color: var(--subtle);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-back:hover { color: var(--text); background: var(--card); }

#code-input {
  width: 100%;
  padding: 18px;
  font-size: 28px;
  text-align: center;
  letter-spacing: 8px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-transform: uppercase;
  font-weight: 700;
}
#code-input:focus {
  outline: none;
  border-color: #555;
}

/* ---- Room ---- */
.screen[data-screen="room"] {
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  padding: 20px;
  gap: 14px;
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}
.room-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 130px;          /* profile-chip 영역 회피 */
  flex-wrap: wrap;
}
.code-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.code-pill:hover { background: #222; }
.code-pill .icon { opacity: 0.55; }
.participant-count {
  color: var(--subtle);
  font-size: 14px;
  margin-right: auto;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 48px;
  height: 48px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, color 0.15s;
}
.icon-btn:hover { background: #222; border-color: #3a3a3a; }
.icon-btn:active { transform: scale(0.95); }
.icon-btn[data-active="true"] {
  background: #2d5a2d;
  border-color: #46a046;
  color: #fff;
}
.icon-btn.primary {
  background: #fff;
  color: #000;
  border-color: #fff;
}
.icon-btn.primary:hover { background: #e8e8e8; }
.icon-btn.primary.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.icon-btn.primary.danger:hover { background: #b62828; }
.icon-btn.danger {
  color: #ff8888;
}
.icon-btn.danger:hover { background: #4d1e1e; border-color: var(--danger); color: #fff; }


.video-area {
  flex: 1;
  background: var(--card-2);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  position: relative;
}
.video-area video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;          /* center fit — letter/pillarbox */
  object-position: center;
  background: #000;
}
.empty-state {
  text-align: center;
  color: var(--hint);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.empty-state p { font-size: 14px; }
.empty-state .sub { font-size: 12px; color: #555; }

/* 비디오 오류 오버레이 — 캔버스 위에 표시 */
.video-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  text-align: center;
  z-index: 10;
}
.video-error p { font-size: 15px; font-weight: 600; max-width: 460px; }
.video-error .sub { font-size: 12px; color: #aaa; font-weight: normal; word-break: break-word; max-width: 480px; }
.video-error .btn-action { width: auto; min-width: 200px; }
#empty-state-default { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--subtle);
}
.empty-loading p { font-size: 14px; }
.empty-loading .sub { font-size: 12px; color: #555; }

/* 가운데 배치 share CTA — 아무도 공유 중이 아닐 때 */
.share-center-cta {
  width: auto;
  padding: 18px 28px;
  font-size: 16px;
  gap: 12px;
}

/* 공유 중 self preview CTA */
.self-preview-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  width: auto;
}
.self-preview-cta:hover { background: #222; border-color: #3a3a3a; }
.self-preview-cta:active { transform: scale(0.98); }

/* 자기 화면 미리보기 중인 비디오 → 클릭해서 닫을 수 있다는 힌트 */
.video-area.is-preview { cursor: pointer; }
.video-area.is-preview::after {
  content: "클릭해서 닫기";
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.video-area.is-preview:hover::after { opacity: 1; }

/* ---- Action bar (room) ---- */
.action-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

/* ---- Fullscreen screen — 전용 모드 ----
   별도 비디오 + exit 버튼만. 다른 chrome 일절 없음.
   profile-chip / room 화면은 CSS routing 으로 숨겨짐. */
.screen[data-screen="fullscreen"] {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}
.screen[data-screen="fullscreen"] video {
  width: 100vw;
  height: 100vh;
  object-fit: contain;          /* center fit — 가로/세로 letterbox */
  object-position: center;
  display: block;
  background: #000;
}
.fs-exit {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  background: rgba(20, 20, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  z-index: 600;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* 기본: 숨김. 비디오 클릭으로 토글. */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out, background 0.15s, transform 0.15s ease-out;
  transform: translateY(-4px);
}
.fs-exit:hover { background: rgba(255, 255, 255, 0.12); }

/* 비디오 클릭 토글 → controls=visible */
body[data-screen="fullscreen"][data-controls="visible"] .fs-exit {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
/* 풀스크린일 때 profile-chip 숨김 */
body[data-screen="fullscreen"] .profile-chip { display: none; }
/* 비디오 자체는 클릭 가능 (pointer 일관성) */
.screen[data-screen="fullscreen"] video { cursor: pointer; }

/* ---- Profile chip ---- */
.profile-chip {
  position: fixed;
  top: 12px;
  right: 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 50;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.profile-chip:hover { background: #222; border-color: #3a3a3a; }
.profile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2a2a2a;
  color: var(--text);
}
.profile-icon .icon { width: 16px; height: 16px; }
.profile-name {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Admin link (landing) ---- */
.admin-link {
  text-align: center;
  margin-top: 6px;
  text-decoration: none;
  font-size: 13px;
  color: var(--hint);
  padding: 8px;
}
.admin-link:hover { color: var(--subtle); }

/* ---- Overlay sheet ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.overlay.open { display: flex; }
.sheet {
  background: var(--card);
  width: 100%;
  max-width: 520px;
  border-radius: 20px 20px 0 0;
  padding: 16px 24px calc(24px + env(safe-area-inset-bottom, 0px));
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.sheet-title {
  color: var(--subtle);
  font-size: 12px;
  margin-bottom: 8px;
}
.sheet .row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sheet .big-name {
  flex: 1;
  font-size: 22px;
  font-weight: 600;
}
.sheet #profile-name {
  flex: 1;
  background: #222;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
}
.btn-link {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 4px 8px;
}
.btn-link:hover { color: #fff; }
.btn-link.subtle { color: var(--hint); }
.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}
.sheet-btn {
  width: 100%;
  background: #222;
  color: var(--text);
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  margin-bottom: 6px;
}
.sheet-btn:hover { background: #2a2a2a; }
.help {
  color: var(--hint);
  font-size: 11px;
  margin-top: 8px;
  line-height: 1.5;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 20, 20, 0.9);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
  max-width: calc(100vw - 32px);
  text-align: center;
  word-break: keep-all;
  line-height: 1.45;
  white-space: pre-wrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- 모바일 반응형 ---- */
@media (max-width: 640px) {
  .screen[data-screen="room"] {
    padding: 12px;
    gap: 10px;
  }
  .room-header {
    padding-right: 100px;
    gap: 8px;
  }
  .code-pill {
    font-size: 16px;
    letter-spacing: 2px;
    padding: 6px 12px;
  }
  .profile-chip {
    top: 8px;
    right: 8px;
    padding: 4px 10px 4px 4px;
  }
  .profile-icon { width: 24px; height: 24px; }
  .profile-name { max-width: 80px; font-size: 12px; }
  .icon-btn { width: 52px; height: 52px; }    /* 터치 친화적 */
  .action-bar { gap: 8px; }
  .video-area { border-radius: 10px; min-height: 220px; }
  .card h1 { font-size: 38px; }
  #code-input { font-size: 24px; letter-spacing: 6px; padding: 16px; }
  .btn-action { padding: 14px; font-size: 14px; }
}

@media (max-width: 380px) {
  .room-header { padding-right: 50px; }
  .profile-name { display: none; }
  .profile-chip { padding: 4px; }
  .code-pill { font-size: 15px; padding: 6px 10px; }
}
