/* ══════════════════════════════════
   BLOOM — GLOBAL CSS
   tokens · reset · nav · buttons · modal · toast · animations
══════════════════════════════════ */

/* ─── DESIGN TOKENS (v4 — Clean White / Indigo) ─── */
:root {
  --ink:        #111827;
  --ink-60:     #6B7280;
  --ink-30:     #D1D5DB;
  --ink-10:     #F3F4F6;
  --paper:      #FFFFFF;
  --warm:       #FAFAFA;
  --terracotta: #4F46E5;
  --terra-lt:   #EEF2FF;
  --terra-dk:   #3730A3;
  --sage:       #059669;
  --sage-lt:    #ECFDF5;
  --gold:       #D97706;
  --gold-lt:    #FFFBEB;

  --r-sm:   12px;
  --r-md:   16px;
  --r-lg:   24px;
  --r-xl:   32px;
  --r-full: 999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.08);

  --nav-h:       72px;
  --sidebar-w:   260px;
  --content-max: 1200px;
  --bottom-nav-h: 0px;

  --ease:   cubic-bezier(.4,0,.2,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ─── TYPOGRAPHY ─── */
.serif { font-family: 'Playfair Display', serif; }
h1, h2, h3 { font-family: 'Pretendard', sans-serif; font-weight: 700; }

/* ─── SVG ICON BASE ─── */
.s-ico {
  display: inline-block;
  vertical-align: middle;
  width: 1em; height: 1em;
  flex-shrink: 0;
}
/* 사이드바/네비 아이콘 크기 */
.si-icon .s-ico,
.s-ico.si { width: 18px; height: 18px; }
/* 하단 탭바 아이콘 */
.bn-icon .s-ico,
.s-ico.bn { width: 22px; height: 22px; }
/* 소형 뱃지/인라인 */
.s-ico.xs { width: 14px; height: 14px; }
.s-ico.sm { width: 16px; height: 16px; }
.s-ico.md { width: 20px; height: 20px; }
.s-ico.lg { width: 28px; height: 28px; }
.s-ico.xl { width: 32px; height: 32px; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-30); border-radius: 10px; }

/* ══════════════════════════════════
   TOP NAV
══════════════════════════════════ */
#topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 48px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(0,0,0,.04);
  transition: box-shadow .3s var(--ease);
}
#topnav.scrolled { box-shadow: var(--shadow-sm); }

.nav-logo {
  display: flex; align-items: center; cursor: pointer;
  text-decoration: none; flex-shrink: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -1px;
  line-height: 1;
}
.nav-logo-a { color: #F2B818; }
.nav-logo-img { display: none; } /* CSS 텍스트 로고로 전환 */
.nav-logo .dot { display: none; }

.nav-center {
  display: flex; align-items: center; gap: 4px;
  position: absolute; left: 50%; transform: translateX(-50%);
}
.nav-link {
  padding: 8px 18px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 500; color: var(--ink-60);
  transition: all .2s var(--ease); cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
  position: relative;
}
.nav-link:hover { color: var(--ink); background: var(--ink-10); }
.nav-link.active { color: var(--ink); background: var(--ink-10); font-weight: 600; }

/* 네비 배지 (메시지, 알림 카운트) */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 10px;
  background: var(--terracotta); color: white;
  font-size: 10px; font-weight: 700; line-height: 1;
}

/* 알림 아이콘 버튼 */
.nav-noti-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 18px;
  transition: background .2s var(--ease);
  text-decoration: none;
}
.nav-noti-btn:hover { background: var(--ink-10); }
.nav-noti-btn .nav-badge {
  position: absolute; top: 2px; right: 0;
}

.nav-right { display: flex; align-items: center; gap: 10px; }

/* ─── HAMBURGER ─── */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  padding: 10px; cursor: pointer; z-index: 1001;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--ink); border-radius: 2px;
  transition: all .3s var(--ease);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ══════════════════════════════════
   MOBILE FULL-SCREEN DRAWER
   ※ visibility + opacity로 제어 (display:none → transition 불가 문제 해결)
══════════════════════════════════ */
.mobile-drawer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.35);
  z-index: 849;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s var(--ease), visibility .3s;
}
.mobile-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer {
  position: fixed;
  top: var(--nav-h); right: 0; bottom: 0;
  width: min(320px, 85vw);
  background: var(--paper);
  z-index: 850;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .3s var(--ease), visibility .3s;
  box-shadow: -4px 0 24px rgba(0,0,0,.08);
}
.mobile-drawer.open {
  transform: translateX(0);
  visibility: visible;
}

.md-inner {
  padding: 16px 20px calc(var(--bottom-nav-h, 0px) + 100px);
  max-width: 480px;
}

/* 프로필 블록 */
.md-profile {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  background: var(--ink-10);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}
.md-avatar { font-size: 28px; }
.md-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.md-role { font-size: 12px; color: var(--ink-60); }

/* 섹션 */
.md-section { margin-top: 20px; }
.md-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--ink-30);
  padding: 0 12px; margin-bottom: 6px;
}

