/* ============================================================
   CIS 223 Final Exam War Room — CSS
   Dark command center theme. No external dependencies.
   ============================================================ */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --surface3: #2d333b;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #7d8590;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --accent: #58a6ff;
  --accent2: #a371f7;
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================================
   HEADER
   ============================================================ */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#site-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

#site-header .subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================================
   NAV MODE BAR
   ============================================================ */
#mode-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  overflow-x: auto;
}

.nav-btn {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-btn:hover {
  background: var(--surface3);
  color: var(--text);
  border-color: var(--accent);
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   LAYOUT
   ============================================================ */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

section { display: none; }
section.active { display: block; }

.section-heading {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading .badge {
  font-size: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  color: var(--text-muted);
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  border-top: 3px solid var(--accent);
}

.stat-card.green-top { border-top-color: var(--green); }
.stat-card.yellow-top { border-top-color: var(--yellow); }
.stat-card.red-top { border-top-color: var(--red); }
.stat-card.purple-top { border-top-color: var(--accent2); }

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

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-success { background: var(--green); color: #0d1117; }
.btn-success:hover { filter: brightness(1.1); }
.btn-warn { background: var(--yellow); color: #0d1117; }
.btn-warn:hover { filter: brightness(1.1); }
.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface3); border-color: var(--accent); }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mode-card:hover { border-color: var(--accent); background: var(--surface2); }

.mode-icon { font-size: 1.6rem; margin-bottom: 6px; }
.mode-title { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.mode-desc { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }

/* ============================================================
   QUIZ TRAINER
   ============================================================ */
.quiz-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.quiz-controls select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.progress-bar-wrap {
  background: var(--surface2);
  border-radius: 6px;
  height: 6px;
  margin-bottom: 16px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.3s ease;
  width: 0%;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.question-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.tag-chapter { background: rgba(88,166,255,0.15); color: var(--accent); border-color: rgba(88,166,255,0.3); }
.tag-topic { background: rgba(163,113,247,0.15); color: var(--accent2); border-color: rgba(163,113,247,0.3); }
.tag-red { background: rgba(248,81,73,0.15); color: var(--red); border-color: rgba(248,81,73,0.3); }
.tag-php { background: rgba(210,153,34,0.15); color: var(--yellow); border-color: rgba(210,153,34,0.3); }
.tag-normal { background: rgba(63,185,80,0.15); color: var(--green); border-color: rgba(63,185,80,0.3); }

.question-text {
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 18px;
  color: var(--text);
}

.code-snippet {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: #c9d1d9;
  margin-bottom: 16px;
  white-space: pre-wrap;
  overflow-x: auto;
}

.choices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-btn {
  width: 100%;
  text-align: left;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-family: var(--font);
  line-height: 1.4;
}

.choice-btn:hover:not(:disabled) {
  background: var(--surface3);
  border-color: var(--accent);
}

.choice-btn.correct {
  background: rgba(63,185,80,0.2);
  border-color: var(--green);
  color: var(--green);
}

.choice-btn.wrong {
  background: rgba(248,81,73,0.2);
  border-color: var(--red);
  color: var(--red);
}

.choice-btn:disabled { cursor: default; opacity: 0.8; }

.feedback-panel {
  display: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-top: 14px;
}

.feedback-panel.visible { display: block; }

.feedback-result {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.feedback-result.correct-text { color: var(--green); }
.feedback-result.wrong-text { color: var(--red); }

.feedback-explanation { color: var(--text); margin-bottom: 10px; line-height: 1.65; }

.feedback-trap {
  background: rgba(248,81,73,0.1);
  border-left: 3px solid var(--red);
  padding: 8px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.feedback-trap strong { color: var(--red); }

.quiz-action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.question-counter {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ============================================================
   MIDTERM RECOVERY
   ============================================================ */
.recovery-header {
  background: rgba(248,81,73,0.1);
  border: 1px solid rgba(248,81,73,0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.recovery-icon { font-size: 2rem; }
.recovery-title { font-size: 1.1rem; font-weight: 700; color: var(--red); }
.recovery-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

.trap-reveal {
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.trap-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--red);
  font-weight: 700;
  margin-bottom: 6px;
}

.trap-text { color: var(--text); font-size: 0.95rem; }

.explain-back-area {
  margin: 14px 0;
}

.explain-back-area label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.explain-back-area textarea {
  width: 100%;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
}

.explain-back-area textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.recovery-progress {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.recovery-score {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

/* ============================================================
   CODE OUTPUT LAB
   ============================================================ */
.code-lab-grid {
  display: grid;
  gap: 16px;
}

.code-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.code-card-header {
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.code-card-header .dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-red { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-green { background: var(--green); }

.code-card-body { padding: 16px; }

.code-question {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--yellow);
  margin: 12px 0 10px;
}

.code-answer-wrap { margin-top: 10px; }

.code-answer {
  display: none;
  background: rgba(63,185,80,0.1);
  border: 1px solid rgba(63,185,80,0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--green);
}

.code-answer .answer-explanation {
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* ============================================================
   FINAL SIMULATION
   ============================================================ */
.sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.timer-display {
  font-family: var(--mono);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 20px;
}

.timer-display.warning { color: var(--yellow); }
.timer-display.danger { color: var(--red); animation: pulse 1s infinite; }

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

.sim-info {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sim-score-label { font-weight: 700; color: var(--accent); font-size: 1.1rem; }

.sim-report {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.sim-report.visible { display: block; }

.report-grade {
  font-size: 3rem;
  font-weight: 900;
  text-align: center;
  margin: 10px 0;
}

.report-grade.a { color: var(--green); }
.report-grade.b { color: var(--accent); }
.report-grade.c { color: var(--yellow); }
.report-grade.d { color: var(--red); }

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.report-box {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.report-box h4 { font-size: 0.82rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.report-box ul { list-style: none; }
.report-box li { font-size: 0.88rem; padding: 4px 0; border-bottom: 1px solid var(--border); }
.report-box li:last-child { border-bottom: none; }
.report-box .mastered-item::before { content: "✓ "; color: var(--green); }
.report-box .missed-item::before { content: "✗ "; color: var(--red); }

/* ============================================================
   FLASHCARDS
   ============================================================ */
.flashcard-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.flashcard-progress {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.flashcard-scene {
  perspective: 1000px;
  max-width: 640px;
  margin: 0 auto 20px;
  height: 240px;
  cursor: pointer;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
}

.flashcard-front {
  background: var(--surface);
  border: 2px solid var(--accent);
}

.flashcard-back {
  background: var(--surface2);
  border: 2px solid var(--green);
  transform: rotateY(180deg);
}

.flashcard-front .fc-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 12px; }
.flashcard-back .fc-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--green); margin-bottom: 12px; }
.flashcard-term { font-size: 1.2rem; font-weight: 700; color: var(--text); line-height: 1.4; }
.flashcard-def { font-size: 0.92rem; color: var(--text); line-height: 1.6; }
.flashcard-trap-note { font-size: 0.78rem; color: var(--red); margin-top: 10px; }
.flashcard-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 16px; }

.fc-action-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   PHP PREP
   ============================================================ */
.php-warning {
  background: rgba(210,153,34,0.12);
  border: 1px solid rgba(210,153,34,0.4);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--yellow);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   TEACH-BACK
   ============================================================ */
.teach-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.teach-concept {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.teach-prompt {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-style: italic;
}

.teach-model-answer {
  display: none;
  background: var(--surface2);
  border-left: 3px solid var(--green);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px;
  margin-top: 14px;
  font-size: 0.92rem;
  line-height: 1.65;
}

.teach-model-answer.visible { display: block; }
.teach-model-answer .model-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  font-weight: 700;
  margin-bottom: 8px;
}

/* ============================================================
   WEAK ZONES
   ============================================================ */
.weak-zone-grid {
  display: grid;
  gap: 14px;
}

.weak-zone-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--red);
  padding: 18px 20px;
}

.weak-zone-card.level-yellow { border-left-color: var(--yellow); }
.weak-zone-card.level-orange { border-left-color: #f0883e; }

.wz-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.wz-why {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.wz-trap {
  background: rgba(248,81,73,0.08);
  border-left: 2px solid var(--red);
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.wz-trap strong { color: var(--red); }

.wz-code {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: #c9d1d9;
  margin-bottom: 10px;
  white-space: pre-wrap;
  overflow-x: auto;
}

.wz-explain {
  font-size: 0.85rem;
  color: var(--accent);
  font-style: italic;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { max-width: 380px; margin: 0 auto; }

/* ============================================================
   MASTERY BADGES
   ============================================================ */
.mastery-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 12px;
}

.mastery-badge.mastered { background: rgba(63,185,80,0.2); color: var(--green); }
.mastery-badge.learning { background: rgba(210,153,34,0.2); color: var(--yellow); }
.mastery-badge.red-zone { background: rgba(248,81,73,0.2); color: var(--red); }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }

hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  #site-header h1 { font-size: 1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .mode-grid { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: 1fr; }
  .sim-header { flex-direction: column; align-items: flex-start; }
  .timer-display { font-size: 1.6rem; }
  .flashcard-scene { height: 200px; }
  .flashcard-term { font-size: 1rem; }
}

@media (max-width: 480px) {
  #mode-nav { padding: 8px 10px; }
  .nav-btn { padding: 4px 10px; font-size: 0.78rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .action-row { flex-direction: column; }
  .btn { width: 100%; justify-content: center; }
}
