/* ══════════════════════════════════════════════════════════════════════════
   Acumen Tutor — Design System (Generated by ui-ux-pro-max v2.5)
   Pattern: Kids Learning Claymorphism
   Colors: Learning Blue #2563EB + CTA Orange #F97316 + Fun Pink #EC4899
   Typography: Baloo 2 (headings) / Comic Neue (body)
   Effects: Clay shadows, spring squish, soft 3D, rounded 20-32px
   ══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500;600;700;800&family=Comic+Neue:wght@300;400;700&display=swap');

:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --on-primary: #FFFFFF;
  --cta: #F97316;
  --cta-hover: #EA580C;
  --on-cta: #FFFFFF;
  --secondary: #F59E0B;
  --accent: #EC4899;
  --success: #10B981;
  --destructive: #EF4444;
  --bg: #F8FAFC;
  --fg: #1E293B;
  --card: #FFFFFF;
  --card-fg: #1E293B;
  --muted: #F1F5F9;
  --muted-fg: #64748B;
  --border: #E2E8F0;

  --radius-outer: 32px;
  --radius-card: 24px;
  --radius-btn: 20px;
  --radius-input: 16px;
  --radius-sm: 12px;

  --shadow-clay: 6px 6px 16px rgba(37, 99, 235, 0.08),
                 -3px -3px 10px rgba(255, 255, 255, 0.9);
  --shadow-clay-hover: 8px 8px 24px rgba(37, 99, 235, 0.12),
                       -4px -4px 14px rgba(255, 255, 255, 1);
  --shadow-clay-sm: 3px 3px 8px rgba(37, 99, 235, 0.06),
                    -2px -2px 6px rgba(255, 255, 255, 0.8);
  --shadow-pressed: inset 2px 2px 6px rgba(37, 99, 235, 0.1),
                    inset -1px -1px 3px rgba(255, 255, 255, 0.3);

  --font-heading: 'Baloo 2', cursive, system-ui;
  --font-body: 'Comic Neue', cursive, system-ui;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  max-width: 540px;
  margin: 0 auto;
  padding: 20px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-heading); }

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Login ────────────────────────────────────────────────────────────────── */
.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 85vh;
  gap: 16px;
  width: 100%;
}

.center-content h1 {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.login-subtitle,
.choose-subtitle {
  font-size: 16px;
  color: var(--muted-fg);
  text-align: center;
  font-weight: 400;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */
input[type="text"], select {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 17px;
  font-family: var(--font-body);
  font-weight: 700;
  background: var(--card);
  color: var(--fg);
  box-shadow: var(--shadow-clay-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

input[type="text"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), var(--shadow-clay-sm);
}

input[type="text"]::placeholder {
  color: var(--muted-fg);
  font-weight: 400;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button {
  display: block;
  width: 100%;
  padding: 15px 24px;
  border: 3px solid transparent;
  border-radius: var(--radius-btn);
  font-size: 17px;
  font-family: var(--font-heading);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
  background: var(--cta);
  color: var(--on-cta);
  box-shadow: var(--shadow-clay);
  letter-spacing: 0.01em;
}

button:hover {
  background: var(--cta-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-clay-hover);
}

button:active {
  transform: scale(0.95);
  box-shadow: var(--shadow-pressed);
}

button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  background: var(--card);
  color: var(--primary);
  border-color: var(--border);
  font-family: var(--font-body);
  font-size: 15px;
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--muted);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 3px solid var(--border);
  box-shadow: none;
  font-family: var(--font-body);
  font-size: 15px;
}

.btn-outline:hover {
  border-color: var(--primary);
  background: var(--muted);
  box-shadow: var(--shadow-clay-sm);
}

/* ── Choose screen ────────────────────────────────────────────────────────── */
.choose-header {
  text-align: center;
  padding: 28px 0 4px;
}

.choose-header h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

/* ── Search box ───────────────────────────────────────────────────────────── */
.search-section { margin: 24px 0 0; }

.search-box {
  display: flex;
  gap: 8px;
}

.search-box input { flex: 1; }

.search-box button {
  width: auto;
  padding: 14px 28px;
  flex-shrink: 0;
  background: var(--primary);
}

.search-box button:hover { background: var(--primary-light); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider-or {
  text-align: center;
  margin: 24px 0;
  position: relative;
}

.divider-or::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 2px;
  background: var(--border);
}

.divider-or span {
  position: relative;
  background: var(--bg);
  padding: 0 16px;
  color: var(--muted-fg);
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-heading);
}

/* ── Drop zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 3px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
  background: var(--card);
  box-shadow: var(--shadow-clay-sm);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: #EFF6FF;
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-clay-hover);
}

.drop-zone-icon { font-size: 3rem; margin-bottom: 10px; }
.drop-zone-text { font-family: var(--font-heading); font-weight: 700; color: var(--fg); font-size: 16px; }
.drop-zone-sub { color: var(--muted-fg); font-size: 14px; margin-top: 4px; }

#upload-preview-img {
  max-width: 100%;
  border-radius: var(--radius-card);
  margin-top: 14px;
  box-shadow: var(--shadow-clay);
}

/* ── Section label ────────────────────────────────────────────────────────── */
.section-label {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: 10px;
}

/* ── Topic cards ──────────────────────────────────────────────────────────── */
.topic-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border: 3px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
  cursor: pointer;
  margin-bottom: 10px;
  box-shadow: var(--shadow-clay-sm);
  transition: all 0.25s var(--ease-spring);
}

.topic-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-clay-hover);
}

