/*
 * drawoneminute — 손그림 두들 디자인 시스템
 * 브리프: docs/superpowers/specs/2026-07-08-drawoneminute-visual-design.md
 * 라이트(종이) 전용 · 모바일 세로 우선 · 카카오 인앱.
 */

/* ── 토큰 ───────────────────────────────────────── */
:root {
  /* 컬러 (브리프 §3) */
  --coral: #ff6b5e;        /* 포인트 */
  --coral-press: #f0574a;  /* 눌림 */
  --sub: #ffd9a0;          /* 서브 살구 */
  --sub-soft: #ffe9c9;     /* 힌트 칸 등 옅은 살구 */
  --paper: #fbf7ef;        /* 배경 종이 */
  --cream: #fefcf7;        /* 캔버스·카드 바탕 */
  --ink: #2b2622;          /* 텍스트·손그림 선 */
  --muted: #8a8178;        /* 보조 텍스트 */
  --success: #3fb984;      /* 정답 */
  --error: #e2503d;        /* 오답 */

  /* 타이포 (브리프 §4) */
  --font-head: "Jua", "Apple SD Gothic Neo", sans-serif;
  --font-accent: "Gaegu", "Apple SD Gothic Neo", cursive;
  --font-body: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", system-ui, "Malgun Gothic", sans-serif;

  /* 형태 (브리프 §5) */
  --r-card: 22px;
  --r-input: 15px;
  --border-hand: 2px solid var(--ink);
  --shadow-sticker: 0 3px 0 rgba(43, 38, 34, 0.12), 0 6px 14px rgba(43, 38, 34, 0.08);
  --shadow-press: 0 1px 0 rgba(43, 38, 34, 0.12);
}

/* ── 리셋 · 베이스 ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  /* 옅은 종이 결 (인라인 SVG 노이즈, 외부 자산 없음) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 400; line-height: 1.22; }

a { color: inherit; }

/* ── 화면 컨테이너 ─────────────────────────────── */
.screen {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  padding-top: calc(24px + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  overflow: hidden; /* 두들 스티커가 넘쳐도 스크롤 안 생기게 */
}
.screen--center {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 22px;
}

/* ── 두들 스티커 (브리프 §5) ───────────────────── */
.doodle {
  position: absolute;
  font-family: var(--font-accent);
  pointer-events: none;
  user-select: none;
  opacity: 0.9;
  z-index: 0;
}
.doodle--star { color: var(--sub); }
.doodle--heart { color: var(--coral); }
.doodle--q { color: var(--muted); }
.doodle--spark { color: var(--success); }
.screen > :not(.doodle) { position: relative; z-index: 1; }

/* ── 버튼 ─────────────────────────────────────── */
.btn, .cta {
  font-family: var(--font-head);
  font-size: 1.05rem;
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: transform 0.08s ease, background-color 0.15s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn--primary, .cta {
  background: var(--coral);
  color: #fff;
  box-shadow: var(--shadow-sticker);
}
.btn--primary:hover, .cta:hover { background: var(--coral-press); }
.btn--primary:active, .cta:active { transform: translateY(2px); box-shadow: var(--shadow-press); }

.btn--ghost {
  background: var(--cream);
  color: var(--ink);
  border: var(--border-hand);
  box-shadow: var(--shadow-press);
}
.btn--ghost:hover { background: var(--sub-soft); }
.btn--ghost:active { transform: translateY(2px); box-shadow: none; }

.btn--sub { background: var(--sub); color: var(--ink); box-shadow: var(--shadow-press); }
.btn--sub:hover { background: #ffcf8c; }
.btn--sub:active { transform: translateY(2px); box-shadow: none; }

/* 텍스트 링크 (손그림 밑줄) */
.link-text {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.cta { font-size: 1.15rem; padding: 15px 30px; margin-top: 6px; }

/* ── 타이틀 · 텍스트 ───────────────────────────── */
.title-hero { font-size: 2rem; letter-spacing: -0.01em; }
.subcopy { font-family: var(--font-accent); color: var(--muted); font-size: 1.15rem; }
.hint-line { color: var(--muted); font-size: 0.95rem; }

/* ── 캔버스 (스케치북 한 장) ───────────────────── */
canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  background: var(--cream);
  border: var(--border-hand);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sticker);
  touch-action: none;
}
.canvas-wrap { position: relative; }
/* 재생 3배속 배지 */
.speed-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: var(--font-head);
  font-size: 0.85rem;
  background: var(--coral);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-press);
  z-index: 2;
}

