/* public/style.css */

:root {
  --bg-deep: #1a1a1f;
  --bg-mid: #25252e;
  --bg-light: #2f2f3a;

  --text: #f5f3f0;
  --text-warm: #e8e5e0;
  --text-dim: #b8b5b0;

  --accent-warm: #f0c674;
  --accent-soft: #d4a574;
}

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

/* ✅ 페이지 스크롤 방지 */
html,
body {
  height: 100%;
  overflow: hidden;
  background: #0a0a0f;
}

/* iOS Safari에서 주소창 등장/숨김 시 튀는 현상 완화 */
html {
  height: -webkit-fill-available;
}

body {
  /* 기본 */
  min-height: 100vh;
  /* 최신 브라우저용: 동적 뷰포트 기준 */
  min-height: 100dvh;
  /* iOS Safari용 */
  min-height: -webkit-fill-available;
}

.container {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

body {
  font-family: "Noto Sans KR", sans-serif;
  background: linear-gradient(
    135deg,
    var(--bg-deep) 0%,
    var(--bg-mid) 50%,
    var(--bg-light) 100%
  );
  color: var(--text-warm);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(240, 198, 116, 0.03) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 520px;
  width: 100%;
  height: 100%;
  /* 뷰포트 높이 변화에도 카드가 위로 튀지 않도록 */
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px
    calc(20px + env(safe-area-inset-bottom, 0px));
  position: relative;
  z-index: 1;
}

/* screens */
.screen {
  display: none;
  height: 100%;
}
.screen.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* header */
.page-header {
  flex: 0 0 auto;
  text-align: center;
  padding-top: 8px;
}
.page-header.compact h1 {
  margin-bottom: 8px;
}
.page-header.compact .subtitle {
  margin-bottom: 14px;
}

h1 {
  font-size: 56px;
  text-align: center;
  margin-bottom: 12px;
  font-weight: 400;
  letter-spacing: 16px;
  color: var(--text);
}

.subtitle {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 40px;
  font-size: 15px;
  font-weight: 300;
  letter-spacing: 4px;
  line-height: 1.8;
}

label {
  display: block;
  margin-bottom: 16px;
  font-size: 15px;
  color: var(--text-dim);
  font-weight: 300;
  text-align: center;
}

textarea {
  width: 100%;
  min-height: 160px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(240, 198, 116, 0.2);
  border-radius: 16px;
  padding: 24px;
  color: var(--text-warm);
  font-size: 17px;
  line-height: 1.8;
  font-family: "Noto Sans KR", sans-serif;
  font-weight: 300;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

textarea:focus {
  outline: none;
  border-color: rgba(240, 198, 116, 0.4);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 30px rgba(240, 198, 116, 0.15);
}

textarea::placeholder {
  color: #6a6a70;
  line-height: 1.8;
}

/* buttons */
button {
  width: 100%;
  padding: 18px;
  background: linear-gradient(
    135deg,
    rgba(240, 198, 116, 0.15) 0%,
    rgba(212, 165, 116, 0.15) 100%
  );
  border: 1.5px solid rgba(240, 198, 116, 0.3);
  border-radius: 16px;
  color: var(--text);
  font-size: 16px;
  font-family: "Noto Sans KR", sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 400;
  letter-spacing: 1px;
}

button:hover {
  background: linear-gradient(
    135deg,
    rgba(240, 198, 116, 0.2) 0%,
    rgba(212, 165, 116, 0.2) 100%
  );
  border-color: rgba(240, 198, 116, 0.5);
  box-shadow: 0 8px 30px rgba(240, 198, 116, 0.2);
  transform: translateY(-2px);
}
button:active {
  transform: translateY(0);
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
}
.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* start */
#startScreen {
  justify-content: center;
  align-items: center;
}
.start-content {
  width: 100%;
  transform: translateY(-20px);
}

/* guide */
.guide-text {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
}
.guide-text p {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-weight: 300;
  line-height: 1.8;
}
.guide-text strong {
  color: var(--accent-soft);
  font-weight: 400;
}
.guide-text .examples {
  font-size: 12px;
  color: #8a8a90;
  line-height: 2;
}
.disclaimer {
  text-align: center;
  font-size: 12px;
  color: #6a6a70;
  margin-top: 22px;
  line-height: 1.8;
  font-weight: 300;
}

/* loading */
#loadingScreen {
  justify-content: center;
  align-items: center;
}
.loading-container {
  text-align: center;
}
.loading-text {
  font-size: 15px;
  color: var(--text-dim);
  font-weight: 300;
  letter-spacing: 1.5px;
}
.gap-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0.7;
}
.gap-icon span {
  display: block;
  width: 6px;
  height: 100%;
  background: rgba(240, 198, 116, 0.6);
  border-radius: 4px;
  animation: gapPulse 2.4s ease-in-out infinite;
}
.gap-icon span:last-child {
  animation-delay: 1.2s;
}
@keyframes gapPulse {
  0%,
  100% {
    transform: scaleY(0.6);
    opacity: 0.4;
  }
  50% {
    transform: scaleY(1);
    opacity: 0.9;
  }
}

