/**
 * exam-runtime.css — Shared Exam Runtime design tokens and chrome.
 * Scoped for student exam shells (MCQ / Coding / future types).
 * Light theme only. Local Vazirmatn via shared-fonts.css.
 * Mobile-first breakpoints: 320 / 480 / 768 / 1024.
 */

:root {
  /* Exam runtime surface (light educational platform) */
  --er-bg: #f4f6fb;
  --er-surface: #ffffff;
  --er-surface-muted: #f8fafc;
  --er-border: #e2e8f0;
  --er-border-strong: #cbd5e1;
  --er-text: #0f172a;
  --er-text-secondary: #334155;
  --er-text-muted: #64748b;
  --er-primary: #4f46e5;
  --er-primary-soft: #eef2ff;
  --er-accent: #0e7490;
  --er-success: #16a34a;
  --er-success-bg: #dcfce7;
  --er-warning: #d97706;
  --er-warning-bg: #fef3c7;
  --er-danger: #dc2626;
  --er-danger-bg: #fee2e2;
  --er-flag: #ea580c;
  --er-flag-bg: #ffedd5;
  --er-radius: 12px;
  --er-radius-sm: 8px;
  --er-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.04);
  --er-shadow-lg: 0 8px 28px rgba(15, 23, 42, 0.1);
  --er-header-h: 56px;
  --er-bottom-h: 64px;
  --er-touch-min: 44px;
  --er-font: 'Vazirmatn', 'Vazir', Tahoma, sans-serif;
  --er-mono: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', Consolas, monospace;
  --er-space-1: 0.25rem;
  --er-space-2: 0.5rem;
  --er-space-3: 0.75rem;
  --er-space-4: 1rem;
  --er-space-5: 1.25rem;
  --er-space-6: 1.5rem;
  --er-space-8: 2rem;
}

/* ── Shared identity / avatar ─────────────────────────────── */
.er-identity {
  display: flex;
  align-items: center;
  gap: var(--er-space-3);
  min-width: 0;
}
.er-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--er-border);
  background: var(--er-primary-soft);
  flex-shrink: 0;
}
.er-avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--er-primary-soft);
  color: var(--er-primary);
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid var(--er-border);
  flex-shrink: 0;
}
.er-identity-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.er-identity-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--er-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.er-identity-id {
  font-size: 0.75rem;
  color: var(--er-text-muted);
}

