/* DRS 관람 화면. 색은 slam 관람 화면(PASS)의 팔레트를 따른다.
   모든 화면이 같은 틀을 쓴다. 위는 머리띠, 가운데는 3D 무대와 설명, 아래는 항만이 대사와 이동 버튼이다.
   구현된 기능은 초록, 준비 중인 비전은 노랑으로 표시한다. 표시는 작은 네모와 글자 하나로만 한다.
   1920 폭에서 1rem = 16px이 되도록 글자 크기를 화면 폭에 맞춘다. 글자에는 대비 4.5:1 이상인 색만 쓴다. */
:root {
  --bg: #f9fafb; --surface: #ffffff; --line: #e5e7eb; --line-strong: #d1d5db;
  --text: #111827; --text-2: #374151; --text-3: #4b5563;
  --brand: #2563eb; --brand-bold: #1e40af; --brand-deep: #1e3a8a; --brand-soft: #eff6ff; --brand-edge: #bfdbfe;
  --done: #15803d; --done-text: #166534;
  --plan: #a16207; --plan-text: #854d0e; --plan-soft: #fef9c3;
  --fail: #b91c1c;
  font-size: clamp(14px, 0.8333vw, 24px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, ol, ul, dl, dd, blockquote { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 0.2rem solid var(--brand); outline-offset: 0.15rem; }
[tabindex="-1"]:focus { outline: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }

/* ── 상태 표시: 작은 네모와 글자 ── */
.tag { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; vertical-align: 0.1em; }
.tag::before { content: ""; width: 0.6rem; height: 0.6rem; background: currentColor; }
.tag.done { color: var(--done-text); }
.tag.plan { color: var(--plan-text); }

/* ── 머리띠 ── */
.bar { display: flex; align-items: center; gap: 2rem; padding: 0.7rem 2.5rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; white-space: nowrap; }
.brand-mark { height: 2.6rem; width: auto; }
.brand-name { font-size: 1.6rem; font-weight: 900; letter-spacing: 0.05em; color: var(--brand-deep); }
.brand-ko { font-size: 1rem; font-weight: 600; color: var(--text-3); }
.progress { display: flex; align-items: center; gap: 1.6rem; margin: 0 auto; }
.progress-group { display: flex; align-items: center; gap: 0.35rem; }
.progress a { text-decoration: none; }
.group-label { display: inline-flex; align-items: center; gap: 0.4rem; margin-right: 0.3rem; font-size: 0.95rem; font-weight: 700; color: var(--text-3); }
.group-label::before { content: ""; width: 0.55rem; height: 0.55rem; }
[data-status="done"] .group-label::before { background: var(--done); }
[data-status="plan"] .group-label::before { background: var(--plan); }
.progress-group a[data-step-link] { display: inline-flex; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem;
  font-size: 0.95rem; font-weight: 700; color: var(--text-3); border: 1px solid var(--line-strong); border-radius: 0.35rem; background: var(--surface); }
.progress a.done { color: var(--brand-bold); border-color: var(--brand-edge); background: var(--brand-soft); }
.progress a[aria-current="step"] { color: #fff; border-color: var(--brand); background: var(--brand); }
.progress-end { font-size: 0.95rem; font-weight: 700; color: var(--text-3); padding: 0.35rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 0.35rem; }
.progress-end[aria-current="step"] { color: #fff; background: var(--brand); border-color: var(--brand); }
.bar-right { display: flex; align-items: center; gap: 1.2rem; margin-left: auto; }
.progress:not([hidden]) + .bar-right { margin-left: 0; }
/* 첫 화면이 아닌 주소로 바로 열 때: 스크립트가 화면을 바꾸기 전에도 단계 줄과 버튼이 제자리를 잡는다.
   그래야 먼저 그려진 내용이 뒤늦게 밀리지 않는다. boot.js가 html에 표시를 달고, visitor.js가 화면을 그린 뒤에 뗀다. */
html.boot-inner .progress { display: flex !important; }
html.boot-inner .bar-right { margin-left: 0; }
html.boot-inner #play-toggle, html.boot-inner #nav-prev, html.boot-scene #section-replay { display: inline-flex !important; }
html.boot-inner .caption-attract { visibility: hidden; }
.voice-btn { display: inline-flex; align-items: center; gap: 0.45rem; height: 2.6rem; padding: 0 0.9rem; font: inherit; font-size: 0.95rem; font-weight: 600;
  color: var(--brand-deep); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 0.5rem; cursor: pointer; }
.voice-btn svg { width: 1.35rem; height: 1.35rem; }
.voice-btn .voice-off, .voice-btn.is-off .voice-on { display: none; }
.voice-btn.is-off .voice-off { display: inline; }
.voice-btn.is-off { color: var(--text-3); }
.bar-logo { height: 1.6rem; width: auto; padding-left: 1.2rem; border-left: 1px solid var(--line); box-sizing: content-box; }

/* ── 가운데: 3D 무대와 설명 ── */
.scene { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(24rem, 1fr); min-height: 0; }
.stage { position: relative; min-height: 0; overflow: hidden; background: #eef3f9; border-right: 1px solid var(--line); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-labels { position: absolute; inset: 0; pointer-events: none; }
.stage-fallback { display: none; position: absolute; inset: auto 1.5rem 1.5rem; font-size: 1rem; color: var(--text-2); }
.no-webgl .stage-fallback { display: block; }
.stage-label { position: absolute; left: 0; top: 0; padding: 0.15rem 0.5rem; font-size: 0.8rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
  color: var(--text); background: rgba(255, 255, 255, 0.94); border: 1px solid #cbd5e1; border-radius: 0.25rem; will-change: transform; }
.stage-label.sub { font-size: 0.72rem; font-weight: 600; color: var(--text-2); }
.stage-label.strong { color: #fff; background: var(--brand-deep); border-color: var(--brand-deep); }
.stage-label.count { color: var(--done-text); font-weight: 800; border-color: #86efac; }
.stage-label.fail { color: var(--fail); border-color: #fca5a5; }
.stage-label.plan { color: var(--plan-text); background: rgba(254, 249, 195, 0.95); border-color: #ca8a04; }
.stage-label.plan.strong { color: var(--plan-text); background: var(--plan-soft); }

.captions { min-height: 0; overflow-y: auto; background: var(--surface); }
.caption { display: flex; flex-direction: column; gap: 1.2rem; padding: 2.4rem 2.4rem 1.6rem; }
.kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; font-size: 0.95rem; font-weight: 700; color: var(--text-3); }
.caption h1 { font-size: 2.2rem; line-height: 1.25; font-weight: 800; letter-spacing: -0.015em; }
.lead { font-size: 1.15rem; color: var(--text-2); }
.points { list-style: none; padding: 0; counter-reset: point; border-top: 1px solid var(--line); }
.points li { counter-increment: point; border-bottom: 1px solid var(--line); }
[data-line] { font: inherit; color: inherit; line-height: inherit; text-align: left; cursor: pointer; border: 0; background: transparent; }
[data-line]:hover, [data-line].listening { background: #e8f3fb; }
.points button { width: 100%; display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; padding: 0.75rem 0; font-size: 1.08rem; color: var(--text-2); }
.points button::before { content: counter(point, decimal-leading-zero); font-size: 0.85rem; font-weight: 800; color: var(--brand); padding-top: 0.15rem; }
/* 줄 끝의 작은 세모: 누르면 그 대사부터 다시 본다는 표시다. 지금 읽는 줄은 색을 칠한다. */
.points button::after { content: ""; align-self: center; margin: 0 0.5rem 0 0.8rem; border-left: 0.5rem solid var(--line-strong);
  border-top: 0.32rem solid transparent; border-bottom: 0.32rem solid transparent; }
.points button.listening::after { border-left-color: var(--brand); }
.note { font-size: 0.92rem; color: var(--text-3); }
.quote { font-size: 1.35rem; font-weight: 700; line-height: 1.4; padding-left: 1rem; border-left: 0.25rem solid var(--plan); }

.caption-attract h1 { font-size: 3.4rem; line-height: 1.12; letter-spacing: -0.025em; }
.legend { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.legend div { display: grid; grid-template-columns: 6rem minmax(0, 1fr); align-items: baseline; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.legend dd { font-size: 1rem; color: var(--text-2); }
.attract-hangmani { width: 13rem; height: auto; align-self: flex-end; margin-top: auto; }

.summary { display: flex; flex-direction: column; gap: 1.2rem; }
.summary h2 { display: flex; align-items: center; gap: 0.8rem; font-size: 1.15rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
.summary ul { padding-left: 1.1rem; margin-top: 0.5rem; font-size: 1rem; color: var(--text-2); }
.summary li + li { margin-top: 0.2rem; }

/* ── 아래 막대: 항만이 대사와 이동 버튼 ── */
.dock { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 2.5rem; background: var(--surface); border-top: 1px solid var(--line); }
.dock-face { width: 3.6rem; height: 3.6rem; flex: none; object-fit: cover; border-radius: 50%; background: #dbeafe; }
.dock-speaker { flex: none; font-size: 0.9rem; font-weight: 800; color: #9a3412; padding: 0.2rem 0.6rem; border: 1px solid #fdba74; border-radius: 0.35rem; background: #fff7ed; }
.dock-line { flex: 1 1 auto; min-width: 0; font-size: 1.2rem; font-weight: 600; color: var(--text); }
.dock-actions { display: flex; gap: 0.6rem; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 3.2rem; padding: 0 1.4rem; font: inherit; font-size: 1.05rem; font-weight: 700;
  text-decoration: none; white-space: nowrap; border-radius: 0.5rem; cursor: pointer; }
.btn.primary { color: #fff; background: var(--brand); border: 1px solid var(--brand); }
.btn.primary:hover { background: var(--brand-bold); }
.btn.ghost { color: var(--brand-deep); background: var(--surface); border: 1px solid var(--line-strong); }
.btn.ghost:hover { background: var(--brand-soft); }

/* ── 큰 화면에서는 한 화면에 다 들어오게 한다 ── */
@media (min-width: 900px) {
  .app { height: 100vh; }
}

/* ── 노트북 폭 ── */
@media (max-width: 1280px) {
  .bar { gap: 1.2rem; padding: 0.6rem 1.4rem; }
  .brand-ko { display: none; }
  .voice-btn .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .voice-btn { width: 2.6rem; padding: 0; justify-content: center; }
  .dock { padding: 0.7rem 1.4rem; }
  .scene { grid-template-columns: minmax(0, 1.5fr) minmax(20rem, 1fr); }
  .caption { padding: 1.8rem 1.6rem 1.2rem; }
}

/* ── 좁은 화면: 무대 위, 설명 아래, 대사와 버튼은 화면 아래에 붙는다 ── */
@media (max-width: 899px) {
  .bar { flex-wrap: wrap; gap: 0.6rem 0.8rem; padding: 0.6rem 1rem; }
  .brand-mark { height: 2.2rem; }
  .brand-name { font-size: 1.35rem; }
  .bar-logo { height: 1.3rem; padding-left: 0.8rem; }
  .progress { order: 3; width: 100%; margin: 0; justify-content: space-between; gap: 0.4rem; }
  .progress-group { gap: 0.2rem; }
  .group-label { font-size: 0.82rem; margin-right: 0.1rem; }
  .progress-group a[data-step-link] { width: 1.9rem; height: 1.9rem; font-size: 0.82rem; }
  .progress-end { font-size: 0.82rem; padding: 0.3rem 0.5rem; }
  .scene { display: block; }
  /* 무대는 화면 위에 붙여 둔다. 설명을 내려 읽어도 무대가 함께 보인다. */
  .stage { position: sticky; top: 0; z-index: 4; height: 44vh; min-height: 17rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .field-readout { left: 0.4rem; bottom: 0.4rem; padding: 0.25rem 0.55rem; font-size: 0.72rem; }
  .field-readout small, .field-readout span { display: none; }
  .field-readout strong::before { content: "예시 "; font-weight: 400; color: #c6d6e5; }
  .camera-tools [data-camera="left"], .camera-tools [data-camera="right"] { display: none; }
  .camera-tools button { min-width: 2.75rem; min-height: 2.75rem; }
  .stage-label { font-size: 0.68rem; padding: 0.1rem 0.35rem; }
  /* 좁은 무대에서는 작은 이름표를 빼서 겹치지 않게 한다 */
  .stage-label.sub { display: none; }
  .caption { padding: 1.2rem 1rem 1rem; gap: 0.9rem; }
  .caption h1 { font-size: 1.55rem; }
  .caption-attract h1 { font-size: 2.3rem; }
  .points button { font-size: 0.98rem; padding: 0.55rem 0; }
  .quote { font-size: 1.1rem; }
  .attract-hangmani { width: 8rem; }
  .dock { position: sticky; bottom: 0; z-index: 5; flex-wrap: wrap; gap: 0.6rem 0.7rem; padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06); }
  .dock-face { width: 2.6rem; height: 2.6rem; }
  .dock-speaker { font-size: 0.75rem; padding: 0.1rem 0.4rem; }
  .dock-line { flex: 1 1 calc(100% - 3.4rem); font-size: 0.98rem; }
  .dock-actions { width: 100%; }
  .dock-actions .btn { flex: 1 1 0; height: 2.9rem; padding: 0 0.6rem; font-size: 0.98rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

.field-readout { position: absolute; left: .75rem; bottom: .75rem; z-index: 2; display: grid; gap: .16rem;
  max-width: calc(100% - 1.5rem); padding: .55rem .85rem; border-left: 3px solid #63d89a; border-radius: .2rem;
  background: #16283a; color: white; pointer-events: none; font-size: .84rem; }
.field-readout[hidden] { display: none; }
.field-readout small { color: #c6d6e5; }
body[data-view^="vision"] .field-readout { border-color: #facc15; }

.stage, .bar, .dock { -webkit-user-select: none; user-select: none; }
.stage canvas { cursor: grab; touch-action: pan-y; }
.stage canvas:active { cursor: grabbing; }
.camera-tools { position: absolute; z-index: 3; top: .55rem; right: .55rem;
  display: flex; gap: 2px; padding: 3px; border-radius: .5rem; background: #23374a; }
.camera-tools[hidden] { display: none; }
.camera-tools button { min-width: 2rem; min-height: 2rem; padding: 0 .4rem; color: white;
  background: transparent; border: 0; border-radius: .3rem; font: inherit; cursor: pointer; }
.camera-tools button:hover, .camera-tools button:focus-visible { background: #42617a; }

.stage-label.mail-notice { background: #17334c; border: 1px solid #a7d6f1; color: white; padding: .45em .7em; font-weight: 700; z-index: 2; }
.stage-label.cert { border-color: #13754a; color: #105637; background: #e9fff4; }

@media (max-width: 600px) {
  .dock-actions { gap: .25rem; }
  .dock-actions .btn { flex-basis: auto; padding-inline: .35rem; }
}
