/* Quiz setup, questions, mock exams and results */

.setup-grid { display: grid; gap: 26px; }
.setup-grid .field > .label { font-size: var(--t-m); color: var(--ink); }
.field-tools { display: flex; gap: 14px; font-size: var(--t-s); margin-top: 4px; }
.pool-info { margin: 0; color: var(--ink-2); }

/* ---------------------------------------------------------------- question */

.q-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 10px; color: var(--muted); font-size: var(--t-s); }
.q-top b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.q-lang { flex: none; }
.q-lang button { min-height: 28px; padding: 3px 10px; font-size: var(--t-xs); letter-spacing: .03em; }
.q-progress { height: 4px; background: var(--paper-3); border-radius: var(--r-s); margin-bottom: 30px; overflow: hidden; }
.q-progress i { display: block; height: 100%; background: var(--ink); border-radius: var(--r-s); transition: width .3s var(--ease); }

.q-choose {
  display: inline-block;
  margin-bottom: 12px;
  padding: 2px 10px;
  border-radius: var(--r-s);
  background: var(--mark);
  color: var(--on-mark);
  font-size: var(--t-s);
  font-weight: 700;
}
.q-count { margin: 0 0 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-count.pulse { animation: q-pulse .35s var(--ease); }
@keyframes q-pulse { 40% { color: var(--bad); transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .q-count.pulse { animation: none; color: var(--bad); } }
/* A question's code wraps instead of scrolling sideways; a wrapped line is indented under its own start. */
.q-code { white-space: pre-wrap; overflow-wrap: anywhere; }
.q-code code > span { display: block; padding-left: 4ch; text-indent: -4ch; }
.q-prompt { font-size: var(--t-xl); line-height: 1.45; font-weight: 500; margin: 0 0 18px; max-width: 70ch; }

.options { display: grid; gap: 10px; margin: 0 0 22px; padding: 0; list-style: none; }
.option {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 13px 16px;
  border: 1.5px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--paper);
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.option:hover { border-color: var(--rule-strong); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option .letter {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--rule-strong);
  font-size: var(--t-xs);
  font-weight: 700;
  color: var(--ink-2);
  transition: background-color .12s, color .12s;
}
.option.multi .letter { border-radius: var(--r-s); }
.option .text { padding-top: 2px; min-width: 0; overflow-wrap: anywhere; }
/* A SQL option keeps its clause per line and wraps a long line, so options are compared line by line. */
.option .sql-opt { display: block; white-space: pre-wrap; font: var(--t-s)/1.6 var(--mono); background: none; border: 0; padding: 0; color: inherit; }
.option .sql-opt > span { display: block; padding-left: 2ch; text-indent: -2ch; }
.option:has(input:checked) { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, var(--paper)); }
.option:has(input:checked) .letter { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.option.locked { cursor: default; }
.option.locked:not(.correct):not(.wrong) { opacity: .7; }
.option.correct, .option.correct:has(input:checked) { border-color: var(--good); background: var(--good-bg); opacity: 1; }
.option.correct .letter { background: var(--good); border-color: var(--good); color: var(--on-good); }
.option.wrong, .option.wrong:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .letter { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.option .mark-label { grid-column: 2; font-size: var(--t-xs); font-weight: 700; }
.option.correct .mark-label { color: var(--good); }
.option.wrong .mark-label { color: var(--bad); }

.confidence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.confidence > span { margin-right: 4px; color: var(--muted); font-size: var(--t-s); }

.q-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

/* ---------------------------------------------------------------- mock exam */

.exam-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: -16px 0 22px;
  padding: 12px 0;
  background: var(--desk);
  border-bottom: 1px solid var(--rule);
}
.exam-bar { flex-wrap: wrap; gap: 8px 16px; }
.exam-code { font-weight: 700; font-size: var(--t-s); padding: 3px 8px; border-radius: var(--r-m); background: var(--paper-3); }
.exam-where { font-weight: 650; font-size: var(--t-s); font-variant-numeric: tabular-nums; }
.exam-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.exam-tools [aria-pressed="true"] { --btn-bg: var(--warn-bg); --btn-fg: var(--warn); }
body.exam-mode .exam-bar { top: 0; }
body.exam-mode main { padding-top: 28px; }
@media (max-width: 600px) {
  .exam-bar .spacer { display: none; }
  .exam-tools { flex-basis: 100%; }
  .exam-tools #bar-submit { margin-left: auto; }
}
.timer { display: inline-flex; align-items: center; gap: 8px; font: 700 var(--t-l)/1 var(--mono); font-variant-numeric: tabular-nums; }
.timer svg { width: 18px; height: 18px; color: var(--muted); }
.timer.warn { color: var(--bad); }
.timer.warn svg { color: var(--bad); }
.exam-saving { color: var(--muted); }
.exam-saving.warn { color: var(--bad); }
@media (max-width: 900px) { .exam-bar { top: 56px; } }
@media (min-width: 1600px) { .q-prompt { font-size: var(--t-xl); } }

.qgrid { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.qgrid button {
  font: 600 var(--t-xs)/1 var(--font);
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--rule);
  border-radius: var(--r-s);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  position: relative;
}
.qgrid button:hover { border-color: var(--ink); }
.qgrid button.answered { background: var(--paper-3); border-color: var(--rule-strong); color: var(--ink); }
.qgrid button.incomplete { border-style: dashed; border-color: var(--warn); color: var(--ink); }
.qgrid button.flagged { box-shadow: inset 0 -3px 0 var(--mark); }
/* State glyphs in the corners: answered or incomplete bottom right, flag top right. */
.qgrid .qmark, .qgrid .qflag { position: absolute; font: 700 var(--t-xs)/1 var(--font); }
.qgrid .qmark { right: 3px; bottom: 3px; }
.qgrid .qflag { right: 3px; top: 3px; color: var(--warn); }
.qgrid button.answered .qmark { color: var(--good); }
.qgrid button.incomplete .qmark { color: var(--warn); }
.qgrid button.current .qmark, .qgrid button.current .qflag { color: inherit; }
.qgrid button.current { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.qgrid button.good { border-color: color-mix(in srgb, var(--good) 60%, transparent); background: var(--good-bg); color: var(--good); }
.qgrid button.bad { border-color: color-mix(in srgb, var(--bad) 55%, transparent); background: var(--bad-bg); color: var(--bad); }
.qgrid-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--t-xs); color: var(--muted); margin: 10px 0 0; }
.qgrid-legend b { display: inline-block; min-width: 12px; margin-right: 6px; color: var(--ink-2); text-align: center; }
.abandon-line { margin-top: 36px; }

.navigator { margin-top: 30px; }
.navigator > summary { margin-bottom: 12px; }

/* ---------------------------------------------------------------- results */

.score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 24px 26px;
  border: 1px solid var(--rule);
  border-radius: var(--r-l);
  background: var(--paper);
}
.score b { font-size: var(--t-hero); font-weight: 750; line-height: 1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.score.pass b { color: var(--good); }
.score.fail b { color: var(--bad); }
.score div { display: grid; gap: 4px; max-width: 60ch; }
.score div strong { font-size: var(--t-l); }
.score div span { color: var(--muted); font-size: var(--t-s); }

.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 24px; }
.result-grid > section { margin: 0; }

