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

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

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

  /* 시안에서 뽑은 색 */
  --purple-900: #14306B;
  --purple-700: #1E54C8;
  --purple-500: #2861D8;
  --purple-300: #B9D3FA;
  --purple-100: #EAF4FF;
  --lavender-bg: #CFE0FF;
  --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: #F6F4F4;              /* 레터박스 여백 색 (배경 이미지와 이어지게) */
  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;
  top: 0;
  left: 0;

  width: 100%;
  height: var(--app-height, 100vh);

  display: flex;
  justify-content: center;
  align-items: center;

  overflow: hidden;
}

.stage {
  position: relative;

  /* 최초 화면 크기 고정 */
  height: var(--app-height, 100vh);

  /* Chromium 79 fallback */
  width: 56.28vh;

  /* JS에서 계산한 9:16 너비 */
  width: var(--app-width, 56.28vh);

  overflow: hidden;

  /* ★ 이 부분이 빠지면 지금처럼 이미지가 확대/잘려 보임 */
  background-size: 100% 100%;
  background-position: center center;
  background-repeat: no-repeat;

  /* cqw 사용하는 최신 브라우저용 */
  container-type: inline-size;
}

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

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

.org-logo {
  position: absolute;
  top: 2.0%; right: 2.1%;
  width: 23%;
  height: auto;
  z-index: 30;
  filter: drop-shadow(0 2px 4px rgba(70,50,140,.15));
}

/* ── 핫스팟 ─────────────────────────────────────────────── */
/* 배경 그림 위 버튼 영역. 기본은 투명이고, 누르면 살짝 눌린 느낌만 준다. */
.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.4%; left: 2.5%;
  width: auto; height: auto;
  border: 0; background: transparent;
  color: #082866;        /* 배경이 밝은 보라라 진한 색으로 */
  font-size: 15vw;
  font-size: 15cqw; 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;
  top: 0; right: 0; bottom: 0; left: 0; /* Chromium 79 fallback */
  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.2vw, 30px);
  font-size: clamp(18px, 4.2cqw, 30px);
  color: #444444;
  letter-spacing: -.02em;
}

.modal p {
  margin: 0 0 1.4em;
  font-size: clamp(14px, 3.4vw, 22px);
  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; }
.no-flex-gap .modal-actions > * + * { margin-left: 10px; }

.btn {
  flex: 1;
  border: 0;
  border-radius: var(--r-md);
  padding: 1em .8em;
  font-size: clamp(14px, 3.4vw, 22px);
  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: #2861D8;
  color: #ffffff;
}

.btn-ghost {
  background: #EAF4FF;
  color: #2861D8;
}

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

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