/* Stim Mode CSS — unified practice exam simulator (adapted from biol3020) */

#stimRoot { font-family: 'Inter', system-ui, sans-serif; color: var(--ink); }

.stim-shell { max-width: 880px; margin: 0 auto; padding: 30px 28px 120px; }
.stim-eyebrow {
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--amber); font-weight: 600; margin-bottom: 8px;
}
.stim-title {
  font-family: 'Fraunces', serif;
  font-size: 38px; line-height: 1.1; margin: 0 0 12px;
}
.stim-subtitle { color: var(--ink-2); margin-bottom: 32px; font-size: 15px; }
.stim-card {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 18px;
}
.stim-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.stim-row label { font-size: 13px; letter-spacing: 0.04em; color: var(--ink-2); min-width: 110px; }
.stim-chip {
  background: var(--bg-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  transition: all .12s;
}
.stim-chip.active { background: var(--amber); color: #14110a; border-color: transparent; font-weight: 600; }
.stim-chip:hover:not(.active) { background: var(--bg-2); border-color: var(--amber); }
.stim-chip.disabled, .stim-chip[disabled] { opacity: 0.42; cursor: not-allowed; }

.stim-unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
  margin: 6px 0 14px;
  padding: 14px;
  background: var(--bg-3);
  border: 1px dashed var(--rule);
  border-radius: 12px;
}
.stim-unit-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 6px 10px;
  text-align: left;
  display: flex; justify-content: space-between; align-items: center;
}
.stim-unit-note {
  font-size: 12px; color: var(--ink-2);
  background: rgba(230,168,92,0.08);
  border: 1px solid rgba(230,168,92,0.25);
  border-radius: 8px; padding: 8px 12px; margin-bottom: 14px;
}

