/* AGENT C — quiz runner + mock exam styles. Namespace: .q-*
 *
 * Consumes design tokens owned by styles.css (AGENT B):
 *   --bg --fg --muted --card --border --accent
 *   domain colours --d-indigo … --d-slate
 * Dark mode is handled entirely by those tokens ([data-theme=dark] overrides in styles.css),
 * so there is NO separate dark block here. Per-quiz accent comes in via --q-accent
 * (set inline on the section) and falls back to --accent.
 */

.q-index,
.q-runner,
.q-mock {
  --q-accent: var(--accent);
  max-width: 860px;
  margin: 0 auto;
}

/* ---------- shared bits ---------- */
.q-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.55em 1.1em;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.q-btn:hover { border-color: var(--q-accent); }
.q-btn:active { transform: translateY(1px); }
.q-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.q-btn-primary {
  background: var(--q-accent);
  border-color: var(--q-accent);
  color: #fff;
}
.q-btn-primary:hover { filter: brightness(1.08); }
.q-btn-lg { padding: 0.75em 1.6em; font-size: 1.05rem; }
.q-btn-ghost { background: transparent; }

/* domain chip */
.q-index-domain,
.q-intro-domain,
.q-mock-badge {
  display: inline-block;
  padding: 0.15em 0.7em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
}

/* ---------- quiz index ---------- */
.q-index-head h1 { margin: 0 0 0.25rem; }
.q-index-sub { color: var(--muted); margin: 0 0 1.5rem; }

.q-mock-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  background: linear-gradient(
    100deg,
    color-mix(in srgb, var(--accent) 14%, var(--card)),
    var(--card)
  );
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.12s ease, transform 0.08s ease;
}
.q-mock-cta:hover { border-color: var(--accent); transform: translateY(-2px); }
.q-mock-cta-kicker {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.q-mock-cta-title { margin: 0.15rem 0; font-size: 1.5rem; }
.q-mock-cta-meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.q-mock-cta-go { font-weight: 700; white-space: nowrap; color: var(--accent); }

.q-index-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.q-index-card {
  border: 1px solid var(--border);
  border-top: 3px solid var(--q-accent);
  border-radius: 10px;
  background: var(--card);
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.q-index-card:hover { transform: translateY(-2px); }
.q-index-link {
  display: block;
  padding: 1rem 1.1rem;
  color: var(--fg);
  text-decoration: none;
  height: 100%;
}
.q-index-title { margin: 0.5rem 0 0.75rem; font-size: 1.05rem; line-height: 1.3; }
.q-index-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.q-index-best:not(:empty) {
  font-weight: 700;
  color: var(--q-accent);
}
.q-index-empty { color: var(--muted); }

/* ---------- runner / mock intro ---------- */
.q-intro { text-align: left; }
.q-intro-title { margin: 0.6rem 0 0.3rem; }
.q-intro-meta { color: var(--muted); margin: 0 0 1rem; }
.q-intro-desc { color: var(--fg); margin: 0 0 1.4rem; line-height: 1.55; }
.q-intro-loading { color: var(--muted); font-style: italic; }
.q-mock-facts { font-weight: 600; color: var(--fg); }
.q-mock-rules { margin: 0.5rem 0 1.4rem; padding-left: 1.2rem; line-height: 1.7; }
.q-mock-rules li { color: var(--fg); }

/* ---------- progress / score bar ---------- */
.q-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.q-progress-count { font-weight: 600; }
.q-scorebar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.q-scorebar-fill {
  height: 100%;
  width: 0;
  background: var(--q-accent);
  transition: width 0.3s ease;
}

/* ---------- timer (mock) ---------- */
.q-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.2em 0.6em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
}
.q-timer.is-warning { color: var(--d-amber); border-color: var(--d-amber); }
.q-timer.is-danger {
  color: var(--d-red);
  border-color: var(--d-red);
  animation: q-pulse 1s ease-in-out infinite;
}
@keyframes q-pulse { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) {
  .q-timer.is-danger { animation: none; }
  .q-index-card:hover, .q-mock-cta:hover { transform: none; }
}

/* ---------- question card ---------- */
.q-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.2rem;
}
.q-card-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.q-card-type {
  margin-left: 0.5em;
  padding: 0.1em 0.5em;
  border-radius: 6px;
  background: color-mix(in srgb, var(--q-accent) 18%, transparent);
  color: var(--q-accent);
}
.q-card-prompt {
  margin: 0.6rem 0 1.2rem;
  font-size: 1.1rem;
  line-height: 1.55;
}
.q-card-prompt p:first-child { margin-top: 0; }
.q-card-prompt pre,
.q-card-prompt code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.q-card-prompt pre {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--fg) 6%, var(--card));
  overflow-x: auto;
}

