/* =========================================================
   현대 구어 아랍어 (이집트 방언 중심) 학습 앱
   Design System | main.css
   Theme: Nile Night — 사막의 밤 × 나일강의 물빛
   ========================================================= */

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

/* ── CSS 변수 ── */
:root {
  --bg:          #06101a;
  --surface:     #0d1a26;
  --surface-2:   #142533;
  --surface-3:   #1d3242;
  --border:      #1f3a52;
  --border-2:    #2d527a;

  /* 사프란 골드 — 아랍/이집트 정서 */
  --gold:        #d4a14a;
  --gold-light:  #e8c373;
  --gold-dark:   #a87825;
  --gold-glow:   rgba(212,161,74,0.14);

  /* 카퍼/적동 */
  --copper:      #c0794a;
  --copper-light:#e89865;
  --copper-dark: #8a4f2b;

  /* 나일 청록 */
  --nile:        #1abc9c;
  --nile-light:  #4dd0ad;
  --nile-dark:   #117a64;

  /* 청금석 블루 */
  --lapis:       #3a78c2;
  --lapis-light: #5c9eea;

  --text:        #f0e6d2;
  --text-muted:  #b8a888;
  --text-dim:    #6e5a40;
  --text-inv:    #06101a;

  --ar-font:     'Noto Naskh Arabic', 'Amiri', 'Traditional Arabic', serif;
  --ar-serif:    'Amiri', serif;
  --font-ui:     'Inter', 'Noto Sans KR', sans-serif;
  --font-serif:  'Amiri', 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-gold: 0 0 30px rgba(212,161,74,0.18);

  --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;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-image:
    radial-gradient(ellipse 70% 50% at 10% 0%, rgba(212,161,74,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(26,188,156,0.05) 0%, transparent 60%);
  background-attachment: fixed;
}

/* 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-ui);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.01em;
}
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(--gold); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--gold-light); }

/* ── 아랍어 텍스트 (RTL) ── */
.ar {
  font-family: var(--ar-font);
  font-size: 1.35em;
  color: var(--gold-light);
  direction: rtl;
  unicode-bidi: isolate;
  letter-spacing: 0;
  font-weight: 500;
}
.ar-lg {
  font-family: var(--ar-font);
  font-size: 2.2rem;
  color: var(--gold-light);
  font-weight: 700;
  direction: rtl;
  unicode-bidi: isolate;
}
.ar-xl {
  font-family: var(--ar-serif);
  font-size: 3.6rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1.2;
  direction: rtl;
  unicode-bidi: isolate;
}
/* 발음 (라틴 전사) */
.tl {
  font-family: var(--font-ui);
  font-style: italic;
  font-size: 0.92em;
  color: var(--copper-light);
  letter-spacing: 0.02em;
}

/* ── Nav ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 64px;
  background: rgba(13,26,38,0.92);
  backdrop-filter: blur(12px);
  -webkit-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-ui);
  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-logo .logo-ar {
  font-family: var(--ar-font);
  color: var(--gold-light);
  font-size: 1.1rem;
  direction: rtl;
}
.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(--gold-glow); color: var(--gold-light); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: var(--transition);
  font-family: var(--font-ui);
  text-decoration: none;
}
.btn-primary {
  background: var(--gold);
  color: var(--text-inv);
}
.btn-primary:hover { background: var(--gold-light); transform: translateY(-1px); box-shadow: var(--shadow-gold); }
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text-muted);
}
.btn-secondary:hover { border-color: var(--gold-dark); color: var(--text); }
.btn-nile {
  background: var(--nile);
  color: #fff;
}
.btn-nile:hover { background: var(--nile-light); }
.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(--gold-dark); color: var(--gold-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(--nile-light);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.btn-tts:hover { border-color: var(--nile); background: rgba(26,188,156,0.1); }
.btn-tts.speaking { border-color: var(--nile); background: rgba(26,188,156,0.18); animation: pulse-nile 1s infinite; }
.btn-tts svg { width: 14px; height: 14px; }

@keyframes pulse-nile {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26,188,156,0.45); }
  50% { box-shadow: 0 0 0 5px 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-gold); border-color: var(--gold-dark); }

/* ── Badges ── */
.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-gold   { background: rgba(212,161,74,0.18); color: var(--gold-light); border: 1px solid rgba(212,161,74,0.3); }
.badge-copper { background: rgba(192,121,74,0.18); color: var(--copper-light); border: 1px solid rgba(192,121,74,0.3); }
.badge-nile   { background: rgba(26,188,156,0.15); color: var(--nile-light); border: 1px solid rgba(26,188,156,0.3); }
.badge-lapis  { background: rgba(58,120,194,0.15); color: var(--lapis-light); border: 1px solid rgba(58,120,194,0.3); }
.badge-dim    { background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }

/* 난이도 뱃지 */
.lvl { font-size:0.68rem; padding:0.12rem 0.5rem; border-radius:4px; letter-spacing:0.04em; font-weight:700; }
.lvl-A2 { background:rgba(26,188,156,.15); color:var(--nile-light); }
.lvl-B1 { background:rgba(212,161,74,.15); color:var(--gold-light); }
.lvl-B2 { background:rgba(192,121,74,.18); color:var(--copper-light); }

/* ── Progress Bar ── */
.progress-bar {
  height: 4px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--gold);
  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(--gold-light); margin-bottom: 1.2rem;
}
.section-label::before, .section-label::after {
  content: ''; width: 30px; height: 1px; background: var(--gold-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-gold { color: var(--gold-light); }
.text-nile { color: var(--nile-light); }
.text-copper { color: var(--copper-light); }
.text-center { text-align: center; }

/* ── TTS Status Bar ── */
.tts-bar {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--nile-dark);
  border-radius: var(--radius);
  padding: 0.75rem 1.2rem;
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.85rem; color: var(--nile-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(--nile); 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(--gold-dark); }

/* ══════════════════════════════════════════
   햄버거 메뉴
══════════════════════════════════════════ */
.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(6,16,26,0.97);
  backdrop-filter: blur(16px);
  -webkit-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.7rem 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(--gold-glow); color: var(--gold-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(--gold-dark); color: var(--gold-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; }
  .ar { font-size: 1.25em; }
  .ar-lg { font-size: 1.8rem; }
  .ar-xl { font-size: 2.4rem; }
}

/* 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); }
}
