/* ─────────────────────────────────────────────
   창세기로 배우는 독일어 — 메인 스타일시트
   다크 테마 · 종교개혁 앰버 팔레트
───────────────────────────────────────────── */

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

/* ── CSS Variables ── */
:root {
  /* Background */
  --bg:           #0d0a07;
  --surface:      #181108;
  --surface-2:    #221809;
  --surface-3:    #2d200e;
  --overlay:      rgba(13,10,7,0.85);

  /* Amber / Gold — primary accent */
  --amber:        #d4963a;
  --amber-light:  #e8b85c;
  --amber-dark:   #a06c20;
  --amber-dim:    rgba(212,150,58,0.12);
  --amber-glow:   rgba(212,150,58,0.25);

  /* CEFR level colors */
  --a1:  #4caf7d;   /* green */
  --a2:  #5ba3d9;   /* blue  */
  --b1:  #e8b85c;   /* amber */
  --b2:  #e05c5c;   /* red   */

  /* Text */
  --text:         #ecdfc8;
  --text-muted:   #9a8878;
  --text-dim:     #5c4e42;

  /* Borders */
  --border:       #3d2d1a;
  --border-light: #5a4030;

  /* State */
  --success:      #4caf7d;
  --error:        #e05c5c;
  --warn:         #e8b85c;
  --info:         #5ba3d9;

  /* Typography */
  --font-ui:      'Noto Sans KR', 'Noto Sans', sans-serif;
  --font-serif:   'Noto Serif KR', 'Noto Serif', Georgia, serif;
  --font-de:      'Noto Serif', Georgia, serif;

  /* Layout */
  --radius:       8px;
  --radius-sm:    4px;
  --radius-lg:    14px;
  --sidebar-w:    260px;
  --topbar-h:     56px;
  --max-w:        900px;

  /* Transition */
  --t:            180ms ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

img, svg { display: block; max-width: 100%; }

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  transition: all var(--t);
}

input, select, textarea {
  font-family: var(--font-ui);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  transition: border-color var(--t);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
}

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

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--text);
  line-height: 1.3;
}
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.7rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; font-family: var(--font-ui); font-weight: 700; }

p { margin-bottom: 0.85rem; }
p:last-child { margin-bottom: 0; }

strong { color: var(--amber-light); font-weight: 600; }
em { color: var(--text-muted); font-style: italic; }

/* ── Utilities ── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted { color: var(--text-muted); }
.text-amber { color: var(--amber); }
.text-de { font-family: var(--font-de); }
.text-center { text-align: center; }
.flex { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

/* ── CEFR Badges ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
  border: 1px solid currentColor;
}
.badge-a1 { color: var(--a1); background: rgba(76,175,125,0.12); }
.badge-a2 { color: var(--a2); background: rgba(91,163,217,0.12); }
.badge-b1 { color: var(--b1); background: rgba(232,184,92,0.12); }
.badge-b2 { color: var(--b2); background: rgba(224,92,92,0.12); }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color var(--t), box-shadow var(--t);
}
.card:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 24px rgba(212,150,58,0.08);
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.45rem;
  font-size: 0.9rem; font-weight: 600;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all var(--t);
  white-space: nowrap;
}
.btn-primary {
  background: var(--amber);
  color: var(--bg);
  border-color: var(--amber);
}
.btn-primary:hover {
  background: var(--amber-light);
  border-color: var(--amber-light);
}
.btn-outline {
  background: transparent;
  color: var(--amber);
  border-color: var(--amber-dark);
}
.btn-outline:hover {
  background: var(--amber-dim);
  border-color: var(--amber);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-light);
}
.btn-sm { font-size: 0.8rem; padding: 0.4rem 0.9rem; }
.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-icon:hover {
  color: var(--amber);
  background: var(--amber-dim);
  border-color: var(--amber-dark);
}

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  background: rgba(13,10,7,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.25rem;
  gap: 0.75rem;
}
.topbar-logo {
  font-family: var(--font-serif);
  font-size: 1rem; font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.topbar-logo span { color: var(--text-muted); font-weight: 400; }
.topbar-spacer { flex: 1; }
.topbar-nav { display: flex; align-items: center; gap: 0.25rem; }
.topbar-nav a {
  font-size: 0.82rem; font-weight: 600;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all var(--t);
  white-space: nowrap;
}
.topbar-nav a:hover, .topbar-nav a.active {
  color: var(--amber);
  background: var(--amber-dim);
}
.topbar-burger {
  display: none;
  flex-direction: column; gap: 5px;
  padding: 8px; cursor: pointer;
}
.topbar-burger span {
  display: block; width: 22px; height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: all var(--t);
}

/* ── Sidebar (for module pages) ── */
.layout {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: calc(100vh - var(--topbar-h));
  position: sticky; top: var(--topbar-h);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  background: var(--surface);
}
.sidebar-title {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 1.25rem 0.75rem;
}
.sidebar-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--t);
}
.sidebar-item:hover { color: var(--text); background: var(--surface-2); }
.sidebar-item.active {
  color: var(--amber);
  background: var(--amber-dim);
  border-left-color: var(--amber);
  font-weight: 600;
}
.sidebar-item .badge { margin-left: auto; }

