/* style.css — BuddyBot */

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background-color: #1a1a2e;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #ffffff;
  user-select: none; -webkit-user-select: none;
}

/* ── 메인 ── */
#app {
  width: 100vw; height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}

#buddy-face {
  width: 80vmin; height: 80vmin;
  max-width: 400px; max-height: 400px;
  cursor: pointer;
  -webkit-touch-callout: none; touch-action: none;
}

#face-group {
  will-change: transform, opacity;
  transition: opacity 0.15s ease;
}

/* 눈/입: d 속성 전환 (같은 구조의 path 간에만 부드럽게 보간됨) */
.face-elem {
  will-change: d, opacity;
}
.eye  { fill: #ffffff; }
.mouth { fill: none; stroke: #ffffff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* 눈썹 */
.brow {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0.9;
}

#state-label {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: rgba(255,255,255,0.2); pointer-events: none; display: none;
}

#hint {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: rgba(255,255,255,0.25); text-align: center;
  pointer-events: none; animation: hint-fade 4s ease 3s forwards;
}
@keyframes hint-fade { 0% { opacity:1; } 100% { opacity:0; } }

/* ── 텍스트 입력 폴백 ── */
#text-fallback {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: none; align-items: center; gap: 8px; padding: 12px 16px;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px); z-index: 100;
}
#text-input {
  flex: 1; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3); border-radius: 24px;
  padding: 10px 16px; color: #fff; font-size: 16px; outline: none;
}
#text-input::placeholder { color: rgba(255,255,255,0.4); }
#text-send {
  background: #4a9eff; color: #fff; border: none; border-radius: 24px;
  padding: 10px 20px; font-size: 15px; cursor: pointer; white-space: nowrap;
}

/* ── 토스트 ── */
#toast {
  position: fixed; top: 24px; left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(0,0,0,0.8); color: #fff; padding: 10px 20px;
  border-radius: 20px; font-size: 14px; z-index: 999;
  transition: transform 0.3s ease; white-space: nowrap; pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ════════════════════════════════
   온보딩
════════════════════════════════ */
.onboarding-wrap {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: 40px; z-index: 500;
  background: transparent;
  pointer-events: none;
}
.onboarding-wrap[hidden] { display: none !important; }

/* 말풍선 */
.ob-bubble {
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 18px 18px 18px 4px;
  padding: 14px 18px; max-width: 80vw;
  font-size: 16px; line-height: 1.5; color: #fff;
  margin-bottom: 20px; pointer-events: none;
  animation: bubble-in 0.3s ease;
  align-self: flex-start; margin-left: 24px;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 스텝 콘텐츠 */
.ob-step {
  width: 100%; padding: 0 20px;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: auto;
  animation: slide-up 0.3s ease;
}
.ob-step[hidden] { display: none !important; }
@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 텍스트 입력 (온보딩) */
.ob-field { display: flex; flex-direction: column; gap: 5px; }
.ob-field-label { font-size: 12px; color: rgba(255,255,255,0.45); letter-spacing: 0.03em; }

.ob-input, .ob-textarea {
  width: 100%; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25); border-radius: 12px;
  padding: 13px 16px; color: #fff; font-size: 17px; outline: none;
  font-family: inherit; resize: none;
}
.ob-input::placeholder, .ob-textarea::placeholder { color: rgba(255,255,255,0.35); }
.ob-textarea { font-size: 14px; line-height: 1.5; }

/* 선택지 버튼 */
.ob-choices {
  display: flex; flex-direction: column; gap: 8px;
}
.ob-choices.inline {
  flex-direction: row; flex-wrap: wrap; gap: 8px;
}
.ob-choice {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 12px;
  padding: 12px 16px; color: rgba(255,255,255,0.85);
  font-size: 15px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  transition: background 0.15s, border-color 0.15s;
}
.ob-choices.inline .ob-choice {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 13px;
  text-align: center; align-items: center;
}
.ob-choice small { font-size: 11px; color: rgba(255,255,255,0.4); }
.ob-choice:active, .ob-choice.selected {
  background: rgba(74,158,255,0.25);
  border-color: #4a9eff; color: #fff;
}

/* 칩 (복수 선택) */
.ob-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.ob-chip {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 20px;
  padding: 8px 14px; color: rgba(255,255,255,0.75);
  font-size: 13px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ob-chip:active, .ob-chip.selected {
  background: rgba(74,158,255,0.25);
  border-color: #4a9eff; color: #fff;
}

/* 온보딩 버튼 */
.ob-btn-next {
  background: #4a9eff; color: #fff; border: none; border-radius: 12px;
  padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}
.ob-btn-finish {
  background: #4a9eff; color: #fff; border: none; border-radius: 12px;
  padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}
.ob-btn-skip {
  background: transparent; color: rgba(255,255,255,0.4);
  border: none; font-size: 13px; cursor: pointer; padding: 8px; width: 100%;
  text-align: center;
}
.ob-summary {
  background: rgba(255,255,255,0.07); border-radius: 12px;
  padding: 14px 16px; font-size: 14px; line-height: 1.6;
  color: rgba(255,255,255,0.8); margin-bottom: 4px;
}

/* ════════════════════════════════
   설정 패널
════════════════════════════════ */
#settings-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
#settings-overlay.visible { opacity: 1; pointer-events: auto; }

#settings-panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #16213e; border-radius: 20px 20px 0 0;
  padding: 24px 20px 40px; z-index: 300;
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}
#settings-panel.open { transform: translateY(0); }
#settings-panel::-webkit-scrollbar { width: 4px; }
#settings-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.settings-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.settings-header h2 { font-size: 20px; font-weight: 600; color: #e0e0e0; }
#settings-close {
  background: rgba(255,255,255,0.1); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* 탭 */
.settings-tabs {
  display: flex; gap: 4px; background: rgba(255,255,255,0.06);
  border-radius: 10px; padding: 4px; margin-bottom: 20px;
}
.stab {
  flex: 1; background: transparent; border: none; color: rgba(255,255,255,0.5);
  padding: 9px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.stab.active { background: rgba(255,255,255,0.12); color: #fff; }

.stab-panel { display: none; }
.stab-panel.active { display: block; }

/* 설정 그룹 */
.settings-group { margin-bottom: 18px; }
.settings-group label {
  display: block; font-size: 12px; color: rgba(255,255,255,0.45);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em;
}
.settings-group input[type="text"],
.settings-group input[type="password"],
.settings-group select,
.settings-group textarea {
  width: 100%; background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 10px;
  padding: 12px 14px; color: #fff; font-size: 15px; outline: none;
  appearance: none; -webkit-appearance: none; font-family: inherit;
}
.settings-group textarea { resize: none; font-size: 14px; line-height: 1.5; }
.settings-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23ffffff80' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
.settings-group input[type="color"] {
  width: 60px; height: 40px; border: none; border-radius: 8px;
  cursor: pointer; padding: 2px; background: transparent;
}

/* 설정 버튼 */
.settings-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.btn-primary {
  background: #4a9eff; color: #fff; border: none; border-radius: 12px;
  padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn-secondary {
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 12px;
  padding: 12px; font-size: 14px; cursor: pointer; width: 100%;
}
.btn-danger {
  background: rgba(255,80,80,0.12); color: #ff7070;
  border: 1px solid rgba(255,80,80,0.3); border-radius: 12px;
  padding: 12px; font-size: 14px; cursor: pointer; width: 100%;
}
