/* ===================================================================
   GreenCheck 디자인 시스템
   색상/간격/카드/반응형 레이아웃 (README 17, 18번 기준)
   =================================================================== */

:root {
  /* 색상 */
  --bg: #F8F9F4;          /* 따뜻한 아이보리 배경 */
  --text: #243A2C;        /* 짙은 녹회색 기본 텍스트 */
  --text-soft: #5d6f62;   /* 보조 설명 */
  --green: #4D936D;       /* 메인 그린 */
  --green-dark: #3c7657;
  --green-soft: #DCEEDC;  /* 보조 그린 */
  --card: #FFFFFF;        /* 카드 */
  --accent-yellow: #F6D06B; /* 성장 강조 */
  --accent-orange: #F2A65A;
  --danger: #d9654b;
  --line: #e7ece5;        /* 옅은 경계선 */

  /* 모양 */
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 6px 18px rgba(36, 58, 44, 0.06);
  --shadow-soft: 0 2px 8px rgba(36, 58, 44, 0.05);

  /* 간격 */
  --gap: 16px;
  --gap-lg: 24px;

  /* 레이아웃 */
  --sidebar-w: 240px;
  --maxw: 1200px;
  --bottomnav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden; /* 가로 스크롤로 화면 깨짐 방지 */
}

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6em; }

a { color: var(--green-dark); }

/* 접근성: 포커스 표시 */
:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--green-soft);
  color: var(--green-dark);
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none;
}
.btn:hover { background: #cfe6cf; }
.btn:active { transform: scale(.97); }
.btn--primary {
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.btn--primary:hover { background: var(--green-dark); }
.btn--block { width: 100%; }
.btn--lg { padding: 16px 24px; font-size: 1.05rem; }
.btn--ghost { background: transparent; color: var(--text-soft); }

/* ---------- 카드 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--gap-lg);
  box-shadow: var(--shadow);
}
.card--pad-sm { padding: var(--gap); }

/* ---------- 폼 ---------- */
.field { margin-bottom: var(--gap); }
.field label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-soft);
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: #fcfdfb;
  color: var(--text);
}
.field input:focus {
  border-color: var(--green);
  outline: none;
}

/* ---------- 플래시 메시지 ---------- */
.flash {
  background: #fff3ef;
  color: var(--danger);
  border: 1px solid #f3cfc5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: var(--gap);
  font-size: .92rem;
}

/* ===================================================================
   인증 화면 (로그인/회원가입) — 가운데 정렬 카드
   =================================================================== */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
}
.auth-brand {
  text-align: center;
  margin-bottom: var(--gap-lg);
}
.auth-brand .logo-mark { width: 72px; height: 72px; }
.auth-brand h1 { margin-top: 10px; color: var(--green-dark); }
.auth-brand p { color: var(--text-soft); font-size: .92rem; }
.auth-switch {
  text-align: center;
  margin-top: var(--gap);
  font-size: .92rem;
  color: var(--text-soft);
}

/* ===================================================================
   앱 레이아웃 (로그인 후)
   모바일: 하단 탭 / 데스크톱: 좌측 사이드바
   =================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* 사이드바 (데스크톱) */
.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--green-dark);
  padding: 0 8px 20px;
}
.sidebar .brand .logo-mark { width: 36px; height: 36px; }
.nav-links { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: .98rem;
}
.nav-link .ic { font-size: 1.25rem; line-height: 1; }
.nav-link:hover { background: var(--bg); }
.nav-link.is-active { background: var(--green-soft); color: var(--green-dark); }
.sidebar .logout {
  margin-top: auto;
  color: var(--text-soft);
  text-decoration: none;
  padding: 12px 14px;
  font-size: .92rem;
}

/* 본문 영역 */
.main {
  flex: 1;
  min-width: 0;
  padding: 20px 16px calc(var(--bottomnav-h) + 24px);
}
.main-inner { max-width: var(--maxw); margin: 0 auto; }

/* 상단 바 (모바일/태블릿) */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--green-dark);
}
.topbar .brand .logo-mark { width: 30px; height: 30px; }

/* 하단 탭 내비 (모바일/태블릿) */
.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bottomnav-h);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 50;
}
.bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-soft);
  font-size: .7rem;
  font-weight: 600;
}
.bottomnav a .ic { font-size: 1.4rem; line-height: 1; }
.bottomnav a.is-active { color: var(--green-dark); }

/* ===================================================================
   홈 대시보드
   =================================================================== */
.greeting { margin-bottom: var(--gap); }
.greeting .sub { color: var(--text-soft); font-size: .92rem; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

/* 초록이 메인 카드 */
.hero-card {
  text-align: center;
  background: linear-gradient(160deg, #ffffff 0%, #f3faf2 100%);
}
.hero-char { width: 180px; height: 180px; margin: 0 auto; }
.hero-stage-name { font-size: 1.3rem; font-weight: 800; color: var(--green-dark); }
.hero-stage-badge {
  display: inline-block;
  background: var(--green-soft);
  color: var(--green-dark);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 8px;
}

/* 진행률 바 */
.progress {
  background: var(--green-soft);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-yellow), var(--accent-orange));
  border-radius: 999px;
  width: 0;
  transition: width .6s ease;
}
.progress-label { font-size: .85rem; color: var(--text-soft); }

/* 지표 묶음 */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}
.stat {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  text-align: center;
}
.stat .num { font-size: 1.6rem; font-weight: 800; color: var(--green-dark); }
.stat .lbl { font-size: .8rem; color: var(--text-soft); }

/* 큰 인증 버튼 */
.cta-verify {
  position: sticky;
  bottom: calc(var(--bottomnav-h) + 12px);
}

/* 섹션 제목 */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--gap-lg) 0 10px;
}
.section-title h2 { margin: 0; }
.section-title a { font-size: .85rem; }

/* 빈 상태 */
.empty {
  text-align: center;
  color: var(--text-soft);
  padding: 24px;
  font-size: .92rem;
}

/* 로딩 스켈레톤 */
.skeleton {
  background: linear-gradient(90deg, #eef2ec 25%, #f6f8f4 50%, #eef2ec 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===================================================================
   반응형
   =================================================================== */

/* 태블릿: 2열 카드 */
@media (min-width: 768px) {
  .main { padding: 24px 24px calc(var(--bottomnav-h) + 24px); }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .hero-card { grid-column: 1 / -1; }
}

/* 데스크톱: 사이드바 + 하단탭 숨김 + 넓은 그리드 */
@media (min-width: 1200px) {
  .sidebar { display: flex; }
  .bottomnav { display: none; }
  .topbar { display: none; }
  .main { padding: 32px 40px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .hero-card { grid-column: span 1; }
  .cta-verify { position: static; }
}

/* 모션 민감 사용자 배려 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ===================================================================
   초록이 캐릭터 애니메이션
   =================================================================== */
.greenie { display: block; }
.gc-bob { animation: gcBob 3.2s ease-in-out infinite; transform-origin: center bottom; }
@keyframes gcBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.gc-sway { animation: gcSway 4s ease-in-out infinite; }
@keyframes gcSway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}
/* 성장 축하 연출 */
.gc-grow-pop { animation: gcPop .8s ease; }
@keyframes gcPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
