/* ==========================================================================
   SOULIGN WEAVE — Design System
   Tone & Manner: Kinfolk Notes (https://kinfolknotes.com/pages/about-us)
   "PRINT TO RITUAL" · Warm Off-White Cream · Editorial Serif · Quiet Whitespace
   인위적인 카드 박스와 그림자를 배제하고, 지면(Print)과 같은 자연스러운 흐름을 연출.
   ========================================================================== */

:root {
  /* ── Kinfolk Notes Color Palette ── */
  --bg-page:           #F9F7F3;   /* Kinfolk Notes 시그니처 웜 크림 페이퍼 (rgb 249, 247, 243) */
  --bg-header-footer:  #F9F7F3;   /* 일체감 있는 심리스 헤더·푸터 배경 */
  --bg-subtle:         #F3EFE8;   /* 은은한 톤 구분용 백그라운드 */
  
  --text-headline:     #212121;   /* Kinfolk Notes 웜 차콜 / 오프블랙 (rgb 33, 33, 33) */
  --text-body:         #333333;   /* 차분하고 깊은 본문 텍스트 */
  --text-secondary:    #666666;   /* 보조 설명문, 레이블 */
  --text-placeholder:  #8A877E;   /* 플레이스홀더 (대비 3.1:1 이상 가독성 유지) */

  --border-divider:    #E3E2DE;   /* Kinfolk Notes 공식 가는 선 (rgb 227, 226, 222) */
  --border-input:      #D2CEC4;   /* 입력창 테두리 */

  /* Soulign 고유의 시그니처 포인트: 딥 올리브 (Olive Calm) */
  --accent-olive:      #5A624D;   /* 강조색 (NEXT 버튼, 시그니처 배지) */
  --accent-olive-hover:#474E3C;   /* 호버 */

  /* 보조 자연색 (모래·화병·잎) */
  --natural-sand:      #D3C4B0;
  --natural-vase:      #E2D6C9;
  --natural-leaf:      #9AA387;

  /* 시스템 호환용 시맨틱 매핑 */
  --white:             #FAF9F6;
  --offwhite-0:        var(--bg-page);
  --offwhite-1:        #FAF8F4;
  --offwhite-2:        var(--border-divider);
  --offwhite-3:        var(--border-input);
  --offwhite-4:        var(--text-placeholder);

  --gray-900:          var(--text-headline);
  --gray-800:          #2A2A2A;
  --gray-700:          var(--text-body);
  --gray-600:          var(--text-secondary);
  --gray-500:          var(--text-placeholder);
  --gray-400:          var(--border-input);
  --gray-300:          var(--border-divider);
  --gray-200:          #EAE7E0;
  --gray-100:          #F2EFE8;

  --primary-900:       #3A4031;
  --primary-800:       var(--accent-olive);
  --primary-700:       var(--accent-olive-hover);
  --primary-600:       #6C765C;
  --primary-500:       var(--natural-leaf);
  --primary-100:       #ECEFE8;
  --primary-50:        #F5F7F3;

  --blue-950:          #212121;
  --blue-900:          var(--primary-900);
  --blue-800:          var(--primary-800);
  --blue-700:          var(--primary-700);
  --blue-600:          var(--primary-600);
  --blue-500:          var(--primary-500);
  --blue-400:          var(--natural-leaf);
  --blue-200:          #D0D5C7;
  --blue-100:          var(--primary-100);
  --blue-50:           var(--primary-50);

  /* 상태 색상 */
  --success:           #4A6B53;
  --warning:           #9E7643;
  --error:             #8E4343;
  --info:              #5A624D;

  --emotion-joy:       #B88438;
  --emotion-calm:      #6F8578;
  --emotion-growth:    #5A6B50;
  --emotion-struggle:  #875E48;
  --emotion-insight:   #786A7E;

  /* ── 타이포그래피 (Kinfolk Notes Typography Spec) ── */
  --font-serif:        'Cormorant Garamond', 'New York', 'Iowan Old Style', 'Apple Garamond', Baskerville, Georgia, serif;
  --font-korean-serif: 'Noto Serif KR', 'KoPub Batang', Batang, serif;
  --font-sans:         'Noto Serif KR', 'Inter', -apple-system, sans-serif;

  --font-display:      var(--font-serif);
  --font-primary:      var(--font-korean-serif);
  --font-body:         var(--font-korean-serif);

  /* Kinfolk Notes 스케일: 대형 디스플레이 타이틀 & 넉넉한 본문 행간 */
  --text-display-giant:clamp(40px, 5.5vw, 84px);
  --text-logo:         clamp(24px, 2.4vw, 34px);
  --text-journey-title:clamp(24px, 2.6vw, 36px);
  --text-korean-head:  clamp(20px, 2.2vw, 32px);
  --text-question:     clamp(15px, 1.1vw, 16.5px);
  --text-option:       14px;
  --text-subhead:      11px;
  --text-quote:        14px;

  --text-xs:           11px;
  --text-sm:           13px;
  --text-base:         15px;      /* Kinfolk Notes 기준 본문 크기 15px */
  --text-md:           17px;
  --text-lg:           19px;
  --text-xl:           24px;
  --text-2xl:          30px;
  --text-3xl:          38px;

  /* 행간: Kinfolk Notes 고유의 여유로운 1.7x 행간 */
  --leading-tight:     1.15;
  --leading-normal:    1.7;       /* 15px 기준 25.5px */
  --leading-loose:     1.85;

  /* Kinfolk Notes 고유의 본문 단락 폭 제한 (최적의 리딩 리듬 520px) */
  --paragraph-max-width: 520px;

  /* ── Spacing ── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* ── Radius & Hairlines ── */
  --radius-xs:         2px;
  --radius-sm:         4px;
  --radius-md:         6px;
  --radius-lg:         10px;
  --radius-xl:         14px;
  --radius-full:       9999px;

  /* Kinfolk 스타일: 인위적 그림자 배제, 평면의 지면 감각 */
  --shadow-none:       none;
  --shadow-xs:         none;
  --shadow-sm:         none;
  --shadow-md:         none;
  --shadow-lg:         none;

  --top-bar-height:    70px;
  --bottom-nav-height: 68px;
  --screen-max-width:  1360px;
  --content-max-width: 640px;

  --transition-fast:   160ms ease;
  --transition-normal: 260ms cubic-bezier(0.2, 0, 0.2, 1);
}

