/* ==========================================================================
   퀴즈 목록 화면 전용 — views/quizzes.hbs + public/js/quizzes.js가 만드는 카드·방 만들기 창
   [2026-11-18 새 디자인] 예전 파일(약 1,190줄)을 통째로 새로 씀. 시안 "02 퀴즈 목록".
     공용 색·버튼·입력칸은 public/css/ui.css(--qb-*, .qb-*), 여기에는 이 화면만의 배치와
     스크립트가 만드는 요소(카드, 방 만들기 창, 문제 수 칸, 스위치, 방 생성 중 화면, 객관식 안내)의 모양만 둠.
   ========================================================================== */

body {
  margin: 0;
  background: var(--qb-bg);
  color: var(--qb-ink);
  font-family: var(--qb-font-body);
}

/* ── 맨 위 배너 + 검색 ── */
.quizzes-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}
.quizzes-hero__title { margin: 0; font-size: 44px; line-height: 1.25; }
.quizzes-hero__sub { margin: 0; font-size: 16px; color: var(--qb-sub); }
.quizzes-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  margin-top: 6px;
  padding: 6px 22px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--qb-surface);
  box-shadow: var(--qb-shadow);
  color: var(--qb-sub);
}
.quizzes-search .search-input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--qb-ink);
  font-family: var(--qb-font-body);
  font-size: 16px;
}

/* ── 제목 + 정렬 ── */
.quizzes-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 36px 0 20px;
}
.quizzes-toolbar__title { margin: 0; font-size: 28px; }

/* ── 카드 목록 ── */
.quizzes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}
.quiz-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 22px 22px;
  border-radius: 30px;
  background: var(--qb-soft);
  color: var(--qb-ink);
}
/* 카드 색 4가지를 순서대로 (예전: 모두 같은 흰 카드). 진한 칸 카드의 버튼만 대표 버튼 색 유지 */
.quiz-card:nth-child(4n + 2) { background: var(--qb-accent-soft); }
.quiz-card:nth-child(4n + 3) { background: var(--qb-deep); color: var(--qb-deep-ink); }
.quiz-card:nth-child(4n + 4) { background: var(--qb-pale); }
.quiz-card-title {
  margin: 0;
  font-family: var(--qb-font-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.35;
  color: inherit;
  word-break: keep-all;
}
.quiz-card-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  opacity: 0.85;
  /* 설명이 길면 3줄까지만 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.quiz-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}
.quiz-card-count { font-size: 14px; font-weight: 700; opacity: 0.85; }

/* [2026-11-18] 방 만들기 창 위쪽: 고른 퀴즈 이름 + 설명 전체 (아주 길면 칸 안에서 스크롤) */
.modal-quiz-info { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; padding: 16px 18px; border-radius: 20px; background: var(--qb-deep); }
.modal-quiz-info strong { font-size: 20px; color: var(--qb-deep-ink); word-break: keep-all; }
.modal-quiz-info p { margin: 0; max-height: 160px; overflow-y: auto; font-size: 14px; line-height: 1.6; color: var(--qb-deep-sub); white-space: pre-line; word-break: keep-all; }
.modal-quiz-info p[hidden] { display: none; }
.quiz-card-desc[title] { cursor: help; }

/* 불러오는 중·결과 없음·오류 */
.loading-message,
.empty-message,
.no-results,
.error-message {
  grid-column: 1 / -1;
  margin: 0;
  padding: 40px 20px;
  text-align: center;
  color: var(--qb-sub);
  font-size: 16px;
}
.error-message { color: var(--qb-bad); }
.message:empty { display: none; }
.message {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--qb-radius-sm);
  background: var(--qb-accent-soft);
  color: var(--qb-accent-ink);
}

/* ── 방 만들기 창 (quizzes.js가 만듦, style.display='block'으로 보임) ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow-y: auto;
  padding: 8vh 16px 40px;
  box-sizing: border-box;
  background: rgba(20, 12, 40, 0.55);
}
.modal-content {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 28px 24px;
  box-sizing: border-box;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 28px; }
.modal-content .qb-label { margin-bottom: -6px; }
.modal-content #nickname-input { width: 100%; }
.modal-buttons { display: flex; gap: 10px; margin-top: 4px; }
.modal-buttons #confirm-nickname { flex: 1; }
.modal-buttons #cancel-nickname { flex: 0 0 110px; }

/* 문제 수: 알약 모양 칸 4개씩 (라디오 동그라미는 숨기고 선택된 칸을 채움) */
.question-count-container { display: flex; flex-direction: column; gap: 8px; }
.question-count-title { margin: 0; }
.question-count-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.question-count-option { position: relative; cursor: pointer; }
.question-count-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.question-count-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 6px;
  border: 2px solid var(--qb-line);
  border-radius: 14px;
  background: var(--qb-surface);
  color: var(--qb-ink);
  font-family: var(--qb-font-display);
  font-size: 15px;
  text-align: center;
  line-height: 1.2;
}
.question-count-option input:checked + span {
  border-color: var(--qb-btn);
  background: var(--qb-btn);
  color: var(--qb-btn-ink);
}
.question-count-option input:focus-visible + span { outline: 3px solid var(--qb-lav); outline-offset: 2px; }
/* "전체 (N문제)" 칸은 한 줄 전체 */
.question-count-option:last-child { grid-column: 1 / -1; }

