/* ═══════════════════════════════════════════════════════════
   Chapter Test — Exam-style styling for APCalc Academy
   Full English test mode with timer, navigator, and grading
   ═══════════════════════════════════════════════════════════ */

/* ── Test Container ── */
.chapter-test-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ── Test Header ── */
.test-header {
  text-align: center;
  padding: var(--space-10) var(--space-6) var(--space-8);
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: #fff;
  margin: 0 calc(-50vw + 50%);
  width: 100vw;
  position: relative;
}
.test-header .inner {
  max-width: 860px;
  margin: 0 auto;
}
.test-header .chapter-label {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  color: rgba(255,255,255,0.9);
}
.test-header h1 {
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: var(--space-2);
}
.test-header .test-subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: var(--space-5);
}
.test-meta {
  display: flex;
  gap: var(--space-6);
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.test-meta-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(255,255,255,0.8);
}
.test-meta-item .icon { font-size: 1.1rem; }

/* ── Instructions Box ── */
.test-instructions {
  background: #f0f4ff;
  border-left: 4px solid #1a56db;
  padding: var(--space-4) var(--space-6);
  margin: var(--space-6) 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.9rem;
  line-height: 1.7;
}
.test-instructions h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: #1a56db;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.test-instructions ul {
  margin: 0;
  padding-left: var(--space-5);
}
.test-instructions li {
  margin-bottom: 0.25rem;
}

