/* ============================================================
   말씀 나눔 (BNSD) — 디자인 시스템
   따뜻하고 경건한 가톨릭 테마
   ============================================================ */

/* ── 디자인 토큰 (CSS 변수) ── */
:root {
  /* 색상 */
  --bg-primary: #FAF7F2;
  --bg-secondary: #F3EDE4;
  --bg-card: #FFFFFF;
  --bg-overlay: rgba(61, 44, 46, 0.5);
  --bg-highlight: #FFF8ED;

  --text-primary: #3D2C2E;
  --text-secondary: #6B5B5E;
  --text-muted: #9B8E90;
  --text-inverse: #FAF7F2;

  --accent-gold: #B8860B;
  --accent-gold-light: #D4A843;
  --accent-wine: #722F37;
  --accent-wine-light: #9B4D56;
  --accent-cream: #F5E6C8;

  --border-light: #E8DDD3;
  --border-gold: rgba(184, 134, 11, 0.3);

  --gradient-gold: linear-gradient(135deg, #B8860B, #D4A843);
  --gradient-wine: linear-gradient(135deg, #722F37, #9B4D56);
  --gradient-accent: linear-gradient(135deg, #B8860B 0%, #722F37 100%);

  /* 그림자 */
  --shadow-sm: 0 1px 3px rgba(61, 44, 46, 0.06);
  --shadow-md: 0 4px 12px rgba(61, 44, 46, 0.08);
  --shadow-lg: 0 8px 24px rgba(61, 44, 46, 0.12);
  --shadow-glow: 0 0 20px rgba(184, 134, 11, 0.15);

  /* 간격 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* 둥글기 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* 폰트 */
  --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Noto Serif KR', Georgia, serif;

  /* 트랜지션 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 레이아웃 ── */
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

.page-section {
  display: none;
  padding: var(--space-lg) var(--space-md);
  animation: fadeIn var(--transition-normal);
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 상단 장식 라인 ── */
.top-decoration {
  height: 3px;
  background: var(--gradient-accent);
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

/* ── 헤더 내비게이션 ── */
.nav-header {
  display: flex;
  align-items: center;
  padding: var(--space-md) 0;
  margin-bottom: var(--space-lg);
}

.btn-back {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.btn-back:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-back svg {
  width: 18px;
  height: 18px;
}

/* ============================================================
   메인 페이지 (#home)
   ============================================================ */
.home.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}

.home__cross {
  font-size: 3rem;
  margin-bottom: var(--space-lg);
  opacity: 0.7;
  animation: gentleFloat 3s ease-in-out infinite;
}

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

.home__title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.home__subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2xl);
  letter-spacing: 0.02em;
}

.home__divider {
  width: 60px;
  height: 2px;
  background: var(--gradient-accent);
  margin: 0 auto var(--space-2xl);
  border-radius: var(--radius-full);
}

.home__buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
  max-width: 300px;
}

/* ── 버튼 공통 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  line-height: 1.4;
}

.btn--primary {
  background: var(--gradient-accent);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

.btn--primary:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: translateY(-2px);
}

.btn--primary:active {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.btn--secondary:hover {
  border-color: var(--accent-gold-light);
  color: var(--accent-gold);
  box-shadow: var(--shadow-md);
}

.btn--full {
  width: 100%;
}

.btn--sm {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
}

.btn--loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn--loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  right: var(--space-md);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   나눔 참여 페이지 (#sharing)
   ============================================================ */
.sharing__header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.sharing__date {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.sharing__liturgy {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-wine);
}

.sharing__divider {
  width: 40px;
  height: 2px;
  background: var(--gradient-gold);
  margin: var(--space-md) auto;
  border-radius: var(--radius-full);
}

/* 복음 참조 (장절) */
.sharing__reference {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-lg);
  letter-spacing: 0.02em;
}

/* 핵심 구절 강조 박스 */
.sharing__key-verse {
  background: var(--bg-highlight);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.sharing__key-verse-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-wine);
  line-height: 1.8;
  font-style: italic;
}

/* 복음 본문 */
.sharing__gospel-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-md);
}