/* 스트리머 모드 · 비밀방 줄 ([2026-11-27] 공개방 줄 삭제 → 비밀방 줄) */
.streamer-mode-container,
.secret-mode-container {
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--qb-pale);
}
.mode-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.mode-option-title {
  margin: 0;
  font-family: var(--qb-font-display);
  font-size: 17px;
  color: var(--qb-ink);
}
.mode-option-desc { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: var(--qb-sub); }
/* [2026-11-27] 비밀방 비밀번호 칸 (비밀방 스위치를 켜면 보임). 스트리머 모드면 비밀방 스위치가 켜진 채 잠김 → 흐리게
   (예전 .mode-option-desc--note "공개방은 혼자하기 모드가 불가능합니다"는 공개방 줄과 함께 삭제) */
.secret-password-row { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.secret-password-row[hidden] { display: none; }
.toggle-switch input:disabled + .slider { opacity: 0.55; cursor: not-allowed; }
/* [2026-11-27] 스트리머 모드 비밀번호(점으로 가림)의 브라우저 "보기(눈 모양)" 버튼 숨김 — 방송 중 실수로 눌러 비밀번호가 보이지 않게 */
#secret-password::-ms-reveal, #secret-password::-ms-clear { display: none; }

/* 켜기/끄기 스위치 */
.toggle-switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 30px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--qb-soft-strong);
  cursor: pointer;
  transition: background 0.2s ease;
}
.toggle-switch .slider::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--qb-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.toggle-switch input:checked + .slider { background: var(--qb-btn); }
.toggle-switch input:checked + .slider::before { transform: translateX(22px); }
.toggle-switch input:focus-visible + .slider { outline: 3px solid var(--qb-lav); outline-offset: 2px; }

.viewer-mode-row { margin-top: 2px; }

/* 객관식 퀴즈라 시청자 모드를 못 쓸 때 창 위에 덮는 안내 (quizzes.js #viewer-block-overlay) */
#viewer-block-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  border-radius: inherit;
  background: var(--qb-surface);
  text-align: center;
}
#viewer-block-overlay .vbo-icon { color: var(--qb-bad); }
#viewer-block-overlay .vbo-title { font-family: var(--qb-font-display); font-size: 22px; color: var(--qb-ink); }
#viewer-block-overlay .vbo-desc { font-size: 15px; line-height: 1.6; color: var(--qb-sub); }

/* 방 생성 중 화면 (quizzes.js #room-loading-overlay) */
#room-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 12, 40, 0.55);
}
.room-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 40px;
  border-radius: var(--qb-radius-lg);
  background: var(--qb-surface);
  box-shadow: var(--qb-shadow);
}
.room-loading-title { font-family: var(--qb-font-display); font-size: 24px; color: var(--qb-head); }
.room-loading-sub { font-size: 14px; color: var(--qb-sub); }
.room-loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--qb-soft);
  border-top-color: var(--qb-btn);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;  /* @keyframes spin은 style.css */
}

/* ── 좁은 화면 ── */
@media (max-width: 640px) {
  /* [2026-11-20 CSS 정리] 배너 여백·제목 크기는 아래 "휴대폰 화면" 묶음(같은 640px)이 덮어써서 적용된 적 없음 → 둥근 모서리만 남김 */
  .quizzes-hero { border-radius: 32px; }
  .question-count-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* [2026-11-21 삭제] 업데이트 소식 창(#updateModal) 삭제 — 사용자 요청. 대신 닉네임 선점 오픈 공지 창을 views/partials/event-notice.hbs 하나로 만들어 메인·퀴즈 목록·참가 화면이 같이 씀 (.update-modal·.update-list·.update-item 규칙) */

/* ==========================================================================
   [2026-11-19 휴대폰 화면] 퀴즈 목록: 방 만들기 창을 화면 아래에서 올라오는 창(바텀 시트)으로, 배너 여백 줄임
   시안: 디자인 캔버스 "27 모바일 시작 화면" · "28 모바일 게임 화면". 640px 이하(휴대폰)에서만 적용, PC 화면은 그대로
   ========================================================================== */
@media (max-width: 640px) {
  .quizzes-hero { padding: 24px 18px; }
  .quizzes-hero__title { font-size: 26px; }
  /* 방 만들기 창: 위쪽만 둥근 칸이 화면 아래까지 (창 바깥 어두운 칸은 위에 조금만) */
  .modal { padding: 10vh 0 0; }
  .modal-content {
    max-width: none;
    min-height: 90vh;
    padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
  }
  .modal-head h3 { font-size: 24px; }
  /* [2026-11-19] 휴대폰에서는 스트리머 모드 스위치 숨김 (쓸 수 없음 — 방 만들 때도 quizzes.js가 끔) */
  .streamer-mode-container { display: none; }
}