.readiness { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 8px; }
.readiness b { font-size: var(--t-3xl); font-weight: 750; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.readiness span { max-width: 60ch; }

@media (max-width: 600px) {
  .q-prompt { font-size: var(--t-l); }
  .score b { font-size: var(--t-hero); }
  .score { padding: 18px; }
}
.confidence { margin-bottom: 18px; }

/* The exhibit above a question: the sample tables it is about, compact, side by side when they fit */
.q-exhibit { margin: 0 0 16px; border: 1px solid var(--rule); border-radius: var(--r-m); background: var(--paper); }
.q-exhibit summary { display: flex; align-items: baseline; gap: 8px; min-height: 40px; padding: 9px 14px; cursor: pointer; list-style: none; }
.q-exhibit summary::-webkit-details-marker { display: none; }
.q-exhibit summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.q-exhibit[open] summary::after { content: "▴"; }
.q-exhibit summary span { color: var(--muted); font: var(--t-xs) var(--mono); }
.q-exhibit summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.q-exhibit-tables { display: flex; flex-wrap: wrap; gap: 14px 22px; padding: 0 14px 14px; }
.q-exhibit figure { margin: 0; min-width: 0; max-width: 100%; }
.q-exhibit figcaption { margin-bottom: 4px; font: 650 var(--t-xs) var(--mono); }
.q-exhibit figcaption span { color: var(--muted); font: var(--t-xs) var(--font); font-weight: 400; margin-left: 6px; }
.q-exhibit .grid-wrap { max-height: 300px; border: 1px solid var(--rule); border-radius: var(--r-s); }
.q-exhibit table.grid td { padding: 3px 10px; }
@media (max-width: 600px) {
  .q-exhibit summary { padding-inline: 12px; }
  .q-exhibit-tables { padding: 0 12px 12px; }
}

/* The question's tools: full screen, save, report, end, as icons in one row */
.q-tools { display: inline-flex; align-items: center; gap: 2px; }
.q-tools:empty { display: none; }
.exam-bar .fs-btn svg { width: 18px; height: 18px; display: block; }

/* the question's tables: a button under the question opens them (ui/sql.js exhibitHtml) */
.q-exhibit-open { display: inline-flex; gap: 6px; align-items: center; margin: 0 0 12px; }
.q-exhibit-open svg { width: 16px; height: 16px; }
dialog .q-exhibit-tables { display: flex; flex-wrap: wrap; gap: 16px; max-height: 70vh; overflow: auto; margin: 12px 0; }
/* practice: how sure is optional, Check checks */
.q-actions .confidence .chip[aria-pressed="true"] { border-color: var(--ink); }
#check[aria-disabled="true"] { opacity: .55; }