/* ── Main content area ── */
.main-content {
  flex: 1;
  max-width: calc(100% - var(--sidebar-w));
  padding: 2rem 2.5rem;
  overflow-x: hidden;
}

/* ── Section header ── */
.section-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.section-header h2 { margin-bottom: 0.35rem; }
.section-header p { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* ── Progress bar ── */
.progress-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-dark), var(--amber));
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ── German text display ── */
.de-text {
  font-family: var(--font-de);
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.8;
}
.de-text-lg {
  font-family: var(--font-de);
  font-size: 1.3rem;
  line-height: 1.9;
}
.ko-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── Table ── */
.tbl-wrap { overflow-x: auto; margin: 1rem 0; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.9rem;
}
th {
  background: var(--surface-3);
  color: var(--amber);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
td.de { font-family: var(--font-de); font-size: 1rem; color: var(--amber-light); }

/* ── Quiz / Flash card ── */
.quiz-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.quiz-question {
  font-size: 1rem; font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}
.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.quiz-btn {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  text-align: left;
  transition: all var(--t);
}
.quiz-btn:hover { border-color: var(--amber-dark); color: var(--text); background: var(--surface-3); }
.quiz-btn.correct { background: rgba(76,175,125,0.15); border-color: var(--a1); color: var(--a1); }
.quiz-btn.wrong   { background: rgba(224,92,92,0.12);  border-color: var(--b2);  color: var(--b2); }
.quiz-result { margin-top: 1rem; font-size: 0.9rem; padding: 0.75rem; border-radius: var(--radius-sm); }
.quiz-result.correct { background: rgba(76,175,125,0.12); color: var(--a1); border: 1px solid rgba(76,175,125,0.3); }
.quiz-result.wrong   { background: rgba(224,92,92,0.10);  color: var(--b2); border: 1px solid rgba(224,92,92,0.3); }

/* ── Popup / Tooltip ── */
.popup {
  position: fixed; z-index: 200;
  background: var(--surface-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  min-width: 200px; max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t), transform var(--t);
}
.popup.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.popup-de { font-family: var(--font-de); font-size: 1.2rem; color: var(--amber-light); font-weight: 700; }
.popup-pos { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); margin: 0.2rem 0; }
.popup-ko { color: var(--text); }
.popup-grammar a { font-size: 0.8rem; color: var(--amber); margin-top: 0.4rem; display: block; }

/* ── TTS button ── */
.tts-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all var(--t);
  flex-shrink: 0;
}
.tts-btn:hover { color: var(--amber); border-color: var(--amber-dark); background: var(--amber-dim); }
.tts-btn.playing { color: var(--amber); border-color: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* ── Toggle switch ── */
.toggle {
  position: relative; width: 40px; height: 22px;
  display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--t);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--t), background var(--t);
}
.toggle input:checked + .toggle-slider { background: var(--amber-dim); border-color: var(--amber); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--amber); }

/* ── Flashcard ── */
.flashcard {
  perspective: 1000px;
  width: 100%; max-width: 480px;
  margin: 0 auto;
}
.flashcard-inner {
  position: relative;
  width: 100%; padding-top: 60%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(.4,0,.2,1);
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem; cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t);
}
.flashcard-face:hover { border-color: var(--amber-dark); box-shadow: 0 4px 20px rgba(212,150,58,0.1); }
.flashcard-back { transform: rotateY(180deg); }
.flashcard-de {
  font-family: var(--font-de);
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  color: var(--amber-light); font-weight: 700;
  text-align: center; margin-bottom: 0.5rem;
}
.flashcard-ko {
  font-size: 1.2rem; color: var(--text);
  text-align: center; margin-bottom: 0.5rem;
}
.flashcard-meta { font-size: 0.8rem; color: var(--text-muted); text-align: center; }

