/* Shared design system: CSS variables, layout chrome (top bar, bottom nav),
   and the core widgets (buttons, cards, exercise UI) every page reuses.
   Page-specific files (css/*.css) should only use these variables and add
   NEW classes — don't redefine variables here. */

:root {
  --green: #58cc02;
  --green-dark: #4caf00;
  --blue: #1cb0f6;
  --red: #ff4b4b;
  --gold: #ffc800;
  --purple: #ce82ff;

  --bg: #ffffff;
  --card-bg: #f7f7f7;
  --text: #4b4b4b;
  --text-muted: #767676;
  --border: #e5e5e5;
  --border-strong: #afafaf;
  --shadow: rgba(0, 0, 0, 0.12);
  --overlay: rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131f24;
    --card-bg: #1c2b33;
    --text: #f0f0f0;
    --text-muted: #a3adb3;
    --border: #2c3e46;
    --border-strong: #4a5b63;
    --shadow: rgba(0, 0, 0, 0.4);
    --overlay: rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --bg: #131f24;
  --card-bg: #1c2b33;
  --text: #f0f0f0;
  --text-muted: #a3adb3;
  --border: #2c3e46;
  --border-strong: #4a5b63;
  --shadow: rgba(0, 0, 0, 0.4);
  --overlay: rgba(0, 0, 0, 0.7);
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --card-bg: #f7f7f7;
  --text: #4b4b4b;
  --text-muted: #767676;
  --border: #e5e5e5;
  --border-strong: #afafaf;
  --shadow: rgba(0, 0, 0, 0.12);
  --overlay: rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-root {
  flex: 1;
  padding-bottom: 76px; /* clear the bottom nav */
}
.page-root.immersive {
  padding-bottom: 0;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--green-dark);
}

.stats {
  display: flex;
  gap: 16px;
  font-weight: 700;
  font-size: 1rem;
}

.exercise-topbar {
  gap: 14px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--border-strong);
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover {
  color: var(--text);
}

.progress-track {
  flex: 1;
  height: 14px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.hearts {
  font-size: 1rem;
  white-space: nowrap;
  letter-spacing: 1px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--bg);
  border-top: 2px solid var(--border);
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px 8px;
  cursor: pointer;
  color: var(--text-muted);
}
.nav-item .nav-icon {
  font-size: 1.4rem;
}
.nav-item .nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.nav-item.active {
  color: var(--blue);
}

/* Home / path */
.home {
  flex: 1;
  padding: 20px 0 40px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.no-hearts-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: #ffdfe0;
  color: #8b0000;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.9rem;
}
:root[data-theme="dark"] .no-hearts-banner {
  background: #4a1414;
  color: #ffb3b3;
}
@media (prefers-color-scheme: dark) {
  .no-hearts-banner {
    background: #4a1414;
    color: #ffb3b3;
  }
}

.unit {
  margin-bottom: 36px;
}

.unit-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--blue);
  color: white;
  padding: 16px 20px;
  border-radius: 14px;
  margin: 20px 16px 28px;
}

.unit-icon {
  font-size: 2rem;
}

.unit-title {
  font-weight: 800;
  font-size: 1.15rem;
}

.unit-subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
}

.path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.lesson-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.lesson-node {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--shadow);
  transition: transform 0.1s ease;
}
.lesson-node:active:not([disabled]) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--shadow);
}

.lesson-node.unlocked {
  background: var(--green);
}
.lesson-node.completed {
  background: var(--gold);
}
.lesson-node.locked {
  background: var(--border);
  color: var(--border-strong);
  cursor: not-allowed;
}

.lesson-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  max-width: 130px;
  text-align: center;
}
.crown-pip {
  color: var(--gold);
  font-weight: 800;
}

/* Exercise screen */
.exercise-screen {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 40px 20px 140px;
}

.exercise-card {
  max-width: 560px;
  width: 100%;
}

