/* Pre-Algebra Lab — warm, readable, kid-friendly without generic “AI slop” */
:root {
  --ink: #1c1917;
  --paper: #fffbf5;
  --accent: #c2410c;
  --accent-soft: #ffedd5;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --violet: #5b21b6;
  --violet-soft: #ede9fe;
  --ok: #15803d;
  --bad: #b91c1c;
  --muted: #57534e;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(28, 25, 23, 0.08);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(ellipse 120% 80% at 10% -20%, rgba(194, 65, 12, 0.12), transparent 50%),
    radial-gradient(ellipse 100% 60% at 100% 0%, rgba(15, 118, 110, 0.1), transparent 45%);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
}

a {
  color: var(--teal);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 251, 245, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(28, 25, 23, 0.08);
}

.app-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--accent);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}

.nav button {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav button:hover,
.nav button:focus-visible {
  background: var(--accent-soft);
  color: var(--ink);
  outline: none;
}

.nav button[aria-current="page"] {
  background: var(--teal-soft);
  color: var(--teal);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(28, 25, 23, 0.06);
}

.panel h2 {
  margin-top: 0;
  font-size: 1.5rem;
}

.lead {
  font-size: 1.1rem;
  color: var(--muted);
  margin-top: 0;
}

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

.topic-card {
  border: 2px solid rgba(28, 25, 23, 0.08);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  background: linear-gradient(145deg, #fff 0%, #fffbf5 100%);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 0.2s, transform 0.15s;
}

.topic-card:hover,
.topic-card:focus-visible {
  border-color: var(--teal);
  transform: translateY(-2px);
  outline: none;
}

.topic-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.topic-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.lesson-body {
  max-width: 720px;
}

.lesson-body ul {
  padding-left: 1.25rem;
}

.example {
  background: var(--violet-soft);
  border-left: 4px solid var(--violet);
  padding: 0.85rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem 0;
}

.example strong {
  color: var(--violet);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  filter: brightness(1.05);
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--teal-soft);
  color: var(--teal);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 2px solid rgba(28, 25, 23, 0.15);
}

.problem-box {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1rem 0;
}

.problem-box .prompt {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

input[type="text"],
input[type="number"],
textarea,
select {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 2px solid rgba(28, 25, 23, 0.15);
  background: #fff;
  min-width: 8rem;
}

textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
}

.feedback {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-weight: 600;
}

.feedback.ok {
  background: #dcfce7;
  color: var(--ok);
}

.feedback.bad {
  background: #fee2e2;
  color: var(--bad);
}

.solution-steps {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: #f5f5f4;
  border-radius: 10px;
  font-size: 0.98rem;
}

.solution-steps ol {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
}

.progress-bar {
  height: 8px;
  background: rgba(28, 25, 23, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0 1rem;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--accent));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.score-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 800;
  font-size: 0.9rem;
}

.puzzle-card {
  border: 2px dashed rgba(91, 33, 182, 0.35);
  background: var(--violet-soft);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.upload-zone {
  border: 2px dashed rgba(15, 118, 110, 0.4);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  background: var(--teal-soft);
  margin-bottom: 1rem;
}

.upload-zone input[type="file"] {
  margin-top: 0.75rem;
}

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

.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(28, 25, 23, 0.1);
  background: #fff;
}

.gallery-item img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.gallery-item figcaption {
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.gallery-item button.delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(185, 28, 28, 0.9);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}

.growth-prompt {
  background: linear-gradient(135deg, #fef3c7, #ffedd5);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(194, 65, 12, 0.2);
}

.growth-prompt h3 {
  margin-top: 0;
  color: var(--accent);
}

.hidden {
  display: none !important;
}

footer.app-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}

.auth-bar input {
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  max-width: 110px;
}

.auth-bar .auth-msg {
  color: var(--muted);
  max-width: 200px;
}

.level-line {
  margin: 0 0 0.75rem;
  font-weight: 700;
  color: var(--violet);
}

.problem-box.marked-wrong {
  border: 2px solid rgba(185, 28, 28, 0.35);
  background: #fff7f7;
}

.coaching-box {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--violet-soft);
  border-radius: 10px;
  border-left: 4px solid var(--violet);
  font-size: 0.98rem;
}

.coaching-box strong {
  color: var(--violet);
}

.rewards-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.rewards-bar__item {
  background: var(--teal-soft);
  color: var(--teal);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-weight: 700;
}

.rewards-bar__item strong {
  color: var(--ink);
}

.course-plan {
  padding: 1rem 1.15rem;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(28, 25, 23, 0.06);
}

.course-plan h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.course-plan__grid {
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  font-size: 0.88rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.course-plan__week {
  background: #fafaf9;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(28, 25, 23, 0.08);
}

.course-plan__week strong {
  color: var(--accent);
}

.reward-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  max-width: min(420px, 92vw);
  background: #fff;
  border: 2px solid var(--ok);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  z-index: 200;
  font-weight: 700;
  color: var(--ink);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.reward-toast.show {
  transform: translateX(-50%) translateY(0);
}

.reward-toast .toast-sub {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.35rem;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -12px;
  animation: confetti-fall 1.6s ease-out forwards;
  border-radius: 2px;
}

@keyframes confetti-fall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0.6;
  }
}

@media (max-width: 600px) {
  .nav {
    width: 100%;
    margin-left: 0;
  }

  .rewards-bar {
    width: 100%;
    order: 3;
  }
}

/* Auth form styles */
.auth-form {
  max-width: 400px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--muted);
  border-radius: 4px;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(194, 65, 12, 0.2);
}

.password-strength {
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

.password-strength.ok {
  color: var(--ok);
}

.password-strength.bad {
  color: var(--bad);
}

.sync-status {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  margin: 0 0.5rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal);
  font-size: 0.9rem;
}

.sync-status.saving {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.sync-status.bad {
  background: rgba(185, 28, 28, 0.12);
  color: var(--bad);
}

.parent-child-form {
  display: grid;
  gap: 1rem;
  max-width: 520px;
}

.parent-child-form .form-group {
  display: grid;
  gap: 0.35rem;
}

.parent-child-form small.muted {
  color: var(--muted);
  font-size: 0.9rem;
}