/* conversation */
#conversationScreen {
  justify-content: flex-start;
}
.conversation-history {
  /* 히스토리가 전체를 먹지 않도록 제한 */
  flex: 0 1 auto;
  max-height: 35vh;
  overflow-y: auto;
  padding: 10px 6px 12px;
  margin-bottom: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.history-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  opacity: 0.6;
}
.history-label {
  font-size: 12px;
  color: #8a8a90;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.history-text {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 6px;
  line-height: 1.7;
}
.history-answer {
  font-size: 15px;
  color: var(--text-warm);
  line-height: 1.8;
  white-space: pre-line;
}
.current-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 30px;
  position: sticky;
  top: 20px;
  z-index: 10;
  /* Safari 주소창 영역 여유 */
  margin-bottom: 80px;
}
/* 모바일 최적화 */
@media (max-width: 480px) {
  .current-card {
    top: 10px;
    padding: 20px;
  }
}
.current-question {
  font-size: 16px;
  color: var(--text);
  font-weight: 300;
  line-height: 1.8;
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.answer-input {
  min-height: 84px;
  max-height: 132px;
  overflow-y: auto;
  resize: none;
  margin-bottom: 10px;
}
.nav-row {
  display: flex;
  gap: 10px;
}
.nav-row button {
  width: 100%;
  padding: 16px;
}

/* breath */
#breathScreen {
  justify-content: flex-start;
}
.breath-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center; /* ✅ 중앙 */
  align-items: center;
  text-align: center;
  padding-bottom: 10px;
}

/* ✅ breath circle: 반드시 크기/테두리/배경 지정 */
.breath-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  margin: 0 auto 34px;

  background: radial-gradient(
    circle,
    rgba(240, 198, 116, 0.06) 0%,
    transparent 70%
  );
  border: 2px solid rgba(240, 198, 116, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;

  animation: gentleBreathe 6s ease-in-out infinite;
}

#breathText {
  font-size: 18px;
  color: var(--text);
  font-weight: 300;
  letter-spacing: 2px;
}

@keyframes gentleBreathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
    border-color: rgba(240, 198, 116, 0.2);
  }
  50% {
    transform: scale(1.1);
    opacity: 0.95;
    border-color: rgba(240, 198, 116, 0.4);
  }
}

.breath-instruction {
  font-size: 16px;
  margin-bottom: 18px;
  color: var(--text-dim);
  font-weight: 300;
  letter-spacing: 2px;
}

.timer {
  font-size: 42px;
  color: var(--accent-warm);
  font-weight: 300;
  letter-spacing: 4px;
  margin-bottom: 18px;
}

/* letter */
#letterScreen {
  justify-content: flex-start;
}
.letter-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.letter-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(240, 198, 116, 0.15);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 18px;
  line-height: 2.1;
  font-size: 17px;
  font-weight: 300;
  white-space: pre-line;
  color: var(--text-warm);
}

