/* ======================================================
   BabyApp PWA — main.css
   아이들용 UI: 큰 버튼, 밝은 색상, 모바일 전체화면 기준
   ====================================================== */

/* ── 기본 ───────────────────────────────────────────── */
html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--color-bg-warm);
  color: var(--color-text);
  touch-action: manipulation;
}

/* ── 화면 레이아웃 ───────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  height: 100svh;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── 헤더 ────────────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 8px;
}

.header-left,
.header-right {
  width: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.header-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: transparent;
  color: #999;
}

.app-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
}

.title-emoji {
  font-size: 2.2rem;
}

.title-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

/* ── 메인 메뉴 그리드 ────────────────────────────────── */
.menu-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 20px 12px;
  justify-content: safe center;
  overflow-y: auto;
  scrollbar-width: none;
}

.menu-grid::-webkit-scrollbar { display: none; }

/* ── 메뉴 행 (가로 배치) ─────────────────────────────── */
.menu-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform var(--touch-duration) ease;
  user-select: none;
  -webkit-user-select: none;
  width: 100%;
}

.menu-row:active {
  transform: scale(var(--touch-scale));
}

/* 아이콘 이미지 (박스 안) */
.menu-icon-img {
  width: auto;
  height: 52px;
  object-fit: contain;
  pointer-events: none;
  flex-shrink: 0;
}

/* 이모지 아이콘 (박스 안) */
.menu-icon-emoji {
  font-size: 2.2rem;
  line-height: 1;
  flex-shrink: 0;
  width: 52px;
  text-align: center;
}

/* 메뉴박스 (아이콘 + 텍스트 통합) */
.menu-box {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-xl);
  color: var(--color-surface);
  box-shadow: var(--shadow-lg);
  min-height: 72px;
}

.menu-box-word         { background: var(--gradient-primary); }
.menu-box-number       { background: var(--gradient-teal); }
.menu-box-hangul       { background: linear-gradient(145deg, #FF6B9D, #FF4081); }
.menu-box-english      { background: linear-gradient(145deg, #42A5F5, #1E88E5); }
.menu-box-number-study { background: linear-gradient(145deg, #66BB6A, #43A047); }

/* 텍스트 영역 */
.menu-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.menu-label {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  text-align: center;
}

.menu-desc {
  font-size: 0.75rem;
  opacity: 0.85;
  font-weight: 400;
  text-align: center;
}

/* ── 푸터 ────────────────────────────────────────────── */
.app-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 24px 16px;
  font-size: 0.75rem;
  color: var(--color-text-faint);
}

.app-footer .menu-row {
  width: 100%;
  max-width: 280px;
}

/* ── 게임 화면 (추후 확장용) ─────────────────────────── */
.screen-game {
  display: none;
  flex-direction: column;
  height: 100svh;
}

.screen-game.active {
  display: flex;
}

/* ── 공통 버튼 ───────────────────────────────────────── */
.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-surface-dim);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: transform var(--touch-duration) ease, background var(--touch-duration) ease;
}

.btn-back:active {
  transform: scale(var(--touch-scale));
  background: var(--color-surface-hover);
}

/* ── 로딩 스피너 ─────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 249, 240, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 999;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--color-spinner-track);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1rem;
  color: var(--color-primary);
  font-weight: 700;
}

/* ── 데이터 다운로드 팝업 + 프로그레스 오버레이 ─────── */
.dl-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  animation: dl-fade-in 0.25s ease;
}

@keyframes dl-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dl-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.dl-card {
  text-align: center;
  padding: 36px 28px 28px;
  max-width: 320px;
  width: 85%;
  background: var(--color-surface, #fff);
  border-radius: var(--radius-xl, 20px);
  box-shadow: var(--shadow-lg, 0 6px 20px rgba(0,0,0,0.10));
  animation: dl-pop-in 0.3s ease;
}

@keyframes dl-pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.dl-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: inline-block;
}

.dl-icon.bounce {
  animation: dl-bounce 1.2s ease-in-out infinite;
}

@keyframes dl-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-14px) scale(1.05); }
}

.dl-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text-dark, #222);
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.dl-body {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted, #888);
  line-height: 1.55;
  margin-bottom: 24px;
}

.dl-buttons {
  display: flex;
  gap: 10px;
}

.dl-btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  border-radius: var(--radius-md, 12px);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.dl-btn:active {
  transform: scale(0.95);
}

.dl-btn.cancel {
  background: var(--color-surface-warm, #f0ebe3);
  color: var(--color-text-secondary, #555);
}

.dl-btn.ok {
  background: var(--gradient-primary, linear-gradient(145deg, #FF8C42, #FF6B6B));
  color: #fff;
}

/* 프로그레스 상태 (팝업 → 프로그레스 전환) */
.dl-bar-wrap {
  width: 100%;
  height: 14px;
  background: var(--color-surface-warm-alt, #e8e3dc);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
  display: none;
}

.dl-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-primary, linear-gradient(90deg, #FF8C42, #FF6B6B));
  border-radius: 7px;
  transition: width 0.2s ease;
  position: relative;
}

.dl-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3) 50%, transparent);
  animation: dl-shimmer 1.5s ease-in-out infinite;
}

@keyframes dl-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.dl-pct {
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-primary, #FF8C42);
  line-height: 1;
  margin-bottom: 2px;
  display: none;
}

.dl-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-disabled, #bbb);
  margin-bottom: 16px;
  display: none;
}

.dl-skip {
  display: none;
  padding: 11px 28px;
  border: none;
  border-radius: var(--radius-md, 12px);
  background: var(--color-surface-warm, #f0ebe3);
  color: var(--color-text-secondary, #555);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.4s ease;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
}

.dl-skip.visible {
  opacity: 1;
}

.dl-skip:active {
  transform: scale(0.93);
  background: var(--color-surface-warm-hover, #e0dbd3);
}

/* ── 미디어쿼리: 태블릿 이상 ─────────────────────────── */
@media (min-width: 480px) {
  .menu-icon-img {
    width: auto;
    height: 62px;
  }
  .menu-icon-emoji {
    font-size: 2.6rem;
    width: 62px;
  }
  .menu-box {
    padding: 16px 20px;
    min-height: 88px;
    gap: 16px;
  }
  .menu-label {
    font-size: 1.4rem;
  }
}

/* ── 관리자 전용 게임 (숨김 상태) ─────────────────────── */
.menu-row.admin-only {
  opacity: 0.45;
  border: 2px dashed #FF8C42;
}
