/* =========================================================
   페니키아어 학습 앱
   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=Frank+Ruhl+Libre:wght@400;700&display=swap');

/* ── CSS 변수 ── */
:root {
  --bg:          #09080c;
  --surface:     #110f15;
  --surface-2:   #1a1720;
  --surface-3:   #221e2a;
  --border:      #2e2838;
  --border-2:    #403858;

  /* 골드 (주 포인트) */
  --gold:        #c9a84c;
  --gold-light:  #e8c96d;
  --gold-dark:   #8a6f2e;
  --gold-glow:   rgba(201,168,76,0.12);

  /* 티리안 퍼플 (페니키아 상징색) */
  --purple:      #9b4dca;
  --purple-l:    #c07ff0;
  --purple-dark: #5c2680;
  --purple-glow: rgba(155,77,202,0.12);

  /* 크림슨 (강조) */
  --crimson:     #8b1a1a;
  --crimson-l:   #b52222;

  --text:        #ede0c8;
  --text-muted:  #9d8f7a;
  --text-dim:    #5e5249;
  --text-inv:    #1a1014;

  --accent:      #4a7fa5;
  --accent-l:    #6aafd4;

  --font-ui:     'Inter', sans-serif;
  --font-serif:  'Noto Serif', serif;
  --font-hebrew: 'Frank Ruhl Libre', 'SBL Hebrew', serif;

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

  --shadow-sm:    0 2px 8px rgba(0,0,0,0.45);
  --shadow:       0 4px 20px rgba(0,0,0,0.55);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.65);
  --shadow-gold:  0 0 30px rgba(201,168,76,0.18);
  --shadow-purple:0 0 30px rgba(155,77,202,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;
}

/* ── 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(--gold); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--gold-light); }

code, .mono {
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.88em;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--gold-light);
}

/* 페니키아 알파벳 (유니코드 페니키아 블록 사용) */
.phoen {
  font-family: 'Segoe UI Historic', 'Noto Sans Phoenician', serif;
  font-size: 1.4em;
  color: var(--gold);
  letter-spacing: 0.1em;
  direction: rtl;
}

/* 히브리어 폰트 */
.heb {
  font-family: var(--font-hebrew);
  font-size: 1.15em;
  direction: rtl;
  color: var(--purple-l);
}

/* 로마자 음역 */
.translit {
  font-style: italic;
  color: var(--gold-light);
  font-family: var(--font-serif);
}

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

/* ── Navigation ── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: 64px;
  background: rgba(9,8,12,0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 2rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}

.navbar-brand .brand-icon {
  font-size: 1.5rem;
  color: var(--gold);
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin-left: auto;
}

.navbar-links a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
}

.navbar-links a:hover,
.navbar-links a.active {
  background: var(--gold-glow);
  color: var(--gold-light);
}

.navbar-links a .icon { font-size: 1rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--gold);
  color: var(--text-inv);
}
.btn-primary:hover {
  background: var(--gold-light);
  color: var(--text-inv);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,168,76,0.4);
}

.btn-purple {
  background: var(--purple);
  color: #fff;
}
.btn-purple:hover {
  background: var(--purple-l);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(155,77,202,0.4);
}

.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dark);
}
.btn-outline:hover {
  background: var(--gold-glow);
  color: var(--gold-light);
  border-color: var(--gold);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* ── 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);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card-gold {
  border-color: var(--gold-dark);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(201,168,76,0.05) 100%);
}
.card-gold:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}
.card-purple {
  border-color: var(--purple-dark);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(155,77,202,0.05) 100%);
}
.card-purple:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow-purple);
}

/* ── Module Cards ── */
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: var(--transition);
}

.module-card.mod-purple::before {
  background: linear-gradient(90deg, transparent, var(--purple), transparent);
}

.module-card:hover {
  border-color: var(--gold-dark);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.module-card.mod-purple:hover {
  border-color: var(--purple-dark);
  box-shadow: var(--shadow-purple);
}

.module-card:hover::before { opacity: 1; }

.module-card .module-icon { font-size: 2.2rem; line-height: 1; }
.module-card .module-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.module-card .module-sub {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.module-card.mod-purple .module-sub { color: var(--purple-l); }
.module-card .module-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}
.module-card .module-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: auto;
}

/* ── Progress Bar ── */
.progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 2px;
  transition: width 0.6s ease;
}
.progress-bar-fill.purple {
  background: linear-gradient(90deg, var(--purple-dark), var(--purple));
}

/* ── Badge / Tag ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge-gold   { background: rgba(201,168,76,0.15); color: var(--gold); border: 1px solid rgba(201,168,76,0.3); }
.badge-purple { background: rgba(155,77,202,0.15); color: var(--purple-l); border: 1px solid rgba(155,77,202,0.3); }
.badge-dim    { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.badge-blue   { background: rgba(74,127,165,0.15); color: var(--accent-l); border: 1px solid rgba(74,127,165,0.3); }

/* ── Chip (문법 태그) ── */
.chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: rgba(74,127,165,0.15);
  color: var(--accent-l);
  border: 1px solid rgba(74,127,165,0.25);
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.divider-gold {
  border-color: transparent;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
  height: 1px;
}
.divider-purple {
  border-color: transparent;
  background: linear-gradient(90deg, transparent, var(--purple-dark), transparent);
  height: 1px;
}