/* drag */
#dragScreen {
  justify-content: flex-start;
}
.switch-screen-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 420px;
}
.switch-top-spacer {
  flex: 0.12;
}
.switch-center-container {
  flex: 0.6;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.you-circle {
  position: absolute;
  left: 30%;
  top: 40%;
  opacity: 1;
}
.you-circle-inner {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.05)
  );
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.you-circle-label {
  font-size: 0.95em;
  color: var(--text);
  font-weight: 300;
  letter-spacing: 1px;
}

/* ✅ thought circle must MOVE */
#thoughtCircleDrag {
  position: absolute;
  left: calc(30% + 90px);
  top: calc(40% + 14px);
  cursor: grab;
  user-select: none;
  touch-action: none;
  z-index: 10;
}
#thoughtCircleDrag.dragging {
  cursor: grabbing;
}
.thought-circle-inner {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(240, 198, 116, 0.16),
    rgba(240, 198, 116, 0.06)
  );
  border: 2px solid rgba(240, 198, 116, 0.22);
  box-shadow: 0 0 25px rgba(240, 198, 116, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.thought-circle-label {
  font-size: 0.8em;
  color: var(--text-warm);
  font-weight: 300;
  pointer-events: none;
}

#connectionLine {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 1;
  pointer-events: none;
}
#connectPath {
  stroke: rgba(240, 198, 116, 0.25);
  stroke-width: 2;
  stroke-dasharray: 6, 6;
}

.switch-bottom-container {
  flex: 0.28;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 6px;
}
.drag-instruction {
  text-align: center;
  font-size: 1.05em;
  color: var(--text-dim);
  font-weight: 300;
  line-height: 1.6;
}
.drag-instruction-detail {
  font-size: 0.85em;
  color: #8a8a90;
  margin-top: 8px;
}
.drag-complete-block {
  display: none;
  text-align: center;
  animation: fadeInSoft 0.4s ease-out;
}
@keyframes fadeInSoft {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.complete-message-title {
  font-size: 1.1em;
  line-height: 1.9;
  margin: 0 0 10px 0;
  font-weight: 300;
  color: #f0ede8;
}
.complete-message-subtitle {
  font-size: 0.95em;
  line-height: 1.6;
  margin: 0 0 14px 0;
  font-weight: 300;
  color: #c8c5c0;
}

/* actions */
#actionScreen {
  justify-content: flex-start;
}
.action-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.action-box {
  background: linear-gradient(
    135deg,
    rgba(240, 198, 116, 0.08) 0%,
    rgba(212, 165, 116, 0.08) 100%
  );
  border: 1px solid rgba(240, 198, 116, 0.25);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 18px;
}
.action-box strong {
  color: var(--accent-warm);
  font-size: 14px;
  display: block;
  margin-bottom: 14px;
  font-weight: 400;
  letter-spacing: 1px;
}
.action-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.action-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px 16px;
  cursor: pointer;
  transition: all 0.25s ease;
  line-height: 1.7;
  font-weight: 300;
}
.action-item::before {
  content: "□";
  margin-right: 10px;
  color: #a8a5a0;
}
.action-item.checked::before {
  content: "✓";
  color: var(--text);
}
.action-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateX(3px);
}

/* SOS top-right */
.crisis-top {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  background: rgba(255, 107, 107, 0.14);
  border: 1.5px solid rgba(255, 107, 107, 0.35);
  border-radius: 999px;
  padding: 10px 14px;
  text-decoration: none;
  color: #ffb0b0;
  font-size: 12px;
  letter-spacing: 1px;
  z-index: 999;
  transition: all 0.25s ease;
}
.crisis-top:hover {
  background: rgba(255, 107, 107, 0.22);
  border-color: rgba(255, 107, 107, 0.5);
  transform: translateY(-1px);
}

/* responsive */
@media (max-width: 600px) {
  h1 {
    font-size: 44px;
    letter-spacing: 12px;
  }
  .subtitle {
    font-size: 14px;
    letter-spacing: 3px;
  }
  textarea {
    font-size: 16px;
    min-height: 140px;
    padding: 20px;
  }
  .breath-circle {
    width: 170px;
    height: 170px;
  }
  .letter-box {
    font-size: 16px;
    padding: 24px;
  }
  .nav-row button {
    padding: 14px;
  }
}