/* ---------- options ---------- */
.q-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.q-option {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.1s ease, background 0.1s ease;
}
.q-option:hover:not(:disabled) { border-color: var(--q-accent); }
.q-option:disabled { cursor: default; }
.q-option-key {
  flex: 0 0 auto;
  width: 1.6em;
  height: 1.6em;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.85em;
}
.q-option.is-selected { border-color: var(--q-accent); }
.q-option.is-selected .q-option-key {
  background: var(--q-accent);
  border-color: var(--q-accent);
  color: #fff;
}
/* graded states */
.q-option.is-correct {
  border-color: var(--d-green);
  background: color-mix(in srgb, var(--d-green) 12%, var(--bg));
}
.q-option.is-correct .q-option-key {
  background: var(--d-green);
  border-color: var(--d-green);
  color: #fff;
}
.q-option.is-incorrect {
  border-color: var(--d-red);
  background: color-mix(in srgb, var(--d-red) 12%, var(--bg));
}
.q-option.is-incorrect .q-option-key {
  background: var(--d-red);
  border-color: var(--d-red);
  color: #fff;
}

/* short / scenario reveal */
.q-reveal { margin-top: 0.5rem; }
.q-model-answer {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--q-accent);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--q-accent) 8%, var(--card));
}
.q-model-answer h4 { margin: 0 0 0.4rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.q-model-answer :last-child { margin-bottom: 0; }

/* self-grade for short/scenario */
.q-selfgrade { display: flex; gap: 0.6rem; margin-top: 1rem; align-items: center; flex-wrap: wrap; }
.q-selfgrade-label { color: var(--muted); font-size: 0.9rem; }

/* ---------- explanation reveal ---------- */
.q-explanation {
  margin-top: 1.1rem;
  padding: 1rem 1.2rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--fg) 4%, var(--card));
}
.q-explanation.is-correct { border-color: var(--d-green); }
.q-explanation.is-incorrect { border-color: var(--d-red); }
.q-explanation-head {
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.q-explanation.is-correct .q-explanation-head { color: var(--d-green); }
.q-explanation.is-incorrect .q-explanation-head { color: var(--d-red); }
.q-explanation-body { line-height: 1.55; }
.q-explanation-body :last-child { margin-bottom: 0; }
.q-concept-link {
  display: inline-block;
  margin-top: 0.7rem;
  font-weight: 600;
  color: var(--q-accent);
  text-decoration: none;
}
.q-concept-link:hover { text-decoration: underline; }
.q-concept-stub { color: var(--muted); font-style: italic; }

/* ---------- nav row ---------- */
.q-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 1.4rem;
}
.q-nav-spacer { flex: 1; }

/* ---------- end / result screen ---------- */
.q-result { text-align: center; }
.q-result-banner {
  padding: 1.6rem;
  border-radius: 14px;
  margin-bottom: 1.6rem;
  border: 2px solid var(--border);
}
.q-result-banner.is-pass {
  border-color: var(--d-green);
  background: color-mix(in srgb, var(--d-green) 12%, var(--card));
}
.q-result-banner.is-fail {
  border-color: var(--d-red);
  background: color-mix(in srgb, var(--d-red) 12%, var(--card));
}
.q-result-verdict { font-size: 1.8rem; margin: 0 0 0.2rem; }
.q-result-banner.is-pass .q-result-verdict { color: var(--d-green); }
.q-result-banner.is-fail .q-result-verdict { color: var(--d-red); }
.q-result-score { font-size: 3rem; font-weight: 800; line-height: 1; margin: 0.3rem 0; }
.q-result-sub { color: var(--muted); margin: 0; }

/* per-domain breakdown table */
.q-breakdown {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
  text-align: left;
}
.q-breakdown caption {
  text-align: left;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.q-breakdown th,
.q-breakdown td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
}
.q-breakdown th { color: var(--muted); font-weight: 600; }
.q-breakdown td.q-bd-domain { font-weight: 600; }
.q-bd-swatch {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  border-radius: 3px;
  margin-right: 0.5em;
  vertical-align: middle;
}
.q-bd-num { text-align: right; font-variant-numeric: tabular-nums; }
.q-bd-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  min-width: 60px;
}
.q-bd-bar-fill { height: 100%; }
.q-bd-unscored td { color: var(--muted); font-style: italic; }

.q-result-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* ---------- noscript fallback ---------- */
.q-noscript {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  background: var(--card);
}
.q-ns-list { line-height: 1.6; }
.q-ns-q { margin-bottom: 1rem; }
.q-ns-options { margin: 0.4rem 0 0; }

/* small screens */
@media (max-width: 560px) {
  .q-mock-cta { flex-direction: column; align-items: flex-start; }
  .q-card { padding: 1.1rem 1.1rem; }
  .q-result-score { font-size: 2.4rem; }
}
