/* =============================================
   VIKI 공통 CSS — main.css
   레이아웃 기준:
   - 모바일/태블릿(~1023px): 풀스크린, radius 0
   - PC(1024px+): 가운데 폰 프레임 + 양옆 광고
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple-deep:   #0d0820;
  --purple-mid:    #1a0f2e;
  --purple-light:  #2d1b4e;
  --accent:        #c084fc;
  --accent-dark:   #9b6ef3;
  --pink:          #db2777;
  --text:          #e2e8f0;
  --text-muted:    #94a3b8;
  --border:        rgba(255,255,255,0.08);
  --border-purple: rgba(167,139,250,0.2);
  --frame-width:   420px;
  --frame-radius:  36px;
}

html, body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--purple-deep);
  color: var(--text);
  /* 모바일: 그냥 block */
  display: block;
}

/* =============================================
   앱 프레임 — 핵심 레이아웃
   ============================================= */
.app-frame {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* 모바일 주소바 대응 */
  background: linear-gradient(160deg, var(--purple-mid) 0%, var(--purple-deep) 100%);
  position: relative;
  overflow-x: hidden;
  /* 모바일/태블릿: radius 없음, 풀스크린 */
  border-radius: 0;
}

/* PC: 가운데 폰 프레임 */
@media (min-width: 1024px) {
  body {
    background: #0a0612;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
  }

  .app-frame {
    width: var(--frame-width);
    max-width: var(--frame-width);
    min-width: var(--frame-width);
    border-radius: var(--frame-radius);
    border: 1.5px solid var(--border-purple);
    box-shadow: 0 0 60px rgba(109,40,217,0.3);
    /* 스크롤은 프레임 안에서 */
    overflow-y: auto;
    max-height: 100vh;
  }
}
/* =============================================
   공통 컴포넌트
   ============================================= */

/* 히어로 (상단 그라데이션 배경) */
.hero {
  background: linear-gradient(155deg, #6d28d9 0%, #9333ea 45%, #db2777 100%);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* 상단바 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  position: relative;
  z-index: 10;
}

.life-pill {
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.38);
  border-radius: 20px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.top-actions { display: flex; gap: 5px; align-items: center; }

.top-btn {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* 섹션 레이블 */
.sec-label {
  font-size: 10px;
  font-weight: 800;
  color: #7c3aed;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
}

/* 그리드 2열 */
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* 메뉴 카드 */
.menu-card {
  border-radius: 18px;
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.menu-card:active { transform: scale(0.96); }
.menu-card-icon { font-size: 32px; line-height: 1; }
.menu-card-name { font-size: 12px; font-weight: 800; text-align: center; line-height: 1.3; }
.menu-card-sub  { font-size: 9px;  font-weight: 700; text-align: center; }

/* 카드 색상 */
.c-dream  { background: linear-gradient(145deg,#1e1b4b,#312e81); border: 1.5px solid #4338ca; }
.c-dream  .menu-card-name { color: #e0e7ff; } .c-dream  .menu-card-sub { color: #a5b4fc; }
.c-love   { background: linear-gradient(145deg,#4a0030,#831843); border: 1.5px solid #be185d; }
.c-love   .menu-card-name { color: #fce7f3; } .c-love   .menu-card-sub { color: #f9a8d4; }
.c-friend { background: linear-gradient(145deg,#052e16,#14532d); border: 1.5px solid #16a34a; }
.c-friend .menu-card-name { color: #dcfce7; } .c-friend .menu-card-sub { color: #86efac; }
.c-report { background: linear-gradient(145deg,#0c1445,#1e3a8a); border: 1.5px solid #2563eb; }
.c-report .menu-card-name { color: #dbeafe; } .c-report .menu-card-sub { color: #93c5fd; }
.c-saju   { background: linear-gradient(145deg,#1c1917,#44403c); border: 1.5px solid #78716c; }
.c-saju   .menu-card-name { color: #fafaf9; } .c-saju   .menu-card-sub { color: #d6d3d1; }
.c-tarot  { background: linear-gradient(145deg,#2d1b00,#78350f); border: 1.5px solid #d97706; }
.c-tarot  .menu-card-name { color: #fef3c7; } .c-tarot  .menu-card-sub { color: #fcd34d; }

/* 하단 탭 */
.bottom-nav {
  padding: 8px 6px 20px;
  display: flex;
  justify-content: space-around;
  border-top: 1.5px solid rgba(237,233,254,0.15);
  background: rgba(13,8,32,0.98);
  flex-shrink: 0;
  /* 모바일: 하단 고정 */
  position: sticky;
  bottom: 0;
  z-index: 50;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { background: rgba(124,58,237,0.15); }
.nav-icon { font-size: 20px; opacity: .35; }
.nav-icon.active { opacity: 1; }
.nav-text { font-size: 8px; font-weight: 700; color: #c4b5fd; }
.nav-text.active { color: #7c3aed; }

/* 팝업 */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.popup.show { display: flex; }

.popup-box {
  background: #1e0a3c;
  border: 1px solid rgba(192,132,252,0.25);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  max-height: 80vh;
  overflow-y: auto;
}
.popup-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 14px;
  text-align: center;
}
.popup-close {
  width: 100%;
  padding: 12px;
  background: rgba(192,132,252,0.15);
  border: 1px solid rgba(192,132,252,0.3);
  border-radius: 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
}

/* 버튼 */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover   { opacity: .9; }
.btn-primary:active  { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* 입력 */
.input-field {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
}
.input-field:focus  { border-color: rgba(192,132,252,0.5); }
.input-field::placeholder { color: var(--text-muted); }

/* 페이지 헤더 */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,8,32,0.8);
  position: sticky;
  top: 0;
  z-index: 30;
}
.back-btn   { font-size: 22px; cursor: pointer; padding: 4px 8px; }
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }

/* 로딩 */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--purple-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity .4s;
}
.loading-overlay.hide { opacity: 0; pointer-events: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(192,132,252,0.2);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 반짝이 */
.sparkle {
  position: absolute;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  animation: tw 2.2s infinite;
  pointer-events: none;
  user-select: none;
}
@keyframes tw {
  0%,100% { opacity: .25; transform: scale(.8); }
  50%      { opacity: 1;   transform: scale(1.25); }
}

/* 스크롤바 */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(192,132,252,0.3); border-radius: 2px; }

/* Safe area (노치 대응) */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
