/* =============================================================================
   Sapital — design system
   A calm, credible palette (deep teal = finance/trust) on a soft neutral canvas.
   Type: Inter for UI. Generous whitespace, soft shadows, and clear correct/incorrect
   states for a focused self-study surface.
   ============================================================================= */

:root {
  /* Brand */
  --brand: #0b6b5b;
  --brand-ink: #084f44;
  --brand-dark: #063c34;
  --brand-tint: #e9f4f1;
  --brand-tint-2: #d6ebe6;

  /* Ink & neutrals */
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e4e7ec;
  --line-soft: #eef0f3;
  --bg: #f6f8f9;
  --surface: #ffffff;

  /* Semantic */
  --correct: #067647;
  --correct-bg: #ecfdf3;
  --correct-line: #a6f0c6;
  --wrong: #b42318;
  --wrong-bg: #fef3f2;
  --wrong-line: #fecdc9;
  --warn: #b54708;
  --warn-bg: #fffaeb;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.14);

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --maxw: 760px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--brand-ink); }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--brand-ink);
  text-decoration: none;
}
.brand-mark { width: 28px; height: 28px; display: block; border-radius: 7px; }

.site-header nav { display: flex; align-items: center; gap: 0.35rem; }
.site-header nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.94rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.site-header nav a:hover { color: var(--brand-ink); background: var(--brand-tint); }

.inline { display: inline; margin: 0; }
.linklike {
  background: none; border: 0; cursor: pointer;
  color: var(--ink-2); font: inherit; font-weight: 500; font-size: 0.94rem;
  padding: 0.4rem 0.7rem; border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.linklike:hover { color: var(--wrong); background: var(--wrong-bg); }

/* --------------------------------------------------------------- Layout --- */
.container { flex: 1; width: 100%; max-width: var(--maxw); margin: 2.25rem auto; padding: 0 1.25rem; }

.muted { color: var(--muted); }
.center { text-align: center; }

/* --------------------------------------------------------------- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.72rem 1.3rem;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 0.85rem 1.6rem; font-size: 1.05rem; }

.btn-ghost {
  background: var(--surface);
  color: var(--brand-ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--brand-tint); border-color: var(--brand-tint-2); }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; margin-top: 1.5rem; }

/* ---------------------------------------------------------------- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1.25rem; }
.card-title { font-size: 1rem; margin: 0 0 1rem; color: var(--ink); font-weight: 650; }

/* ---------------------------------------------------------- Landing hero --- */
.hero { text-align: center; padding: 1rem 0 0.5rem; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--brand-ink);
  background: var(--brand-tint);
  border: 1px solid var(--brand-tint-2);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.1rem;
}
.hero h1 {
  font-size: 2.4rem;
  margin: 0 0 0.75rem;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, var(--ink) 0%, var(--brand-ink) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 560px; margin: 0 auto 1.4rem; }
.hero .btn-row { justify-content: center; }
.hero-note { font-size: 0.9rem; color: var(--muted); margin-top: 0.9rem; }

/* Trust strip */
.trust-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem 1.4rem;
  margin: 1.75rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}
.trust-strip span { display: inline-flex; align-items: center; gap: 0.4rem; }
.trust-strip svg { color: var(--brand); flex-shrink: 0; }

/* Feature grid */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand-tint);
  color: var(--brand);
  margin-bottom: 0.85rem;
}
.feature h3 { font-size: 1.02rem; margin: 0 0 0.35rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.94rem; }