/* ── Timer Bar ── */
.test-timer-bar {
  position: sticky;
  top: 64px;
  z-index: 100;
  background: #1a56db;
  color: #fff;
  padding: var(--space-2) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 0.3s;
  margin: 0 calc(-50vw + 50%);
  width: 100vw;
}
.test-timer-bar .inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  justify-content: center;
}
.test-timer-bar .timer-icon { font-size: 1.2rem; }
.test-timer-bar .timer-display { font-family: 'Courier New', monospace; font-size: 1.1rem; letter-spacing: 0.05em; }
.test-timer-bar.warning { background: #dc2626; animation: timer-pulse 1s infinite; }
@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* ── Question Navigator ── */
.test-nav {
  position: sticky;
  top: 105px;
  z-index: 99;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
  margin: 0 calc(-50vw + 50%);
  width: 100vw;
}
.test-nav .inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
.test-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
  gap: var(--space-2);
}
.test-nav-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.test-nav-progress {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}
.test-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.test-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  border: 2px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--color-text-muted);
  padding: 0;
}
.test-nav-btn:hover { border-color: #1a56db; color: #1a56db; }
.test-nav-btn.answered { background: #d1fae5; border-color: #059669; color: #059669; }
.test-nav-btn.current { border-color: #1a56db; background: #e8effd; color: #1a56db; transform: scale(1.15); }
.test-nav-btn.wrong { background: #fee2e2; border-color: #dc2626; color: #dc2626; }

/* ── Exam Questions ── */
.test-questions {
  padding: var(--space-6) 0;
}
.test-question {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-6) 0;
  scroll-margin-top: 120px;
}
.test-question:last-child { border-bottom: none; }
.test-q-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.test-q-number {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1a56db;
  min-width: 2.5rem;
}
.test-q-text {
  font-size: 1.05rem;
  line-height: 1.7;
  font-weight: 500;
}
.test-q-text .test-table {
  margin-top: var(--space-3);
  margin-bottom: var(--space-2);
  border-collapse: collapse;
  width: auto;
  max-width: 100%;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.test-q-text .test-table th,
.test-q-text .test-table td {
  padding: 0.6rem 1rem;
  border: 1px solid var(--color-border);
  text-align: center;
}
.test-q-text .test-table thead {
  background: #f1f5f9;
  font-weight: 700;
}
.test-q-text .test-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

/* ── Options ── */
.test-options {
  padding-left: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}
.test-option {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.25rem 1.5rem;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 1rem;
  line-height: 1.7;
  min-height: auto;
  height: auto;
  overflow: visible;
}
.test-option > span:last-child,
.test-option-text {
  flex: 1 1 auto;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.test-option:hover { border-color: #1a56db; background: #f0f4ff; }
.test-option.selected { border-color: #1a56db; background: #e8effd; font-weight: 500; }
.test-option.correct { border-color: #059669 !important; background: #d1fae5 !important; }
.test-option.wrong { border-color: #dc2626 !important; background: #fee2e2 !important; }
.test-option-letter {
  font-weight: 800;
  color: var(--color-text-muted);
  min-width: 1.5rem;
  flex-shrink: 0;
}
.test-option.selected .test-option-letter { color: #1a56db; }
.test-option.correct .test-option-letter { color: #059669; }
.test-option.wrong .test-option-letter { color: #dc2626; }
.test-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* ── Actions Bar ── */
.test-actions {
  text-align: center;
  padding: var(--space-6) 0 var(--space-10);
  background: #fff;
  border-top: 2px solid var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-6);
}
/* ── Result Panel ── */
.test-result {
  display: none;
  padding: var(--space-6) 0;
}
.test-result.show { display: block; }
.test-result-header {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}
.test-result-emoji { font-size: 3rem; margin-bottom: var(--space-3); }
.test-result-grade { font-size: 1.5rem; font-weight: 800; margin-bottom: var(--space-2); }
.test-result-score {
  font-size: 3rem;
  font-weight: 900;
  margin-bottom: var(--space-1);
}
.test-result-score.excellent { color: #059669; }
.test-result-score.good { color: #1a56db; }
.test-result-score.fair { color: #d97706; }
.test-result-score.poor { color: #dc2626; }
.test-result-detail { font-size: 0.9rem; color: var(--color-text-muted); }
.test-result-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  margin: var(--space-4) auto;
  max-width: 400px;
  overflow: hidden;
}
.test-result-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ── Per-Question Review ── */
.test-review {
  margin-top: var(--space-6);
}
.test-review h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: var(--space-4);
}
.test-review-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  scroll-margin-top: 120px;
}
.test-review-item.correct { border-left: 4px solid #059669; }
.test-review-item.incorrect { border-left: 4px solid #dc2626; }
.test-review-q {
  font-weight: 600;
  margin-bottom: var(--space-2);
  font-size: 0.95rem;
}
.test-review-answer {
  font-size: 0.85rem;
  margin-bottom: var(--space-2);
}
.test-review-answer .your { color: #dc2626; }
.test-review-answer .correct-ans { color: #059669; font-weight: 600; }
.test-solution {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: 0.85rem;
  line-height: 1.6;
  margin-top: var(--space-2);
}
.test-solution strong { color: #1a56db; }

/* ── Post-Result Actions ── */
.test-post-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-6);
  padding-bottom: var(--space-8);
}

/* ── Print Styles ── */
@media print {
  .nav, .footer, .test-timer-bar, .test-nav, .test-actions, .test-post-actions { display: none !important; }
  .test-header { background: #fff !important; color: #000 !important; padding: 1rem 0; margin: 0; width: auto; }
  .test-header h1, .test-header .test-subtitle, .test-header .test-meta-item, .test-header .chapter-label { color: #000 !important; }
  .test-question { break-inside: avoid; padding: 0.75rem 0; scroll-margin-top: 0; }
  .test-option { border: 1px solid #ccc; }
  .test-result-header { background: #fff !important; border: 1px solid #ccc; }
}

/* ── Fullscreen Mode ── */
body.test-fullscreen .nav,
body.test-fullscreen .footer,
body.test-fullscreen .test-header,
body.test-fullscreen .test-instructions,
body.test-fullscreen .formula-sheet-fab { display: none !important; }
body.test-fullscreen {
  padding: 0;
}
body.test-fullscreen .chapter-test-container {
  max-width: 1400px;
  padding: 1rem 2rem;
}
body.test-fullscreen .test-question {
  break-inside: avoid;
  padding: 1rem 0;
}
body.test-fullscreen .test-options {
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
body.test-fullscreen .test-option {
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  line-height: 1.55;
}
body.test-fullscreen .test-q-text {
  font-size: 1rem;
}
.test-fullscreen-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  background: #1a56db;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.test-fullscreen-toggle:hover { background: #1e40af; }

/* ── One-by-One (Bluebook) Mode ── */
.obo {
  max-width: 860px;
  margin: 0 auto;
  padding: var(--space-5) 0;
}
.obo-progress {
  position: sticky;
  top: 64px;
  z-index: 99;
  background: #fff;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.obo-progress-inner {
  max-width: 860px;
  margin: 0 auto;
}
.obo-count {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  display: block;
  margin-bottom: var(--space-2);
}
.obo-count b { color: #1a56db; }
.obo-track {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.obo-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a56db, #3b82f6);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.obo-card {
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--color-border);
}
.obo-image {
  margin: var(--space-4) 0;
  text-align: center;
}
.obo-image img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}
.obo-feedback {
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.obo-feedback.correct { background: #d1fae5; color: #065f46; border-left: 4px solid #059669; }
.obo-feedback.incorrect { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.obo-fb-emoji { font-size: 1.4rem; }
.obo-fb-ans { font-weight: 700; }
.obo-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) 0 var(--space-8);
}
.obo-nav button:disabled { opacity: 0.4; cursor: not-allowed; }
@media (max-width: 768px) {
  .test-header h1 { font-size: 1.5rem; }
  .test-header { padding: var(--space-6) var(--space-4) var(--space-5); }
  .test-meta { gap: var(--space-3); font-size: 0.8rem; }
  .test-nav-btn { width: 24px; height: 24px; font-size: 0.6rem; }
  .test-options { padding-left: 0; }
  .test-q-number { min-width: 1.8rem; font-size: 1rem; }
  .test-option { padding: 0.6rem 0.75rem; font-size: 0.9rem; }
}
