/* ============================================================
   public/css/stage.css
   배경 이미지(941×1672 = 9:16) 위에 버튼을 정확히 얹기 위한 좌표계.

   원리
     화면비가 제각각인 태블릿에서도 버튼이 그림 위 같은 자리에 붙어야 한다.
     → 9:16 비율의 .stage를 화면 안에 레터박스로 앉히고,
       배경과 모든 요소를 .stage 기준 %로 배치한다.
       뷰포트 단위(vw/vh)를 직접 쓰면 기기마다 어긋난다.
   ============================================================ */

:root {
  --stage-w: 941;
  --stage-h: 1672;

  /* 시안에서 뽑은 색 */
  --purple-900: #3b2f6b;
  --purple-700: #6b5bd2;
  --purple-500: #8b7ae8;
  --purple-300: #c9c0f5;
  --purple-100: #ede9fd;
  --lavender-bg: #b9a9ef;
  --ink: #2e2a45;
  --ink-soft: #6b6785;
  --white-card: rgba(255, 255, 255, 0.92);

  --r-sm: 14px;
  --r-md: 22px;
  --r-lg: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;                 /* 키오스크: 페이지 자체는 스크롤 금지 */
  background: #a99adf;              /* 레터박스 여백 색 (배경 이미지와 이어지게) */
  font-family: 'Pretendard', -apple-system, 'Apple SD Gothic Neo',
               'Noto Sans KR', sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;       /* 더블탭 확대 방지 */
  user-select: none;
}

/* ── 스테이지 ───────────────────────────────────────────── */
.stage-wrap {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.stage {
  position: relative;
  aspect-ratio: var(--stage-w) / var(--stage-h);

  /* 화면 안에 최대한 크게, 비율은 유지 */
  height: 100dvh;
  width: auto;
  max-width: 100vw;
  max-height: 100dvh;

  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;       /* 스테이지와 이미지 비율이 같으므로 왜곡 없음 */
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.12);
}

/* 화면비가 이미지보다 세로로 길면 폭 기준으로 맞춘다 */
@media (max-aspect-ratio: 941/1672) {
  .stage { width: 100vw; height: auto; }
}

/* 여백 없이 꽉 채우고 싶을 때 body에 .fill 추가 (위아래가 잘림) */
body.fill .stage {
  width: 100vw;
  height: 100dvh;
  aspect-ratio: auto;
  background-size: cover;
}

/* ── 핫스팟 ─────────────────────────────────────────────── */
/* 배경 그림 위 버튼 영역. 기본은 투명이고, 누르면 살짝 눌린 느낌만 준다. */
.hotspot {
  position: absolute;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: transform .12s ease, background-color .12s ease;
}

.hotspot:active {
  transform: scale(.97);
  background: rgba(255, 255, 255, .18);
}

/* 키보드 접근성 — 외부 키보드를 쓰므로 포커스 링이 반드시 보여야 한다 */
.hotspot:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ── 뒤로가기 버튼 ── */
.back-btn {
  position: absolute;
  top: 0.7%; left: 2.5%;
  width: auto; height: auto;
  border: 0; background: transparent;
  color: rgba(70, 55, 120, .8);        /* 배경이 밝은 보라라 진한 색으로 */
  font-size: 13cqw; font-weight: 400; line-height: 1;
  font-family: inherit;
  padding: 2% 3%;
  cursor: pointer;
  z-index: 50;
  transition: transform .12s ease, opacity .15s ease;
}
.back-btn:active { transform: scale(.88); opacity: .6; }

/* 스크린리더용 라벨 (그림에만 글자가 있으므로 필요) */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── 보정 모드 ──────────────────────────────────────────── */
/* URL에 ?calibrate=1 을 붙이면 핫스팟이 눈에 보이고, Alt+드래그로 새 좌표를 딸 수 있다 */
body.calibrating .hotspot {
  background: rgba(255, 80, 120, .28);
  outline: 2px dashed rgba(255, 255, 255, .9);
}

#calib-box {
  position: absolute;
  border: 2px solid #ff2d78;
  background: rgba(255, 45, 120, .2);
  pointer-events: none;
  display: none;
  z-index: 9999;
}

#calib-readout {
  position: fixed;
  left: 12px; bottom: 12px;
  z-index: 10000;
  background: rgba(0, 0, 0, .82);
  color: #7CFFB2;
  font: 12px/1.5 ui-monospace, Menlo, monospace;
  padding: 10px 14px;
  border-radius: 10px;
  white-space: pre;
  display: none;
}

/* ── 공용 모달 ──────────────────────────────────────────── */
.modal-veil {
  position: absolute;
  inset: 0;
  background: rgba(46, 40, 78, .55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 6%;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.modal-veil.open { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%;
  background: #fff;
  border-radius: var(--r-lg);
  padding: 8% 7%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(46, 40, 78, .3);
  transform: translateY(12px) scale(.97);
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.2);
}

.modal-veil.open .modal { transform: none; }

.modal h2 {
  margin: 0 0 .6em;
  font-size: clamp(18px, 4.2cqw, 30px);
  color: var(--purple-900);
  letter-spacing: -.02em;
}

.modal p {
  margin: 0 0 1.4em;
  font-size: clamp(14px, 3.4cqw, 22px);
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-line;
}

.modal-actions { display: flex; gap: 10px; }

.btn {
  flex: 1;
  border: 0;
  border-radius: var(--r-md);
  padding: 1em .8em;
  font-size: clamp(14px, 3.4cqw, 22px);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--purple-700); color: #fff; }
.btn-ghost   { background: var(--purple-100); color: var(--purple-700); }

/* 스테이지 안에서 clamp()가 화면 크기가 아니라 스테이지 폭을 따르게 한다 */
.stage { container-type: inline-size; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}