@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Open+Sans:wght@400;500;600&display=swap');

:root {
  --green:       #1A6B3A;
  --green-mid:   #22894c;
  --green-light: #d4eddb;
  --gold:        #C9974A;
  --gold-light:  #f0d4a8;
  --bg:          #F9F7F2;
  --text:        #0D2B1A;
  --text-muted:  #4a6b56;
  --white:       #ffffff;
  --border:      #dde8e1;
  --shadow:      0 4px 24px rgba(13,43,26,0.10);
  --shadow-lg:   0 8px 36px rgba(13,43,26,0.16);
  --radius:      18px;
  --radius-sm:   10px;
  --ease:        cubic-bezier(0.34,1.04,0.64,1);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Open Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  overflow-x: hidden;
}

h1, h2, h3, h4, .heading { font-family: 'Nunito', sans-serif; }

a { color: var(--green); text-decoration: none; }

/* ── BACKGROUND TEXTURE ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(26,107,58,0.06) 0%, transparent 50%),
    radial-gradient(circle at 82% 78%, rgba(201,151,74,0.07) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Ccircle fill='%231A6B3A' fill-opacity='0.025' cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── HEADER ── */
.site-header {
  position: relative;
  background: var(--green);
  color: var(--white);
  text-align: center;
  padding: 28px 20px 60px;
  z-index: 1;
}

.site-header .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: clamp(1.5rem, 5vw, 2rem);
  color: var(--white);
  letter-spacing: -0.5px;
}

.site-header .logo-icon {
  font-size: 1.5em;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.site-header .logo-tag {
  display: block;
  font-size: 0.55em;
  font-weight: 600;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  margin-top: -4px;
}

.header-wave {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  overflow: hidden;
  line-height: 0;
}

.header-wave svg { display: block; width: 100%; height: 40px; }

/* ── MAIN ── */
main {
  position: relative;
  z-index: 1;
  padding: 0 16px 48px;
  max-width: 600px;
  margin: 0 auto;
}

/* ── PROGRESS BAR ── */
.progress-wrap {
  margin: -20px auto 28px;
  max-width: 420px;
}

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  border-radius: 99px;
  transition: width 0.5s var(--ease);
  width: 0%;
}

.progress-dots {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}

.progress-dot {
  font-size: 0.7rem;
  font-weight: 600;
  font-family: 'Nunito', sans-serif;
  color: var(--text-muted);
  transition: color 0.3s;
}

.progress-dot.done  { color: var(--green); }
.progress-dot.current { color: var(--gold); }

/* ── CARD ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  border: 1px solid var(--border);
}

/* ── SCREENS (ONBOARDING) ── */
.screen { display: none; }
.screen.active { display: block; animation: fadeSlideIn 0.35s var(--ease) both; }
.screen.exit    { animation: fadeSlideOut 0.25s ease both; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}

.question-label {
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.question-text {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 24px;
}

/* ── OPTIONS ── */
.options { display: flex; flex-direction: column; gap: 10px; }

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.option-btn:hover, .option-btn:focus-visible {
  border-color: var(--green-mid);
  background: var(--green-light);
  transform: translateX(3px);
}

.option-btn.selected {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
}

.option-btn.selected .opt-icon { filter: none; }

.opt-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.opt-text { flex: 1; }

.option-btn.selected::after {
  content: '✓';
  margin-left: auto;
  font-weight: 800;
  color: var(--green);
  font-size: 1rem;
}

/* ── NAV BUTTONS ── */
.card-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 13px 26px;
  border-radius: 99px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.22s ease;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: var(--white);
  box-shadow: 0 4px 16px rgba(26,107,58,0.30);
}

.btn-primary:hover:not(:disabled) {
  background: var(--green-mid);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(26,107,58,0.38);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border);
}

.btn-ghost:hover { background: var(--green-light); border-color: var(--green); color: var(--green); }

.btn-gold {
  background: var(--gold);
  color: var(--white);
  box-shadow: 0 4px 16px rgba(201,151,74,0.35);
  font-size: 1.05rem;
  padding: 15px 34px;
}

.btn-gold:hover {
  background: #b8863a;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(201,151,74,0.45);
}

.btn-lg { padding: 16px 36px; font-size: 1.1rem; }

