/* ============================================
   별의 기억 - 메인 스타일시트
   모바일 퍼스트 반응형 디자인
   ============================================ */

/* --- CSS Variables (컬러 시스템) --- */
:root {
  --primary: #8B7FD6;
  --secondary: #B8A5E8;
  --accent: #FFD4E5;
  --dark: #2D1B4E;
  --bg-gradient: linear-gradient(135deg, #1a0933, #2d1b4e, #4a2c6f);
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --error: #FF6B8A;
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.12);
  --input-bg: rgba(255, 255, 255, 0.1);
  --input-border: rgba(184, 165, 232, 0.3);
  --input-focus: var(--secondary);
  --radius: 16px;
  --radius-sm: 10px;
}

/* --- 리셋 & 기본 --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- 화면 전환 --- */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px 0;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
}

/* --- 배경 별 --- */
#stars-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
}

/* --- 메인 타이틀 --- */
.main-title {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--secondary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* --- 카드 --- */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.input-card {
  position: relative;
  z-index: 1;
}

/* --- 입력 그룹 --- */
.input-group {
  margin-bottom: 22px;
}

.input-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.label-icon {
  margin-right: 4px;
  font-size: 1.1rem;
}

/* --- 입력 필드 --- */
.input-field {
  width: 100%;
  padding: 14px 16px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.25s, box-shadow 0.25s;
  appearance: none;
  -webkit-appearance: none;
}

.input-field:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(184, 165, 232, 0.2);
}

/* date/select 컬러 스킴 */
.input-field::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

select.input-field {
  cursor: pointer;
}

select.input-field option {
  background: var(--dark);
  color: var(--text-primary);
}

/* --- 시간 선택 행 --- */
.time-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-select {
  flex: 1;
}

.time-separator {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--secondary);
}

/* --- 체크박스 --- */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--input-border);
  border-radius: 4px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* --- 에러 메시지 --- */
.error-message {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 6px;
  min-height: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.error-message.visible {
  opacity: 1;
}

/* --- 버튼 --- */
.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.25s;
  letter-spacing: 0.02em;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:hover {
  box-shadow: 0 4px 24px rgba(139, 127, 214, 0.4);
}

.btn-submit {
  margin-top: 8px;
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* --- 로딩 화면 --- */
#loading-screen .container {
  text-align: center;
  font-size: 1.1rem;
  color: var(--secondary);
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loading-icon {
  font-size: 4rem;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.loading-text {
  font-size: 1.1rem;
  color: var(--secondary);
}

.progress-bar-track {
  width: 100%;
  max-width: 280px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.loading-percent {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.loading-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 12px;
}

/* ============================================
   결과 화면 스타일
   ============================================ */

#result-screen {
  padding: 40px 0;
}

#result-screen.active {
  display: block;
}

.result-container {
  max-width: 520px;
}

/* --- 결과 헤더 --- */
.result-header {
  text-align: center;
  margin-bottom: 32px;
}

.result-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.birth-info {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* --- 스토리 섹션 --- */
.story-section {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.story-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  text-align: center;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  text-align: center;
  line-height: 1.4;
}

/* 핵심 정체성 섹션의 summary 제목 - 더 강렬하게 */
[data-section="identity"] .section-title {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.4;
  margin-bottom: 20px;
  padding: 0 10px;
}

.section-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
  text-align: justify;
  word-break: keep-all;
}

/* --- 섹션별 세부 레이아웃 --- */
.identity-grid,
.pastlife-content,
.love-content,
.thisyear-content,
.why-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.identity-grid > div,
.identity-item,
.pastlife-content > div,
.pastlife-item,
.love-content > div,
.love-item,
.thisyear-content > div,
.thisyear-item,
.why-content > div,
.why-item {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.2rem;
  border-radius: 8px;
}

.identity-item.highlight,
.love-item.highlight,
.thisyear-item.highlight {
  background: rgba(139, 127, 214, 0.1);
  border-left-color: var(--secondary);
}

.why-item.warning {
  background: rgba(255, 107, 138, 0.08);
  border-left-color: var(--error);
}

.identity-label,
.pastlife-label,
.love-label,
.thisyear-label,
.why-label,
.identity-grid h3,
.pastlife-content h3,
.love-content h3,
.thisyear-content h3,
.why-content h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: -0.01em;
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.identity-content,
.pastlife-item p,
.love-item p,
.thisyear-item p,
.why-item p {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin: 0;
}

/* --- 재능/상처 카드 --- */
.gift-cards,
.wound-cards {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.gift-card,
.wound-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(139, 127, 214, 0.2);
}

.gift-card .card-title,
.wound-card .card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: -0.01em;
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.gift-card .card-desc,
.wound-card .card-pattern {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.wound-card .card-reframe {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--primary);
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.wound-card .card-reframe::before {
  content: "다르게 보면: ";
  font-weight: 600;
  color: var(--primary);
}

/* --- 액션 버튼 영역 --- */
.action-buttons {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- 에러 상태 --- */
.error-state {
  text-align: center;
  padding: 40px 20px;
}

.error-state .error-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.error-state .error-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--error);
}

.error-state .error-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ============================================
   랜딩 화면 스타일
   ============================================ */

.landing-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
}

.landing-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}

