/* ========== Earth Science Regents Study Hub ==========
   Soft purple & teal theme, friendly + studious 8th-grade vibe
*/

:root {
  --purple-50:  #f7f4fb;
  --purple-100: #ece4f6;
  --purple-200: #d4c2ec;
  --purple-300: #b89bdf;
  --purple-400: #9c79d2;
  --purple-500: #8154c2;  /* primary purple */
  --purple-600: #6b3fae;
  --purple-700: #553289;

  --teal-50:    #effbfa;
  --teal-100:   #d3f4f1;
  --teal-200:   #a4e7e0;
  --teal-300:   #6dd5cc;
  --teal-400:   #3dbeb3;
  --teal-500:   #25a094;  /* primary teal */
  --teal-600:   #1f8479;
  --teal-700:   #185f57;

  --rose-300:   #f5b1d1;
  --rose-500:   #e670a5;

  --bg:         #fbf8ff;
  --card-bg:    #ffffff;
  --text:       #2a2340;
  --text-soft:  #5b5475;
  --text-faint: #8b85a3;
  --border:     #e7defb;
  --shadow-sm:  0 2px 4px rgba(85, 50, 137, 0.06);
  --shadow-md:  0 6px 18px rgba(85, 50, 137, 0.10);
  --shadow-lg:  0 12px 32px rgba(85, 50, 137, 0.16);

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Avenir Next",
               Avenir, "Helvetica Neue", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 0% 0%, var(--purple-100) 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, var(--teal-100) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--purple-600); text-decoration: none; }
a:hover { color: var(--teal-600); text-decoration: underline; }

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

header.site-header {
  padding: 28px 0 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 22px;
  color: var(--purple-700);
}

.brand .logo-orb {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: conic-gradient(from 220deg, var(--teal-400), var(--purple-500), var(--rose-300), var(--teal-400));
  box-shadow: var(--shadow-md);
  position: relative;
}
.brand .logo-orb::after {
  content: "";
  position: absolute; inset: 6px;
  border-radius: 50%;
  background: var(--card-bg);
}
.brand .logo-orb::before {
  content: "";
  position: absolute; inset: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-400), var(--purple-500));
  z-index: 1;
}

nav.nav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}
nav.nav a {
  color: var(--text-soft);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 15px;
}
nav.nav a:hover {
  background: var(--purple-100);
  color: var(--purple-700);
  text-decoration: none;
}
nav.nav a.cta {
  background: linear-gradient(135deg, var(--purple-500), var(--teal-500));
  color: white;
  box-shadow: var(--shadow-sm);
}
nav.nav a.cta:hover {
  background: linear-gradient(135deg, var(--purple-600), var(--teal-600));
  color: white;
}

main {
  padding: 36px 0 80px;
}

footer.site-footer {
  text-align: center;
  color: var(--text-faint);
  padding: 32px 16px;
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 60px;
  background: rgba(255,255,255,0.4);
}

/* ============ Hero ============ */
.hero {
  padding: 28px 0 40px;
  text-align: center;
}
.hero h1 {
  font-size: 42px;
  font-weight: 800;
  margin: 0 0 12px;
  background: linear-gradient(135deg, var(--purple-600), var(--teal-600));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.hero p {
  font-size: 18px;
  color: var(--text-soft);
  max-width: 640px;
  margin: 0 auto 24px;
}
.hero .actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--purple-500), var(--teal-500));
  color: white;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--purple-600), var(--teal-600));
  color: white;
  box-shadow: var(--shadow-lg);
}
.btn-outline {
  border: 2px solid var(--purple-300);
  color: var(--purple-700);
  background: rgba(255,255,255,0.7);
}
.btn-outline:hover {
  border-color: var(--teal-500);
  color: var(--teal-700);
}
.btn-ghost {
  color: var(--text-soft);
  background: transparent;
}
.btn-ghost:hover {
  background: var(--purple-100);
  color: var(--purple-700);
}

/* ============ Section ============ */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 36px 0 18px;
  flex-wrap: wrap;
}
.section-title h2 {
  font-size: 26px;
  margin: 0;
  color: var(--purple-700);
}
.section-title .subtle { color: var(--text-faint); font-size: 14px; }

/* ============ Chapter Grid (home) ============ */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.chapter-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.chapter-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--purple-400), var(--teal-400));
}
.chapter-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--purple-200);
  text-decoration: none;
}
.chapter-card .ch-num {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--teal-600);
  text-transform: uppercase;
}
.chapter-card .ch-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--purple-700);
  line-height: 1.25;
}
.chapter-card .ch-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-soft);
  flex-wrap: wrap;
}
.chapter-card .pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--purple-100);
  color: var(--purple-700);
  font-weight: 600;
  font-size: 12px;
}
.chapter-card .pill.teal {
  background: var(--teal-100);
  color: var(--teal-700);
}

