@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Source+Sans+3:wght@300;400;600;700&display=swap');

:root {
  --navy: #0f1f38;
  --navy-mid: #1a2f4e;
  --navy-light: #243b5e;
  --gold: #c9a84c;
  --gold-light: #e8c97a;
  --gold-pale: #f5e9c8;
  --cream: #faf7f0;
  --white: #ffffff;
  --red: #c0392b;
  --green: #1e7e4a;
  --text-dark: #1a1a2e;
  --text-mid: #3a4a6b;
  --text-light: #6b7a99;
  --border: #dde3ee;
  --shadow: 0 4px 24px rgba(15,31,56,0.10);
  --shadow-lg: 0 8px 40px rgba(15,31,56,0.16);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Source Sans 3', sans-serif;
  background: var(--cream);
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold); }

h1, h2, h3 { font-family: 'Libre Baskerville', serif; line-height: 1.25; }

/* ── TOP NAV ── */
.topnav {
  background: var(--navy);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.topnav-brand {
  font-family: 'Libre Baskerville', serif;
  color: var(--gold);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.topnav-brand span { color: var(--white); font-weight: 400; }
.topnav-home {
  color: var(--gold-light);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.2s;
}
.topnav-home:hover { color: var(--white); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: 4px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
}
.btn-primary {
  background: var(--gold);
  color: var(--navy);
}
.btn-primary:hover { background: var(--gold-light); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-outline {
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold);
}
.btn-outline:hover { background: var(--gold); color: var(--navy); }
.btn-navy {
  background: var(--navy);
  color: var(--gold);
}
.btn-navy:hover { background: var(--navy-mid); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ── PROGRESS BAR ── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── QUESTION CARD ── */
.question-card {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 2rem 2.5rem;
  max-width: 820px;
  margin: 0 auto;
}
.question-number {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.6rem;
}
.question-text {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.1rem;
  color: var(--text-dark);
  margin-bottom: 1.5rem;
  line-height: 1.55;
}
.options-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.option-btn {
  width: 100%;
  text-align: left;
  padding: 0.75rem 1.1rem;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--cream);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.95rem;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.option-btn:hover:not(:disabled) { border-color: var(--gold); background: var(--gold-pale); }
.option-btn .opt-letter {
  font-weight: 700;
  color: var(--text-light);
  min-width: 1.2rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.option-btn.selected { border-color: var(--navy); background: #eef1f8; }
.option-btn.correct { border-color: var(--green); background: #eaf7ee; }
.option-btn.correct .opt-letter { color: var(--green); }
.option-btn.incorrect { border-color: var(--red); background: #fdecea; }
.option-btn.incorrect .opt-letter { color: var(--red); }
.option-btn:disabled { cursor: default; }

.reveal-btn { margin-top: 1.2rem; }

.explanation-box {
  margin-top: 1.2rem;
  padding: 1rem 1.25rem;
  background: #f0f4fb;
  border-left: 4px solid var(--navy);
  border-radius: 0 6px 6px 0;
  font-size: 0.93rem;
  color: var(--text-mid);
  line-height: 1.6;
  display: none;
}
.explanation-box.visible { display: block; }
.explanation-box strong { color: var(--navy); }

.nav-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

/* ── SCORE SCREEN ── */
.score-screen { max-width: 820px; margin: 0 auto; padding: 2rem 1rem; }
.score-badge {
  text-align: center;
  padding: 2.5rem;
  background: var(--navy);
  border-radius: 12px;
  color: var(--white);
  margin-bottom: 2rem;
}
.score-pct { font-size: 4rem; font-family: 'Libre Baskerville', serif; color: var(--gold); line-height: 1; }
.score-verdict { font-size: 1.1rem; margin-top: 0.5rem; color: var(--gold-light); }
.section-bar-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.section-bar-label { width: 240px; font-size: 0.85rem; color: var(--text-mid); flex-shrink: 0; }
.section-bar-track { flex: 1; background: var(--border); border-radius: 99px; height: 10px; overflow: hidden; }
.section-bar-fill { height: 100%; border-radius: 99px; }
.section-bar-pct { font-size: 0.82rem; font-weight: 700; width: 40px; text-align: right; flex-shrink: 0; }

/* ── REVIEW SCREEN ── */
.review-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filter-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 99px;
  border: 2px solid var(--border);
  background: var(--white);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-mid);
}
.filter-btn.active { border-color: var(--navy); background: var(--navy); color: var(--white); }
.review-item { margin-bottom: 1.5rem; }
.review-item .question-card { padding: 1.5rem 1.75rem; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .question-card { padding: 1.25rem 1.1rem; }
  .score-pct { font-size: 3rem; }
  .section-bar-label { width: 140px; font-size: 0.78rem; }
}

/* ── FLAG WIDGET ── */
.flag-widget {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0.25rem 0 0.75rem 0;
  position: relative;
}
.flag-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-mid);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.flag-btn:hover { border-color: #e67e22; color: #e67e22; }
.flag-btn.flagged { border-color: #e67e22; color: #e67e22; background: #fef9f5; }
.flag-icon { font-size: 0.9rem; }
.flag-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  width: 280px;
}
.flag-popover-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.flag-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-mid);
  margin-bottom: 0.35rem;
  cursor: pointer;
}
.flag-radio input { cursor: pointer; accent-color: #e67e22; }
.flag-notes {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.4rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  resize: vertical;
  font-family: inherit;
  color: var(--text);
  box-sizing: border-box;
}
.flag-notes:focus { outline: none; border-color: #e67e22; }
.flag-popover-btns {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ── NAV AVATAR ── */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topnav-greeting {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.02em;
}
.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
  border: 2px solid rgba(201,168,76,0.4);
}
.avatar-btn:hover {
  background: var(--gold-light);
  transform: scale(1.07);
}

/* ── AVATAR DROPDOWN ── */
.avatar-wrap { position: relative; }
.avatar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(15,31,56,0.18);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
}
.avatar-dropdown.open { display: block; }
.avatar-dropdown-header {
  padding: 0.9rem 1rem;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.avatar-dropdown-header span:first-child {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--navy);
}
.avatar-dropdown-header span:last-child {
  font-size: 0.78rem;
  color: var(--text-light);
}
.avatar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--text-dark);
  text-decoration: none;
  font-family: inherit;
  font-weight: 600;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.avatar-dropdown-item:hover { background: var(--cream); }
.avatar-dropdown-divider { height: 1px; background: var(--border); margin: 0; }
.avatar-dropdown-signout { color: var(--red); }
.avatar-dropdown-signout:hover { background: #fdecea; }