/* How it works */
.section-head { text-align: center; margin: 3rem 0 1.5rem; }
.section-head h2 { font-size: 1.5rem; margin: 0 0 0.4rem; }
.section-head p { margin: 0; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.step { position: relative; padding: 1.3rem; background: var(--surface);
        border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 999px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 0.9rem;
  margin-bottom: 0.7rem;
}
.step h3 { font-size: 1rem; margin: 0 0 0.3rem; }
.step p { margin: 0; color: var(--muted); font-size: 0.93rem; }

/* Closing CTA band */
.cta-band {
  margin-top: 3rem;
  text-align: center;
  background: linear-gradient(135deg, var(--brand-ink), var(--brand-dark));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 2.4rem 1.5rem;
  box-shadow: var(--shadow-md);
}
.cta-band h2 { font-size: 1.55rem; margin: 0 0 0.5rem; color: #fff; }
.cta-band p { margin: 0 auto 1.4rem; color: rgba(255, 255, 255, 0.82); max-width: 460px; }
.cta-band .btn { background: #fff; color: var(--brand-ink); border-color: #fff; }
.cta-band .btn:hover { background: var(--brand-tint); }

/* ------------------------------------------------------- Question card --- */
.q-progress { margin-bottom: 1.5rem; }
.q-progress-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem;
}
.q-progress-meta strong { color: var(--ink-2); font-weight: 600; }

.meta { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1.15rem; align-items: center; }
.tag {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand-ink);
  letter-spacing: 0.01em;
}
.tag-muted { background: var(--line-soft); color: var(--muted); }
.tag-correct { background: var(--correct-bg); color: var(--correct); border: 1px solid var(--correct-line); }
.tag-wrong { background: var(--wrong-bg); color: var(--wrong); border: 1px solid var(--wrong-line); }

.stem { font-size: 1.12rem; line-height: 1.6; color: var(--ink); margin-bottom: 1.4rem; }

.choices { list-style: none; padding: 0; margin: 0 0 1.4rem; }
.choices li { margin-bottom: 0.6rem; }
.choices label {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.choices label:hover { border-color: var(--brand); background: var(--brand-tint); }
.choices input[type="radio"] { margin-top: 0.2rem; accent-color: var(--brand); width: 1.05rem; height: 1.05rem; flex-shrink: 0; }
.choices label:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: 0 0 0 3px var(--brand-tint-2);
}

/* Resolved (after answering) */
.choices-resolved { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.choices-resolved li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  color: var(--ink-2);
}
.choice-correct { border-color: var(--correct-line); background: var(--correct-bg); color: var(--ink); }
.choice-chosen-wrong { border-color: var(--wrong-line); background: var(--wrong-bg); color: var(--ink); }
.badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--correct);
  color: #fff;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-wrong { background: var(--wrong); }

/* Explanation panel */
.explanation {
  margin-top: 1.4rem;
  padding: 1.2rem 1.25rem;
  background: var(--brand-tint);
  border: 1px solid var(--brand-tint-2);
  border-radius: var(--radius-sm);
}
.explanation h2 {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.95rem; margin: 0 0 0.6rem; color: var(--brand-ink); font-weight: 650;
}
.explanation > div { color: var(--ink-2); line-height: 1.65; }

/* Bilingual mode: English explanation sits under the Vietnamese one, visually set off. */
.explanation-en {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--brand-tint-2);
}
.explanation-lang {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

/* Language toggle in the header. */
.lang-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
}
.lang-toggle:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-tint); }

/* -------------------------------------------------------- Progress page --- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 1.7rem; margin: 0; letter-spacing: -0.02em; }
.page-head .btn { margin-top: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 2rem; font-weight: 750; color: var(--brand-ink); letter-spacing: -0.02em; }
.stat-den { font-size: 1rem; font-weight: 600; color: var(--faint); }
.stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }

.bar {
  height: 10px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.7rem;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-ink));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--line-soft);
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table td:not(:first-child), .data-table th:not(:first-child) { text-align: right; }
.data-table td:first-child { font-weight: 500; }

.activity { list-style: none; padding: 0; margin: 0; }
.activity li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.activity li:last-child { border-bottom: 0; }
.activity-stem { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.activity-when { font-size: 0.8rem; white-space: nowrap; color: var(--faint); }
.dot { width: 9px; height: 9px; border-radius: 999px; flex-shrink: 0; }
.dot-ok { background: var(--correct); }
.dot-no { background: var(--wrong); }

/* --- Feedback & question reports --- */
.footer-link { color: var(--brand-ink); text-decoration: none; font-weight: 600; }
.footer-link:hover { text-decoration: underline; }