/* ── 120% 큰 글씨 모드 ── */
[data-text-size="large"],
body[data-text-size="large"] {
  font-size: 19.2px;
  --text-question: clamp(18px, 1.32vw, 19.8px);
  --text-option: 16.8px;
  --text-quote: 16.8px;
  --text-subhead: 13.2px;
  --text-journey-title: clamp(28px, 3.1vw, 43.2px);
  --text-korean-head: clamp(24px, 2.6vw, 38.4px);
  --text-logo: clamp(28px, 2.9vw, 40.8px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background-color: var(--bg-page);
}

body {
  font-family: var(--font-korean-serif);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-normal);
  color: var(--text-body);
  background-color: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100dvh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  outline: none;
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: var(--screen-max-width);
  margin: 0 auto;
  background: var(--bg-page);
  position: relative;
  overflow: hidden;
  z-index: 2;
}

/* ── Top Bar (Kinfolk Style Editorial Header) ── */
.top-bar {
  height: var(--top-bar-height);
  background: var(--bg-header-footer);
  border-bottom: 1px solid var(--border-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.top-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.top-bar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}

.top-bar__brand-text {
  font-family: var(--font-serif);
  font-size: var(--text-logo);
  font-weight: 500;
  letter-spacing: 0.28em;
  color: var(--text-headline);
  text-transform: uppercase;
}

.top-bar__brand-sub {
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--natural-sand);
  margin-left: 10px;
  text-transform: uppercase;
  border-left: 1px solid var(--border-divider);
  padding-left: 10px;
  white-space: nowrap;
}

