/* public/style.css — WP7 UI 스타일 (WP7-spec.md §스타일 계약)
   모바일 퍼스트(기준 375px) · 컨테이너 max-width 520px 중앙 · 터치 타깃 최소 44px
   가로 스크롤 금지 · 시스템 한글 폰트 스택만(웹폰트·외부 CDN 0) · image-rendering: pixelated
   prefers-reduced-motion 존중 · 외부 리소스 참조 0 (map.kakao.com 새 탭 이동 제외) */

:root {
  --bg: #1b1b2b;
  --bg2: #242438;
  --bg3: #2e2a4a;
  --ink: #f3efe4;
  --sub: #b9b3a4;
  --amber: #f5a742;
  --coral: #e2603f;
  --leaf: #7fb069;
  --line: #3c3a58;
  --shadow: rgba(0, 0, 0, 0.45);
  --radius: 2px;
  --touch: 44px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
  cursor: pointer;
}

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100svh;
}

/* --- 로딩/에러 --------------------------------------------------------- */

.app-status {
  text-align: center;
  padding: 40px 12px;
  color: var(--sub);
}

.app-status p {
  margin-bottom: 14px;
}

/* --- 화면 공통 ----------------------------------------------------------- */

.screen {
  text-align: center;
}

.screen[hidden] {
  display: none;
}

/* flex/grid 등의 author display 선언보다 hidden 상태가 항상 우선해야 한다. */
[hidden] {
  display: none !important;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--ink);
  box-shadow: 3px 3px 0 0 var(--shadow);
  letter-spacing: 0.03em;
  transition: transform 0.1s ease;
}

.btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 0 var(--shadow);
}

.btn-primary {
  background: var(--amber);
  color: var(--bg);
  border-color: var(--amber);
}

.btn-secondary {
  background: var(--bg2);
  border-color: var(--leaf);
  color: var(--leaf);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--sub);
}

.btn-cta {
  display: flex;
  width: 100%;
  max-width: 320px;
  margin: 28px auto 8px;
  font-size: 1.05rem;
  padding: 14px 20px;
}

.link-secondary {
  margin-top: 18px;
  background: none;
  border: none;
  color: var(--sub);
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 8px 12px;
  text-decoration: underline;
  letter-spacing: 0.04em;
}

/* --- HOME: 저녁이 켜지는 픽셀 마을 (CSS와 로컬 sprite만) ---------------- */

.home-mood {
  position: relative;
  isolation: isolate;
  height: clamp(224px, 62vw, 280px);
  margin-bottom: 12px;
  overflow: hidden;
  border: 2px solid var(--line);
  box-shadow: 3px 3px 0 0 var(--shadow);
}

.mood-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    #211b45 0%,
    #4e365b 29%,
    #a85255 57%,
    #eea24d 100%
  );
}

.mood-hill {
  position: absolute;
  z-index: 1;
  left: -8%;
  right: -8%;
  bottom: 0;
  height: 37%;
  background: #384454;
  clip-path: polygon(0 58%, 10% 47%, 19% 55%, 31% 30%, 44% 48%, 58% 23%, 74% 49%, 88% 34%, 100% 56%, 100% 100%, 0 100%);
}

.mood-road {
  position: absolute;
  z-index: 2;
  left: 18%;
  right: -12%;
  bottom: -8%;
  height: 24%;
  background: #2a2739;
  transform: skewX(-25deg);
}

.mood-house {
  position: absolute;
  z-index: 3;
  bottom: 14%;
  background: #292642;
  border: 2px solid #17172a;
  box-shadow: 3px 3px 0 #17172a;
}

.mood-house::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -30px;
  left: -6px;
  right: -6px;
  height: 32px;
  background: #4b2942;
  clip-path: polygon(0 100%, 0 75%, 14% 75%, 14% 57%, 28% 57%, 28% 39%, 42% 39%, 42% 20%, 57% 20%, 57% 0, 72% 0, 72% 20%, 86% 20%, 86% 39%, 100% 39%, 100% 100%);
}

.mood-house--a {
  left: 5%;
  width: 59px;
  height: 48px;
}

.mood-house--b {
  left: 37%;
  width: 80px;
  height: 72px;
}

.mood-house--c {
  right: 5%;
  width: 62px;
  height: 55px;
}

.mood-chimney {
  position: absolute;
  top: -35px;
  right: 10px;
  width: 12px;
  height: 27px;
  background: #2c2336;
  border: 2px solid #17172a;
}

.mood-window {
  position: absolute;
  width: 10px;
  height: 13px;
  border: 2px solid #17172a;
  background: #17172a;
  opacity: 0.88;
  animation: home-window-light 0.12s steps(1, end) forwards;
}

.mood-window--1 { bottom: 11px; left: 10px; animation-delay: 0.6s; }
.mood-window--2 { bottom: 11px; right: 10px; animation-delay: 0.85s; }
.mood-window--3 { bottom: 12px; left: 12px; animation-delay: 1.1s; }
.mood-window--4 { bottom: 12px; left: 34px; animation-delay: 1.35s; }
.mood-window--5 { bottom: 12px; right: 12px; animation-delay: 1.6s; }
.mood-window--6 { top: 15px; left: 34px; animation-delay: 1.85s; }
.mood-window--7 { bottom: 12px; left: 11px; animation-delay: 2.1s; }
.mood-window--8 { bottom: 12px; right: 11px; animation-delay: 2.35s; }

