/* Design system: DESIGN.md — "The Banker's Lamp" */

:root {
  --ink: #14181f;
  --ink-raised: #1c2330;
  --brass: #ab8552;
  --brass-deep: #8f6d40;
  --paper: #f4f2ee;
  --ink-text: #e8e6e0;
  --ink-text-muted: #a9adb8;
  --text: #1c1f26;
  --muted: #6b6f7a;
  --border-light: #d8d5cd;
  --correct: #4f7a5c;
  --partial: #b08a3f;
  --wrong: #9c4a44;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--paper);
  line-height: 1.5;
}

button { font-family: inherit; }

a { color: var(--brass-deep); }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ---------- App shell: 3 panels ---------- */

.app {
  display: grid;
  grid-template-columns: 20% 60% 20%;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: var(--ink-text);
  padding: 1.5rem 1rem;
}

.sidebar h2 {
  color: var(--ink-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar nav li { margin-bottom: 0.125rem; }

.sidebar nav button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink-text);
  padding: 0.55rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

.sidebar nav button:hover {
  background: var(--ink-raised);
}

.sidebar nav button.active {
  background: var(--ink-raised);
  color: var(--brass);
  font-weight: 600;
}

.sidebar nav button.completed::after {
  content: " \2713";
  color: var(--brass);
}

.main-content {
  background: var(--paper);
  color: var(--text);
  padding: 2rem 2.5rem;
  overflow-y: auto;
}

.main-content h1 { margin-top: 0; }

.summary-panel {
  background: var(--ink);
  color: var(--ink-text);
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
}

.summary-panel h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-text-muted);
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
}

.summary-panel h2:first-child { margin-top: 0; }

.progress-bar {
  height: 8px;
  background: var(--ink-raised);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-bar__fill {
  height: 100%;
  background: var(--brass);
  transition: width 0.2s ease-out;
}

.progress-count { font-size: 0.85rem; color: var(--ink-text-muted); }

.tag-list { list-style: none; padding: 0; margin: 0; }

.tag-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--ink-raised);
  color: var(--ink-text);
  border-radius: 4px;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.tag-list li.empty {
  background: none;
  border: 1px dashed rgba(232, 230, 224, 0.25);
  color: var(--ink-text-muted);
}

.tag-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.weakness-tag { color: var(--wrong); }
.weakness-tag span.tag-label { color: var(--ink-text); }

.glossary-term { color: var(--brass); }
.glossary-term div { display: flex; flex-direction: column; gap: 0.1rem; }
.glossary-term strong { color: var(--ink-text); font-weight: 600; }
.glossary-term small { color: var(--ink-text-muted); }

/* ---------- Exercises ---------- */

.exercise {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  background: #ffffff;
}

.exercise h3 { margin-top: 0; }

.exercise .options label {
  display: block;
  margin: 0.4rem 0;
  cursor: pointer;
}

.exercise textarea {
  width: 100%;
  min-height: 100px;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  resize: vertical;
  background: var(--paper);
  color: var(--text);
}

.exercise .submit-btn {
  background: var(--brass);
  color: var(--ink);
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.75rem;
}

.exercise .submit-btn:hover { background: var(--brass-deep); }
.exercise .submit-btn:disabled { opacity: 0.6; cursor: default; }

.feedback-box {
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: 6px;
  font-size: 0.92rem;
}

.feedback-box.score-correct { background: rgba(79, 122, 92, 0.12); border: 1px solid rgba(79, 122, 92, 0.4); color: #2f4d38; }
.feedback-box.score-partial { background: rgba(176, 138, 63, 0.12); border: 1px solid rgba(176, 138, 63, 0.4); color: #6b4f20; }
.feedback-box.score-wrong { background: rgba(156, 74, 68, 0.12); border: 1px solid rgba(156, 74, 68, 0.4); color: #6b302b; }

/* ---------- Misc UI ---------- */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.4rem;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  background: rgba(156, 74, 68, 0.12);
  border: 1px solid rgba(156, 74, 68, 0.4);
  color: #6b302b;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin: 1rem;
}

.mobile-nav-toggle { display: none; }

/* ---------- Mobile adaptations (per prompt §5.4) ---------- */

@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .sidebar { display: flex; flex-direction: column; }
  .sidebar nav ul { display: none; }
  .sidebar nav ul.open { display: block; }
  .mobile-nav-toggle {
    display: inline-block;
    background: var(--ink-raised);
    color: var(--brass);
    border: 1px solid var(--brass);
    border-radius: 4px;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    align-self: flex-start;
  }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  .main-content, .summary-panel, .sidebar { padding: 1rem; }
}

@media print {
  .sidebar, .summary-panel, .mobile-nav-toggle { display: none; }
  .app { display: block; }
}