/* ── SRS rating buttons ── */
.srs-btns {
  display: flex; gap: 0.6rem;
  justify-content: center; margin-top: 1.25rem;
  flex-wrap: wrap;
}
.srs-btn {
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 600;
  border: 1px solid transparent;
}
.srs-again  { background: rgba(224,92,92,0.15);  color: var(--b2);     border-color: rgba(224,92,92,0.3);  }
.srs-hard   { background: rgba(232,184,92,0.12); color: var(--b1);     border-color: rgba(232,184,92,0.3); }
.srs-good   { background: rgba(91,163,217,0.12); color: var(--a2);     border-color: rgba(91,163,217,0.3); }
.srs-easy   { background: rgba(76,175,125,0.12); color: var(--a1);     border-color: rgba(76,175,125,0.3); }
.srs-again:hover  { background: rgba(224,92,92,0.25); }
.srs-hard:hover   { background: rgba(232,184,92,0.22); }
.srs-good:hover   { background: rgba(91,163,217,0.22); }
.srs-easy:hover   { background: rgba(76,175,125,0.22); }

/* ── POS color coding ── */
.pos-VERB  { color: #7ec8e3; }
.pos-NOUN  { color: #e8b85c; }
.pos-ADJ   { color: #a8e6a3; }
.pos-ADV   { color: #d4a5e8; }
.pos-PREP  { color: #f0a080; }
.pos-ART   { color: #80c8a0; }
.pos-PRON  { color: #e0d080; }
.pos-CONJ  { color: #c0c0c0; }

/* ── Verse / Reader ── */
.verse {
  display: flex; gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  cursor: default;
  transition: background var(--t);
  border-radius: var(--radius-sm);
}
.verse:last-child { border-bottom: none; }
.verse:hover { background: var(--surface-2); padding-left: 0.5rem; }
.verse-num {
  flex-shrink: 0;
  width: 2rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--amber-dark);
  padding-top: 0.25rem;
  text-align: right;
  font-family: var(--font-de);
}
.verse-body { flex: 1; }
.verse-de {
  font-family: var(--font-de);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.verse-ko {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: none;
}
.verse-ko.show { display: block; }
.word-token {
  cursor: pointer;
  border-radius: 3px;
  transition: background var(--t), color var(--t);
  padding: 0 1px;
}
.word-token:hover { background: var(--amber-dim); color: var(--amber-light); }

/* ── Phrase card (conversation) ── */
.phrase-card {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  transition: border-color var(--t);
}
.phrase-card:hover { border-color: var(--border-light); }
.phrase-de { font-family: var(--font-de); font-size: 1rem; color: var(--text); }
.phrase-phonetic { font-size: 0.78rem; color: var(--amber-dark); font-style: italic; margin-top: 0.1rem; }
.phrase-ko { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Stat chip ── */
.stat { text-align: center; }
.stat-num {
  font-family: var(--font-serif);
  font-size: 2rem; font-weight: 700;
  color: var(--amber);
  line-height: 1;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.3rem;
}

/* ── Mobile navigation drawer ── */
.mobile-menu {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: var(--overlay);
}
.mobile-menu.open { display: flex; }
.mobile-drawer {
  width: min(280px, 85vw);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  overflow-y: auto;
}
.mobile-drawer nav { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 1.5rem; }
.mobile-drawer nav a {
  font-size: 1rem; font-weight: 600;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  transition: all var(--t);
}
.mobile-drawer nav a:hover, .mobile-drawer nav a.active {
  color: var(--amber);
  background: var(--amber-dim);
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; z-index: 500;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem; font-weight: 600;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transition: transform 0.35s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ────────────────────
   RESPONSIVE
──────────────────── */

/* Tablet */
@media (max-width: 900px) {
  .topbar-nav { display: none; }
  .topbar-burger { display: flex; }
  .sidebar { display: none; }
  .main-content {
    max-width: 100%;
    padding: 1.5rem 1.25rem;
  }
  .quiz-choices { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 600px) {
  :root { --topbar-h: 50px; }
  .main-content { padding: 1rem; }
  .card { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .topbar-logo { font-size: 0.9rem; }
  .flashcard { max-width: 100%; }
  .flashcard-inner { padding-top: 70%; }
  .flashcard-de { font-size: 1.8rem; }
  .srs-btns { gap: 0.4rem; }
  .srs-btn { padding: 0.45rem 0.8rem; font-size: 0.8rem; }
  .verse-de { font-size: 0.97rem; }
  .stat-num { font-size: 1.6rem; }
  table { font-size: 0.82rem; }
  th, td { padding: 0.45rem 0.7rem; }
  .btn { font-size: 0.85rem; padding: 0.55rem 1rem; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
}

/* Print */
@media print {
  .topbar, .sidebar, .tts-btn, .btn, .quiz-wrap { display: none !important; }
  body { background: white; color: black; }
  .de-text, .verse-de, td.de { color: #1a1a1a; }
  .verse-ko.show { color: #555; }
}