/* ============ Chapter detail ============ */
.crumbs {
  font-size: 14px;
  color: var(--text-faint);
  margin-bottom: 18px;
}
.crumbs a { color: var(--text-soft); }

.chapter-hero {
  background: linear-gradient(135deg, var(--purple-500), var(--teal-500));
  color: white;
  padding: 30px;
  border-radius: var(--radius-xl);
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
}
.chapter-hero .ch-num {
  font-size: 13px;
  letter-spacing: 1.5px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.85;
}
.chapter-hero h1 {
  margin: 6px 0 10px;
  font-size: 32px;
}
.chapter-hero p { margin: 0; opacity: 0.9; }

.subsection-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.subsection-row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.subsection-row .title {
  font-weight: 600;
  font-size: 17px;
  color: var(--purple-700);
}
.subsection-row .quiz-pill {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--rose-300), var(--purple-300));
  color: var(--purple-700);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}
.subsection-row .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.subsection-row .actions a {
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
}
.subsection-row .actions .q {
  background: var(--purple-500);
  color: white;
}
.subsection-row .actions .q:hover { background: var(--purple-600); color: white; text-decoration: none; }
.subsection-row .actions .a {
  background: var(--teal-100);
  color: var(--teal-700);
}
.subsection-row .actions .a:hover { background: var(--teal-200); color: var(--teal-700); text-decoration: none; }
.subsection-row .actions .a.disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 600px) {
  .subsection-row { grid-template-columns: 1fr; }
  .subsection-row .actions { justify-content: flex-start; }
}

/* ============ Quiz selector ============ */
.quiz-setup {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.quiz-setup h2 {
  margin: 0 0 8px;
  color: var(--purple-700);
}
.quiz-setup p.lead { color: var(--text-soft); margin: 0 0 22px; }

.quiz-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.mode-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  background: var(--purple-50);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}
.mode-card:hover { transform: translateY(-2px); }
.mode-card.active {
  border-color: var(--purple-500);
  background: white;
  box-shadow: var(--shadow-md);
}
.mode-card .mode-title {
  font-weight: 700;
  font-size: 17px;
  color: var(--purple-700);
  margin-bottom: 4px;
}
.mode-card .mode-desc { font-size: 13px; color: var(--text-soft); }

.chapter-picker {
  display: none;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.chapter-picker.visible { display: block; }
.chapter-picker .ch-block {
  margin-bottom: 14px;
  background: var(--purple-50);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
.chapter-picker .ch-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--purple-700);
  cursor: pointer;
}
.chapter-picker .ch-head input { accent-color: var(--purple-500); width: 16px; height: 16px; }
.chapter-picker .ch-head .count {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
}
.chapter-picker .subs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 14px;
  margin-top: 8px;
  padding-left: 26px;
}
.chapter-picker .subs label {
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.chapter-picker .subs label.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chapter-picker .subs input { accent-color: var(--teal-500); }
.chapter-picker .no-quiz {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

.feedback-toggle {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--teal-50);
  border: 1px solid var(--teal-200);
  border-radius: var(--radius-md);
  font-size: 14px;
}
.feedback-toggle label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.feedback-toggle input {
  accent-color: var(--teal-500);
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}
.feedback-toggle .ft-text {
  color: var(--text-soft);
}
.feedback-toggle strong {
  color: var(--teal-700);
}

.start-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
}
.start-row .summary {
  color: var(--text-soft);
  font-size: 14px;
  flex-grow: 1;
}
.start-row .summary strong { color: var(--purple-700); }

/* ============ Quiz player ============ */
.quiz-player { display: none; }
.quiz-player.active { display: block; }

.quiz-bar {
  background: var(--card-bg);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--border);
}
.quiz-bar .progress {
  font-weight: 700;
  color: var(--purple-700);
}
.quiz-bar .progress-track {
  flex: 1 1 200px;
  height: 8px;
  border-radius: 999px;
  background: var(--purple-100);
  overflow: hidden;
  margin: 0 16px;
  min-width: 180px;
}
.quiz-bar .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-400), var(--purple-500));
  transition: width 0.3s ease;
}

