/* Calvin's 3rd Grade Study Site — Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --math:    #4F46E5;
  --math-lt: #EEF2FF;
  --ela:     #059669;
  --ela-lt:  #ECFDF5;
  --sci:     #7C3AED;
  --sci-lt:  #F5F3FF;
  --ss:      #D97706;
  --ss-lt:   #FFFBEB;
  --bg:      #F0F9FF;
  --card:    #FFFFFF;
  --text:    #1E293B;
  --muted:   #64748B;
  --border:  #E2E8F0;
  --green:   #16A34A;
  --red:     #DC2626;
  --radius:  14px;
  --shadow:  0 4px 16px rgba(0,0,0,0.08);
}

html { font-size: 16px; }

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ── Header / Nav ── */
.site-header {
  background: var(--card);
  border-bottom: 2px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-logo {
  font-size: 1.4rem;
  font-weight: 900;
  color: #4F46E5;
  white-space: nowrap;
}
.site-logo span { color: var(--text); }
.nav-links { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-link {
  padding: 6px 14px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
  color: var(--muted);
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.math   { color: var(--math); }
.nav-link.ela    { color: var(--ela); }
.nav-link.sci    { color: var(--sci); }
.nav-link.ss     { color: var(--ss); }
.nav-link.active { background: var(--math-lt); color: var(--math); }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 52px 20px 36px;
}
.hero h1 {
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 12px;
}
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 500px; margin: 0 auto; }

/* ── Subject Cards (Dashboard) ── */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  padding: 0 0 40px;
}
.subject-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 5px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}
.subject-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.subject-card.math  { border-color: var(--math); }
.subject-card.ela   { border-color: var(--ela); }
.subject-card.sci   { border-color: var(--sci); }
.subject-card.ss    { border-color: var(--ss); }

.card-icon { font-size: 2.8rem; line-height: 1; }
.card-title { font-size: 1.3rem; font-weight: 800; }
.card-subtitle { font-size: 0.85rem; color: var(--muted); margin-top: -10px; }

.best-score {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
}
.math  .best-score { background: var(--math-lt); color: var(--math); }
.ela   .best-score { background: var(--ela-lt);  color: var(--ela); }
.sci   .best-score { background: var(--sci-lt);  color: var(--sci); }
.ss    .best-score { background: var(--ss-lt);   color: var(--ss); }

