/* BrainBox – brainbox.quest
   Colors: Deep navy #0D1B2A, Electric blue #1E90FF, Bright yellow #FFD700, White
   Font: Nunito
*/
:root {
  --navy: #0D1B2A;
  --blue: #1E90FF;
  --yellow: #FFD700;
  --white: #FFFFFF;
  --gray-100: #F8FAFC;
  --gray-200: #E2E8F0;
  --gray-500: #64748B;
  --success: #22C55E;
  --error: #EF4444;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(13, 27, 42, 0.1), 0 2px 4px -2px rgba(13, 27, 42, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(13, 27, 42, 0.1), 0 4px 6px -4px rgba(13, 27, 42, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--navy);
  min-height: 100vh;
  line-height: 1.6;
}

/* Landing */
.landing {
  background: linear-gradient(135deg, var(--navy) 0%, #1a2d42 100%);
  color: var(--white);
  text-align: center;
  padding: 3rem 1.5rem;
}

.hero .logo {
  margin-bottom: 1.5rem;
}

.logo-icon {
  font-size: 4rem;
  display: block;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.tagline {
  font-size: 1rem;
  opacity: 0.9;
}

.hero-text {
  max-width: 500px;
  margin: 0 auto 2rem;
  font-size: 1.1rem;
}

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  max-width: 900px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.feature-card {
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}

.feature-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.feature-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  font-size: 0.9rem;
  opacity: 0.9;
}

footer {
  margin-top: 3rem;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}

.btn-secondary {
  background: var(--yellow);
  color: var(--navy);
}

.btn-block {
  width: 100%;
  text-align: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  text-decoration: underline;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #1a2d42 100%);
  padding: 1rem;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.logo-small {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  text-decoration: none;
  margin-bottom: 1.5rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.auth-hint {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.auth-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.auth-form input,
.auth-form select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.auth-form input:focus,
.auth-form select:focus {
  outline: none;
  border-color: var(--blue);
}

.error-msg {
  color: var(--error);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.auth-form .btn {
  margin-top: 0.5rem;
}

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
}

.auth-footer a {
  color: var(--blue);
  font-weight: 600;
}

/* App header */
.app-header {
  background: var(--navy);
  color: var(--white);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.app-header .logo {
  color: var(--white);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
}

.app-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-header nav a {
  color: var(--white);
  text-decoration: none;
  opacity: 0.9;
}

.app-header nav a:hover {
  opacity: 1;
}

.app-header .btn-link {
  color: var(--yellow);
}

/* Dashboard */
.dashboard {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.dashboard h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--gray-500);
  margin-bottom: 2rem;
}

.subject-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.subject-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}

.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--blue);
}

.subject-card.math { border-left: 4px solid var(--blue); }
.subject-card.english { border-left: 4px solid var(--yellow); }

.subject-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.subject-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
}

.subject-card p {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.subject-progress {
  font-size: 0.85rem;
  color: var(--blue);
  font-weight: 600;
}

/* Subject / Skill list */
.subject-page,
.teacher-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.back-link {
  display: inline-block;
  color: var(--blue);
  text-decoration: none;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

.subject-page h1,
.teacher-page h1 {
  margin-bottom: 0.5rem;
}

.skill-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.skill-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--white);
  padding: 1.25rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.skill-card:hover {
  transform: translateY(-2px);
}

.skill-card.mastered {
  border: 2px solid var(--yellow);
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
}

.skill-score-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) calc(var(--score) * 1%), var(--gray-200) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.skill-score-ring span {
  background: var(--white);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.skill-info h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.skill-info p {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.badge {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Skill practice page */
.skill-header {
  flex-wrap: wrap;
}

.skill-progress-bar {
  flex: 1;
  min-width: 120px;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--blue);
  transition: width 0.3s ease;
}

.smartscore-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.score-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: conic-gradient(var(--yellow) calc(var(--score, 0) * 1%), var(--gray-200) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.score-ring span {
  background: var(--navy);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
}

.skill-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

#skill-name {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--gray-500);
}

#question-area {
  background: var(--white);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.question-prompt {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.options-list {
  list-style: none;
}

.option-btn {
  display: block;
  width: 100%;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
  background: var(--gray-100);
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--blue);
  background: rgba(30, 144, 255, 0.08);
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.option-btn.correct {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.15);
}

.option-btn.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.option-btn.correct {
  animation: flash 0.3s ease;
}

@keyframes flash {
  0% { background: rgba(34, 197, 94, 0.4); }
  100% { background: rgba(34, 197, 94, 0.15); }
}

.fill-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1.1rem;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
}

.fill-input:focus {
  outline: none;
  border-color: var(--blue);
}

.feedback {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 600;
}

.feedback.correct {
  background: rgba(34, 197, 94, 0.2);
  color: #166534;
}

.feedback.incorrect {
  background: rgba(239, 68, 68, 0.15);
  color: #B91C1C;
}

.feedback.hidden {
  display: none;
}

.question-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

/* Mastery celebration */
.mastery-celebration {
  text-align: center;
  padding: 3rem 2rem;
}

.mastery-celebration.hidden {
  display: none;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle fill='%23FFD700' cx='20' cy='30' r='2'/%3E%3Ccircle fill='%231E90FF' cx='50' cy='20' r='2'/%3E%3Ccircle fill='%2322C55E' cx='80' cy='40' r='2'/%3E%3Ccircle fill='%23EF4444' cx='30' cy='70' r='2'/%3E%3Ccircle fill='%23FFD700' cx='70' cy='80' r='2'/%3E%3C/svg%3E") repeat;
  animation: confetti-fall 3s ease-out forwards;
  opacity: 0;
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(-100%); }
  100% { opacity: 0.8; transform: translateY(0); }
}

.mastery-celebration h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.mastery-celebration p {
  margin-bottom: 1.5rem;
  color: var(--gray-500);
}

/* Awards */
.awards-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.awards-grid {
  margin-top: 1.5rem;
}

.award-placeholder {
  background: var(--white);
  padding: 2rem;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}

.award-placeholder p {
  margin-bottom: 1rem;
  color: var(--gray-500);
}

.award-summary h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.mastery-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.award-badge {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 2px solid var(--yellow);
}

.badge-icon {
  font-size: 1.25rem;
}

/* Teacher */
.students-table-wrap {
  overflow-x: auto;
  margin-top: 1.5rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.students-table {
  width: 100%;
  border-collapse: collapse;
}

.students-table th,
.students-table td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.students-table th {
  background: var(--gray-100);
  font-weight: 700;
}

.students-table tr:hover td {
  background: var(--gray-100);
}

.progress-table th,
.progress-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.score-badge {
  background: var(--blue);
  color: var(--white);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
}

/* Error page */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.loading {
  color: var(--gray-500);
}

/* Responsive */
@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .skill-header .skill-progress-bar {
    order: 3;
    width: 100%;
  }

  .subject-cards {
    grid-template-columns: 1fr;
  }
}