.mood-smoke {
  position: absolute;
  z-index: 2;
  left: calc(37% + 54px);
  bottom: calc(14% + 93px);
  width: 12px;
  height: 12px;
  background: #d9b6a9;
  opacity: 0;
  animation: home-smoke 2.8s steps(6, end) infinite;
  animation-delay: 2.4s;
}

.mood-smoke--2 {
  margin-left: 13px;
  margin-bottom: 10px;
  width: 9px;
  height: 9px;
  animation-delay: 3.05s;
}

.home-mystery {
  position: absolute;
  z-index: 4;
  left: 22%;
  bottom: 6%;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
}

.home-mystery-sprite {
  width: 56px;
  height: 56px;
  filter: brightness(0);
  image-rendering: pixelated;
}

.home-mystery-mark {
  position: absolute;
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 2px 2px 0 #17172a;
}

@keyframes home-window-light {
  to {
    background: var(--amber);
    border-color: #ffe0a2;
    box-shadow: 0 0 0 2px rgba(245, 167, 66, 0.18);
    opacity: 1;
  }
}

@keyframes home-smoke {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }

  18% { opacity: 0.55; }

  100% {
    opacity: 0;
    transform: translate(18px, -44px);
  }
}

.brand {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.brand span {
  color: var(--amber);
}

.tagline {
  color: var(--sub);
  font-size: clamp(0.95rem, 3.5vw, 1.05rem);
  line-height: 1.7;
}

/* --- 스프라이트 프레임 ---------------------------------------------------- */

.sprite-frame {
  width: 140px;
  height: 140px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg2);
  border: 2px solid var(--line);
  box-shadow: 0 0 0 2px var(--bg), 4px 4px 0 0 var(--shadow);
}

.sprite-frame--lg {
  width: 168px;
  height: 168px;
}

.sprite-img {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
}

.sprite-frame--lg .sprite-img {
  width: 128px;
  height: 128px;
}

.dish-name {
  margin: 4px 0 6px;
  font-size: clamp(1.15rem, 4.5vw, 1.4rem);
  color: var(--amber);
  letter-spacing: 0.04em;
}

.dish-copy {
  color: var(--sub);
  font-size: 0.9rem;
  max-width: 320px;
  margin: 0 auto 8px;
}

/* --- DISCOVERY: 후보 퍼레이드 --------------------------------------------- */

.discovery-parade {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.parade-sprite {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  animation: parade-pop 0.12s steps(2, end);
}

@keyframes parade-pop {
  from {
    transform: scale(0.85);
    opacity: 0.5;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* --- UNLOCK ---------------------------------------------------------------- */

.unlock-fx {
  height: 0;
}

.unlock-fx--active {
  height: 12px;
  background: radial-gradient(closest-side, var(--amber), transparent);
  opacity: 0.6;
  animation: sparkle 1.4s ease-in-out infinite;
}

@keyframes sparkle {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.75;
  }
}

.unlock-heading:empty {
  display: none;
}

.unlock-title {
  color: var(--amber);
  font-size: clamp(1.3rem, 5vw, 1.7rem);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.unlock-dexno {
  color: var(--sub);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.unlock-message {
  color: var(--sub);
}

.unlock-message[hidden] {
  display: none;
}

.unlock-actions-extra {
  display: contents;
}

/* --- COLLECTION -------------------------------------------------------------- */

.collection-title {
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  color: var(--amber);
}

.collection-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}

.tab {
  min-height: var(--touch);
  padding: 6px 10px;
  font-size: 0.82rem;
  background: var(--bg2);
  border: 2px solid var(--line);
  color: var(--sub);
}

.tab--active {
  border-color: var(--amber);
  color: var(--amber);
}

.collection-progress {
  color: var(--sub);
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  min-height: var(--touch);
  background: var(--bg2);
  border: 2px solid var(--line);
}

.grid-item-sprite {
  width: 48px;
  height: 48px;
}

.grid-item-name {
  font-size: 0.72rem;
  color: var(--ink);
  text-align: center;
}

/* 미해금 실루엣: 형태만 보이고 이름은 렌더되지 않는다 */
.grid-item--locked {
  cursor: default;
}

.grid-item--locked .grid-item-sprite {
  filter: brightness(0);
  opacity: 0.35;
}

.collection-detail {
  padding-top: 6px;
}

.detail-dexno {
  color: var(--sub);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.detail-copies {
  max-width: 360px;
  margin: 0 auto 14px;
  color: var(--sub);
  font-size: 0.9rem;
}

.detail-copies[hidden] {
  display: none;
}

.detail-copy + .detail-copy {
  margin-top: 6px;
}

/* --- 접근성: 모션 감소 --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  .mood-window {
    animation: none !important;
    background: var(--amber);
    border-color: #ffe0a2;
    box-shadow: 0 0 0 2px rgba(245, 167, 66, 0.18);
    opacity: 1;
  }

  .mood-smoke {
    animation: none !important;
    opacity: 0;
  }
}

/* --- 아주 좁은 화면 보정 (기준 375px 이하 여유) --------------------------- */

@media (max-width: 340px) {
  .sprite-frame {
    width: 120px;
    height: 120px;
  }
  .sprite-img {
    width: 84px;
    height: 84px;
  }
}
