/* =========================================================
   터키어 여행 학습 앱 — 성지순례자를 위한 터키어
   Design System | main.css
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Serif:ital,wght@0,400;0,600;0,700;1,400&family=Noto+Sans:wght@400;500;700&display=swap');

/* ── CSS 변수 ── */
:root {
  --bg:          #0a0805;
  --surface:     #130f0a;
  --surface-2:   #1c1510;
  --surface-3:   #261c14;
  --border:      #3a2518;
  --border-2:    #5a3820;

  --red:         #c0392b;
  --red-light:   #e74c3c;
  --red-dark:    #922b21;
  --red-glow:    rgba(192,57,43,0.13);

  --amber:       #e67e22;
  --amber-light: #f39c12;
  --amber-dark:  #a04000;
  --amber-glow:  rgba(230,126,34,0.12);

  --teal:        #1abc9c;
  --teal-light:  #48c9b0;
  --teal-dark:   #148f77;

  --text:        #f5ede4;
  --text-muted:  #b89880;
  --text-dim:    #6b4e3a;
  --text-inv:    #0a0805;

  --tr-font:     'Noto Sans', 'Inter', sans-serif;
  --font-ui:     'Inter', sans-serif;
  --font-serif:  'Noto Serif', serif;

  --radius-sm:   6px;
  --radius:      12px;
  --radius-lg:   20px;
  --radius-xl:   28px;

  --shadow-sm:   0 2px 8px rgba(0,0,0,0.5);
  --shadow:      0 4px 20px rgba(0,0,0,0.6);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.7);
  --shadow-red:  0 0 30px rgba(192,57,43,0.2);

  --transition:  all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  /* iOS 폰트 자동확대 방지 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iOS 터치 최적화 */
a, button, [role="button"], input, select, textarea, label {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
h1 { font-size: 2.4rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.1rem; }

p { color: var(--text-muted); line-height: 1.8; margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--amber); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--amber-light); }

/* 터키어 텍스트 */
.tr {
  font-family: var(--tr-font);
  font-size: 1.2em;
  color: var(--amber-light);
  letter-spacing: 0.01em;
}
.tr-lg {
  font-family: var(--tr-font);
  font-size: 2rem;
  color: var(--amber-light);
  font-weight: 600;
}
.tr-xl {
  font-family: var(--tr-font);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--amber-light);
  line-height: 1.1;
}

/* ── Nav ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 64px;
  background: rgba(19,15,10,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 2rem;
  gap: 1.5rem;
}
.nav-logo {
  font-family: var(--font-serif);
  font-size: 1rem; font-weight: 700;
  color: var(--text);
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none;
  white-space: nowrap;
}
.nav-logo .flag { font-size: 1.3rem; }
.nav-links {
  display: flex; gap: 0.25rem;
  margin-left: auto;
}
.nav-link {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--red-glow); color: var(--red-light); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: var(--transition);
  font-family: var(--font-ui);
  text-decoration: none;
}
.btn-primary {
  background: var(--red);
  color: #fff;
}
.btn-primary:hover { background: var(--red-light); color: #fff; transform: translateY(-1px); }
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text-muted);
}
.btn-secondary:hover { border-color: var(--amber-dark); color: var(--text); }
.btn-amber {
  background: var(--amber);
  color: #fff;
}
.btn-amber:hover { background: var(--amber-light); color: #fff; }
.btn-icon {
  padding: 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.btn-icon:hover { border-color: var(--amber-dark); color: var(--amber-light); }
.btn-tts {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  color: var(--teal-light);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.btn-tts:hover { border-color: var(--teal); background: rgba(26,188,156,0.1); }
.btn-tts.speaking { border-color: var(--teal); background: rgba(26,188,156,0.15); animation: pulse-teal 1s infinite; }
.btn-tts svg { width: 14px; height: 14px; }

@keyframes pulse-teal {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26,188,156,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(26,188,156,0); }
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.card-link { text-decoration: none; display: block; }
.card-link:hover .card { transform: translateY(-3px); box-shadow: var(--shadow-red); border-color: var(--red-dark); }

/* ── Badges / Tags ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.05em;
}
.badge-red   { background: rgba(192,57,43,0.18); color: var(--red-light); border: 1px solid rgba(192,57,43,0.3); }
.badge-amber { background: rgba(230,126,34,0.18); color: var(--amber-light); border: 1px solid rgba(230,126,34,0.3); }
.badge-teal  { background: rgba(26,188,156,0.15); color: var(--teal-light); border: 1px solid rgba(26,188,156,0.3); }
.badge-dim   { background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Progress Bar ── */
.progress-bar {
  height: 4px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--red);
  border-radius: 99px; transition: width 0.4s ease;
}

