/* Chapter Practice — styling carried over from the single-chapter prototype.
   Dropped from the prototype: filter chips, progress bar, score/counter, and
   the results screen (this app deliberately shows no score of any kind). */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e3e6;
  --text: #1c1c1f;
  --muted: #6b6b72;
  --accent: #2b6cb0;
  --accent-dark: #245a93;
  --accent-soft: #e8f0fb;
  --correct: #2f855a;
  --correct-bg: #e8f4ed;
  --wrong: #c53030;
  --wrong-bg: #fbe8e8;
  --warn: #b7791f;
  --warn-bg: #fbf5e3;
  --pill: #f0f0f3;
  --discord: #5865f2;
  --discord-dark: #4752c4;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }

/* ---------- Header ---------- */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}
.header-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
header h1 { margin: 0; font-size: 17px; font-weight: 700; }
header .tag { font-size: 12px; color: var(--muted); }
.link-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.link-btn:hover { color: var(--accent); }

/* ---------- Layout ---------- */
main {
  max-width: 780px;
  margin: 0 auto;
  padding: 22px 20px 60px;
}
.screen { display: none; }
.screen.visible { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 19px; }
.card h3 { margin: 0 0 4px; font-size: 14px; }
.card p { margin: 6px 0; }
.hint { color: var(--muted); font-size: 13px; }
.intro p { color: #3a3a40; }
.notice {
  margin-top: 12px !important;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 13px;
  color: var(--accent-dark);
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f0f0f3; }
a.btn { text-decoration: none; display: inline-block; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-dark); }
.btn:disabled, .btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary:disabled:hover { background: var(--accent); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.discord {
  background: var(--discord);
  border-color: var(--discord);
  color: #fff;
  font-weight: 600;
  padding: 12px 18px;
  font-size: 15px;
}
.btn.discord:hover { background: var(--discord-dark); }

/* ---------- Chapter menu ---------- */
.chapter-list { display: flex; flex-direction: column; gap: 10px; }
.chapter-card {
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 15px 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .12s, background .12s;
}
.chapter-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.chapter-card .ch-title { font-weight: 600; flex: 1; line-height: 1.4; }
.chapter-card .ch-count { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.chapter-card .ch-arrow { color: var(--accent); font-weight: 700; flex-shrink: 0; }

/* ---------- Question ---------- */
.quiz-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
.quiz-bar .spacer { margin-left: auto; }

.stem { font-size: 17px; line-height: 1.5; font-weight: 500; margin-bottom: 16px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.option:not(.answered):hover { border-color: var(--accent); background: var(--accent-soft); }
.option:not(.answered):active { transform: scale(.995); }
.opt-head { display: flex; align-items: baseline; gap: 11px; }
.opt-letter {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--pill);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  align-self: flex-start;
}
.opt-text { flex: 1; line-height: 1.5; }
.opt-mark { margin-left: 8px; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.opt-mark.correct { color: var(--correct); }
.opt-mark.wrong { color: var(--wrong); }

/* Answered options are disabled buttons; override the browser's default washed
   -out disabled text so the reviewed answer stays readable (accessibility). */
.option:disabled { color: var(--text); }
.option.answered { cursor: default; }
.option.answered .opt-text { color: var(--text); }
.option.correct .opt-text { color: #1e5c40; font-weight: 500; }
.option.wrong .opt-text { color: #8f2323; }
.option.correct { border-color: var(--correct); background: var(--correct-bg); }
.option.correct .opt-letter { background: var(--correct); color: #fff; }
.option.wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.option.wrong .opt-letter { background: var(--wrong); color: #fff; }
.option.dim { opacity: .72; }
.option.pending { opacity: .6; cursor: wait; }

.opt-explain {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0,0,0,0.13);
  font-size: 13.5px;
}
.opt-explain .rationale { margin: 0; color: #38383e; line-height: 1.5; }

.banner {
  display: flex;
  align-items: center;
  gap: 11px;
  border-radius: 9px;
  padding: 12px 15px;
  margin-bottom: 14px;
  font-weight: 600;
}
.banner.ok { background: var(--correct-bg); color: var(--correct); }
.banner.no { background: var(--wrong-bg); color: var(--wrong); }
.banner-icon {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff;
}
.banner.ok .banner-icon { background: var(--correct); }
.banner.no .banner-icon { background: var(--wrong); }

.q-foot {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.q-foot p { margin: 4px 0; }
.q-foot strong { color: #45454c; }

.next-btn { margin-top: 16px; width: 100%; padding: 12px; font-size: 15px; }

/* Retry state while a submission is failing (FR4: never lose the selection) */
.retry-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 9px;
  background: var(--warn-bg);
  color: #6b551c;
  font-size: 13.5px;
}
.spinner {
  width: 15px; height: 15px; flex-shrink: 0;
  border: 2px solid rgba(107,85,28,.25);
  border-top-color: #6b551c;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  padding: 14px 16px;
  border-radius: 9px;
  background: var(--wrong-bg);
  color: var(--wrong);
  font-size: 14px;
}

/* ---------- Auth message pages (login denied, cancelled, errors) ---------- */
.msg p { margin: 10px 0; line-height: 1.55; }
.msg .muted { color: var(--muted); font-size: 13.5px; }
.msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.msg-actions .btn { text-decoration: none; }

/* ---------- Flag control ---------- */
.flag-row { margin-top: 14px; display: flex; }
.flag-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.flag-btn:hover { color: var(--wrong); background: var(--wrong-bg); }
.flag-btn[disabled] { opacity: .5; cursor: default; }
.flag-btn[disabled]:hover { color: var(--muted); background: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20,20,25,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--panel);
  border-radius: 12px;
  padding: 20px 22px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .hint { margin: 0 0 14px; }

.reasons { border: none; padding: 0; margin: 0 0 16px; }
.reasons legend {
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.reason {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  margin-bottom: 7px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color .12s, background .12s;
}
.reason:hover { border-color: #c5c5cb; }
.reason:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.reason input { margin-top: 3px; width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.reason .r-sub { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.expl-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
#flag-text {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}
#flag-text:focus { outline: none; border-color: var(--accent); }
.char-count { font-size: 12.5px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.char-count.short { color: var(--warn); }
.char-count.ok { color: var(--correct); }

.modal-error {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 7px;
  background: var(--wrong-bg);
  color: var(--wrong);
  font-size: 13px;
}
.modal-error[hidden] { display: none; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.28);
  z-index: 60;
}
.toast[hidden] { display: none; }

footer {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px 30px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 560px) {
  .stem { font-size: 16px; }
  header h1 { font-size: 15px; }
}
