/* =========================================================
   바알의 서판 — 우가릿어 학습앱
   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+Ugaritic&display=swap');

/* ── CSS 변수 ── */
:root {
  --bg:          #080b0f;
  --surface:     #0f141a;
  --surface-2:   #161d26;
  --surface-3:   #1e2836;
  --border:      #253040;
  --border-2:    #334560;

  --gold:        #c9a84c;
  --gold-light:  #e8c96d;
  --gold-dark:   #8a6f2e;
  --gold-glow:   rgba(201,168,76,0.12);

  --lapis:       #1e5799;
  --lapis-l:     #4a9fd4;
  --lapis-dark:  #0f3a6e;
  --lapis-glow:  rgba(30,87,153,0.15);

  --text:        #d8e8f0;
  --text-muted:  #7a99b0;
  --text-dim:    #4a6070;
  --text-inv:    #080b0f;

  --accent:      #4a9fd4;
  --accent-l:    #7bc4e8;

  --font-ui:     'Inter', sans-serif;
  --font-serif:  'Noto Serif', serif;
  --font-ugr:    'Noto Sans Ugaritic', 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(201,168,76,0.18);
  --shadow-lapis:0 0 30px rgba(74,159,212,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(--accent-l);
}

/* 우가릿 문자 표시 클래스 */
.ugr {
  font-family: var(--font-ugr);
  font-size: 1.4em;
  color: var(--gold);
  letter-spacing: 0.05em;
}

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

/* ── Navigation ── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: 64px;
  background: rgba(8,11,15,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;
}

.navbar-brand .ugr {
  font-size: 1.6rem;
  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.88rem;
  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.65rem 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);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,168,76,0.35);
  color: var(--text-inv);
}

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

.btn-lapis {
  background: var(--lapis);
  color: #fff;
}
.btn-lapis:hover {
  background: var(--lapis-l);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lapis);
  color: #fff;
}

.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-lapis {
  border-color: var(--lapis-dark);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(30,87,153,0.08) 100%);
}
.card-lapis:hover {
  border-color: var(--lapis);
  box-shadow: var(--shadow-lapis);
}

/* ── 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:hover {
  border-color: var(--gold-dark);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  color: inherit;
}

.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 .module-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
  margin: 0;
}

.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;
}

/* ── 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-dim   { background: var(--surface-2);        color: var(--text-dim); border: 1px solid var(--border); }
.badge-lapis { background: rgba(74,159,212,0.15);   color: var(--accent-l); border: 1px solid rgba(74,159,212,0.3); }

/* ── 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;
  border: none;
}

/* ── 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-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(--lapis);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.example-ugr {
  font-family: var(--font-ugr);
  font-size: 1.5rem;
  color: var(--gold-light);
  margin-bottom: 0.4rem;
  letter-spacing: 0.1em;
}

.example-translit {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--accent-l);
  margin-bottom: 0.3rem;
}

.example-translation {
  font-size: 0.9rem;
  color: var(--text-muted);
}

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

/* ── 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-lapis {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,159,212,0.3); }
  50%       { box-shadow: 0 0 0 8px rgba(74,159,212,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-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; }
.mb-4 { margin-bottom: 2rem; }
.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(--lapis); color: var(--accent-l); background: var(--lapis-glow); }
.search-btn .search-kbd {
  padding: 0.1rem 0.35rem;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.search-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  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(--lapis-dark);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 640px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.search-input-wrap {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.search-input-icon { color: var(--text-dim); font-size: 1.1rem; flex-shrink: 0; }
.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-close-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 1rem; cursor: pointer; padding: 0.2rem 0.4rem;
  border-radius: 4px; transition: var(--transition);
}
.search-close-btn:hover { background: var(--surface-3); color: var(--text); }
.search-results { max-height: 60vh; overflow-y: auto; padding: 0.5rem 0; }
.search-group-label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--lapis-l); text-transform: uppercase;
  padding: 0.6rem 1.25rem 0.3rem;
}
.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(37,48,64,0.6);
  text-decoration: none; color: inherit;
}
.search-result-item:hover { background: var(--lapis-glow); }
.search-result-ugr { font-family: var(--font-ugr); font-size: 1.4rem; color: var(--gold); flex-shrink: 0; min-width: 2.5rem; text-align: center; }
.search-result-body { flex: 1; }
.search-result-title { font-size: 0.9rem; color: var(--text); margin-bottom: 0.15rem; }
.search-result-title mark { background: rgba(201,168,76,0.22); color: var(--gold-light); border-radius: 2px; padding: 0 2px; }
.search-result-sub { font-size: 0.78rem; color: var(--text-dim); }
.search-result-tag {
  padding: 0.15rem 0.4rem; border-radius: 4px;
  font-size: 0.68rem; font-weight: 600; flex-shrink: 0;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border);
  align-self: flex-start;
}
.search-empty { padding: 2.5rem 1.5rem; text-align: center; color: var(--text-dim); font-size: 0.9rem; }
.search-hint { padding: 0.8rem 1.25rem; font-size: 0.75rem; color: var(--text-dim); border-top: 1px solid var(--border); display: flex; gap: 1.5rem; flex-wrap: wrap; }
.search-hint span { display: flex; align-items: center; gap: 0.3rem; }

/* ═══════════════════════════════════════════
   모바일 반응형 (네비게이션 + 햄버거)
═══════════════════════════════════════════ */
.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(8,11,15,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; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.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);
}

@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; }

  .reader-layout,
  .grammar-layout,
  .voc-layout,
  .alp-layout { grid-template-columns: 1fr !important; }

  .reader-sidebar,
  .grammar-sidebar,
  .voc-sidebar,
  .alp-sidebar {
    position: static !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
  }
}
