/* components.css — 글로벌 컴포넌트 (레이아웃/탭 바/버튼/카드/스탯 바/토스트/모달) */

#app {
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 상단 콘텐츠 영역 / 화면 전환 ───── */
.app-main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 20px 16px;
}

.screen.active {
  display: block;
  animation: screen-in 0.16s ease;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 홈은 서식지가 전체를 차지한다 */
#screen-home {
  padding: 0;
  overflow: hidden;
  position: relative;
}

.hidden {
  display: none !important;
}

.screen-title {
  font-size: 20px;
  margin-bottom: 6px;
}

.screen-desc {
  color: var(--color-text-sub);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── 하단 탭 바 ─────────────────────── */
.tab-bar {
  display: flex;
  align-items: stretch;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--color-bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-sub);
  cursor: pointer;
  transition: color 0.15s ease;
}

.tab i {
  font-size: 17px;
}

.tab.active {
  color: var(--color-primary-dark);
}

/* 중앙 홈 버튼 — 크고 떠 있게 */
.tab-home {
  flex: 0 0 72px;
  align-self: flex-start;
  width: 56px;
  height: 56px;
  margin: 0 8px;
  transform: translateY(-14px);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 14px rgba(50, 70, 45, 0.35);
}

.tab-home i {
  font-size: 20px;
}

.tab-home.active {
  color: #fff;
  box-shadow: 0 4px 10px rgba(50, 70, 45, 0.45), 0 0 0 4px rgba(255, 255, 255, 0.35);
}

/* ── 카드 ───────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
}

/* ── 버튼 ───────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn:disabled:active {
  transform: none;
}

.btn-primary {
  background: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-ghost {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow);
}

.btn-danger {
  background: var(--color-danger);
}

.btn-wide {
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 14px;
}

/* ── 입력 ───────────────────────────── */
.text-input {
  width: 100%;
  border: 2px solid #dde3da;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
  background: rgba(255, 255, 255, 0.9);
}

.text-input:focus {
  border-color: var(--color-primary);
}

/* ── 스탯 바 ────────────────────────── */
.stat {
  margin-top: 14px;
  text-align: left;
}

.stat-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-sub);
  margin-bottom: 6px;
}

.stat-bar {
  height: 12px;
  background: #e8ece5;
  border-radius: 999px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.fill-exp {
  background: var(--color-exp);
}

.fill-hunger {
  background: var(--color-hunger);
}

.fill-happiness {
  background: var(--color-happiness);
}

/* ── 토스트 ─────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  width: max-content;
  max-width: 90vw;
  pointer-events: none; /* 토스트는 표시 전용 — 아래 행동 버튼 탭을 막지 않는다 */
}

.toast {
  background: rgba(45, 52, 40, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  animation: toast-in 0.25s ease;
}

.toast-warn {
  background: rgba(176, 104, 70, 0.95);
}

.toast.out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 모달 ───────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: toast-in 0.2s ease;
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
  width: min(320px, 85vw);
  box-shadow: var(--shadow);
}

.modal-box.celebrate .modal-emoji {
  font-size: 64px;
  animation: celebrate-pop 0.6s ease;
}

.modal-box.celebrate .modal-emoji-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 3px 5px rgba(20, 18, 10, 0.28));
  animation: celebrate-pop 0.6s ease;
}

.modal-box h3 {
  font-size: 20px;
  margin: 12px 0 6px;
}

.modal-box p {
  color: var(--color-text-sub);
  font-size: 14px;
  margin-bottom: 20px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.report-lines {
  list-style: none;
  text-align: left;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-lines li {
  font-size: 13px;
  color: var(--color-text-sub);
  padding: 9px 12px;
  background: rgba(120, 145, 100, 0.1);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

@keyframes celebrate-pop {
  0%   { transform: scale(0.3); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── 지갑 먹이 버튼 / 먹이 시트 ─────── */
.wallet-food {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
}

.fab-emoji {
  font-size: 18px;
  line-height: 1;
}

.food-sheet {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.food-sheet-row {
  border: 2px solid #e2e6de;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  padding: 10px 12px;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.food-sheet-row.active {
  border-color: var(--color-primary);
  background: rgba(120, 145, 100, 0.12);
}

.food-sheet-row.locked {
  opacity: 0.6;
  cursor: default;
}

.food-sheet-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--color-text);
}

.food-sheet-desc {
  font-size: 11px;
  color: var(--color-text-sub);
  margin-top: 2px;
}

/* 모습 바꾸기 행 — food-sheet-row 재사용 + 스프라이트 미리보기 */
.skin-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skin-row-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.shop-item.locked {
  opacity: 0.65;
}

.shop-food-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── 게임필 연출 (FX) ───────────────── */
.fx-pulse {
  animation: fx-pulse 0.35s ease;
}

@keyframes fx-pulse {
  40% { transform: scale(1.12); }
}

.fx-delta {
  position: fixed;
  z-index: 150;
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
  animation: fx-delta 0.9s ease forwards;
}

.fx-delta.gain { color: var(--color-warn); }
.fx-delta.loss { color: var(--color-danger); }

@keyframes fx-delta {
  0%   { opacity: 0; transform: translate(-50%, -4px); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, 14px); }
}

.fx-coin {
  position: fixed;
  z-index: 150;
  color: var(--color-warn);
  font-size: 14px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.fx-confetti {
  position: fixed;
  top: -14px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  z-index: 210;
  pointer-events: none;
  animation: fx-confetti-fall 1.6s ease-in forwards;
}

@keyframes fx-confetti-fall {
  to {
    transform: translate(var(--dx, 0), 106vh) rotate(var(--rot, 360deg));
    opacity: 0.75;
  }
}

/* 접근성: 모션 축소 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  .screen.active,
  .fx-pulse,
  .fx-delta,
  .fx-confetti {
    animation: none;
  }
}

/* ── 모바일 (390px 기준) ────────────── */
@media (max-width: 390px) {
  .screen {
    padding: 16px 12px;
  }

  .btn {
    padding: 11px 14px;
    font-size: 14px;
  }
}
