/* ===================================================================
   GreenCheck 2단계 컴포넌트 (행동 탐색 / 인증 / 기록·통계·캘린더)
   app.css 를 보완한다.
   =================================================================== */

/* 검색 입력 */
.search-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);
}
.search-input:focus { border-color: var(--green); outline: none; }

/* 카테고리 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
}
.chip.is-active { background: var(--green); color: #fff; border-color: var(--green); }

/* 행동 카드 그리드 */
.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  margin-top: var(--gap);
}
.action-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
}
.action-top { display: flex; justify-content: space-between; align-items: center; }
.action-emoji { font-size: 1.6rem; }
.action-energy {
  background: var(--green-soft); color: var(--green-dark);
  border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 700;
}
.action-title { margin: 10px 0 4px; font-size: 1.05rem; }
.action-desc { color: var(--text-soft); font-size: .9rem; flex: 1; }
.action-meta { margin: 8px 0; }
.tag {
  display: inline-block; background: #f0f4ee; color: var(--text-soft);
  border-radius: 8px; padding: 2px 10px; font-size: .78rem; font-weight: 600;
}
.action-actions { display: flex; gap: 8px; margin-top: 10px; }
.action-actions .btn { flex: 1; padding: 10px; font-size: .9rem; }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(36,58,44,.4); }
.modal-card {
  position: relative; background: #fff; border-radius: var(--radius);
  padding: 24px; max-width: 420px; width: 100%; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow); z-index: 1;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; border: none; background: #f0f4ee;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1rem;
}
.detail-row { margin: 12px 0; }
.detail-row b { display: block; color: var(--green-dark); font-size: .85rem; margin-bottom: 2px; }
.detail-row p { margin: 0; color: var(--text); }

/* ----- 데모 배너 ----- */
.demo-banner {
  background: #fff6e6; border: 1px solid #f3dca8; color: #8a6d1f;
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: .9rem;
  margin-bottom: var(--gap);
}

/* ----- 인증 화면 ----- */
.photo-drop {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--line); border-radius: var(--radius-sm);
  min-height: 180px; cursor: pointer; background: #fcfdfb; overflow: hidden;
}
.photo-drop:hover { border-color: var(--green); }
#photo-hint { color: var(--text-soft); font-weight: 600; }
#photo-preview { max-width: 100%; max-height: 320px; border-radius: var(--radius-sm); }