.report { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
.report-trigger { font-size: 0.85rem; }

.report-form .report-title { font-size: 0.9rem; font-weight: 600; margin: 0 0 0.6rem; }
.report-cats { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.7rem; }
.report-cats label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; }
.report-actions { display: flex; align-items: center; gap: 0.75rem; }
.report-actions .btn { margin-top: 0; }

.report-done { display: flex; align-items: center; gap: 0.5rem; color: var(--correct); font-size: 0.9rem; margin: 0; }
.report-done-mark { font-weight: 700; }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; }

/* Shared form controls (feedback page + report message) */
.field-label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.9rem 0 0.35rem; color: var(--brand-ink); }
.field-label:first-of-type { margin-top: 0; }
.field-input, .field-select, .field-textarea, .report-message {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
.field-textarea, .report-message { resize: vertical; }
.report-message { margin-bottom: 0.7rem; }
.field-input:focus, .field-select:focus, .field-textarea:focus, .report-message:focus {
  outline: none; border-color: var(--brand);
}
.feedback-form .btn { margin-top: 1.1rem; }
.form-error { color: var(--wrong); font-size: 0.88rem; margin: 0.6rem 0 0; }

/* ----------------------------------------------------------- Auth pages --- */
.auth-wrap { max-width: 400px; margin: 0 auto; }
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-head .brand { justify-content: center; font-size: 1.3rem; margin-bottom: 1rem; }
.auth-head h1 { font-size: 1.5rem; margin: 0 0 0.35rem; }
.auth-head p { margin: 0; color: var(--muted); }

.form-field { margin-bottom: 1rem; }
.form-field > label { display: block; font-weight: 550; font-size: 0.9rem; margin-bottom: 0.35rem; color: var(--ink-2); }
.form-field input:not([type="checkbox"]) {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.98rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint-2);
}
.form-field .helptext { display: block; font-size: 0.8rem; color: var(--faint); margin-top: 0.35rem; line-height: 1.4; }
.form-field ul { margin: 0.35rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--faint); }
.form-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--ink-2); }
.form-check input { accent-color: var(--brand); }
.btn-block { width: 100%; justify-content: center; margin-top: 0.5rem; }

.errorlist { list-style: none; margin: 0.3rem 0 0; padding: 0; color: var(--wrong); font-size: 0.85rem; }
.form-errors {
  background: var(--wrong-bg);
  border: 1px solid var(--wrong-line);
  color: var(--wrong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.auth-alt { text-align: center; margin-top: 1.25rem; color: var(--muted); font-size: 0.92rem; }
.auth-aux { text-align: right; margin: -0.4rem 0 0.9rem; font-size: 0.85rem; }

/* Django messages */
.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.messages li {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  font-size: 0.92rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
.messages li.success { background: var(--correct-bg); border-color: var(--correct-line); color: var(--correct); }
.messages li.error { background: var(--wrong-bg); border-color: var(--wrong-line); color: var(--wrong); }
.messages li.warning { background: var(--warn-bg); color: var(--warn); }

/* --------------------------------------------------------------- Footer --- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.6rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer .brand { justify-content: center; font-size: 0.95rem; margin-bottom: 0.5rem; }
.site-footer p { margin: 0.25rem auto; }
.fine-print { font-size: 0.75rem; max-width: 640px; color: var(--faint); line-height: 1.5; }

/* --------------------------------------------------------------- Motion --- */
@media (prefers-reduced-motion: no-preference) {
  #question-card { animation: fadeUp 0.25s ease; }
  @keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* -------------------------------------------------------------- Responsive - */
@media (max-width: 560px) {
  .hero h1 { font-size: 1.85rem; }
  .lede { font-size: 1.05rem; }
  .container { margin: 1.5rem auto; }
  .card { padding: 1.25rem; }
  .site-header { padding: 0.6rem 1rem; }
  .site-header nav { gap: 0.1rem; }
  .site-header nav a, .linklike { padding: 0.35rem 0.5rem; font-size: 0.88rem; }
}
