@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Literata:opsz,wght@18..144,400;18..144,500;18..144,600;18..144,700&display=swap");

:root {
  --bg: #0f1a1c;
  --panel: #16262a;
  --panel-raised: #1c2f33;
  --border: #274246;
  --text: #eef3f2;
  --muted: #8fa9ac;
  --amber: #e8a33d;
  --amber-dim: #a67628;
  --mint: #6fd6c4;
  --danger: #e2665f;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--mint); }

code {
  font-family: var(--mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

pre {
  font-family: var(--mono);
  background: #0b1416;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 6px;
}

.muted { color: var(--muted); }

button {
  font-family: var(--mono);
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--amber);
  color: #1a1204;
  font-weight: 700;
  padding: 10px 18px;
}
.btn-primary:hover { background: #f0b155; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--mint); }

/* ---------- Login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, rgba(111, 214, 196, 0.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(232, 163, 61, 0.08), transparent 40%),
    var(--bg);
}

.login-card {
  width: 340px;
  padding: 36px 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
}

.login-card h1 {
  font-family: var(--mono);
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.login-sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 24px;
}

.login-form label {
  display: block;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-form input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1rem;
  margin-bottom: 16px;
}

.login-form button {
  width: 100%;
  padding: 12px;
}

.login-error {
  color: var(--danger);
  font-family: var(--mono);
  font-size: 0.8rem;
  margin-top: 16px;
}

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.sidebar-header { padding: 0 24px 20px; }
.sidebar-header h1 { font-family: var(--mono); font-size: 1.2rem; margin: 0; }

.course-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.course-group { margin-bottom: 6px; }

.course-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.course-btn:hover { background: var(--panel-raised); }
.course-btn.active { background: var(--panel-raised); color: var(--amber); }
.course-btn .count { color: var(--muted); font-size: 0.75rem; }

.module-list { margin: 2px 0 10px 8px; padding-left: 10px; border-left: 1px solid var(--border); }

.module-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: var(--serif);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.module-btn .lvl {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--amber-dim);
  min-width: 34px;
}
.module-btn:hover { color: var(--text); }
.module-btn.active { color: var(--mint); background: rgba(111, 214, 196, 0.08); }
.module-btn.done .lvl { color: var(--mint); }
.module-btn.done::after { content: "✓"; margin-left: auto; color: var(--mint); font-size: 0.75rem; }

.other-section-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.other-section-btn:hover { color: var(--text); }
.other-section-btn.active { color: var(--amber); }

.empty-hint { color: var(--muted); font-family: var(--mono); font-size: 0.8rem; padding: 10px 12px; }

.sidebar-footer { padding: 16px 24px 0; border-top: 1px solid var(--border); margin-top: 12px; }
.sidebar-footer button { width: 100%; padding: 9px; }

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
}

/* ---------- Content ---------- */

.content {
  padding: 48px 56px 80px;
  max-width: 780px;
}

.welcome-screen h2 { font-family: var(--mono); font-size: 1.4rem; margin: 0 0 12px; }

.module-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.module-header h2 { font-size: 1.9rem; margin: 0; }

.module-progressbar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 18px 0 32px;
  overflow: hidden;
}
.module-progressbar-fill {
  height: 100%;
  background: var(--amber);
  transition: width 0.3s ease;
}

.lesson-body h3 { font-family: var(--mono); font-size: 1.1rem; color: var(--amber); margin-top: 2em; }
.lesson-body table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: 0.92rem; }
.lesson-body th, .lesson-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.lesson-body th { background: var(--panel-raised); font-family: var(--mono); font-size: 0.78rem; text-transform: uppercase; color: var(--muted); }
.lesson-body strong { color: var(--amber); }
.lesson-body ul, .lesson-body ol { padding-left: 1.3em; }
.lesson-body hr { border: none; border-top: 1px solid var(--border); margin: 2.2em 0; }

.module-actions {
  display: flex;
  gap: 12px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.mark-done-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- Flashcards ---------- */

.flashcard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 13, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.flashcard-modal {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flashcard-topbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.flashcard-progress { font-family: var(--mono); color: var(--muted); font-size: 0.85rem; }
.flashcard-actions { display: flex; gap: 8px; }

.flashcard {
  width: 100%;
  height: 280px;
  perspective: 1200px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.flashcard-back { transform: rotateY(180deg); border-color: var(--mint); }

.flashcard-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 14px;
}
.flashcard-back .flashcard-label { color: var(--mint); }

.flashcard-text { font-size: 1.2rem; margin: 0; }

.flashcard-hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin: 14px 0 0;
}

.flashcard-nav {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  width: 100%;
}
.flashcard-nav button { flex: 1; padding: 12px; }

@media (prefers-reduced-motion: reduce) {
  .flashcard-inner { transition: none; }
  .module-progressbar-fill { transition: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 20% 0 0;
    z-index: 15;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: flex; align-items: center; gap: 6px; }
  .content { padding: 90px 22px 60px; }
  .module-header h2 { font-size: 1.5rem; }
}

.flashcard-overlay[hidden] {
  display: none;
}
