/* Math Galaxy — Space/Rocket themed styles
   Uses app theme vars (--color-*) for light/dark/blue mode compat */

/* ======== HOME SCREEN ======== */
.math-home {
  padding: var(--space-4) var(--space-6);
  max-width: 900px;
  margin: 0 auto;
}

.math-home h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.math-home .math-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

.math-stats-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.math-stat-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.math-stat-chip .stat-icon {
  font-size: var(--text-base);
}

/* ======== TIER SECTIONS ======== */
.math-tier {
  margin-bottom: var(--space-6);
}

.math-tier-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-border);
}

.math-tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  font-size: var(--text-lg);
  font-weight: 800;
  color: white;
}

.math-tier-badge.beginner { background: linear-gradient(135deg, #4CAF50, #66BB6A); }
.math-tier-badge.intermediate { background: linear-gradient(135deg, #FF9800, #FFB74D); }
.math-tier-badge.advanced { background: linear-gradient(135deg, #E91E63, #F06292); }

.math-tier-info h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.math-tier-info p {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin: 0;
}

/* ======== CARD GRID ======== */
.math-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

.math-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.math-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #7c3aed, #2563eb);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.math-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.math-card:hover::before {
  opacity: 1;
}

.math-card.completed {
  border-color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 5%, var(--color-surface));
}

.math-card.completed::before {
  background: var(--color-success);
  opacity: 1;
}

.math-card-icon {
  font-size: 2rem;
  margin-bottom: var(--space-2);
}

.math-card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.math-card-desc {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
  line-height: 1.4;
}

.math-card-tag {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.math-card-tag.lesson {
  background: color-mix(in srgb, #2563eb 15%, transparent);
  color: #2563eb;
}

.math-card-tag.game {
  background: color-mix(in srgb, #7c3aed 15%, transparent);
  color: #7c3aed;
}

.math-card-status {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  font-size: var(--text-sm);
}

.math-card-score {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-success);
  margin-top: var(--space-2);
}

/* ======== LESSON VIEW ======== */
.math-lesson {
  padding: var(--space-4) var(--space-6);
  max-width: 700px;
  margin: 0 auto;
}

.math-lesson-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.math-lesson-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.math-lesson-progress {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.math-concept-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  animation: mathFadeIn 0.4s ease;
}

@keyframes mathFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.math-concept-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.math-explanation {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.7;
  margin-bottom: var(--space-4);
}

.math-visual-box {
  background: var(--color-surface-2);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: var(--space-4);
  letter-spacing: 0.02em;
}

.math-tip {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.math-tip::before {
  content: "\1F4A1  ";
}

.math-lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.math-lesson-nav button {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all 0.2s ease;
}

.math-lesson-nav button:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.math-lesson-nav button.primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.math-lesson-nav button.primary:hover {
  opacity: 0.9;
}

/* ======== GAME VIEW ======== */
.math-game {
  padding: var(--space-4) var(--space-6);
  max-width: 700px;
  margin: 0 auto;
}

.math-game-header {
  text-align: center;
  margin-bottom: var(--space-4);
}

.math-game-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
}

.math-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-5);
}

.math-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #2563eb);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.math-question-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  animation: mathFadeIn 0.3s ease;
}

.math-question-number {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.math-question-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-5);
  line-height: 1.5;
}

.math-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.math-option-btn {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.math-option-btn:hover:not(.selected):not(.disabled) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.math-option-btn.correct {
  border-color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 15%, var(--color-surface));
  color: var(--color-success);
  animation: mathCorrectPop 0.3s ease;
}

@keyframes mathCorrectPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.math-option-btn.wrong {
  border-color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 10%, var(--color-surface));
  color: var(--color-error);
  animation: mathWrongShake 0.4s ease;
}

@keyframes mathWrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.math-option-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.math-hint-box {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-top: var(--space-3);
  animation: mathFadeIn 0.3s ease;
}

.math-hint-box::before {
  content: "\1F4A1  ";
}

.math-feedback {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  animation: mathFadeIn 0.3s ease;
}

.math-feedback.correct-feedback {
  background: color-mix(in srgb, var(--color-success) 12%, transparent);
  color: var(--color-success);
}

.math-feedback.wrong-feedback {
  background: color-mix(in srgb, var(--color-error) 10%, transparent);
  color: var(--color-text);
}

.math-feedback .got-it-btn {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
}

/* ======== RESULTS SCREEN ======== */
.math-results {
  padding: var(--space-6);
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  animation: mathFadeIn 0.5s ease;
}

.math-results-icon {
  font-size: 4rem;
  margin-bottom: var(--space-3);
}

.math-results h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.math-results .score-display {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: var(--space-1);
}

.math-results .score-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.math-stars {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.math-stars .star {
  font-size: 2.5rem;
  transition: transform 0.3s ease;
}

.math-stars .star.earned {
  animation: mathStarPop 0.5s ease both;
}

.math-stars .star:nth-child(2).earned { animation-delay: 0.2s; }
.math-stars .star:nth-child(3).earned { animation-delay: 0.4s; }

@keyframes mathStarPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

.math-xp-badge {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.math-results-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

.math-results-actions button {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  cursor: pointer;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all 0.2s ease;
}

.math-results-actions button:hover {
  border-color: var(--color-primary);
}

.math-results-actions button.primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* ======== LESSON COMPLETE ======== */
.math-lesson-complete {
  padding: var(--space-6);
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  animation: mathFadeIn 0.5s ease;
}

.math-lesson-complete-icon {
  font-size: 4rem;
  margin-bottom: var(--space-3);
}

.math-lesson-complete h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.math-lesson-complete p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-5);
}

/* ======== RESPONSIVE ======== */
@media (max-width: 600px) {
  .math-home, .math-lesson, .math-game, .math-results, .math-lesson-complete {
    padding: var(--space-3) var(--space-4);
  }

  .math-card-grid {
    grid-template-columns: 1fr;
  }

  .math-options-grid {
    grid-template-columns: 1fr;
  }

  .math-stats-bar {
    gap: var(--space-2);
  }

  .math-stat-chip {
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-2);
  }
}