.card-buttons { display: flex; gap: 8px; margin-top: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 50px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  border: none;
  transition: filter 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { filter: brightness(0.92); transform: scale(1.02); }
.btn:active { transform: scale(0.98); }
.btn-primary { color: #fff; }
.math  .btn-primary { background: var(--math); }
.ela   .btn-primary { background: var(--ela); }
.sci   .btn-primary { background: var(--sci); }
.ss    .btn-primary { background: var(--ss); }
.btn-outline {
  background: transparent;
  border: 2px solid;
  color: var(--text);
}
.math  .btn-outline { border-color: var(--math); color: var(--math); }
.ela   .btn-outline { border-color: var(--ela); color: var(--ela); }
.sci   .btn-outline { border-color: var(--sci); color: var(--sci); }
.ss    .btn-outline { border-color: var(--ss); color: var(--ss); }

/* standalone colored buttons */
.btn-math   { background: var(--math); color: #fff; }
.btn-ela    { background: var(--ela);  color: #fff; }
.btn-sci    { background: var(--sci);  color: #fff; }
.btn-ss     { background: var(--ss);   color: #fff; }
.btn-green  { background: var(--green); color: #fff; }
.btn-gray   { background: #94A3B8; color: #fff; }
.btn-lg     { padding: 14px 28px; font-size: 1.05rem; }
.btn-sm     { padding: 7px 14px; font-size: 0.82rem; }

/* ── History Table ── */
.section-title {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 16px;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.93rem;
}
.history-table th {
  background: #F8FAFC;
  padding: 12px 16px;
  text-align: left;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
}
.history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: #F8FAFC; }
.pct-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.85rem;
}
.pct-great { background: #DCFCE7; color: #15803D; }
.pct-good  { background: #FEF9C3; color: #854D0E; }
.pct-low   { background: #FEE2E2; color: #991B1B; }
.subject-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.8rem;
}
.pill-math { background: var(--math-lt); color: var(--math); }
.pill-ela  { background: var(--ela-lt);  color: var(--ela); }
.pill-sci  { background: var(--sci-lt);  color: var(--sci); }
.pill-ss   { background: var(--ss-lt);   color: var(--ss); }

/* ── Subject Page ── */
.subject-hero {
  padding: 40px 0 30px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.subject-hero .big-icon { font-size: 4rem; }
.subject-hero h1 { font-size: 2.2rem; font-weight: 900; }
.subject-hero p { color: var(--muted); margin-top: 4px; }

.subject-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 28px;
  padding-bottom: 60px;
}
@media (max-width: 768px) { .subject-layout { grid-template-columns: 1fr; } }

/* Topic accordion */
.topic-list { display: flex; flex-direction: column; gap: 14px; }
.topic-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.05rem;
  user-select: none;
  gap: 12px;
}
.topic-header:hover { background: #F8FAFC; }
.topic-header .chevron {
  font-size: 0.9rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.topic-card.open .chevron { transform: rotate(180deg); }
.topic-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}
.topic-card.open .topic-body { display: block; }
.topic-skills {
  list-style: none;
  margin: 14px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.topic-skills li { padding-left: 20px; position: relative; color: var(--muted); font-size: 0.93rem; }
.topic-skills li::before {
  content: '✓';
  position: absolute;
  left: 0;
  font-weight: 900;
  color: var(--green);
}
.resource-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.resource-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
  background: #F8FAFC;
}
.resource-link:hover { background: var(--bg); border-color: #CBD5E1; }
.topic-quiz-btn {
  margin-top: 14px;
  display: inline-block;
}

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.sidebar-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 14px; }
.sidebar-btn-list { display: flex; flex-direction: column; gap: 8px; }

/* ── Quiz Page ── */
.quiz-wrapper {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}
.quiz-title { font-size: 1.1rem; font-weight: 800; color: var(--muted); }
.quiz-counter { font-size: 0.9rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.progress-bar-track {
  height: 10px;
  background: var(--border);
  border-radius: 50px;
  overflow: hidden;
  flex: 1;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 50px;
  background: var(--math);
  transition: width 0.3s ease;
}
.progress-bar-fill.ela { background: var(--ela); }
.progress-bar-fill.sci { background: var(--sci); }
.progress-bar-fill.ss  { background: var(--ss); }

.question-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  margin-bottom: 24px;
}
.question-text {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 28px;
  line-height: 1.5;
}
.options-grid { display: flex; flex-direction: column; gap: 12px; }
.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: #F8FAFC;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.option-btn:hover:not(:disabled) { border-color: #94A3B8; background: var(--bg); transform: translateX(3px); }
.option-btn:disabled { cursor: default; }
.option-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.option-btn.correct { border-color: var(--green); background: #DCFCE7; }
.option-btn.correct .option-label { background: var(--green); color: #fff; }
.option-btn.wrong   { border-color: var(--red);   background: #FEE2E2; }
.option-btn.wrong   .option-label { background: var(--red);   color: #fff; }
.option-btn.dimmed  { opacity: 0.45; }

.explanation-box {
  display: none;
  margin-top: 20px;
  padding: 14px 18px;
  background: #F0FFF4;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.6;
}
.explanation-box.show { display: block; }
.explanation-box.wrong-exp { background: #FFF5F5; border-color: var(--red); }

.next-btn-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Results */
.results-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 32px;
  text-align: center;
}
.results-emoji { font-size: 4rem; margin-bottom: 12px; }
.results-score { font-size: 3rem; font-weight: 900; margin-bottom: 4px; }
.results-pct   { font-size: 1.4rem; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.results-stars { font-size: 2rem; margin-bottom: 16px; }
.results-msg   { font-size: 1.1rem; color: var(--muted); margin-bottom: 32px; max-width: 400px; margin-left: auto; margin-right: auto; }
.results-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.save-status { margin-top: 16px; font-size: 0.9rem; color: var(--muted); font-weight: 700; min-height: 24px; }

/* Loading spinner */
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--math);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty/error states */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .big { font-size: 3rem; margin-bottom: 12px; }

/* ── Study Notes ── */
.study-notes {
  margin: 14px 0 10px;
  padding: 13px 16px;
  background: #F8FAFC;
  border-radius: 8px;
  border-left: 3px solid var(--border);
}
.study-notes h4 {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.study-notes ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.study-notes li {
  font-size: 0.91rem;
  padding-left: 18px;
  position: relative;
  line-height: 1.5;
}
.study-notes li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--muted);
  font-size: 0.8rem;
  top: 2px;
}
.study-notes strong { color: var(--text); }

/* ── Video Embeds ── */
.video-section { margin: 14px 0 10px; }
.video-section h4 {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.video-item {}
.video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #0f0f0f;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.video-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}
.video-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  margin-top: 6px;
  padding-left: 2px;
}
@media (max-width: 600px) { .video-grid { grid-template-columns: 1fr; } }

/* ── Utilities ── */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.font-bold { font-weight: 800; }
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .hero h1 { font-size: 1.9rem; }
  .question-card { padding: 24px 18px; }
  .question-text { font-size: 1.05rem; }
  .results-score { font-size: 2.4rem; }
  .subjects-grid { grid-template-columns: 1fr; }
  .site-logo { font-size: 1.1rem; }
}