/* 메뉴 아이템 — 터치 타겟 최소 44px */
.md-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 10px;
  min-height: 44px;
  font-size: 15px; font-weight: 500; color: var(--ink-60);
  text-decoration: none;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.md-item:hover,
.md-item:active { background: var(--ink-10); color: var(--ink); }
.md-item.active { background: var(--terra-lt); color: var(--terracotta); font-weight: 600; }
.md-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.md-logout { color: #B91C1C; }
.md-logout:hover,
.md-logout:active { background: #FEE2E2; color: #B91C1C; }

/* 모바일 메뉴 배지 */
.mm-badge {
  margin-left: auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--terracotta); color: white;
  font-size: 11px; font-weight: 700; line-height: 1;
}

.md-divider {
  border: none; border-top: 1px solid var(--ink-10);
  margin: 8px 0;
}

/* 드로어 오버레이 (body scroll lock) */
body.drawer-open { overflow: hidden; }


/* ══════════════════════════════════
   MOBILE BOTTOM TAB NAV
══════════════════════════════════ */
.mobile-bottom-nav { display: none; }

.mbn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; padding: 6px 4px; transition: color .2s, transform .2s;
  text-decoration: none; position: relative;
  min-height: 44px; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.mbn-item:active { transform: scale(0.92); }
.mbn-icon {
  font-size: 20px; color: var(--ink-60);
  position: relative; display: inline-flex;
  align-items: center; justify-content: center;
}
.mbn-label { font-size: 10px; font-weight: 500; color: var(--ink-60); }
.mbn-item.active .mbn-label { color: var(--terracotta); font-weight: 600; }
.mbn-item.active .mbn-icon { color: var(--terracotta); }

/* 하단 탭 배지 도트 */
.mbn-dot {
  position: absolute; top: -2px; right: -6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  border: 2px solid white;
}


/* ══════════════════════════════════
   BUTTONS
══════════════════════════════════ */
.btn-ghost {
  padding: 8px 20px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 500; color: var(--ink-60);
  border: 1.5px solid rgba(0,0,0,.1);
  transition: all .2s var(--ease); cursor: pointer;
  background: transparent; display: inline-block;
  text-decoration: none;
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); background: var(--ink-10); }

.btn-fill {
  padding: 10px 24px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--terracotta); color: white;
  transition: all .25s var(--ease);
  box-shadow: 0 2px 10px rgba(79,70,229,.2);
  border: none; display: inline-block; text-decoration: none;
}
.btn-fill:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,70,229,.3); background: var(--terra-dk); }

.btn-terra {
  padding: 14px 32px; border-radius: 14px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  background: var(--terracotta); color: white;
  transition: all .25s var(--ease);
  box-shadow: 0 4px 16px rgba(79,70,229,.25);
  border: none; display: inline-block; text-decoration: none;
}
.btn-terra:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(79,70,229,.3); background: var(--terra-dk); }

.btn-terra-outline {
  padding: 14px 32px; border-radius: 14px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--ink);
  border: 1.5px solid var(--ink-30);
  transition: all .25s var(--ease);
  display: inline-block; text-decoration: none;
}
.btn-terra-outline:hover { border-color: var(--ink); }

.btn-white {
  padding: 14px 32px; border-radius: 14px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  background: white; color: var(--ink);
  transition: all .25s var(--ease);
  border: none; display: inline-block; text-decoration: none;
}
.btn-white:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.15); }

.btn-submit {
  width: 100%; padding: 14px; border-radius: 14px;
  background: var(--terracotta); color: white;
  font-size: 15px; font-weight: 600; cursor: pointer;
  margin-top: 8px; transition: all .25s var(--ease);
  box-shadow: 0 4px 16px rgba(79,70,229,.2);
  border: none;
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(79,70,229,.3); background: var(--terra-dk); }

.btn-submit-terra {
  width: 100%; padding: 14px; border-radius: 14px;
  background: var(--terracotta); color: white;
  font-size: 15px; font-weight: 600; cursor: pointer;
  margin-top: 8px; transition: all .25s var(--ease);
  box-shadow: 0 4px 16px rgba(79,70,229,.2);
  border: none;
}
.btn-submit-terra:hover { transform: translateY(-1px); background: var(--terra-dk); box-shadow: 0 8px 24px rgba(79,70,229,.3); }

/* ══════════════════════════════════
   ANIMATIONS
══════════════════════════════════ */
.stagger > * {
  opacity: 0; transform: translateY(18px);
  animation: fadeUp .55s var(--ease) forwards;
}
.stagger > *:nth-child(1) { animation-delay: .05s; }
.stagger > *:nth-child(2) { animation-delay: .12s; }
.stagger > *:nth-child(3) { animation-delay: .19s; }
.stagger > *:nth-child(4) { animation-delay: .26s; }
.stagger > *:nth-child(5) { animation-delay: .33s; }
.stagger > *:nth-child(6) { animation-delay: .40s; }

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp .5s var(--ease) forwards; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
@keyframes heartbeat { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }
@keyframes heroFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(12px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

/* ══════════════════════════════════
   MODAL & OVERLAY
══════════════════════════════════ */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 1000; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); padding: 20px;
}
.overlay.open { display: flex; }