.topic-card.selected {
  border-color: var(--primary);
  background: #EFF6FF;
  box-shadow: var(--shadow-pressed);
  transform: scale(0.98);
}

.topic-card-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
}

.topic-card-detail {
  font-size: 13px;
  color: var(--muted-fg);
  margin-top: 3px;
}

/* ── Question screen ──────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

#kc-label { font-family: var(--font-heading); font-weight: 700; color: var(--primary); }
#mastery-pct { font-family: var(--font-heading); font-weight: 800; color: var(--success); }

.question-body {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-clay);
  font-size: 18px;
  line-height: 1.7;
}

.answer-area {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.answer-area input { flex: 1; }

.answer-area button {
  width: auto;
  padding: 14px 28px;
  flex-shrink: 0;
  background: var(--primary);
}

.answer-area button:hover { background: var(--primary-light); }

/* ── Feedback ─────────────────────────────────────────────────────────────── */
#feedback-area { min-height: 40px; margin: 14px 0; }

#feedback-text {
  font-size: 16px;
  line-height: 1.7;
  padding: 18px;
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-clay-sm);
}

.feedback-correct #feedback-text {
  border-left: 5px solid var(--success);
  background: #ECFDF5;
}

.feedback-incorrect #feedback-text {
  border-left: 5px solid var(--destructive);
  background: #FEF2F2;
}

.feedback-thinking #feedback-text {
  color: var(--muted-fg);
  font-style: italic;
}

/* ── Hints ─────────────────────────────────────────────────────────────────── */
#hint-area {
  background: #FFFBEB;
  border: 3px solid var(--secondary);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 14px;
}

#hint-text { font-size: 16px; color: #92400E; }

/* ── Progress ─────────────────────────────────────────────────────────────── */
#skill-bars { margin: 16px 0; }

.skill-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
}

.skill-name { flex: 1; font-weight: 700; color: var(--fg); }

.skill-bar-bg {
  width: 120px; height: 14px;
  background: var(--muted);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.05);
}

.skill-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 7px;
  transition: width 0.6s var(--ease-spring);
}

.skill-pct {
  width: 45px;
  text-align: right;
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--primary);
}

/* ── Upload status ────────────────────────────────────────────────────────── */
#upload-status {
  background: var(--muted);
  border: 3px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  margin: 14px 0;
}

#upload-status-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-heading);
}

/* ── Connection banner ────────────────────────────────────────────────────── */
#connection-banner {
  background: var(--secondary);
  color: #0F172A;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-heading);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

/* ── Button spacing in question screen ────────────────────────────────────── */
#btn-next, #btn-hint, #btn-progress, #btn-topic { margin-bottom: 10px; }

#btn-next { background: var(--success); }
#btn-next:hover { background: #059669; }

#btn-hint { background: var(--secondary); color: #0F172A; }
#btn-hint:hover { background: #D97706; }

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  body { padding: 14px; }
  .center-content h1 { font-size: 2rem; }
  .choose-header h2 { font-size: 1.6rem; }
  .search-box { flex-direction: column; }
  .search-box button { width: 100%; }
  .answer-area { flex-direction: column; }
  .answer-area button { width: 100%; }
  .question-body { padding: 16px; font-size: 16px; }
}

/* -- Deep Solve ------------------------------------------------------------ */
.solve-header { text-align: center; padding: 28px 0 16px; }
.solve-header h2 { font-size: 2rem; font-weight: 800; color: var(--primary); }
.solve-subtitle { font-size: 16px; color: var(--muted-fg); }

.solve-textarea {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 16px;
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--card);
  color: var(--fg);
  box-shadow: var(--shadow-clay-sm);
  resize: vertical;
  min-height: 100px;
  margin-bottom: 12px;
  outline: none;
}
.solve-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), var(--shadow-clay-sm);
}

/* Phase progress bar */
.solve-phase-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 20px 0;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay-sm);
}

.solve-phase-dot {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted-fg);
  background: var(--muted);
  transition: all 0.3s var(--ease-spring);
  text-align: center;
}
.solve-phase-dot.active {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: var(--shadow-clay);
  transform: scale(1.05);
}
.solve-phase-dot.completed {
  color: var(--on-primary);
  background: var(--success);
}

.solve-phase-connector {
  width: 20px;
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}

/* Output area */
#solve-output {
  max-height: 500px;
  overflow-y: auto;
  margin: 16px 0;
}

.solve-phase-section {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-clay-sm);
}

.solve-phase-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  font-family: var(--font-heading);
}

.solve-phase-content {
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Tool call/result display */
.solve-tool-call {
  background: #FEF3C7;
  border: 2px solid var(--secondary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 13px;
  font-family: var(--font-heading);
  font-weight: 600;
  color: #92400E;
}

.solve-tool-result {
  background: var(--muted);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 4px 0 10px;
  font-size: 13px;
  font-family: monospace;
  white-space: pre-wrap;
  color: var(--fg);
}

/* Status */
#solve-status {
  text-align: center;
  margin: 10px 0;
}
#solve-status-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
}

/* ── Accessibility (UI audit fix #2) ──────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Quiz Cards (UI audit fix #1) ─────────────────────────── */
.quiz-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--clay-shadow);
}
.quiz-q-num {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 8px;
}
.quiz-question {
  font-family: var(--font-body);
  font-size: 16px;
  margin-bottom: 12px;
  line-height: 1.5;
}
.quiz-answer-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.quiz-answer-row input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 15px;
}
.quiz-answer-row button {
  padding: 10px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
}
.quiz-correct { color: var(--success); font-weight: 700; }
.quiz-incorrect { color: var(--error); font-weight: 700; }
