/* Shared quiz shell styles. Palette matches the site: pink #f267a0 accent,
   ink #2c2e25 borders/text, warm cream #fff8dc background (matches
   archive/ai-governance-audit's palette). */
:root {
  --pink: #f267a0;
  --navy: #2c2e25;
  --bg: #fff8dc;
  --card: #fffdf3;
  --green: #16a34a;
  --red: #dc2626;
  --gray: #595b4a;
  --lgray: #e8e0c0;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,400;0,500;1,400&display=swap');
.q-card h1, .q-brand-mono { font-family: 'DM Mono', monospace; }

.q-wrap { max-width: 820px; margin: 0 auto; padding: 16px; }

/* ── HUD (score / progress / timer) ─────────────────────────────── */
.q-hud-title {
  font-family: 'DM Mono', monospace; font-size: 16px; font-weight: 800;
  color: var(--navy); margin: 0 0 8px; text-align: center;
}
.q-hud {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff; border: 3px solid var(--navy); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.q-hud .q-stat { display: flex; flex-direction: column; line-height: 1.1; }
.q-hud .q-stat b { font-size: 20px; font-weight: 800; color: var(--navy); }
.q-hud .q-stat span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); }
.q-hud .q-spacer { flex: 1; }
.q-progress-bar { height: 8px; background: var(--lgray); border-radius: 99px; overflow: hidden; width: 100%; margin-top: 8px; }
.q-progress-bar > i { display: block; height: 100%; width: 0; background: var(--pink); transition: width .25s ease; }