.q-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.q-card .meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-600);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.q-card .stem {
  font-size: 18px;
  margin: 0 0 18px;
  line-height: 1.5;
}
.q-card .visual-hint {
  background: var(--purple-50);
  border: 1px solid var(--purple-200);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--purple-700);
}
.q-card .visual-hint a {
  color: var(--purple-600);
  font-weight: 700;
}
.q-card .choice-note {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 12px;
  font-style: italic;
}
.q-card .pdf-embed-wrap {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--purple-50);
}
.q-card .pdf-embed-bar {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--purple-700);
  background: var(--purple-100);
  border-bottom: 1px solid var(--purple-200);
}
.q-card .pdf-embed-bar a {
  color: var(--purple-600);
  font-weight: 600;
}
.q-card .pdf-embed {
  display: block;
  width: 100%;
  height: 720px;
  border: none;
  background: #fff;
}
.q-card .q-image-wrap {
  margin: 6px 0 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.q-card .q-image {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}
.q-card .q-image-bar {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-faint);
  background: var(--purple-50);
  border-top: 1px solid var(--border);
}
.q-card .q-image-bar a {
  color: var(--purple-600);
  font-weight: 600;
}
.q-card .options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.q-card .opt {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--purple-50);
  transition: border-color 0.12s ease, background 0.12s ease;
  font-size: 16px;
}
.q-card .opt:hover {
  border-color: var(--purple-300);
  background: white;
}
.q-card .opt.selected {
  border-color: var(--purple-500);
  background: white;
  box-shadow: 0 0 0 3px var(--purple-100);
}
.q-card .opt.correct {
  border-color: var(--teal-500);
  background: var(--teal-50);
  animation: flashGreen 0.45s ease;
}
.q-card .opt.correct::after {
  content: " ✓";
  margin-left: auto;
  color: var(--teal-600);
  font-weight: 800;
  font-size: 18px;
}
.q-card .opt.wrong {
  border-color: #e07a8a;
  background: #fbe9ec;
  animation: flashRed 0.45s ease;
}
.q-card .opt.wrong::after {
  content: " ✗";
  margin-left: auto;
  color: #c44a5e;
  font-weight: 800;
  font-size: 18px;
}
@keyframes flashGreen {
  0%   { box-shadow: 0 0 0 0 rgba(37, 160, 148, 0.6); }
  50%  { box-shadow: 0 0 0 10px rgba(37, 160, 148, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 160, 148, 0); }
}
@keyframes flashRed {
  0%   { box-shadow: 0 0 0 0 rgba(196, 74, 94, 0.6); }
  50%  { box-shadow: 0 0 0 10px rgba(196, 74, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(196, 74, 94, 0); }
}
.q-card .opt .letter {
  font-weight: 700;
  color: var(--purple-600);
  flex-shrink: 0;
  width: 22px;
}
.q-card .opt-minimal {
  padding: 14px 16px;
}
.q-card .opt-minimal .letter {
  font-size: 18px;
  width: 28px;
}
.q-card .opt.correct .letter { color: var(--teal-700); }
.q-card .opt.wrong .letter { color: #c44a5e; }

.q-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============ Results ============ */
.results { display: none; }
.results.active { display: block; }

.score-card {
  background: linear-gradient(135deg, var(--purple-500), var(--teal-500));
  color: white;
  border-radius: var(--radius-xl);
  padding: 36px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  margin-bottom: 28px;
}
.score-card .score {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}
.score-card .score-fraction {
  font-size: 22px;
  opacity: 0.9;
  margin-bottom: 14px;
}
.score-card .verdict { font-size: 18px; opacity: 0.95; }
.score-card .actions {
  margin-top: 22px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.score-card .actions .btn-light {
  background: white;
  color: var(--purple-600);
}
.score-card .actions .btn-light:hover { color: var(--teal-700); }
.score-card .actions .btn-clear {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
}

.review-list { display: flex; flex-direction: column; gap: 14px; }
.review-item {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  border-left: 4px solid var(--teal-400);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--teal-400);
}
.review-item.wrong { border-left-color: #e07a8a; }
.review-item .qmeta {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.review-item .qstem {
  font-weight: 600;
  margin-bottom: 8px;
}
.review-item .ainfo {
  font-size: 14px;
  color: var(--text-soft);
}
.review-item .ainfo .your { color: #c44a5e; font-weight: 600; }
.review-item .ainfo .right { color: var(--teal-700); font-weight: 600; }
.review-item.correct .ainfo .your { color: var(--teal-700); }

/* ============ Misc ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
}

.notice {
  background: var(--teal-50);
  border: 1px solid var(--teal-200);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: var(--teal-700);
  margin-bottom: 22px;
  font-size: 14px;
}
.notice strong { color: var(--teal-700); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 24px 0;
}
.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.stat-tile .num {
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--purple-600), var(--teal-600));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-tile .label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-top: 4px;
}