.prompt {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.exercise-body {
  margin-top: 24px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  padding: 16px 18px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.option-btn:hover:not([disabled]) {
  border-color: var(--blue);
}
.option-btn.selected {
  border-color: var(--blue);
  background: #ddf4ff;
}
.option-btn.correct {
  border-color: var(--green);
  background: #d7ffb8;
}
.option-btn.incorrect {
  border-color: var(--red);
  background: #ffdfe0;
}
:root[data-theme="dark"] .option-btn.selected {
  background: #123a4d;
}
:root[data-theme="dark"] .option-btn.correct {
  background: #23430a;
}
:root[data-theme="dark"] .option-btn.incorrect {
  background: #4a1414;
}
@media (prefers-color-scheme: dark) {
  .option-btn.selected {
    background: #123a4d;
  }
  .option-btn.correct {
    background: #23430a;
  }
  .option-btn.incorrect {
    background: #4a1414;
  }
}

.type-input {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--bg);
  color: var(--text);
}
.type-input:focus {
  border-color: var(--blue);
}

.build-strip {
  min-height: 56px;
  border-bottom: 2px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0 20px;
  margin-bottom: 20px;
}

.strip-placeholder {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 12px 0;
}

.build-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  padding: 10px 16px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.pill:hover:not([disabled]) {
  border-color: var(--blue);
}
.strip-pill {
  border-color: var(--blue);
  background: #ddf4ff;
}
:root[data-theme="dark"] .strip-pill {
  background: #123a4d;
}
@media (prefers-color-scheme: dark) {
  .strip-pill {
    background: #123a4d;
  }
}

/* Footer / feedback */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 2px solid var(--border);
  padding: 18px 20px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
}

.btn-check,
.btn-continue,
.btn-secondary {
  padding: 14px 28px;
  border-radius: 12px;
  border: none;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-check {
  background: var(--green);
  color: white;
}
.btn-check[disabled] {
  background: var(--border);
  color: var(--border-strong);
  cursor: not-allowed;
}

.btn-continue {
  background: var(--green);
  color: white;
  margin-left: auto;
}

.btn-secondary {
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
}
.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.btn-wide {
  width: 100%;
  margin-top: 12px;
}

.feedback {
  justify-content: space-between;
}
.feedback-correct {
  background: #d7ffb8;
  border-top-color: var(--green);
}
.feedback-incorrect {
  background: #ffdfe0;
  border-top-color: var(--red);
}
:root[data-theme="dark"] .feedback-correct {
  background: #23430a;
}
:root[data-theme="dark"] .feedback-incorrect {
  background: #4a1414;
}
@media (prefers-color-scheme: dark) {
  .feedback-correct {
    background: #23430a;
  }
  .feedback-incorrect {
    background: #4a1414;
  }
}
.feedback-title {
  font-weight: 800;
  font-size: 1.1rem;
}
.feedback-correct .feedback-title {
  color: var(--green-dark);
}
.feedback-incorrect .feedback-title {
  color: var(--red);
}
.feedback-answer {
  font-size: 0.9rem;
  margin-top: 2px;
}

/* Result screens */
.result-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.result-card {
  text-align: center;
  max-width: 380px;
}

.result-icon {
  font-size: 4rem;
  margin-bottom: 12px;
}

.result-sub {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.result-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
  font-weight: 700;
}

.new-badges {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 20px;
}
.new-badges-title {
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--gold);
}
.new-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-weight: 600;
}
.new-badge-icon {
  font-size: 1.4rem;
}

/* Onboarding */
.onboarding-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  max-width: 420px;
  margin: 0 auto;
}
.onboarding-mascot {
  font-size: 4.5rem;
  margin-bottom: 12px;
}
.onboarding-sub {
  color: var(--text-muted);
  margin-bottom: 28px;
}
.goal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-bottom: 20px;
}
.goal-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.goal-option.selected {
  border-color: var(--green);
  background: #d7ffb8;
}
:root[data-theme="dark"] .goal-option.selected {
  background: #23430a;
}
@media (prefers-color-scheme: dark) {
  .goal-option.selected {
    background: #23430a;
  }
}
.goal-icon {
  font-size: 1.4rem;
}
.goal-label {
  font-weight: 700;
  flex: 1;
}
.goal-xp {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Generic placeholder page (used by stub pages before they're built out) */
.placeholder-page {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* Confetti canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

@media (max-width: 480px) {
  .unit-banner {
    margin: 16px 8px 24px;
  }
  .footer {
    padding: 14px 16px;
  }
}
