/* ui-gallery.css — 작품 고르기(카드 격자·보기 창·채점·요약·아래 고정 줄). split from ui.css (RULE-code-19) */

/* ─── 작품 고르기 (카드 격자 · 보기 창 · 고른 작품 요약) ───────── */
.sv-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; flex-direction: row; }

.sv-gallery__card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--sv-surface);
  box-shadow: var(--sv-shadow);
  transition: border-color 0.15s, background 0.15s, opacity 0.15s, transform 0.15s;
}

.sv-gallery__card:hover { transform: translateY(-2px); box-shadow: var(--sv-shadow-lift); }
.sv-gallery__card.is-on { border-color: var(--sv-brand); background: var(--sv-brand-soft); }
.sv-gallery__card.is-off { opacity: 0.55; }
.sv-gallery__card.is-full { opacity: 0.5; }
.sv-gallery--rate .sv-gallery__card { cursor: pointer; }
.sv-gallery__card.is-viewing { outline: 3px solid #ffb020; outline-offset: 2px; }

/* 표지 — 색은 modifier 가 변수로 정한다(문항의 표지 색, 자동이면 PDF 파랑 · 영상 남색) */
.sv-gallery__thumb {
  --cover-from: #e8ecff;
  --cover-to: #d6ddff;
  --cover-ink: #2f3f86;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 112px;
  padding: 12px 14px;
  overflow: hidden;
  border: 0;
  background: linear-gradient(160deg, var(--cover-from), var(--cover-to));
  color: var(--cover-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sv-gallery__thumb--blue { --cover-from: #e8ecff; --cover-to: #d6ddff; --cover-ink: #2f3f86; }
.sv-gallery__thumb--green { --cover-from: #e0f2ea; --cover-to: #c8e8da; --cover-ink: #1d5b44; }
.sv-gallery__thumb--navy { --cover-from: #2a3048; --cover-to: #151a2b; --cover-ink: #fff; }
.sv-gallery__thumb--orange { --cover-from: #fff1e0; --cover-to: #ffe0bf; --cover-ink: #7a3d00; }
.sv-gallery__thumb--gray { --cover-from: #eef0f3; --cover-to: #dfe3e8; --cover-ink: #3a4250; }

.sv-gallery__thumb > * { position: relative; }
.sv-gallery__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.sv-gallery__thumb.has-image { color: #fff; }
.sv-gallery__thumb.has-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.1) 45%, rgba(0, 0, 0, 0.6));
}

/* 그림 놓기 "오른쪽에 두기" — 색 표지와 글자는 그대로, 그림은 오른쪽에 높이를 맞춰 얹는다 */
.sv-gallery__thumb--side .sv-gallery__img {
  inset: auto;
  top: 6px;
  right: 8px;
  bottom: 6px;
  width: auto;
  max-width: 55%;
  height: calc(100% - 12px);
  object-fit: contain;
  pointer-events: none;
}
.sv-gallery__thumb--side > small,
.sv-gallery__thumb--side > strong,
.sv-gallery__thumb--side > .sv-gallery__open { max-width: 55%; }

.sv-gallery__thumb.has-image > small,
.sv-gallery__thumb.has-image > strong,
.sv-gallery__thumb.has-image > .sv-gallery__open { z-index: 1; }

.sv-gallery__kind { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; opacity: 0.8; }
.sv-gallery__num { font-size: 28px; line-height: 1; }
.sv-gallery__open { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; }

.sv-gallery__body { display: flex; flex: 1; flex-direction: column; gap: 8px; padding: 10px 14px 12px; }
.sv-gallery__title { flex: 1; font-size: 15px; font-weight: 600; line-height: var(--lh-base, 1.5); word-break: keep-all; }

.sv-gallery__pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--sv-line);
  font-size: 14px;
  cursor: pointer;
}

.sv-gallery__pick input { width: 18px; height: 18px; accent-color: var(--sv-brand); }
.sv-gallery__card.is-on .sv-gallery__pick { color: var(--sv-brand-dark); font-weight: 700; }

.sv-gallery__hint { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sv-gallery__count { display: inline-flex; align-items: center; gap: 8px; color: var(--sv-brand); font-weight: 700; }
.sv-gallery__dots { display: inline-flex; gap: 4px; }
.sv-gallery__dots b { width: 10px; height: 10px; border-radius: 50%; background: var(--sv-line); }
.sv-gallery__dots b.is-on { background: var(--sv-brand); }
.sv-gallery__warn { margin: 0 0 8px; color: var(--sv-danger); font-size: 14px; }

.sv-gallery__thumb:focus-visible,
.sv-gallery__pick:focus-within,
.sv-viewer button:focus-visible,
.sv-viewer a:focus-visible,
.sv-gallery-summary button:focus-visible {
  outline: 3px solid var(--sv-brand);
  outline-offset: 2px;
}

/* 보기 창 — 넓은 화면은 오른쪽 반쪽(목록은 그대로 쓸 수 있다), 좁은 화면은 전체 화면 */
.sv-viewer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: 50vw;
  min-width: 420px;
  background: var(--sv-surface);
  border-left: 1px solid var(--sv-line);
  box-shadow: var(--sv-shadow-lift);
}

.sv-viewer:focus { outline: none; }

.sv-viewer__head,
.sv-viewer__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--sv-surface);
}

.sv-viewer__head { border-bottom: 1px solid var(--sv-line); }
.sv-viewer__foot { flex-wrap: wrap; border-top: 1px solid var(--sv-line); }
.sv-viewer__title { flex: 1; min-width: 0; margin: 0; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.sv-viewer__pos { flex: 1; text-align: center; color: var(--sv-ink-soft); font-size: 14px; }
.sv-viewer__toggle { flex: 1 0 100%; }
.sv-viewer__toggle.is-on { background: var(--sv-ok); border-color: var(--sv-ok); }
.sv-viewer__msg { margin: 0; padding: 8px 16px; color: var(--sv-danger); font-size: 14px; }

/* 작품 채점 — 보기 창 아래 점수 칸 · 카드 상태 줄 · 결과 표 */
.sv-viewer__score { max-height: 30vh; padding: 6px 16px; overflow-y: auto; border-top: 1px solid var(--sv-line); background: var(--sv-bg); }
.sv-viewer__crit { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; padding: 3px 0; }
.sv-viewer__crit-name { display: flex; flex: 1 1 140px; flex-direction: column; min-width: 0; }
.sv-viewer__crit-name small { color: var(--sv-ink-soft); font-size: 13px; }
.sv-viewer__crit-input { display: inline-flex; align-items: center; gap: 6px; }
.sv-viewer__crit-num { width: 72px; height: 32px; padding-top: 0; padding-bottom: 0; box-sizing: border-box; background: var(--sv-surface); text-align: center; }
.sv-viewer__crit-max { color: var(--sv-ink-soft); font-size: 14px; white-space: nowrap; }
.sv-viewer__crit-msg { flex: 1 0 100%; color: var(--sv-danger); font-size: 13px; }
.sv-viewer__total { margin: 2px 0 0; padding-top: 4px; border-top: 1px solid var(--sv-line); text-align: right; font-size: 15px; }
.sv-viewer__total b { color: var(--sv-brand); font-size: 18px; }
.sv-gallery__rate { margin: 0; color: var(--sv-ink-soft); font-size: 14px; }
.sv-gallery__card.is-on .sv-gallery__rate { color: var(--sv-brand-dark); font-weight: 700; }
.sv-rate-sum td, .sv-rate-sum th { vertical-align: middle; }

.sv-viewer__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  background: var(--sv-bg);
}

.sv-viewer__body:fullscreen { background: #000; }
.sv-viewer__note { margin: auto; padding: 24px; text-align: center; color: var(--sv-ink-soft); }
.sv-viewer__pages { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 8px; }
.sv-viewer__page { flex: none; margin: 0 auto; background: var(--sv-surface); box-shadow: var(--sv-shadow); }
.sv-viewer__page canvas { display: block; }

.sv-viewer__video {
  flex: 1;
  min-height: 0;
  aspect-ratio: 9 / 16;
  max-width: 100%;
  margin: 0 auto;
  background: #000;
}

.sv-viewer__video iframe { width: 100%; height: 100%; border: 0; }

/* 고른 작품 요약 */
.sv-gallery-summary {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--sv-line);
  border-radius: var(--sv-radius);
  background: var(--sv-surface);
}

.sv-gallery-summary__title { margin: 0 0 8px; font-size: 17px; }
.sv-gallery-summary__row { padding: 8px 0; border-top: 1px solid var(--sv-line); }
.sv-gallery-summary__head { display: flex; align-items: center; gap: 8px; }
.sv-gallery-summary__head strong { flex: 1; min-width: 0; }
.sv-gallery-summary__count { color: var(--sv-brand); font-weight: 700; }
.sv-gallery-summary__list { margin: 8px 0 0; padding-left: 20px; font-size: 15px; }
.sv-gallery-summary__none { margin: 8px 0 0; color: var(--sv-ink-soft); font-size: 14px; }

/* 결과 화면 — 작품 보기 단추 줄 · 제작 화면 — 유튜브 주소 칸 */
.sv-gallery-list { margin: 12px 0 0; padding: 0; list-style: none; }
.sv-gallery-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.sv-ed-youtube { display: inline-flex; flex-direction: column; min-width: 160px; }
.sv-ed-youtube .form__hint--error { color: var(--sv-danger); }

body.sv-viewer-open .sv-shell { padding-right: 0; }

@media (min-width: 861px) {
  body.sv-viewer-open .sv-shell { margin-left: 16px; margin-right: calc(50vw + 16px); width: auto; }
  /* 설문 본문과 아래 고정 줄도 왼쪽 절반으로 민다 — 보기 창(오른쪽 절반)이 가리지 않게 */
  body.sv-viewer-open .sv-play { width: auto; max-width: 760px; margin-left: 16px; margin-right: calc(50vw + 16px); }
  body.sv-viewer-open .sv-dock { right: 50vw; }
  /* Rate panel sits in the left half above the dock so the PDF keeps the full right height.
     Fixed to the viewport (the viewer has no transform). Dock = 1px line + 4px progress + 64px step nav. */
  body.sv-viewer-open .sv-viewer__score {
    position: fixed;
    left: 0;
    right: 50vw;
    bottom: 0;
    z-index: 31;
    max-height: var(--sv-score-max);
    box-shadow: var(--sv-shadow-lift);
  }
  body.sv-viewer-open:has(#playDock) .sv-viewer__score { bottom: calc(69px + env(safe-area-inset-bottom)); }
  /* Keep the last cards reachable above the panel (and the dock, when there is one) */
  body.sv-viewer-open:has(#svViewScore:not([hidden])) .sv-play { padding-bottom: calc(var(--sv-score-max) + 16px); }
  body.sv-viewer-open:has(#svViewScore:not([hidden])):has(#playDock) .sv-play {
    padding-bottom: calc(var(--sv-score-max) + 96px + env(safe-area-inset-bottom));
  }
}

body { --sv-score-max: 40vh; }

@media (max-width: 860px) {
  body.sv-viewer-open { overflow: hidden; }
  .sv-viewer { width: 100vw; min-width: 0; border-left: 0; }
  .sv-gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sv-gallery__thumb { height: 92px; }
  .sv-viewer { z-index: 70; }
}

/* 아래 고정 줄 — 쪽을 나눈 작품 고르기 설문. 진행 막대 · 쪽 넘기기 · 제출을 한 줄에 모은다 */
.sv-play--dock { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.sv-play--dock .sv-submit { display: none; }

.sv-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--sv-line);
}

.sv-dock .sv-progress { position: static; margin: 0; border-radius: 0; }
.sv-dock .sv-stepnav { width: min(100%, 960px); min-height: 64px; margin: 0 auto; padding: 0 16px; }
.sv-dock .sv-stepnav__pos { flex: 1; text-align: center; font-weight: 700; }
