/* ═══════════════════════════════════════════════════
   Prep for Aerospace — Stylesheet
   Palette: Creme bg, Navy accent, warm typography
═══════════════════════════════════════════════════ */

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

:root {
  --bg:          #F5F0E8;
  --bg-card:     #FDFAF5;
  --bg-card-alt: #F0EBE0;
  --navy:        #1E3A5F;
  --navy-mid:    #2C5282;
  --navy-light:  #4A7BAF;
  --accent:      #C8860A;
  --accent-soft: #F0C060;
  --red:         #C0392B;
  --red-soft:    #FADBD8;
  --green:       #1E6B3A;
  --green-soft:  #D5F0E0;
  --text:        #2D2D2D;
  --text-muted:  #7A7060;
  --border:      #D9D2C5;
  --shadow:      0 2px 12px rgba(30,58,95,0.10);
  --shadow-lg:   0 8px 32px rgba(30,58,95,0.15);
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  0.18s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; }

/* ─── Screen Management ─────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ─── Utility ────────────────────────────────────── */
.hidden { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--navy-mid); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--navy);
}
.btn-outline:hover:not(:disabled) { background: rgba(30,58,95,0.07); }

.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #a93226; }

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-full { width: 100%; }
.btn-large { padding: 14px 36px; font-size: 1.05rem; }

.error-msg {
  color: var(--red);
  font-size: 0.88rem;
  margin-top: -4px;
  margin-bottom: 8px;
}

/* ─── Password Gate ──────────────────────────────── */
#screen-password {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.logo-block { margin-bottom: 32px; }

.logo-icon {
  font-size: 2.8rem;
  margin-bottom: 8px;
  display: block;
}

.logo-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

#password-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.field-group label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.field-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}
.field-group input:focus { border-color: var(--navy-light); }

/* Shake animation on wrong password */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}
.shake { animation: shake 0.4s ease; }

/* ─── Home / Mode Selection ──────────────────────── */
#screen-home {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 100vh;
}

.home-container {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.home-header { text-align: center; }

.home-header .logo-title { font-size: 2.4rem; color: var(--navy); }

.home-subtitle {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 1rem;
}

.section-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 560px) {
  .mode-cards { grid-template-columns: 1fr; }
}

.mode-card {
  cursor: pointer;
  display: block;
}
.mode-card input[type="radio"] { display: none; }

.mode-card-inner {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  height: 100%;
}

.mode-card:hover .mode-card-inner {
  border-color: var(--navy-light);
  box-shadow: var(--shadow);
}

.mode-card input:checked ~ .mode-card-inner {
  border-color: var(--navy);
  background: #EDF2F8;
  box-shadow: 0 0 0 3px rgba(30,58,95,0.15);
}

.mode-icon { font-size: 2rem; margin-bottom: 10px; }

.mode-title {
  font-size: 1.25rem;
  color: var(--navy);
  margin-bottom: 12px;
}

.mode-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-features li {
  font-size: 0.88rem;
  color: var(--text-muted);
  padding-left: 16px;
  position: relative;
}
.mode-features li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--navy-light);
}

.home-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.home-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Exam Screen ─────────────────────────────────── */
#screen-exam {
  flex-direction: column;
  min-height: 100vh;
}

.exam-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(30,58,95,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.exam-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.question-counter {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--navy);
}

.topic-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-card-alt);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  width: fit-content;
}

.exam-header-center { text-align: center; }

.overall-timer {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--navy);
  letter-spacing: 2px;
  transition: color 0.4s ease;
  line-height: 1;
}

.overall-timer.ahead  { color: var(--green); }
.overall-timer.behind { color: var(--red); }
.overall-timer.urgent { color: var(--red); animation: pulse-red 1s ease-in-out infinite; }

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.timer-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

.exam-header-right { display: flex; justify-content: flex-end; }

.per-q-timer {
  text-align: center;
  background: var(--bg-card-alt);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-width: 80px;
}

.per-q-value {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--navy);
  letter-spacing: 1px;
}

.per-q-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Per-question timer: turns amber when over 90s */
.per-q-value.over-pace { color: var(--accent); }

.per-q-nudge {
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 3px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Time-up banner */
.timeup-banner {
  background: #FFF4CC;
  border-bottom: 1px solid #E6C84A;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #7A5C00;
}

/* Dot map */
.dot-map-wrapper {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}

.dot-map {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 860px;
  margin: 0 auto;
}

.dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  background: var(--bg-card-alt);
  color: var(--text-muted);
}