/* ── 그리기: 제시어 · 도구 · 타이머 ────────────── */
.draw-word { text-align: center; font-size: 1.05rem; color: var(--ink); }
.draw-word__label { font-family: var(--font-body); font-size: 0.85rem; color: var(--muted); display: block; letter-spacing: 0.02em; }
.draw-word strong { font-family: var(--font-accent); color: var(--coral); font-size: 2rem; font-weight: 700; display: block; margin-top: 2px; }
.draw-guide { text-align: center; color: var(--muted); font-size: 0.95rem; margin-top: -6px; }

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 4px 0;
}
.tools button {
  font-family: var(--font-body);
  font-size: 0.85rem;
  min-height: 40px;
  padding: 0 14px;
  border: var(--border-hand);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease;
}
.tools button:active { transform: translateY(1px); }
.tools .swatch {
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
}
.tools .width {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}
.tools .is-selected { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--coral); }

.draw-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto; /* 하단으로 밀어 엄지 위치 */
  padding-top: 6px;
}
.timer { font-family: var(--font-head); font-size: 1.9rem; color: var(--ink); line-height: 1; }
.timer__unit { font-size: 0.9rem; color: var(--muted); margin-left: 2px; }
[data-drawing-target="timer"] { display: inline-block; }
[data-drawing-target="timer"].is-urgent { color: var(--coral); animation: pulse 0.9s ease-in-out infinite; }

/* ── 맞추기: 힌트 · 입력 · 결과 ────────────────── */
.replay-btn {
  align-self: center;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: transparent;
  border: var(--border-hand);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  color: var(--ink);
}
.guess { display: flex; flex-direction: column; gap: 12px; }
.guess-hint { text-align: center; font-size: 1.05rem; color: var(--ink); }
.guess-hint [data-guess-target="hint"] {
  font-family: var(--font-head);
  color: var(--coral);
  letter-spacing: 0.25em;
  font-size: 1.2rem;
  margin-left: 4px;
}
.guess input[type="text"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.05rem;
  padding: 14px 16px;
  min-height: 52px;
  background: var(--cream);
  border: var(--border-hand);
  border-radius: var(--r-input);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.guess input[type="text"]::placeholder { color: var(--muted); }
.guess input[type="text"]:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(255, 107, 94, 0.18); }
.guess__actions { display: flex; gap: 10px; }
.guess__actions .btn { flex: 1; }

/* 결과 피드백 (JS가 상태 클래스 부여) */
[data-guess-target="result"] {
  font-family: var(--font-accent);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  min-height: 1.5em;
}
[data-guess-target="result"]:empty { min-height: 0; }
.result--win { color: var(--success); animation: pop 0.4s ease; }
.result--miss { color: var(--error); animation: shake 0.35s ease; }
.result--reveal { color: var(--ink); }

/* 결과 뒤 붙는 "나도 내기" CTA를 크게 (바이럴 루프) */
[data-guess-target="result"] + .cta { align-self: stretch; }

/* ── 빈 상태 · 404 ─────────────────────────────── */
.empty-mark, .lost-mark {
  font-family: var(--font-head);
  font-size: 3.4rem;
  color: var(--muted);
}
.lost-box {
  width: 130px;
  height: 130px;
  border: 3px dashed var(--muted);
  border-radius: var(--r-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 2.6rem;
}
.state-title { font-size: 1.5rem; }
.state-desc { color: var(--muted); font-size: 0.95rem; }

/* ── 공유 ─────────────────────────────────────── */
.share-title { font-size: 1.6rem; text-align: center; }
.share-preview { width: 200px; align-self: center; }
.share-thumb {
  align-self: center;
  width: 180px;
  height: 180px;
  background: var(--cream);
  border: var(--border-hand);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sticker);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--font-accent);
}

/* ── 모션 ─────────────────────────────────────── */
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