.landing-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

.landing-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent), var(--secondary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subtitle {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.landing-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.btn-start {
  padding: 18px 48px;
  font-size: 1.15rem;
}

.landing-footer {
  padding-bottom: 40px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 12px;
  transition: color 0.2s;
}

.btn-text:hover {
  color: var(--secondary);
}

/* ============================================
   보관함 화면 스타일
   ============================================ */

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-top: 20px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
}

.screen-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.archive-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.archive-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.archive-item:active {
  transform: scale(0.98);
}

.archive-info {
  flex: 1;
}

.archive-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.archive-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.archive-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon.delete:hover {
  color: var(--error);
}

.archive-empty {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-text {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ============================================
   설정 화면 스타일
   ============================================ */

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-group {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
}

.settings-group-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--card-border);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.settings-value {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.settings-btn-danger {
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  background: rgba(255, 107, 138, 0.1);
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.settings-btn-danger:hover {
  background: rgba(255, 107, 138, 0.2);
}

.settings-link {
  display: block;
  padding: 12px 0;
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.95rem;
}

.settings-footer {
  text-align: center;
  padding: 40px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ============================================
   하단 네비게이션
   ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(26, 9, 51, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav.hidden {
  display: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  cursor: pointer;
  padding: 8px 20px;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--secondary);
}

.nav-icon {
  font-size: 1.3rem;
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 500;
}

/* ============================================
   토스트 메시지
   ============================================ */

.toast-message {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(45, 27, 78, 0.95);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 12px 24px;
  color: var(--text-primary);
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  white-space: nowrap;
}

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

/* ============================================
   유틸리티 클래스
   ============================================ */

.hidden {
  display: none !important;
}

/* ============================================
   반응형 (태블릿 이상)
   ============================================ */

@media (min-width: 601px) {
  .main-title {
    font-size: 2.2rem;
  }

  .card {
    padding: 36px 32px;
  }

  .landing-title {
    font-size: 3rem;
  }

  .landing-subtitle {
    font-size: 1.25rem;
  }

  .bottom-nav {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
  }
}

/* ============================================
   작은 화면 (iPhone SE 등)
   ============================================ */

@media (max-width: 374px) {
  .main-title {
    font-size: 1.5rem;
  }

  .landing-title {
    font-size: 2rem;
  }

  .landing-subtitle {
    font-size: 1rem;
  }

  .card {
    padding: 20px 16px;
  }

  .input-field {
    padding: 12px 14px;
    font-size: 0.95rem;
  }

  .btn-primary {
    padding: 14px;
    font-size: 1rem;
  }
}

/* ============================================
   가로 모드 대응
   ============================================ */

@media (orientation: landscape) and (max-height: 500px) {
  .screen {
    min-height: auto;
    padding: 20px 0;
  }

  .landing-content {
    padding: 20px 0;
  }

  .landing-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
  }

  .landing-title {
    font-size: 1.8rem;
    margin-bottom: 8px;
  }
}