.result-head {
  font-size: 1.1rem; font-weight: 800; padding: 14px; border-radius: var(--radius-sm);
}
.result-success { background: var(--green-soft); color: var(--green-dark); }
.result-fail { background: #fdecea; color: #b23b2b; }
.result-unsure { background: #fff6e6; color: #8a6d1f; }
.result-detail { margin-top: 14px; }
.result-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.result-row b { flex-shrink: 0; width: 110px; color: var(--green-dark); }
.reward-box {
  margin-top: 14px; background: linear-gradient(90deg, #fef3d4, #fde3c0);
  color: #7a5a1a; font-weight: 800; text-align: center; padding: 14px; border-radius: var(--radius-sm);
}
.reward-dup { background: #eef2ec; color: var(--text-soft); font-weight: 600; }
.levelup-box {
  margin-top: 10px; background: var(--green); color: #fff; font-weight: 800;
  text-align: center; padding: 14px; border-radius: var(--radius-sm);
  animation: gcPop .6s ease;
}
.result-img { margin-top: 14px; width: 100%; border-radius: var(--radius-sm); }

/* ----- 홈 미니 요소 ----- */
.mini-actions { display: flex; flex-direction: column; gap: 8px; }
.mini-action {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  color: var(--text); padding: 10px 12px; border-radius: var(--radius-sm); background: #fcfdfb;
}
.mini-action:hover { background: var(--bg); }
.mini-title { flex: 1; font-weight: 600; }
.mini-energy { color: var(--green-dark); font-weight: 700; font-size: .9rem; }

/* ----- 기록 카드 ----- */
.rec-card {
  display: flex; align-items: center; gap: 12px; background: #fff;
  border-radius: var(--radius-sm); padding: 12px; box-shadow: var(--shadow-soft); margin-bottom: 10px;
}
.rec-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.rec-body { flex: 1; min-width: 0; }
.rec-title { font-weight: 700; }
.rec-meta { font-size: .8rem; color: var(--text-soft); }
.rec-reward { color: var(--green-dark); font-weight: 800; font-size: .85rem; white-space: nowrap; }
.rec-demo { color: #8a6d1f; font-size: .8rem; font-weight: 700; }

/* ----- 탭 ----- */
.tabs { display: flex; gap: 6px; margin-bottom: var(--gap); background: #eef2ec; padding: 5px; border-radius: 999px; }
.tab {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 999px;
  font-weight: 700; color: var(--text-soft); cursor: pointer; font-size: .92rem;
}
.tab.is-active { background: #fff; color: var(--green-dark); box-shadow: var(--shadow-soft); }

/* ----- 최근 7일 막대 ----- */
.bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 140px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: .75rem; color: var(--text-soft); margin-bottom: 2px; }
.bar { width: 70%; background: linear-gradient(180deg, var(--green), var(--green-dark)); border-radius: 6px 6px 0 0; min-height: 6px; }
.bar-label { font-size: .72rem; color: var(--text-soft); margin-top: 4px; }

/* ----- 분야별 ----- */
.catbar-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.catbar-name { width: 80px; font-size: .85rem; font-weight: 600; flex-shrink: 0; }
.catbar-track { flex: 1; background: var(--green-soft); border-radius: 999px; height: 12px; overflow: hidden; }
.catbar-fill { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.catbar-num { width: 28px; text-align: right; font-weight: 700; color: var(--green-dark); }

/* ----- 캘린더 ----- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-controls { display: flex; gap: 8px; }
.cal-year { width: 90px; padding: 8px; border: 1.5px solid var(--line); border-radius: 10px; }
.cal-month { padding: 8px; border: 1.5px solid var(--line); border-radius: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: .78rem; color: var(--text-soft); font-weight: 700; padding: 4px 0; }
.cal-cell {
  position: relative; aspect-ratio: 1; border: none; background: #fcfdfb; border-radius: 10px;
  cursor: pointer; display: flex; align-items: flex-start; justify-content: flex-start; padding: 4px;
}
.cal-empty { background: transparent; cursor: default; }
.cal-num { font-size: .8rem; color: var(--text-soft); }
.cal-has { background: var(--green-soft); }
.cal-stamp { position: absolute; right: 3px; bottom: 2px; font-size: .9rem; }
.cal-today { outline: 2px solid var(--green); }

/* 태블릿/데스크톱: 행동 2~3열 */
@media (min-width: 768px) {
  .action-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1200px) {
  .action-grid { grid-template-columns: repeat(3, 1fr); }
  .result-img { max-width: 420px; }
}

/* ===================================================================
   3단계: 챌린지 / 뽑기 / 옷장 / 배지 + 스피너
   =================================================================== */

/* 스피너 */
.spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: -2px;
  border: 2.5px solid rgba(255,255,255,.5); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 챌린지 카드 */
.challenge-card {
  background: #fff; border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-soft); margin-bottom: var(--gap);
}
.ch-top { display: flex; gap: 12px; align-items: flex-start; }
.ch-emoji { font-size: 2rem; }
.ch-head h3 { margin: 0 0 4px; }
.ch-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-tag { font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 9px; }
.ch-tag-period { background: #fdeedd; color: #a9671f; }
.ch-tag-cumul { background: var(--green-soft); color: var(--green-dark); }
.ch-tag-self { background: #fff3cd; color: #8a6d1f; }
.ch-desc { color: var(--text-soft); font-size: .9rem; margin: 10px 0; }
.ch-prog-label { font-size: .82rem; color: var(--text-soft); margin: 4px 0 10px; }
.ch-done { color: var(--green-dark); font-weight: 700; margin: 8px 0; }
.ch-expired { color: #b23b2b; font-weight: 600; margin: 8px 0; }
.ch-left { color: #a9671f; font-size: .85rem; margin: 6px 0; }
.ch-how { color: var(--text-soft); font-size: .9rem; }
.selfreport-note {
  background: #fff3cd; color: #8a6d1f; border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: .85rem; margin: 10px 0;
}
.ch-result { margin-top: 14px; }

/* 뽑기 */
.gacha-card { text-align: center; }
.gacha-ticket { font-size: 1.05rem; font-weight: 700; }
.gacha-ticket b { color: var(--green-dark); font-size: 1.3rem; }
.gacha-progress { color: var(--text-soft); margin: 6px 0 16px; font-size: .9rem; }
.gacha-stage { min-height: 140px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.gacha-rolling { font-size: 1.2rem; animation: gcBob 1s ease-in-out infinite; }
.gacha-msg { color: var(--text-soft); }
.gacha-reveal { animation: gcPop .5s ease; }
.gacha-item-thumb { margin: 0 auto; }
.gacha-item-name { font-weight: 800; font-size: 1.1rem; margin-top: 8px; }
.gacha-item-rarity { font-size: .78rem; font-weight: 700; letter-spacing: .05em; }
.gacha-note { color: var(--text-soft); font-size: .8rem; margin-top: 10px; }

/* 등급 색 */
.rarity-common .gacha-item-rarity, .item-card.rarity-common .item-meta { color: #6b7f70; }
.rarity-rare .gacha-item-rarity { color: #3b7fb0; }
.rarity-epic .gacha-item-rarity { color: #a3519a; }
.item-card.rarity-rare { box-shadow: 0 0 0 2px #cfe3f3 inset; }
.item-card.rarity-epic { box-shadow: 0 0 0 2px #ecd3f0 inset; }

/* 옷장 미리보기 */
.closet-preview { text-align: center; }
.closet-slots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.slot-chip {
  display: flex; align-items: center; gap: 6px; background: #f3f8f0;
  border-radius: 999px; padding: 6px 12px; font-size: .82rem;
}
.slot-label { font-weight: 700; color: var(--green-dark); }
.slot-item { color: var(--text-soft); }
.slot-off { border: none; background: #e2b4ab; color: #fff; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: .7rem; line-height: 1; }

/* 아이템 그리드 */
.item-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.item-card {
  background: #fff; border-radius: var(--radius-sm); padding: 12px; text-align: center;
  box-shadow: var(--shadow-soft);
}
.item-card.is-locked { opacity: .7; }
.item-card.is-equipped { outline: 2px solid var(--green); }
.item-thumb { display: flex; justify-content: center; }
.item-lock { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; background: #eef2ec; border-radius: 14px; }
.item-name { font-weight: 700; margin-top: 6px; font-size: .9rem; }
.item-meta { font-size: .76rem; color: var(--text-soft); margin-bottom: 8px; }
.item-cond { font-size: .76rem; color: var(--text-soft); }
.item-card .btn-equip { width: 100%; padding: 8px; font-size: .85rem; }
.count { font-size: .85rem; color: var(--text-soft); font-weight: 700; }

/* 배지 그리드 */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge-card {
  background: #fff; border-radius: var(--radius-sm); padding: 16px; text-align: center;
  box-shadow: var(--shadow-soft); opacity: .72;
}
.badge-card.is-earned { opacity: 1; outline: 2px solid var(--accent-yellow); }
.badge-emoji { font-size: 2rem; }
.badge-name { font-weight: 800; margin-top: 4px; }
.badge-desc { font-size: .78rem; color: var(--text-soft); margin: 4px 0 8px; }
.badge-earned { color: var(--green-dark); font-weight: 700; font-size: .82rem; }
.badge-prog { font-size: .76rem; color: var(--text-soft); margin-top: 4px; }

/* 축하 모달 */
.modal-celebrate { text-align: center; }
.celebrate-emoji { font-size: 3rem; animation: gcPop .6s ease; }

@media (min-width: 768px) {
  .item-grid { grid-template-columns: repeat(3, 1fr); }
  .badge-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .item-grid { grid-template-columns: repeat(4, 1fr); }
  .badge-grid { grid-template-columns: repeat(4, 1fr); }
}