@media (max-width: 768px) {
  :root {
    --top-bar-height: 56px;
    --bottom-nav-height: 60px;
  }

  .top-bar {
    height: 56px;
    padding: 0 12px;
  }

  .top-bar__left {
    gap: 6px;
  }

  .top-bar__brand-text {
    font-size: 19px;
    letter-spacing: 0.16em;
  }

  .top-bar__brand-sub {
    display: none !important;
  }

  .top-bar__right {
    gap: 4px;
  }

  .lang-toggle-btn {
    height: 26px;
    padding: 0 7px;
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
  }

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

  .avatar {
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
  }

  .top-bar-logout-btn {
    height: 28px;
    padding: 0 8px;
    font-size: 12px;
    gap: 3px;
  }

  .screen-container {
    padding: 0 12px;
  }

  .bottom-nav {
    height: 60px;
    padding: 0 4px;
  }

  .nav-item {
    min-height: 48px;
    gap: 2px;
    padding: 4px 0;
  }

  .nav-item span {
    font-size: 10px;
  }

  .nav-icon {
    width: 18px;
    height: 18px;
  }

  .app-editorial-footer {
    display: none !important;
  }
}

/* Desktop Editorial Nav */
.top-bar__nav {
  display: none;
  align-items: center;
  gap: 2.5rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

@media (min-width: 768px) {
  .top-bar__nav {
    display: flex;
  }
}

.top-nav-link {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 6px;
  position: relative;
  transition: color var(--transition-fast);
}

.top-nav-link:hover {
  color: var(--text-headline);
}

.top-nav-link.active {
  color: var(--text-headline);
  font-weight: 500;
}

.top-nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 10%;
  right: 10%;
  height: 1px;
  background-color: var(--text-headline);
}

.top-bar__right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-headline);
  background: transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.lang-toggle-btn {
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  border: 1px solid var(--border-divider);
  background: transparent;
  color: var(--text-headline);
  padding: 0 10px;
  height: 28px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lang-toggle-btn:hover {
  background: var(--text-headline);
  color: var(--bg-page);
  border-color: var(--text-headline);
}

.notification-badge,
.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  background: var(--text-headline);
  color: var(--bg-page);
  font-size: 9px;
  font-weight: 600;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--text-headline);
  color: var(--bg-page);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.top-bar-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #B91C1C;
  background: rgba(185, 28, 28, 0.05);
  border: 1px solid rgba(185, 28, 28, 0.28);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 32px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
  font-family: inherit;
  margin-left: 2px;
}

.top-bar-logout-btn:hover {
  background: rgba(185, 28, 28, 0.12);
  border-color: rgba(185, 28, 28, 0.5);
  color: #991B1B;
}

.top-bar-logout-btn svg {
  stroke-width: 2.2;
}

/* ── Screen Container ── */
.screen-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  position: relative;
  padding: 0 var(--space-6);
}

@media (min-width: 1024px) {
  .screen-container {
    padding: 0 var(--space-12);
  }
}

.screen-container::-webkit-scrollbar {
  width: 4px;
}
.screen-container::-webkit-scrollbar-thumb {
  background: var(--border-divider);
}

/* ── Bottom Navigation ── */
.bottom-nav {
  height: var(--bottom-nav-height);
  background: var(--bg-header-footer);
  border-top: 1px solid var(--border-divider);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-4);
  padding-bottom: env(safe-area-inset-bottom, 0);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

@media (min-width: 992px) {
  .bottom-nav {
    display: none;
  }
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) 0;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
  min-height: 52px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-headline);
}

.nav-item.active .nav-icon {
  stroke: var(--text-headline);
  stroke-width: 2;
}

.nav-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: stroke var(--transition-fast);
}

.nav-item span {
  font-family: var(--font-korean-serif);
  font-size: var(--text-xs);
  font-weight: 400;
}

.nav-item--fab {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--accent-olive);
  color: #FFFFFF !important;
  margin-top: -14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item--fab .nav-icon {
  stroke: #FFFFFF;
}

.nav-item--fab:hover {
  background: var(--accent-olive-hover);
}

/* ── Kinfolk Notes Style Footer ── */
.app-editorial-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border-divider);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  font-family: var(--font-serif);
  font-size: var(--text-subhead);
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--text-secondary);
  text-transform: uppercase;
  background: var(--bg-header-footer);
  flex-shrink: 0;
  user-select: none;
}

.app-editorial-footer .footer-sep {
  color: var(--border-divider);
}

@media (max-width: 600px) {
  .app-editorial-footer {
    display: none;
  }
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-headline);
  color: var(--bg-page);
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-family: var(--font-korean-serif);
  font-size: var(--text-sm);
  font-weight: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  z-index: 9999;
  white-space: nowrap;
  max-width: 90vw;
}

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