/* ── Section ── */
.section { padding: 4rem 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }

.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.section-label.purple { color: var(--purple-l); }

.section-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.section-desc {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 600px;
  line-height: 1.7;
}

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ── Table ── */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  background: var(--surface-2);
  color: var(--gold);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 0.65rem 1rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody td:first-child { color: var(--text); font-weight: 500; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ── Example Block ── */
.example-block {
  background: var(--surface-2);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}
.example-phoenician {
  font-family: 'Segoe UI Historic', 'Noto Sans Phoenician', serif;
  font-size: 1.3rem;
  color: var(--gold-light);
  margin-bottom: 0.3rem;
  direction: rtl;
  letter-spacing: 0.1em;
}
.example-translit {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 0.25rem;
}
.example-hebrew {
  font-family: var(--font-hebrew);
  font-size: 1.1rem;
  color: var(--purple-l);
  margin-bottom: 0.25rem;
  direction: rtl;
}
.example-translation {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Parallel Text (나란히 보기) ── */
.parallel-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.parallel-col {
  padding: 1rem;
  border-right: 1px solid var(--border);
}
.parallel-col:last-child { border-right: none; }
.parallel-col-header {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 900px) {
  .parallel-wrap { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 580px) {
  .parallel-wrap { grid-template-columns: 1fr; }
}

/* ── Word Token (클릭 가능한 단어) ── */
.word-token {
  display: inline-block;
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 3px;
  transition: var(--transition);
  position: relative;
}
.word-token:hover {
  background: var(--gold-glow);
  color: var(--gold-light);
}
.word-token.active {
  background: rgba(201,168,76,0.2);
  color: var(--gold);
}

/* ── Word Popup ── */
.word-popup {
  position: fixed;
  z-index: 3000;
  background: var(--surface-2);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-width: 280px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  display: none;
}
.word-popup.open { display: block; }
.word-popup-phoen {
  font-family: 'Segoe UI Historic', 'Noto Sans Phoenician', serif;
  font-size: 2rem;
  color: var(--gold);
  direction: rtl;
  margin-bottom: 0.3rem;
}
.word-popup-translit {
  font-style: italic;
  color: var(--gold-light);
  font-family: var(--font-serif);
  margin-bottom: 0.5rem;
}
.word-popup-row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
}
.word-popup-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  min-width: 50px;
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,168,76,0.3); }
  50%       { box-shadow: 0 0 0 8px rgba(201,168,76,0); }
}
@keyframes pulse-purple {
  0%, 100% { box-shadow: 0 0 0 0 rgba(155,77,202,0.3); }
  50%       { box-shadow: 0 0 0 8px rgba(155,77,202,0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeInUp 0.5s ease both; }
.fade-in-delay-1 { animation-delay: 0.1s; }
.fade-in-delay-2 { animation-delay: 0.2s; }
.fade-in-delay-3 { animation-delay: 0.3s; }
.fade-in-delay-4 { animation-delay: 0.4s; }

/* ── Utility ── */
.text-center { text-align: center; }
.text-gold   { color: var(--gold); }
.text-purple { color: var(--purple-l); }
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* ═══════════════════════════════════════════
   검색 오버레이 (전체 모듈 공통)
═══════════════════════════════════════════ */
.search-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.search-btn:hover { border-color: var(--gold-dark); color: var(--gold); background: var(--gold-glow); }

.search-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.search-overlay.open { display: flex; }
.search-modal {
  background: var(--surface-2);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 640px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 1rem; font-family: var(--font-ui);
}
.search-input::placeholder { color: var(--text-dim); }
.search-results { max-height: 60vh; overflow-y: auto; padding: 0.5rem 0; }
.search-result-item {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.6rem 1.25rem; cursor: pointer; transition: var(--transition);
  border-bottom: 1px solid rgba(46,40,56,0.4);
  text-decoration: none; color: inherit;
}
.search-result-item:hover { background: var(--gold-glow); }
.search-empty { padding: 2.5rem 1.5rem; text-align: center; color: var(--text-dim); font-size: 0.9rem; }

/* ═══════════════════════════════════════════
   모바일 반응형 (네비게이션 + 햄버거)
═══════════════════════════════════════════ */
.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(9,8,12,0.97);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 999;
  padding: 1rem 1.5rem;
  flex-direction: column; gap: 0.3rem;
  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);
}
.nav-drawer a:hover, .nav-drawer a.active {
  background: var(--gold-glow); color: var(--gold-light);
}

/* 사이드바 레이아웃 (reader, grammar, vocab, alphabet) */
.page-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 64px);
}
.page-sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem 0;
}
.page-main { padding: 2rem; overflow-y: auto; }

.sidebar-header {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.sidebar-nav-item:hover { color: var(--text); background: var(--surface-2); }
.sidebar-nav-item.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: var(--gold-glow);
}

@media (max-width: 768px) {
  .navbar { padding: 0 1rem; gap: 0.75rem; }
  .navbar-links { display: none; }
  .nav-hamburger { display: flex; }
  .section { padding: 3rem 0; }
  .container { padding: 0 1rem; }
  .page-layout { grid-template-columns: 1fr; }
  .page-sidebar { display: none; }
}