/* ── Buttons ────────────────────────────────────────────────────── */
.q-btn {
  font-weight: 800; font-size: 14px; cursor: pointer;
  border: 3px solid var(--navy); border-radius: 10px;
  padding: 8px 16px; background: #fff; color: var(--navy);
  transition: transform .12s ease, background .12s ease;
}
.q-btn:hover { transform: translateY(-2px); }
.q-btn.primary { background: var(--pink); color: #fff; border-color: var(--pink); }
.q-btn.danger { color: var(--red); border-color: var(--red); }
.q-btn:disabled { opacity: .5; cursor: default; transform: none; }

/* ── Start / results screens ────────────────────────────────────── */
.q-card { background: var(--card); border: 4px solid var(--navy); border-radius: 16px; padding: 28px; text-align: center; }
.q-card h1 { font-size: 30px; font-weight: 800; color: var(--navy); margin: 0 0 8px; }
.q-card p.blurb { color: var(--gray); font-weight: 600; margin: 0 0 12px; }
.q-card .q-meta { font-size: 13px; color: var(--gray); font-weight: 700; margin-bottom: 20px; }
.q-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── Tags (start screen) ─────────────────────────────────────────── */
.q-tags { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 4px; }
.q-tags:empty { margin-bottom: 0; }
.q-tag {
  font-size: 11px; font-weight: 700; color: var(--navy); background: var(--lgray);
  border-radius: 99px; padding: 3px 10px;
}
.q-tag-suggest { margin-bottom: 14px; }
.q-issue-report { margin-bottom: 14px; }

/* Shared by "+ suggest a tag" and "report an issue": a small link that
   reveals an inline form, plus a feedback line under it. */
.q-inline-link {
  border: none; background: transparent; cursor: pointer; padding: 0;
  font-size: 11px; font-weight: 700; color: var(--gray); text-decoration: underline;
}
.q-inline-link:hover { color: var(--navy); }
.q-inline-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.q-inline-form input[type="text"], .q-inline-form textarea {
  font-size: 13px; font-weight: 600; padding: 6px 10px;
  border: 2px solid var(--navy); border-radius: 8px; outline: none; background: #fff;
  font-family: inherit;
}
.q-inline-form input[type="text"]:focus, .q-inline-form textarea:focus { border-color: var(--pink); }
.q-inline-form textarea { width: 100%; max-width: 420px; min-height: 70px; resize: vertical; box-sizing: border-box; }
.q-inline-toast { font-size: 12px; font-weight: 700; margin-top: 8px; min-height: 1em; }
.q-inline-toast.ok { color: #14532d; }
.q-inline-toast.ok a { color: inherit; }
.q-inline-toast.err { color: var(--red); }

/* ── Text input ─────────────────────────────────────────────────── */
.q-input {
  width: 100%; box-sizing: border-box; font-size: 18px; font-weight: 600;
  padding: 12px 14px; border: 3px solid var(--navy); border-radius: 10px;
  outline: none;
}
.q-input:focus { border-color: var(--pink); }
.q-flash-ok { animation: qflashok .5s ease; }
@keyframes qflashok { 0% { background: #bbf7d0; } 100% { background: #fff; } }

/* ── Answer slots grid (text-entry / map list) ──────────────────── */
.q-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 16px; }
.q-slot { border: 2px solid var(--lgray); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; color: #bbb; background: #fff; min-height: 20px; }
.q-slot.filled { color: var(--navy); border-color: var(--green); background: #f0fdf4; }
.q-slot.missed { color: var(--red); border-color: var(--red); background: #fef2f2; }

/* ── Grouped fill-in sub-boxes (shared input, labeled buckets) ───── */
.q-group + .q-group { margin-top: 20px; }
.q-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 2px solid var(--navy); padding-bottom: 4px; }
.q-group-label { font-size: 14px; font-weight: 800; color: var(--navy); }
.q-group-count { font-size: 12px; font-weight: 700; color: var(--gray); }

/* ── Text-entry table mode ───────────────────────────────────────── */
.q-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.q-table th { background: var(--navy); color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; text-align: left; }
.q-table th:last-child, .q-table td:last-child { width: 40%; }
.q-table td { border-bottom: 1px solid var(--lgray); padding: 6px 10px; font-weight: 600; color: var(--navy); }
.q-table tr.correct td { background: #f0fdf4; }
.q-table tr.missed td { background: #fef2f2; }
.q-table-input {
  width: 100%; box-sizing: border-box; font: inherit; font-weight: 600; padding: 6px 8px;
  border: 1.5px solid var(--lgray); border-radius: 5px; outline: none;
}
.q-table-input:focus { border-color: var(--pink); }
tr.correct .q-table-input { border-color: var(--green); background: #f0fdf4; color: #14532d; }
tr.missed .q-table-input { border-color: var(--red); background: #fef2f2; color: #7f1d1d; }

/* ── Multiple choice ────────────────────────────────────────────── */
.q-mc-block { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 2px solid var(--lgray); }
.q-mc-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.q-question { font-size: 22px; font-weight: 800; color: var(--navy); margin: 8px 0 18px; text-align: center; }
.q-options { display: grid; gap: 10px; }
.q-opt {
  text-align: left; font-size: 16px; font-weight: 600; cursor: pointer;
  border: 3px solid var(--navy); border-radius: 10px; padding: 12px 16px; background: #fff; color: var(--navy);
}
.q-opt:hover:not(:disabled) { background: #faf0f6; }
.q-opt.correct { background: #dcfce7; border-color: var(--green); color: #14532d; }
.q-opt.wrong { background: #fee2e2; border-color: var(--red); color: #7f1d1d; }
.q-opt:disabled { cursor: default; }

/* ── Matching ───────────────────────────────────────────────────── */
.q-match { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.q-col { display: flex; flex-direction: column; gap: 8px; }
.q-match-item {
  border: 3px solid var(--navy); border-radius: 10px; padding: 10px 12px;
  font-weight: 700; cursor: pointer; background: #fff; color: var(--navy); text-align: center;
}
.q-match-item.selected { background: var(--pink); color: #fff; border-color: var(--pink); }
.q-match-item.matched { background: #dcfce7; border-color: var(--green); color: #14532d; cursor: default; }
.q-match-item.badmatch { animation: qshake .35s; }
@keyframes qshake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* Drag-to-match: right tiles are draggable, left prompts are drop targets. */
.q-match-drag { cursor: grab; touch-action: none; }
.q-match-drag.matched { cursor: default; }
.q-match-target { cursor: default; }
.q-match-item.dragging-src { opacity: .35; }
.q-match-target.drop-hover { border-color: var(--pink); background: #faf0f6; }
.q-match-clone {
  position: fixed; z-index: 1000; margin: 0; pointer-events: none;
  box-shadow: 0 10px 24px rgba(0,0,0,.28); opacity: .96; cursor: grabbing;
}

/* ── Ranking ────────────────────────────────────────────────────── */
.q-rank { display: flex; flex-direction: column; gap: 8px; }
.q-rank-item {
  display: flex; align-items: center; gap: 10px;
  border: 3px solid var(--navy); border-radius: 10px; padding: 10px 12px; background: #fff; font-weight: 700; color: var(--navy);
}
.q-rank-item .q-rank-num { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.q-rank-item .q-rank-label { flex: 1; }
.q-rank-handle { flex-shrink: 0; cursor: grab; touch-action: none; color: var(--gray); font-size: 16px; letter-spacing: -2px; padding: 4px 6px; user-select: none; }
.q-rank-item.dragging { position: relative; box-shadow: 0 8px 20px rgba(0,0,0,.18); cursor: grabbing; background: #faf0f6; }
.q-rank-move { display: flex; flex-direction: column; gap: 2px; }
.q-rank-move button { border: none; background: var(--lgray); border-radius: 5px; width: 26px; height: 18px; cursor: pointer; font-size: 11px; line-height: 1; }
.q-rank-move button:hover { background: var(--pink); color: #fff; }
.q-rank-item.correct { border-color: var(--green); background: #f0fdf4; }
.q-rank-item.incorrect { border-color: var(--red); background: #fef2f2; }
.q-rank-item.revealed { border-color: var(--gray); background: #f9fafb; }
.q-rank-item .q-rank-value { flex-shrink: 0; font-size: 13px; font-weight: 800; color: var(--gray); font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-rank-item.correct .q-rank-value { color: #14532d; }
.q-rank-item.incorrect .q-rank-value { color: #7f1d1d; }
.q-rank-caption { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--gray); margin: 4px 0 6px; }
.q-rank-hintbar { margin-bottom: 10px; }
.q-rank-hintbar .q-btn { font-size: 12px; padding: 6px 12px; }
.q-rank-item .q-rank-hint { color: var(--pink); }

/* ── Image ──────────────────────────────────────────────────────── */
.q-image-wrap { text-align: center; margin-bottom: 16px; }
.q-image-wrap img { max-width: 100%; max-height: 300px; border: 3px solid var(--navy); border-radius: 12px; }

.q-image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px 8px; }
.q-image-cell { display: flex; flex-direction: column; gap: 5px; }
.q-img-box { aspect-ratio: 4 / 3; overflow: hidden; border-radius: 6px; border: 1px solid var(--lgray); background: var(--lgray); }
.q-img-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.q-image-input {
  width: 100%; box-sizing: border-box; font-size: 12px; font-weight: 600;
  padding: 5px 7px; border: 1.5px solid var(--lgray); border-radius: 5px; outline: none; background: #fff;
}
.q-image-input:focus { border-color: var(--pink); }
.q-image-cell.correct .q-img-box { border-color: var(--green); border-width: 2px; }
.q-image-cell.correct .q-image-input { border-color: var(--green); background: #f0fdf4; color: #14532d; }
.q-image-cell.missed .q-img-box { border-color: var(--red); border-width: 2px; }
.q-image-cell.missed .q-image-input { border-color: var(--red); background: #fef2f2; color: #7f1d1d; }

/* ── Map ────────────────────────────────────────────────────────── */
.q-map-wrap { border: 3px solid var(--navy); border-radius: 12px; background: #fff; padding: 8px; margin-bottom: 12px; overflow: hidden; }
.q-map-wrap svg { width: 100%; height: auto; max-height: 60vh; display: block; }
.q-map-wrap svg path, .q-map-wrap svg [data-region] { fill: #cdd3e0; stroke: #fff; stroke-width: .5; transition: fill .2s; cursor: pointer; }
.q-map-wrap svg path:hover { fill: var(--pink); }
.q-map-wrap svg .q-solved { fill: var(--green) !important; cursor: default; }
.q-map-wrap svg .q-revealed { fill: #f59e0b !important; }
.q-map-target { text-align: center; font-size: 20px; font-weight: 800; color: var(--navy); margin-bottom: 10px; min-height: 26px; }

/* ── Results ────────────────────────────────────────────────────── */
.q-result-score { font-size: 46px; font-weight: 800; color: var(--pink); margin: 4px 0; }
.q-result-best { font-size: 13px; font-weight: 700; color: var(--gray); margin-bottom: 20px; }

@media (max-width: 520px) {
  .q-match { grid-template-columns: 1fr 1fr; gap: 12px; }
  .q-card { padding: 20px; }
  .q-card h1 { font-size: 24px; }
}