.sharing__gospel-title {
  font-size: 0.8rem;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sharing__gospel-title::before {
  content: '';
  width: 16px;
  height: 2px;
  background: var(--gradient-gold);
  border-radius: var(--radius-full);
}

.sharing__gospel-text {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 2;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: keep-all;
}

/* 성찰하기 / 새겨보기 카드 */
.sharing__card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.sharing__card-title {
  font-size: 0.8rem;
  color: var(--accent-wine);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sharing__card-title::before {
  content: '';
  width: 16px;
  height: 2px;
  background: var(--gradient-wine);
  border-radius: var(--radius-full);
}

.sharing__card-text {
  font-size: 0.95rem;
  line-height: 1.9;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: keep-all;
}

/* 나눔 미설정 상태 */
.sharing__empty {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}

.sharing__empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.sharing__empty-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ============================================================
   나눔 설정 페이지 (#admin)
   ============================================================ */
.admin__title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: var(--space-lg);
}

/* 관리자 폼 */
.admin__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-group__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-group__label--required::after {
  content: ' *';
  color: var(--accent-wine);
}

.form-group__hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* 날짜 선택 + 가져오기 */
.admin__date-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.admin__date-row .form-group {
  flex: 1;
}

/* 입력 필드 공통 */
.input,
.textarea {
  width: 100%;
  padding: var(--space-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  outline: none;
}

.input:focus,
.textarea:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input[type="date"] {
  cursor: pointer;
}

.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.7;
}

.textarea--large {
  min-height: 200px;
  font-family: var(--font-serif);
  line-height: 2;
}

/* 자동 채움 표시 */
.form-group--auto-filled .input,
.form-group--auto-filled .textarea {
  border-color: var(--accent-gold-light);
  background: var(--bg-highlight);
}

.form-group__auto-badge {
  display: none;
  font-size: 0.7rem;
  color: var(--accent-gold);
  background: rgba(184, 134, 11, 0.1);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-weight: 500;
  width: fit-content;
}

.form-group--auto-filled .form-group__auto-badge {
  display: inline-block;
}

/* 섹션 구분선 */
.admin__section-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.admin__section-divider::before,
.admin__section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* 설정 완료 버튼 */
.admin__submit {
  margin-top: var(--space-md);
}

/* 크롤링 결과 미리보기 */
.admin__preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
}

/* ============================================================
   PIN 인증 모달
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-fast);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: calc(100% - var(--space-xl));
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp var(--transition-normal);
  text-align: center;
}

@keyframes modalSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.modal__desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.modal__input {
  width: 100%;
  padding: var(--space-md);
  font-family: var(--font-sans);
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 0.3em;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.modal__input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

.modal__input--error {
  border-color: var(--accent-wine);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.modal__error {
  font-size: 0.8rem;
  color: var(--accent-wine);
  margin-top: var(--space-sm);
  min-height: 1.2em;
}

.modal__buttons {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.modal__buttons .btn {
  flex: 1;
}

/* ============================================================
   확인 팝업
   ============================================================ */
.confirm-modal .modal__icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
}

/* ============================================================
   토스트 메시지
   ============================================================ */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transition: transform var(--transition-normal);
  white-space: nowrap;
}

.toast.active {
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   로딩 스피너
   ============================================================ */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  gap: var(--space-md);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-spinner__icon {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================================
   반응형 (모바일 우선)
   ============================================================ */
@media (min-width: 480px) {
  .page-section {
    padding: var(--space-xl) var(--space-lg);
  }

  .home__title {
    font-size: 2.5rem;
  }

  .sharing__gospel-card {
    padding: var(--space-xl);
  }
}

@media (min-width: 640px) {
  .page-section {
    padding: var(--space-2xl) var(--space-xl);
  }
}

/* ── 스크롤바 커스텀 ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── 선택 영역 색상 ── */
::selection {
  background: rgba(184, 134, 11, 0.2);
  color: var(--text-primary);
}
