/* style.css — TrailTrip 가파도 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;900&family=Space+Mono:wght@400;700&display=swap');

:root {
  --bg:        #0a1628;
  --bg2:       #0f1e35;
  --bg3:       #162540;
  --card:      #1a2d48;
  --border:    #243a56;
  --accent:    #3dd68c;
  --accent2:   #2ab97a;
  --amber:     #f5a623;
  --red:       #ff5f5f;
  --blue:      #4a9eff;
  --text:      #e8f0f8;
  --text2:     #8ba4c0;
  --text3:     #4a6580;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior: none;
}

/* ── 앱 컨테이너 ── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── 화면 전환 ── */
.screen { display: none; flex-direction: column; flex: 1; }
.screen.active { display: flex; }

/* ── 로그인 화면 ── */
#screen-login {
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: 40px 24px;
  background: radial-gradient(ellipse at 50% 0%, #162540 0%, #0a1628 70%);
}

.login-hero {
  text-align: center;
  margin-bottom: 48px;
}

.login-logo {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 20px;
}

.login-title {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #e8f0f8 0%, #3dd68c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-sub {
  color: var(--text2);
  font-size: 14px;
}

.login-course-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 32px;
}

.login-course-badge {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.login-course-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-course-stats {
  display: flex;
  gap: 16px;
}

.login-course-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.login-course-stat span:first-child {
  font-size: 11px;
  color: var(--text3);
}

.login-course-stat span:last-child {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.kakao-btn {
  width: 100%;
  padding: 16px;
  background: #FEE500;
  color: #191919;
  border: none;
  border-radius: var(--radius);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s, opacity 0.15s;
}

.kakao-btn:active { transform: scale(0.98); opacity: 0.9; }

.kakao-btn svg { width: 22px; height: 22px; }

/* ── 상단 헤더 ── */
.topbar {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 10px; }

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  object-fit: cover;
  background: var(--bg3);
}

.topbar-name {
  font-size: 14px;
  font-weight: 700;
}

.topbar-logo {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.1em;
}

/* ── 탭바 ── */
.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  position: sticky;
  bottom: 0;
  z-index: 100;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border: none;
  background: none;
  color: var(--text3);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.tab-btn.active { color: var(--accent); }
.tab-btn svg { width: 22px; height: 22px; }

/* ── 공통 스크롤 영역 ── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── 카드 ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ── 지도 탭 ── */
.map-container {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg3);
}

#map { width: 100%; height: 52dvh; min-height: 320px; }

.map-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.stat-label {
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 4px;
}

.stat-value {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.map-fab {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.fab:active { transform: scale(0.92); }
.fab.primary { background: var(--accent); color: #0a1628; border-color: var(--accent); }

/* ── 버튼들 ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  width: 100%;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #0a1628; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(255,95,95,0.15); color: var(--red); border: 1px solid rgba(255,95,95,0.3); }
.btn-amber { background: rgba(245,166,35,0.15); color: var(--amber); border: 1px solid rgba(245,166,35,0.3); }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; border-radius: var(--radius-sm); }

.btn-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ── 폼 요소 ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text2); font-weight: 700; letter-spacing: 0.05em; }

input[type=text], input[type=date], select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 100px; }
select option { background: var(--bg3); }

.field-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; }

/* ── 사진 미리보기 ── */
.photo-preview {
  width: 100%;
  height: 160px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 13px;
  overflow: hidden;
  background: var(--bg3);
  cursor: pointer;
  position: relative;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── 좌표 표시 ── */
.coords-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text2);
}

/* ── 스팟 리스트 ── */
.spot-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spot-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.spot-item-title { font-size: 14px; font-weight: 700; }
.spot-item-desc { font-size: 13px; color: var(--text2); }
.spot-item-meta { font-size: 11px; color: var(--text3); font-family: 'Space Mono', monospace; }

.spot-item img {
  width: 100%;
  border-radius: 8px;
  margin-top: 4px;
  max-height: 200px;
  object-fit: cover;
}

/* ── 태그 ── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(61,214,140,0.15);
  color: var(--accent);
  border: 1px solid rgba(61,214,140,0.3);
}

.tag-amber { background: rgba(245,166,35,0.15); color: var(--amber); border-color: rgba(245,166,35,0.3); }
.tag-red { background: rgba(255,95,95,0.15); color: var(--red); border-color: rgba(255,95,95,0.3); }
.tag-blue { background: rgba(74,158,255,0.15); color: var(--blue); border-color: rgba(74,158,255,0.3); }

/* ── 편지 화면 ── */
.letter-locked {
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.letter-lock-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.letter-unlock-date {
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  color: var(--accent);
  font-weight: 700;
}

.letter-days-left {
  color: var(--text2);
  font-size: 14px;
}

.letter-content {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text);
}

/* ── 완주 배지 ── */
.complete-banner {
  background: linear-gradient(135deg, rgba(61,214,140,0.2), rgba(61,214,140,0.05));
  border: 1px solid rgba(61,214,140,0.4);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.complete-banner h3 { font-size: 20px; color: var(--accent); margin-bottom: 6px; }
.complete-banner p { font-size: 13px; color: var(--text2); }

/* ── 섹션 헤더 ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── 빈 상태 ── */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text3);
  font-size: 14px;
}

/* ── 로딩 ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text2);
  gap: 10px;
  font-size: 14px;
}

/* ── 토스트 알림 ── */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
  max-width: calc(100% - 40px);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#toast.success { border-color: var(--accent); color: var(--accent); }
#toast.error { border-color: var(--red); color: var(--red); }

/* ── 진행률 바 ── */
.progress-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* ── 체크포인트 ── */
.checkpoint-list { display: flex; flex-direction: column; gap: 0; }

.checkpoint-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  position: relative;
}

.checkpoint-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

.checkpoint-dot.done { background: var(--accent); border-color: var(--accent); }
.checkpoint-dot.current { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 4px rgba(245,166,35,0.2); }

.checkpoint-line {
  position: absolute;
  left: 7px;
  top: 28px;
  bottom: -12px;
  width: 2px;
  background: var(--border);
}

.checkpoint-line.done { background: var(--accent); }

.checkpoint-info { flex: 1; }
.checkpoint-name { font-size: 14px; font-weight: 700; }
.checkpoint-km { font-size: 12px; color: var(--text2); font-family: 'Space Mono', monospace; }
.checkpoint-facilities { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* ── 반응형 ── */
@media (max-width: 380px) {
  .map-stats { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
}