.stim-btn {
  background: var(--amber); color: #14110a; border: none;
  border-radius: 10px; padding: 12px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.stim-btn:hover { filter: brightness(1.05); }
.stim-btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.stim-btn-ghost:hover { background: var(--bg-2); border-color: var(--amber); }
.stim-btn-danger { background: #c74e4e; color: white; }

/* Exam top bar */
.stim-exam-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; border-bottom: 1px solid var(--rule);
  position: sticky; top: 56px; background: var(--bg); z-index: 5;
  flex-wrap: wrap; gap: 12px;
}
.stim-progress { display: flex; gap: 14px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.stim-progress strong { font-family: 'JetBrains Mono', monospace; }
.stim-progress .hint { color: var(--ink-3); font-size: 12px; }
.stim-timer { font-family: 'JetBrains Mono', monospace; font-size: 16px; color: var(--amber); }
.stim-timer.urgent { color: #ff7a5c; animation: pulse 1s infinite; }
.stim-timer.paused { color: var(--ink-3); opacity: 0.7; }
@keyframes pulse { 50% { opacity: 0.5; } }

.stim-paused-shell { display: flex; align-items: center; justify-content: center; min-height: 60vh; padding: 32px 16px; }
.stim-paused-card {
  text-align: center; background: var(--bg-2);
  border: 1px dashed var(--rule); border-radius: 16px;
  padding: 56px 40px; max-width: 480px; width: 100%;
}
.stim-paused-eyebrow { text-transform: uppercase; letter-spacing: 0.22em; font-size: 11px; color: var(--ink-2); margin-bottom: 14px; }
.stim-paused-title { font-family: 'Fraunces', serif; font-size: 32px; margin: 0 0 12px; color: var(--ink); }
.stim-paused-msg { color: var(--ink-2); font-size: 14px; margin: 0 0 24px; line-height: 1.6; }

/* Question pager */
.stim-pager { display: flex; gap: 6px; flex-wrap: wrap; padding: 16px 28px 0; max-width: 880px; margin: 0 auto; }
.stim-pager button {
  width: 30px; height: 30px; border-radius: 6px;
  border: 1px solid var(--rule);
  background: transparent; color: var(--ink); cursor: pointer; font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}
.stim-pager button:hover { border-color: var(--amber); }
.stim-pager button.answered { background: rgba(230,168,92,0.18); border-color: var(--amber); }
.stim-pager button.current { background: var(--amber); color: #14110a; }
.stim-pager button.flagged { box-shadow: inset 0 0 0 2px #ff7a5c; }

.stim-q-meta { display: flex; gap: 12px; font-size: 12px; color: var(--ink-3); margin-bottom: 16px; flex-wrap: wrap; }
.stim-q-meta span { background: var(--bg-3); padding: 3px 10px; border-radius: 999px; }

.stim-q-stem {
  font-family: 'Fraunces', serif;
  font-size: 22px; line-height: 1.4; margin-bottom: 24px;
  color: var(--ink);
}

.stim-choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.stim-choice {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 10px; cursor: pointer; background: transparent;
  text-align: left; color: var(--ink); font-family: inherit; font-size: 14px;
  line-height: 1.5; transition: all .15s;
}
.stim-choice:hover:not(:disabled) { background: var(--bg-2); border-color: var(--amber); }
.stim-choice.selected { border-color: var(--amber); background: rgba(230,168,92,0.08); }
.stim-choice.correct-rev { border-color: #5fb87a; background: rgba(95,184,122,0.12); }
.stim-choice.wrong-rev { border-color: #c74e4e; background: rgba(199,78,78,0.12); }
.stim-choice:disabled { cursor: default; }
.stim-choice-key { width: 22px; flex-shrink: 0; font-weight: 600; color: var(--ink-3); font-family: 'JetBrains Mono', monospace; }
.stim-choice-text { flex: 1; }
.stim-choice-why {
  display: block; margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed rgba(255,255,255,0.12);
  font-size: 12.5px; color: var(--ink-2);
  line-height: 1.45; font-weight: 400;
}
.stim-choice.correct-rev .stim-choice-why { color: #b5e2c2; border-top-color: rgba(95,184,122,0.3); }
.stim-choice.wrong-rev .stim-choice-why { color: #ffb5b5; border-top-color: rgba(199,78,78,0.3); }

/* Practice-mode feedback panel */
.stim-feedback {
  margin: 18px 0 24px; padding: 14px 18px;
  border-radius: 10px; border-left: 4px solid;
  background: var(--bg-2); font-size: 14px; line-height: 1.5;
}
.stim-feedback.correct { border-left-color: #5fb87a; background: rgba(95,184,122,0.08); }
.stim-feedback.incorrect { border-left-color: #c74e4e; background: rgba(199,78,78,0.08); }
.stim-feedback .fb-verdict { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.stim-feedback.correct .fb-verdict { color: #5fb87a; }
.stim-feedback.incorrect .fb-verdict { color: #ff8b8b; }
.stim-feedback .fb-correct, .stim-feedback .fb-why, .stim-feedback .fb-user-why { margin-bottom: 6px; color: var(--ink); }
.stim-feedback strong { color: var(--amber-2); }
.stim-feedback .fb-source {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed rgba(255,255,255,0.15);
  font-size: 12.5px; color: var(--ink); line-height: 1.55;
}
.stim-feedback .fb-hint { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); font-style: italic; }

/* SA textarea */
.stim-textarea {
  width: 100%; min-height: 140px; padding: 14px 16px;
  background: var(--bg-3); border: 1px solid var(--rule);
  border-radius: 10px; color: var(--ink); font-family: inherit; font-size: 14px;
  line-height: 1.5; resize: vertical;
}
.stim-textarea:focus { outline: none; border-color: var(--amber); }
.stim-char-count { text-align: right; font-size: 11px; color: var(--ink-3); margin-top: 4px; }

.stim-nav { display: flex; gap: 10px; justify-content: space-between; margin-top: 24px; align-items: center; flex-wrap: wrap; }

/* Results view */
.stim-result-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px; margin-bottom: 28px;
}
.stim-stat { background: var(--bg-2); padding: 16px; border-radius: 10px; border: 1px solid var(--rule); }
.stim-stat-num { font-size: 28px; font-family: 'Fraunces', serif; color: var(--amber-2); }
.stim-stat-lbl { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-top: 4px; }

.stim-q-result { padding: 14px; margin-bottom: 12px; border: 1px solid var(--rule); border-radius: 10px; background: var(--bg-2); }
.stim-q-result.correct { border-left: 3px solid #5fb87a; }
.stim-q-result.wrong { border-left: 3px solid #c74e4e; }
.stim-q-result.ungraded { border-left: 3px solid var(--amber); }
.stim-q-result-stem { font-size: 14px; margin-bottom: 10px; line-height: 1.5; color: var(--ink); }
.stim-q-result-meta { font-size: 11px; color: var(--ink-3); margin-bottom: 8px; font-family: 'JetBrains Mono', monospace; }
.stim-q-result-why { font-size: 13px; color: var(--ink-2); padding: 10px 12px; background: var(--bg-3); border-radius: 6px; margin-top: 10px; }
.stim-q-result-user { font-size: 13px; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
.stim-q-result-user.correct { background: rgba(95,184,122,0.1); color: #b5e2c2; }
.stim-q-result-user.wrong { background: rgba(199,78,78,0.1); color: #ffb5b5; }

/* Heatmap */
.stim-heat-section { margin: 22px 0 6px; }
.stim-heat-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.stim-heat-legend { font-size: 11px; opacity: 0.7; letter-spacing: 0.04em; }
.stim-heatmap-units {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.stim-heat-cell {
  border-radius: 6px; padding: 10px 12px;
  font-size: 11px; font-family: 'JetBrains Mono', monospace;
  cursor: help; min-height: 48px;
  display: flex; flex-direction: column; gap: 3px;
  color: #1a1a1a; font-weight: 600;
}
.stim-heat-cell .pct { font-size: 16px; font-family: 'Fraunces', serif; }
.stim-heat-cell .label { font-size: 10px; opacity: 0.85; line-height: 1.2; word-break: break-word; }

/* Modal */
.stim-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100;
  display: none; align-items: center; justify-content: center;
}
.stim-modal-backdrop.show { display: flex; }
.stim-modal {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 12px; padding: 28px; max-width: 440px; width: 90%;
  color: var(--ink);
}
.stim-modal h3 { margin: 0 0 12px; font-family: 'Fraunces', serif; }
.stim-modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; flex-wrap: wrap; }

@media (max-width: 600px) {
  .stim-shell { padding: 24px 16px 100px; }
  .stim-title { font-size: 26px; }
  .stim-q-stem { font-size: 18px; }
  .stim-exam-bar { padding: 10px 16px; }
  .stim-pager { padding: 12px 16px 0; }
  .stim-row label { min-width: 100%; }
}