.modal-box {
  background: white; border-radius: var(--r-xl);
  max-width: 600px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .35s var(--spring);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 28px 28px 0;
}
.modal-head h3 { font-size: 22px; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--ink-10); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; border: none;
}
.modal-close:hover { background: var(--ink); color: white; }
.modal-body { padding: 20px 28px 28px; }

/* Planner detail modal */
.pdetail-banner {
  height: 140px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--ink-10), var(--terra-lt));
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; margin-bottom: 20px;
}
.pdetail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.pdetail-tag { padding: 5px 12px; border-radius: var(--r-full); background: var(--ink-10); font-size: 12px; color: var(--ink-60); }
.pdetail-stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px; }
.pdetail-stat { text-align: center; padding: 16px; background: var(--ink-10); border-radius: 12px; }
.pdetail-stat-num { font-family: 'Playfair Display', serif; font-size: 22px; color: var(--ink); }
.pdetail-stat-label { font-size: 11px; color: var(--ink-60); margin-top: 3px; }
.pdetail-desc { font-size: 14px; color: var(--ink-60); line-height: 1.75; margin-bottom: 24px; font-weight: 300; }
.pdetail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ══════════════════════════════════
   TOAST
══════════════════════════════════ */
.toast {
  position: fixed; bottom: 32px; right: 32px; z-index: 2000;
  background: var(--ink); color: white; padding: 14px 22px;
  border-radius: var(--r-full); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); pointer-events: none;
  opacity: 0; transform: translateY(12px);
  transition: all .3s var(--ease);
  display: flex; align-items: center; gap: 10px;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ══════════════════════════════════
   SHARED SECTION ELEMENTS
══════════════════════════════════ */
.section-tag {
  display: inline-flex; padding: 6px 14px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600;
  margin-bottom: 16px;
}
.section-h2 {
  font-size: clamp(28px, 3.2vw, 36px);
  line-height: 1.3; letter-spacing: -1px; margin-bottom: 16px;
}
.section-lead {
  font-size: 16px; font-weight: 300; color: var(--ink-60);
  max-width: 500px; line-height: 1.75;
}

/* ──────────────────────────────────
   RESPONSIVE — GLOBAL
────────────────────────────────── */

/* ── 와이드스크린 ── */
@media (min-width: 1400px) {
  #topnav { padding: 0 80px; }
}

/* ── 중간 데스크톱 ── */
@media (max-width: 1100px) {
  #topnav { padding: 0 32px; }
  .nav-link { padding: 8px 12px; font-size: 13px; }
}

/* ── 태블릿 ── */
@media (max-width: 900px) {
  :root { --nav-h: 60px; }
  #topnav { padding: 0 24px; }
  .nav-center { display: none; }
  .hamburger { display: flex; }
  .nav-right .btn-ghost { display: none; }
  .nav-right .btn-fill { display: none; }
  .nav-noti-btn { display: none; }

  /* 모달 태블릿 최적화 */
  .modal-content { max-width: 90vw; margin: 20px; }

  /* 버튼 터치 타겟 최소 44px */
  .btn-terra, .btn-fill, .btn-ghost {
    min-height: 44px;
    padding: 10px 22px;
  }

  /* 섹션 타이틀 태블릿 */
  .section-heading { font-size: clamp(22px, 3vw, 30px); }
  .section-lead { font-size: 15px; }
}

/* ── 소형 태블릿 / 대형 모바일 ── */
@media (max-width: 768px) {
  #topnav { padding: 0 20px; }
  .nav-logo { font-size: 24px; }

  /* 모달 풀화면에 가깝게 */
  .modal-content {
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 80px);
    border-radius: var(--r-lg);
  }
}

/* ── 모바일 ── */
@media (max-width: 640px) {
  :root {
    --nav-h: 56px;
    --bottom-nav-h: 60px;
  }
  #topnav { padding: 0 16px; }
  .nav-logo { font-size: 22px; }

  /* ── 모바일 하단 탭바 활성화 ── */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 800;
    background: white;
    border-top: 1px solid rgba(0,0,0,.06);
    padding: 8px 0 max(env(safe-area-inset-bottom), 8px);
    box-shadow: 0 -2px 12px rgba(0,0,0,.04);
  }

  /* 토스트 하단 탭 위로 */
  .toast {
    bottom: calc(var(--bottom-nav-h) + 16px);
    right: 16px; left: 16px;
    justify-content: center;
  }

  /* 모달 풀화면 */
  .modal-content {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 100px);
    border-radius: var(--r-md);
    padding: 20px;
  }

  /* 버튼 모바일 전체폭 */
  .btn-terra, .btn-fill {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 15px;
  }
}

/* ── 초소형 모바일 (SE, Galaxy Fold 등) ── */
@media (max-width: 360px) {
  :root { --nav-h: 52px; }
  #topnav { padding: 0 12px; }
  .nav-logo { font-size: 20px; }

  .mobile-bottom-nav {
    padding: 6px 0 max(env(safe-area-inset-bottom), 6px);
  }
}