/* ── practice.css — Adaptive Practice Mode ── */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0b1121;
  --surface: #141d2f;
  --surface2: #1e2a42;
  --border: #263350;
  --purple: #6366f1;
  --purple-light: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --text: #e2e8f0;
  --muted: #64748b;
  --radius: 14px;
}

body.practice-page {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Nav ───────────────────────────────────────────────────────────────────── */

.practice-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.nav-active {
  color: var(--purple-light);
}

/* ── Hero ──────────────────────────────────────────────────────────────────── */

.practice-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  border-bottom: 1px solid var(--border);
  padding: 3rem 2rem 2.5rem;
  text-align: center;
}

.practice-hero-inner {
  max-width: 700px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  background: rgba(99,102,241,0.15);
  color: var(--purple-light);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 100px;
  padding: 0.35rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}

.practice-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.practice-hero p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── Main ──────────────────────────────────────────────────────────────────── */

.practice-main {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* ── Radar section ─────────────────────────────────────────────────────────── */

.radar-section {
  display: flex;
  justify-content: center;
}

.radar-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 680px;
}

.radar-container h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.radar-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.radar-chart-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.radar-chart-wrap canvas {
  max-width: 280px;
  width: 100%;
  height: auto;
}

/* ── Topic grid ────────────────────────────────────────────────────────────── */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.topic-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: inherit;
  color: var(--text);
}

.topic-card:hover {
  border-color: var(--purple);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,0.15);
}

.topic-card.selected {
  border-color: var(--purple);
  background: rgba(99,102,241,0.08);
}

.topic-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.topic-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.accuracy-bar-wrap {
  background: var(--border);
  border-radius: 3px;
  height: 4px;
  overflow: hidden;
}

.accuracy-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--purple);
  transition: width 0.6s ease;
}

.accuracy-pct {
  font-size: 0.7rem;
  color: var(--muted);
}

/* Colour-code accuracy bars */
.topic-card[data-accuracy="0"] .accuracy-bar,
.topic-card[data-accuracy="5"] .accuracy-bar,
.topic-card[data-accuracy="15"] .accuracy-bar,
.topic-card[data-accuracy="25"] .accuracy-bar,
.topic-card[data-accuracy="35"] .accuracy-bar,
.topic-card[data-accuracy="40"] .accuracy-bar {
  background: var(--red);
}

.topic-card[data-accuracy="45"] .accuracy-bar,
.topic-card[data-accuracy="50"] .accuracy-bar,
.topic-card[data-accuracy="55"] .accuracy-bar,
.topic-card[data-accuracy="60"] .accuracy-bar,
.topic-card[data-accuracy="65"] .accuracy-bar {
  background: var(--yellow);
}

/* ── Drill section ─────────────────────────────────────────────────────────── */

.drill-section {
  width: 100%;
}

.drill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.drill-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.drill-topic-badge {
  background: rgba(99,102,241,0.15);
  color: var(--purple-light);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 100px;
  padding: 0.25rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.drill-progress {
  flex: 1;
  min-width: 140px;
}

#drillProgressText {
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.3rem;
}

.drill-progress-bar {
  background: var(--border);
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
}

.drill-progress-fill {
  height: 100%;
  background: var(--purple);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.question-area {
  padding: 2rem 1.5rem;
  min-height: 280px;
}

/* Loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 200px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Question content */
.question-type-label {
  font-size: 0.75rem;
  color: var(--purple-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.question-prompt {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
  background: var(--surface2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--purple);
}

.choices-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.choice-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--purple);
  background: rgba(99,102,241,0.06);
}

.choice-btn.selected {
  border-color: var(--purple);
  background: rgba(99,102,241,0.12);
}

.choice-btn.correct {
  border-color: var(--green);
  background: rgba(34,197,94,0.1);
  color: var(--green);
}

.choice-btn.wrong {
  border-color: var(--red);
  background: rgba(239,68,68,0.08);
  color: #fca5a5;
}

.choice-letter {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 22px;
  color: var(--muted);
}

.choice-btn.selected .choice-letter,
.choice-btn.correct .choice-letter { color: inherit; }

/* Answer reveal */
.result-banner {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.result-banner.correct {
  background: rgba(34,197,94,0.12);
  color: var(--green);
  border: 1px solid rgba(34,197,94,0.3);
}

.result-banner.wrong {
  background: rgba(239,68,68,0.1);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.2);
}

.explanation-box {
  background: var(--surface2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 1.25rem;
  border-left: 3px solid var(--yellow);
}

/* ── Results section ───────────────────────────────────────────────────────── */

.results-section {
  display: flex;
  justify-content: center;
}

.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.results-score-ring {
  position: relative;
  width: 120px;
  height: 120px;
}

.results-score-ring svg {
  width: 100%;
  height: 100%;
}

.score-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.results-body {
  width: 100%;
}

.results-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.encouragement {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.results-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
  margin-bottom: 1.5rem;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.breakdown-item.correct { background: rgba(34,197,94,0.08); }
.breakdown-item.wrong { background: rgba(239,68,68,0.07); }

.breakdown-icon { font-size: 1.1rem; }

.badge-earned {
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--purple-light);
  margin-bottom: 1.25rem;
}

.badge-emoji { font-size: 1.5rem; }

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ── History section ───────────────────────────────────────────────────────── */

.history-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.history-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}

.history-item:first-child { border-top: none; }

.history-topic {
  flex: 1;
  text-transform: capitalize;
  color: var(--text);
}

.history-score {
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.78rem;
}

.score-high { background: rgba(34,197,94,0.15); color: var(--green); }
.score-mid { background: rgba(234,179,8,0.15); color: var(--yellow); }
.score-low { background: rgba(239,68,68,0.12); color: #fca5a5; }
.score-incomplete { background: var(--surface2); color: var(--muted); }

.history-date {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ── How section ───────────────────────────────────────────────────────────── */

.how-section {
  padding: 1rem 0;
}

.how-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  text-align: center;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.how-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.how-icon { font-size: 1.75rem; margin-bottom: 0.6rem; }

.how-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.how-card p {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.55;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
}

.btn-primary:hover { background: #4f46e5; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s;
  width: 100%;
}

.btn-secondary:hover { border-color: var(--purple); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  width: 100%;
}

.btn-ghost:hover { color: var(--text); border-color: var(--text); }

.btn-full { width: 100%; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .practice-hero h1 { font-size: 1.6rem; }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .practice-main { padding: 0 1rem; }
  .drill-header { gap: 0.5rem; }
  .nav-links { display: none; }
}