/* ── Section ── */
.section { padding: 5rem 2rem; }
.section-inner { max-width: 1100px; margin: 0 auto; }
.section-label {
  display: inline-flex; align-items: center; gap: 0.75rem;
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--red-light); margin-bottom: 1.2rem;
}
.section-label::before, .section-label::after {
  content: ''; width: 30px; height: 1px; background: var(--red-dark);
}

/* ── Divider ── */
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Utility ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-amber { color: var(--amber-light); }
.text-red { color: var(--red-light); }
.text-teal { color: var(--teal-light); }

/* ── TTS Status Bar ── */
.tts-bar {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--teal-dark);
  border-radius: var(--radius);
  padding: 0.75rem 1.2rem;
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.85rem; color: var(--teal-light);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.tts-bar.visible { opacity: 1; transform: translateY(0); pointer-events: all; }
.tts-wave { display: flex; gap: 3px; align-items: flex-end; height: 16px; }
.tts-wave span {
  width: 3px; background: var(--teal); border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite;
}
.tts-wave span:nth-child(2) { animation-delay: 0.1s; }
.tts-wave span:nth-child(3) { animation-delay: 0.2s; }
.tts-wave span:nth-child(4) { animation-delay: 0.15s; }
.tts-wave span:nth-child(5) { animation-delay: 0.05s; }
@keyframes wave {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber-dark); }

/* ══════════════════════════════════════════
   햄버거 메뉴 (모든 페이지 공통 nav)
══════════════════════════════════════════ */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  background: none; border: none;
  cursor: pointer; padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-left: auto;
}
.nav-hamburger:hover { background: var(--surface-3); }
.nav-hamburger span {
  display: block; height: 2px;
  background: var(--text-muted); border-radius: 2px;
  transition: var(--transition);
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 모바일 드로어 */
.nav-drawer {
  display: none;
  position: fixed; top: 64px; left: 0; right: 0;
  background: rgba(10,8,5,0.97);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 199;
  padding: 1rem 1.5rem;
  flex-direction: column; gap: 0.25rem;
  animation: slideDown 0.2s ease;
}
.nav-drawer.open { display: flex; }
.nav-drawer a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  text-decoration: none;
}
.nav-drawer a:hover,
.nav-drawer a.active { background: var(--red-glow); color: var(--red-light); }

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

/* ══════════════════════════════════════════
   공통 모바일 사이드바 드로어 패턴
══════════════════════════════════════════ */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(2px);
  z-index: 150;
}
.sidebar-backdrop.open { display: block; }

.mobile-topbar {
  display: none;
  position: sticky;
  top: 64px; z-index: 80;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 1rem;
  align-items: center;
  gap: 0.75rem;
}
.mobile-topbar-toggle {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem; font-family: var(--font-ui);
  cursor: pointer; min-height: 36px;
}
.mobile-topbar-toggle:hover { border-color: var(--amber-dark); color: var(--amber-light); }
.mobile-topbar-title {
  font-size: 0.85rem; font-weight: 600;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; gap: 0.5rem; }
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .section { padding: 2.5rem 1rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.15rem; }
  .btn { min-height: 44px; }
  .card { padding: 1rem; }
  .mobile-topbar { display: flex; }
}

/* iOS 안전영역 */
@supports (padding: max(0px)) {
  .nav {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .nav-drawer {
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
  }
  body { padding-bottom: env(safe-area-inset-bottom); }
}