/* ── Header chrome ────────────────────────────────────────── */
.er-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--er-space-3);
  min-height: var(--er-header-h);
  padding: var(--er-space-2) var(--er-space-4);
  background: var(--er-surface);
  border-bottom: 1px solid var(--er-border);
  box-shadow: var(--er-shadow);
  font-family: var(--er-font);
}
.er-header-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.er-exam-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--er-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.er-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--er-primary-soft);
  color: var(--er-primary);
  width: fit-content;
}
.er-badge-coding { background: #ecfeff; color: #0e7490; }
.er-badge-mcq { background: #eef2ff; color: #4f46e5; }
.er-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--er-text);
  min-width: 4.5rem;
  text-align: center;
  padding: 6px 10px;
  border-radius: var(--er-radius-sm);
  background: var(--er-surface-muted);
  border: 1px solid var(--er-border);
}
.er-timer.warn { color: var(--er-warning); background: var(--er-warning-bg); border-color: #fde68a; }
.er-timer.danger { color: var(--er-danger); background: var(--er-danger-bg); border-color: #fecaca; }

/* ── Question navigator ───────────────────────────────────── */
.er-nav {
  font-family: var(--er-font);
  background: var(--er-surface);
  border: 1px solid var(--er-border);
  border-radius: var(--er-radius);
  padding: var(--er-space-3);
  box-shadow: var(--er-shadow);
}
.er-nav-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--er-space-2) var(--er-space-4);
  font-size: 0.8rem;
  color: var(--er-text-secondary);
  margin-bottom: var(--er-space-3);
}
.er-nav-summary strong { color: var(--er-text); font-weight: 700; }
.er-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  direction: ltr; /* number order: 1 left … N right */
  max-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.er-nav-btn {
  min-width: var(--er-touch-min);
  min-height: var(--er-touch-min);
  padding: 0 8px;
  border-radius: var(--er-radius-sm);
  border: 1.5px solid var(--er-border);
  background: var(--er-surface);
  color: var(--er-text);
  font-weight: 700;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.er-nav-btn:hover { border-color: var(--er-primary); }
.er-nav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35);
}
.er-nav-btn.is-current {
  background: var(--er-primary);
  border-color: var(--er-primary);
  color: #fff;
}
.er-nav-btn.is-answered:not(.is-current) {
  background: var(--er-success-bg);
  border-color: #86efac;
  color: #166534;
}
.er-nav-btn.is-flagged {
  box-shadow: inset 0 -3px 0 var(--er-flag);
}
.er-nav-btn.is-answered.is-flagged:not(.is-current) {
  background: var(--er-flag-bg);
  border-color: #fdba74;
  color: #9a3412;
}
.er-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.er-nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--er-space-2);
  margin-top: var(--er-space-3);
}
.er-btn {
  min-height: var(--er-touch-min);
  padding: 0.55rem 1rem;
  border-radius: var(--er-radius-sm);
  border: 1.5px solid var(--er-border);
  background: var(--er-surface);
  color: var(--er-text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.er-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35);
}
.er-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.er-btn-primary {
  background: var(--er-primary);
  border-color: var(--er-primary);
  color: #fff;
}
.er-btn-primary:hover:not(:disabled) { filter: brightness(1.05); }
.er-btn-danger {
  background: var(--er-danger);
  border-color: var(--er-danger);
  color: #fff;
}
.er-btn-flag.is-active {
  background: var(--er-flag-bg);
  border-color: #fdba74;
  color: #9a3412;
}

/* ── Question card / options (MCQ) ────────────────────────── */
.er-question-card {
  background: var(--er-surface);
  border: 1px solid var(--er-border);
  border-radius: var(--er-radius);
  padding: var(--er-space-5);
  box-shadow: var(--er-shadow);
  color: var(--er-text);
}
.er-question-card img,
.er-question-card .er-q-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--er-space-3) auto;
  object-fit: contain;
  border-radius: var(--er-radius-sm);
}
.er-option {
  display: flex;
  align-items: flex-start;
  gap: var(--er-space-3);
  width: 100%;
  text-align: start;
  min-height: var(--er-touch-min);
  padding: var(--er-space-3) var(--er-space-4);
  margin-bottom: var(--er-space-2);
  border: 1.5px solid var(--er-border);
  border-radius: var(--er-radius);
  background: var(--er-surface);
  color: var(--er-text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.er-option:hover { border-color: #a5b4fc; background: #fafafe; }
.er-option:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
}
.er-option.is-selected {
  border-color: var(--er-primary);
  background: var(--er-primary-soft);
  box-shadow: 0 0 0 1px var(--er-primary);
}
.er-option-label {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  background: var(--er-surface-muted);
  color: var(--er-text-secondary);
  border: 1px solid var(--er-border);
}
.er-option.is-selected .er-option-label {
  background: var(--er-primary);
  color: #fff;
  border-color: var(--er-primary);
}
.er-option-text {
  flex: 1;
  min-width: 0;
  line-height: 1.65;
  padding-top: 0.2rem;
}

/* ── Code always LTR ──────────────────────────────────────── */
.er-code,
.er-code-block,
.er-question-card pre,
.er-question-card code {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--er-mono);
  text-align: left;
}

@media (max-width: 768px) {
  .er-header {
    flex-wrap: wrap;
    padding: var(--er-space-2) var(--er-space-3);
  }
  .er-nav-grid { max-height: 96px; }
  .er-question-card { padding: var(--er-space-4); }
}
@media (max-width: 480px) {
  .er-identity-id { display: none; }
  .er-timer { font-size: 0.95rem; min-width: 4rem; }
  .er-nav-btn {
    min-width: 40px;
    min-height: 40px;
  }
}