.dot:hover              { border-color: var(--navy-light); }
.dot.active             { border-color: var(--navy); background: var(--navy); color: #fff; }
.dot.answered           { background: var(--navy-light); color: #fff; border-color: var(--navy-light); }
.dot.answered.active    { border-color: var(--navy); }
.dot.flagged            { border-color: var(--accent); }
.dot.flagged::after     { content: ""; position: absolute; }
.dot.correct            { background: var(--green); border-color: var(--green); color: #fff; }
.dot.incorrect          { background: var(--red); border-color: var(--red); color: #fff; }
.dot.unanswered-result  { background: #ccc; border-color: #aaa; color: #666; }

/* Main exam area */
.exam-main {
  flex: 1;
  padding: 32px 24px;
  display: flex;
  justify-content: center;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 40px;
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
}

/* KaTeX overrides */
.katex { font-size: 1.1em; }
.katex-display { margin: 12px 0; }

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
  line-height: 1.5;
}

.option-item:hover { border-color: var(--navy-light); background: #EEF4FF; }

.option-item input[type="radio"] { display: none; }

.option-letter {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition);
  margin-top: 1px;
}

.option-text { flex: 1; font-size: 0.97rem; color: var(--text); }

/* Selected option */
.option-item.selected {
  border-color: var(--navy);
  background: #EDF2F8;
}
.option-item.selected .option-letter {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* Results-phase option styling */
.option-item.correct-answer {
  border-color: var(--green);
  background: var(--green-soft);
}
.option-item.correct-answer .option-letter {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.option-item.wrong-selected {
  border-color: var(--red);
  background: var(--red-soft);
}
.option-item.wrong-selected .option-letter {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ─── Helper Mode In-Exam Panels ──────────────────── */
.helper-actions {
  display: flex;
  gap: 10px;
}

.helper-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: var(--navy-mid);
  cursor: pointer;
  transition: all var(--transition);
}
.helper-btn:hover { border-color: var(--navy-light); background: #EDF2F8; }
.helper-btn.active { border-color: var(--navy); background: #EDF2F8; }

.helper-panel {
  background: #F0F5FF;
  border: 1.5px solid #C5D8F5;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.helper-panel-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy-mid);
}

.helper-panel-content {
  font-size: 0.93rem;
  color: var(--text);
  line-height: 1.7;
}

/* Flag button */
.flag-btn {
  align-self: flex-start;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.flag-btn:hover { border-color: var(--accent); color: var(--accent); }
.flag-btn.flagged { border-color: var(--accent); color: var(--accent); background: #FFF8E6; }

/* Exam footer */
.exam-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  gap: 12px;
}

/* ─── Submit Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card h2 { color: var(--navy); font-size: 1.5rem; }
.modal-card p  { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

/* ─── Results Screen ─────────────────────────────── */
#screen-results {
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 60px;
}

.results-container {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.results-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.results-header .logo-title { color: var(--navy); font-size: 2rem; }

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.score-fraction {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.score-pct {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.results-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.results-meta span { display: flex; align-items: center; gap: 5px; }

/* Results table */
.results-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--bg-card);
}

.results-table th {
  background: var(--bg-card-alt);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.results-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

.results-table tr:last-child td { border-bottom: none; }

.results-table tr:hover td { background: var(--bg-card-alt); }

.result-correct { color: var(--green); font-weight: 600; }
.result-wrong   { color: var(--red);   font-weight: 600; }
.result-skip    { color: var(--text-muted); }

/* Clickable result rows */
.result-row { cursor: pointer; transition: background var(--transition); }
.result-row:hover td { background: #EEF2F8; }
.result-row td:last-child { position: relative; padding-right: 36px !important; }
.result-row td:last-child::after {
  content: "▸";
  font-size: 1.05rem;
  color: var(--text-muted);
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  transition: transform var(--transition);
}
.result-row.expanded td:last-child::after {
  content: "▾";
  color: var(--navy);
}

/* Expandable detail row */
.result-detail td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border);
}

.review-panel {
  padding: 20px 24px 24px;
  background: #F7F5F0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}

.review-question {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}

.review-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  line-height: 1.5;
}

.review-letter {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid var(--border);
  color: var(--text-muted);
  margin-top: 1px;
}

.review-text { flex: 1; font-size: 0.93rem; }

/* Correct answer highlight */
.review-correct {
  border-color: var(--green);
  background: var(--green-soft);
}
.review-correct .review-letter {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* Wrong answer the user picked */
.review-wrong {
  border-color: var(--red);
  background: var(--red-soft);
}
.review-wrong .review-letter {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Explanation in review */
.review-explanation {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  border-left: 3px solid var(--navy-light);
  padding-left: 14px;
}

.review-explanation-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy-mid);
  margin-bottom: 4px;
}

.results-actions {
  display: flex;
  justify-content: center;
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 640px) {
  .exam-header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px;
  }
  .exam-header-right { grid-column: 1 / -1; justify-content: center; }

  .question-card { padding: 24px 20px; }

  .overall-timer { font-size: 1.5rem; }

  .exam-footer { flex-wrap: wrap; }
  .exam-footer .btn-danger { order: 3; width: 100%; }
}