/* ===== MATH SECTIONS (Lessons/Games separation) ===== */
.math-section {
  margin-bottom: var(--space-6, 1.5rem);
}

.math-section-title {
  font-family: 'Baloo 2', cursive;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text, #1e293b);
  margin: 0 0 var(--space-1, 0.25rem) 0;
}

.math-section-desc {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-muted, #64748b);
  margin: 0 0 var(--space-3, 0.75rem) 0;
}

/* Tier badge on cards */
.math-card-tag.beginner { background: #4CAF50 !important; }
.math-card-tag.intermediate { background: #FFB300 !important; }
.math-card-tag.advanced { background: #FF7043 !important; }

/* ===== DAILY MATH CHALLENGE ===== */
.math-daily-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.math-daily-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 50%, rgba(255,215,0,0.08), transparent 60%),
              radial-gradient(ellipse at 80% 30%, rgba(138,43,226,0.06), transparent 50%);
  pointer-events: none;
}
.math-daily-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15,52,96,0.3);
}
.math-daily-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 1;
}
.math-daily-icon {
  font-size: 2.5rem;
  line-height: 1;
  animation: dailyPulse 2s ease-in-out infinite;
}
@keyframes dailyPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.math-daily-info { z-index: 1; }
.math-daily-title {
  font-family: 'Baloo 2', cursive;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.math-daily-desc {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  margin: 2px 0 0 0;
}
.math-daily-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 1;
}
.math-daily-streak {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #fff;
}
.math-streak-fire {
  font-size: 1.4rem;
}
.math-streak-num {
  font-family: 'Baloo 2', cursive;
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffd700;
  line-height: 1;
}
.math-streak-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.math-daily-play-btn {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  color: #1a1a2e;
  border: none;
  border-radius: 20px;
  padding: 0.45rem 1.2rem;
  font-family: 'Baloo 2', cursive;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.math-daily-play-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255,215,0,0.4);
}

/* Daily Results */
.math-daily-results-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.math-daily-result-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-surface, #f8fafc);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 12px;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text, #1e293b);
}
.math-daily-result-item.streak-bonus {
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  border-color: #ffd700;
  color: #856404;
}
[data-theme="dark"] .math-daily-result-item.streak-bonus {
  background: linear-gradient(135deg, #5c4a00, #6b5a10);
  border-color: #ffd700;
  color: #ffeaa7;
}
.math-daily-result-icon {
  font-size: 1.2rem;
}

/* Review section */
.math-review {
  margin-top: 1.25rem;
  text-align: left;
}
.math-review h3 {
  font-family: 'Baloo 2', cursive;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}
.math-review-item {
  background: var(--color-bg-card, #f8fafc);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
}
.math-review-q {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}
.math-review-wrong {
  color: #e74c3c;
  font-size: 0.85rem;
}
.math-review-correct {
  color: #27ae60;
  font-size: 0.85rem;
  font-weight: 600;
}
.math-review-hint {
  color: var(--color-text-muted, #64748b);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .math-daily-banner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1rem;
  }
  .math-daily-left {
    flex-direction: column;
    gap: 0.5rem;
  }
  .math-daily-right {
    flex-direction: row;
    gap: 1rem;
  }
}