/* ── CONFIRMATION SCREEN ── */
.confirm-icon {
  font-size: 3.5rem;
  text-align: center;
  margin-bottom: 16px;
  animation: popIn 0.5s var(--ease) 0.1s both;
}

@keyframes popIn {
  from { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.confirm-title {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(1.35rem, 5vw, 1.65rem);
  font-weight: 900;
  color: var(--green);
  text-align: center;
  margin-bottom: 12px;
}

.confirm-body {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
  line-height: 1.7;
}

.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: var(--green-light);
  color: var(--green);
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  border: 1.5px solid rgba(26,107,58,0.2);
}

.confirm-cta { text-align: center; }

/* ── SOLVER PAGE ── */
.solver-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 24px;
}

.solver-header .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'Nunito', sans-serif;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  transition: all 0.2s ease;
}

.solver-header .back-link:hover { background: var(--green-light); border-color: var(--green); color: var(--green); }

.solver-header h1 {
  font-size: 1.25rem;
  font-weight: 800;
  flex: 1;
  text-align: right;
}

/* Profile banner */
.profile-banner {
  background: linear-gradient(135deg, var(--green) 0%, #22894c 100%);
  color: var(--white);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.profile-banner .avatar {
  font-size: 2.2rem;
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-banner .pb-title {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 2px;
}

.profile-banner .pb-sub {
  font-size: 0.82rem;
  opacity: 0.85;
}

/* Topic tabs */
.topic-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.topic-tabs::-webkit-scrollbar { display: none; }

.topic-tab {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 99px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  transition: all 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.topic-tab:hover { border-color: var(--green); color: var(--green); }
.topic-tab.active { background: var(--green); color: var(--white); border-color: var(--green); }

/* Solver input */
.solver-input-wrap {
  position: relative;
  margin-bottom: 14px;
}

#problem-input {
  width: 100%;
  padding: 16px 60px 16px 18px;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.95rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
  min-height: 60px;
  line-height: 1.6;
}

#problem-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(26,107,58,0.10); }
#problem-input::placeholder { color: #a0b8a8; }

.solve-btn-wrap {
  text-align: right;
  margin-bottom: 20px;
}

/* Examples */
.examples-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.example-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.example-card:hover {
  border-color: var(--gold);
  background: #fdf8f0;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(201,151,74,0.15);
}

.example-card .ex-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  font-family: 'Nunito', sans-serif;
}

.example-card .ex-problem {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

/* Solution display */
#solution-area { margin-top: 10px; }

.solution-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: fadeSlideIn 0.35s var(--ease) both;
}

.solution-header {
  background: linear-gradient(135deg, var(--green) 0%, #22894c 100%);
  color: var(--white);
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.solution-header h3 {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
}

.solution-type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 99px;
  font-family: 'Nunito', sans-serif;
}

.steps-list { padding: 22px; }

.step-item {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  animation: fadeSlideIn 0.3s var(--ease) both;
}

.step-item:last-child { margin-bottom: 0; }

.step-num {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  background: var(--green-light);
  color: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  margin-top: 1px;
}

.step-content .step-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.step-content .step-text {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.6;
}

.step-content .step-math {
  display: inline-block;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: 'Courier New', monospace;
  font-size: 0.92rem;
  color: var(--green);
  font-weight: 600;
  margin-top: 6px;
}

.solution-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.encouragement {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--green);
}

.error-card {
  background: #fff5f5;
  border: 1.5px solid #f5c2c7;
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  color: #842029;
  font-size: 0.9rem;
  animation: fadeSlideIn 0.3s var(--ease) both;
}

.error-card strong {
  font-family: 'Nunito', sans-serif;
  display: block;
  margin-bottom: 4px;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

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

/* Section headings */
.section-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── FOOTER ── */
.site-footer {
  text-align: center;
  padding: 28px 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .card { padding: 24px 18px; }
  .card-nav { flex-direction: column-reverse; }
  .card-nav .btn { width: 100%; }
  .examples-grid { grid-template-columns: 1fr; }
  .profile-banner { flex-direction: column; text-align: center; }
  .solution-footer { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 600px) {
  .site-header { padding: 36px 20px 70px; }
}
