/* =========================================================
   듀오 잔소리 감지 - style.css
   ========================================================= */

/* ===== 기본 리셋 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* hidden 속성이 항상 동작하도록 강제 */
[hidden] {
  display: none !important;
}

:root {
  --bg: #0e1013;
  --panel: #181b20;
  --text: #f5f6f8;
  --muted: #9aa0ad;
  --duo: #58cc02;        /* 듀오링고 초록 */
  --duo-dark: #46a302;
  --green: #34c759;
  --red: #ff3b30;
  --amber: #ffd479;
  --radius: 18px;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR",
    "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

#app {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ===== 화면 전환 ===== */
.screen {
  display: none;
  width: 100%;
  max-width: 640px;
  animation: fade 0.35s ease;
}
.screen.active {
  display: block;
}
@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 카메라 ===== */
.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.camera-container video,
.camera-container canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 거울 모드 */
}
.camera-container canvas {
  pointer-events: none;
}
.camera-slot {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: #000;
}

/* ===== 버튼 공통 ===== */
.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--duo);
  color: #fff;
  box-shadow: 0 4px 0 var(--duo-dark);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.6; cursor: default; box-shadow: none; }

/* ===== 0단계: 동의 / 안내 ===== */
.consent-wrap {
  text-align: center;
  background: var(--panel);
  border: 1px solid #2a2e38;
  border-radius: var(--radius);
  padding: 36px 28px;
  max-width: 460px;
  margin: 0 auto;
}
.consent-owl {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 12px;
}
.consent-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--duo);
}
.consent-body p {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 12px;
}
.consent-body b { color: var(--duo); }
.consent-privacy {
  margin-top: 16px !important;
  font-size: 13.5px !important;
  color: var(--muted) !important;
}
.consent-privacy b { color: var(--muted); }
.consent-ios {
  margin-top: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--amber);
  background: rgba(255, 212, 121, 0.1);
  border: 1px solid rgba(255, 212, 121, 0.3);
  border-radius: 12px;
  padding: 12px 14px;
}
.consent-ios b { color: var(--amber); }
.consent-btn {
  margin-top: 24px;
  width: 100%;
  font-size: 17px;
  padding: 16px 20px;
}
.consent-error {
  margin-top: 16px;
  color: var(--red);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== 1단계: 캘리브레이션 ===== */
.calib-wrap { text-align: center; }
.calib-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 18px;
  line-height: 1.4;
}
.calib-count-wrap { margin-top: 20px; }
.calib-count {
  font-size: 64px;
  font-weight: 800;
  color: var(--duo);
  font-variant-numeric: tabular-nums;
}
.calib-sub {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

/* ===== 2단계: 메인 감지 ===== */
.detect-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.detect-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--duo);
  background: rgba(88, 204, 2, 0.14);
  padding: 6px 12px;
  border-radius: 999px;
}
.detect-count {
  font-size: 15px;
  color: var(--muted);
}
.detect-count b {
  color: var(--text);
  font-size: 18px;
}
.detect-stage { position: relative; }

.detect-status {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 800;
  transition: background 0.2s ease, color 0.2s ease;
}
.detect-status.ok   { background: rgba(52, 199, 89, 0.14); color: var(--green); }
.detect-status.warn { background: rgba(255, 212, 121, 0.14); color: var(--amber); }
.detect-status.bad  { background: rgba(255, 59, 48, 0.16); color: var(--red); }
.detect-angle {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.detect-hint {
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ===== 듀오 잔소리 오버레이 ===== */
.duo-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.55);
  animation: duoFade 0.2s ease;
}
.duo-overlay.final {
  background: rgba(70, 0, 0, 0.62); /* 3회 이상: 더 강렬한 배경 */
}
@keyframes duoFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.duo-box {
  width: 30vmin;              /* JS가 시작 크기를 다시 지정 */
  transform-origin: center center;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
}
.duo-img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 14px 40px rgba(0, 0, 0, 0.55));
}
/* 이미지가 없을 때 대체 표시 */
.duo-fallback {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(88, 204, 2, 0.12);
  border: 2px dashed var(--duo);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.duo-fallback-emoji { font-size: 22vmin; line-height: 1; }
.duo-fallback-text {
  font-size: 2.2vmin;
  color: var(--text);
  word-break: keep-all;
}
/* 3회 이상: 사진과 함께 뜨는 자막 */
.duo-subtitle {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(92vw, 680px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  padding: 16px 24px;
  border-radius: 16px;
  font-size: clamp(16px, 3.6vw, 23px);
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  word-break: keep-all;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  border: 1.5px solid rgba(255, 59, 48, 0.6);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  animation: subtitlePop 0.35s ease, subtitlePulse 1.4s ease-in-out infinite 0.35s;
}
@keyframes subtitlePop {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.94); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes subtitlePulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%      { transform: translateX(-50%) scale(1.035); }
}

.duo-audio-btn {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #fff;
  color: #15171c;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.duo-audio-btn:active { transform: translateX(-50%) scale(0.96); }

/* ===== 반응형 ===== */
@media (max-width: 600px) {
  .calib-title { font-size: 19px; }
  .consent-title { font-size: 21px; }
  .detect-status { font-size: 16px; }
}
