/* Gameficate cartridge — Question panel: category, question card, clues, hints, quiz answers, pin box, buttons, feedback and progress. */
/* ---------- Main (930 tall) ---------- */
#main {
  flex: 0 0 var(--main-h, 930px);
  height: var(--main-h, 930px);
  display: flex;
  position: relative;
}
#qpanel {
  flex: 0 0 var(--panel-w, 400px);
  width: var(--panel-w, 400px);
  height: var(--main-h, 930px);
  background: var(--panel);
  border-inline-end: 2px solid var(--line);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 2;
}
/* ---------- Category header and question card ---------- */
.cat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: calc(16px * var(--rs, 1));
  background: var(--soft2);
  border: 2px solid var(--line);
  flex: 0 0 auto;
}
.cat-head .ic img {
  width: 34px;
  height: 34px;
  display: block;
}
.cat-head .t {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}
.cat-head .s {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
.mode-pill {
  margin-inline-start: auto;
  padding: 4px 10px;
  border-radius: calc(999px * var(--rs, 1));
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: var(--navy);
  color: #fff;
  white-space: nowrap;
}

.qcard {
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  border: 2px solid var(--line);
  overflow: hidden;
  flex: 0 0 auto;
}
.qmedia {
  position: relative;
  width: 100%;
  height: 150px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--sea-deep) 60%, var(--card)),
    color-mix(in srgb, var(--gold) 22%, var(--card))
  );
  overflow: hidden;
  transition: height 0.25s;
}
.qmedia img.photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s;
}
.qmedia.loaded img.photo {
  opacity: 1;
}
.qmedia .fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.25s;
}
.qmedia.loaded .fallback {
  opacity: 0;
}
.qmedia .fallback img {
  width: 76px;
  height: 76px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.15));
}
.qmedia .fallback .hint {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
}
.qcard.has-clues .qmedia {
  height: 92px;
}
.qcard.has-clues .qmedia .fallback img {
  width: 52px;
  height: 52px;
}
.qcard.has-clues .qmedia .fallback .hint {
  display: none;
}
.qbody {
  padding: 16px 20px 18px;
}
.qnum {
  font-size: 14px;
  font-weight: 900;
  color: var(--orange-d);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.qprompt {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
}
/* ---------- Clues and the hint bar ---------- */
.clues {
  list-style: none;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clues li {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  color: color-mix(in srgb, var(--gold) 30%, #000);
  background: color-mix(in srgb, var(--gold) 18%, var(--card));
  border-inline-start: 5px solid var(--gold);
  padding: 6px 10px;
  border-radius: calc(10px * var(--rs, 1));
}
.clues li::before {
  content: '💡 ';
}
.clues li.special {
  background: color-mix(in srgb, var(--orange) 14%, var(--card));
  border-inline-start-color: var(--orange);
  color: color-mix(in srgb, var(--orange) 45%, #000);
}
.clues li.special::before {
  content: '🎯 ';
}
.clues li.new {
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.hintbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: calc(16px * var(--rs, 1));
  background: color-mix(in srgb, var(--violet) 7%, var(--card));
  border: 2px solid color-mix(in srgb, var(--violet) 25%, var(--card));
  flex: 0 0 auto;
}
.hintbar .hb-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.hintbar .hb-num {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  color: color-mix(in srgb, var(--violet) 88%, #000);
  line-height: 1;
  min-width: 22px;
  text-align: center;
}
.hintbar .hb-t1 {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--violet) 88%, #000);
}
.hintbar .hb-t2 {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  line-height: 1.25;
}
.hb-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}
.btn-chip {
  height: 36px;
  padding: 0 12px;
  border-radius: calc(11px * var(--rs, 1));
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  background: var(--violet);
  color: #fff;
  box-shadow: inset 0 -3px 0 var(--violet-d);
  transition:
    transform 0.1s,
    opacity 0.15s;
}
.btn-chip.alt {
  background: var(--card);
  color: color-mix(in srgb, var(--violet) 88%, #000);
  border: 2px solid color-mix(in srgb, var(--violet) 32%, var(--card));
  box-shadow: none;
}
.btn-chip:active:not(:disabled) {
  transform: translateY(1px);
}
.btn-chip:disabled {
  opacity: 0.4;
}

/* Quiz answers (MCQ, multi-select, true/false, typed) live in the question panel. */
.quizbox {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qz-head {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.qz-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qz-opts.tf {
  flex-direction: row;
}
.qz-opts.tf .qz-opt {
  flex: 1;
  justify-content: center;
}
.qz-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: calc(14px * var(--rs, 1));
  background: var(--card);
  border: 2px solid var(--line);
  text-align: start;
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.25;
  transition:
    border-color 0.12s,
    background 0.12s,
    transform 0.1s;
}
.qz-opt:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--orange) 42%, var(--card));
  background: color-mix(in srgb, var(--orange) 4%, var(--card));
}
.qz-opt:active:not(:disabled) {
  transform: translateY(1px);
}
.qz-opt .qz-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--edge);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
  color: var(--muted);
  background: var(--soft2);
}
.qz-opts.multi .qz-mark {
  border-radius: calc(8px * var(--rs, 1));
}
.qz-opts.tf .qz-mark {
  display: none;
}
.qz-opt img {
  width: 54px;
  height: 40px;
  object-fit: cover;
  border-radius: calc(8px * var(--rs, 1));
  flex: 0 0 auto;
}
.qz-opt .qz-txt {
  flex: 1;
  min-width: 0;
}
.qz-opt.sel {
  border-color: var(--orange);
  background: color-mix(in srgb, var(--orange) 9%, var(--card));
}
.qz-opt.sel .qz-mark {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
}
.qz-opts.multi .qz-opt.sel .qz-mark::after {
  content: '✓';
}
.qz-opt.ok {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, var(--card));
}
.qz-opt.ok .qz-mark {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.qz-opt.missed {
  border-color: var(--green);
  border-style: dashed;
  background: color-mix(in srgb, var(--green) 6%, var(--card));
}
.qz-opt.bad {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 10%, var(--card));
  color: color-mix(in srgb, var(--red) 62%, #000);
}
.qz-opt.bad .qz-mark {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}
.qz-opt.dim {
  opacity: 0.55;
}
.qz-opt.gone {
  opacity: 0.25;
  text-decoration: line-through;
}
.qz-opt:disabled {
  cursor: default;
}
.qz-input {
  width: 100%;
  height: 56px;
  border-radius: calc(14px * var(--rs, 1));
  border: 2px solid var(--line);
  padding: 0 16px;
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  background: var(--card);
  user-select: text;
  -webkit-user-select: text;
}
.qz-input:focus {
  outline: none;
  border-color: var(--orange);
  background: color-mix(in srgb, var(--orange) 4%, var(--card));
}
.qz-typed {
  border-radius: calc(14px * var(--rs, 1));
  padding: 12px 16px;
  font-size: 20px;
  font-weight: 800;
  border: 2px solid var(--line);
}
.qz-typed.ok {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, var(--card));
  color: color-mix(in srgb, var(--green) 70%, #000);
}
.qz-typed.bad {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 10%, var(--card));
  color: color-mix(in srgb, var(--red) 62%, #000);
  text-decoration: line-through;
}
.qz-tried {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.qz-tried span {
  padding: 3px 10px;
  border-radius: calc(999px * var(--rs, 1));
  background: color-mix(in srgb, var(--red) 10%, var(--card));
  color: color-mix(in srgb, var(--red) 62%, #000);
  font-size: 14px;
  font-weight: 800;
  text-decoration: line-through;
}
#qpanel.quiz .qmedia:not(.loaded) {
  height: 84px;
}
#qpanel.quiz .qmedia:not(.loaded) .fallback img {
  width: 46px;
  height: 46px;
}
#qpanel.quiz .qmedia:not(.loaded) .fallback .hint {
  display: none;
}
/* ---------- Pin box (classic questions) ---------- */
.pinbox {
  border-radius: calc(16px * var(--rs, 1));
  padding: 12px 16px;
  border: 2px dashed var(--edge);
  background: var(--soft2);
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}
.pinbox.has-pin {
  border-style: solid;
  border-color: color-mix(in srgb, var(--orange) 42%, var(--card));
  background: color-mix(in srgb, var(--orange) 9%, var(--card));
}
.pinbox .pin-ic {
  width: 44px;
  height: 44px;
  border-radius: calc(12px * var(--rs, 1));
  background: var(--card);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.pinbox .pin-ic img {
  width: 30px;
  height: 30px;
}
.pinbox .t1 {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.pinbox .t2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* ---------- Main and secondary buttons ---------- */
.btn-primary {
  width: 100%;
  height: 64px;
  border-radius: calc(18px * var(--rs, 1));
  flex: 0 0 auto;
  background: linear-gradient(180deg, color-mix(in srgb, var(--orange) 72%, #fff), var(--orange));
  color: #fff;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow:
    inset 0 -5px 0 var(--orange-d),
    0 6px 14px rgba(255, 122, 61, 0.35);
  transition:
    transform 0.1s,
    filter 0.15s,
    opacity 0.15s;
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(2px);
}
.btn-primary:disabled {
  opacity: 0.45;
  filter: grayscale(0.4);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12);
}
.btn-primary.teal {
  background: linear-gradient(180deg, color-mix(in srgb, var(--teal) 80%, #fff), var(--teal));
  box-shadow:
    inset 0 -5px 0 color-mix(in srgb, var(--teal) 80%, #000),
    0 6px 14px rgba(19, 168, 158, 0.35);
}
.btn-secondary {
  width: 100%;
  height: 48px;
  border-radius: calc(14px * var(--rs, 1));
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  color: var(--navy);
  background: var(--soft);
  border: 2px solid var(--line);
}
.btn-secondary:hover {
  background: var(--soft3);
}

/* ---------- Answer feedback card (shown inside the feedback pop-up) ---------- */
.feedback {
  border-radius: calc(18px * var(--rs, 1));
  padding: 14px 16px;
  text-align: center;
  flex: 0 0 auto;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}
.feedback.perfect,
.feedback.correct {
  background: color-mix(in srgb, var(--green) 12%, var(--card));
  border: 2px solid color-mix(in srgb, var(--green) 45%, var(--card));
}
.feedback.close,
.feedback.retry {
  background: color-mix(in srgb, var(--gold) 16%, var(--card));
  border: 2px solid color-mix(in srgb, var(--gold) 55%, var(--card));
}
.feedback.miss {
  background: color-mix(in srgb, var(--red) 10%, var(--card));
  border: 2px solid color-mix(in srgb, var(--red) 40%, var(--card));
}
.feedback .f-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--navy);
}
.feedback .f-name {
  font-size: 17px;
  font-weight: 800;
  margin-top: 6px;
  color: var(--ink);
}
.feedback .f-dist {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 4px;
}
.feedback .f-points {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 16px;
  border-radius: calc(999px * var(--rs, 1));
  background: var(--navy);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
}

/* ---------- Progress dots ---------- */
.progress {
  margin-top: auto;
  padding-top: 4px;
  flex: 0 0 auto;
}
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 8px;
}
.dots {
  display: flex;
  gap: 6px;
}
.dots button {
  flex: 1;
  height: 14px;
  border-radius: calc(99px * var(--rs, 1));
  background: var(--soft3);
  border: 2px solid transparent;
  transition: transform 0.12s;
}
.dots button:hover {
  transform: scaleY(1.25);
}
.dots button.cur {
  border-color: var(--navy);
}
.dots button.perfect,
.dots button.correct {
  background: var(--green);
}
.dots button.close {
  background: var(--amber);
}
.dots button.miss {
  background: var(--red);
}
/* Not colour alone: right answers are solid, wrong ones striped, partly-right ones dotted. */
.dots button.miss {
  background: repeating-linear-gradient(
    135deg,
    var(--red) 0 4px,
    color-mix(in srgb, var(--red) 45%, var(--card)) 4px 7px
  );
}
.dots button.close {
  background:
    radial-gradient(circle, #fff 1.6px, transparent 2px) 0 0 / 7px 7px,
    var(--amber);
}
.feedback .f-title .fx {
  display: inline-block;
  margin-inline-end: 8px;
  font-size: 0.85em;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Questions unlock in order: locked ones are greyed out with a lock. */
.dots button.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: repeating-linear-gradient(90deg, var(--soft3) 0 3px, transparent 3px 6px);
}
.dots button.locked:hover {
  transform: none;
}

/* Folding the question panel away (every layout): the panel hides and the map takes its place. */
#qpanel.collapsed {
  display: none !important;
}
/* Split layout: the fold-away tab on the panel's edge. */
.side-toggle {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: calc(var(--panel-w) - 2px);
  transform: translateY(-50%);
  width: 30px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 0 calc(14px * var(--rs, 1)) calc(14px * var(--rs, 1)) 0;
  background: var(--panel);
  border: 2px solid var(--line);
  border-left: 0;
  box-shadow: 6px 0 14px rgba(10, 25, 40, 0.12);
  color: var(--navy);
}
.side-toggle:hover {
  background: var(--soft);
}
.side-toggle .ar {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}
.side-toggle .ar::before {
  content: '‹';
}
.side-toggle .lbl {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
body.q-collapsed .side-toggle {
  left: 0;
}
body.q-collapsed .side-toggle .ar::before {
  content: '›';
}
/* Puzzle questions: a compact question card (no picture placeholder) so the piece tray gets the room. */
#qpanel.puzzle .qmedia:not(.loaded) {
  display: none;
}

/* All questions answered: the “See my report” button invites a press. */
.btn-primary.ready {
  animation: readyPulse 1.2s ease-in-out 3;
}
@keyframes readyPulse {
  50% {
    transform: scale(1.04);
    box-shadow:
      inset 0 -5px 0 color-mix(in srgb, var(--teal) 80%, #000),
      0 0 0 8px color-mix(in srgb, var(--teal) 25%, transparent);
  }
}
/* Question papers with sections: "Section A · 2 marks" beside the question number. */
.q-section {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--navy) 10%, transparent);
  color: var(--navy);
  letter-spacing: 0.3px;
}

/* ---------- Passage and sound (js/ui/PassagePanel.js): reading comprehension and listening ---------- */
.q-passage {
  margin: 0 0 14px;
  border: 2px solid var(--line);
  border-radius: calc(16px * var(--rs, 1));
  background: var(--soft2);
  overflow: hidden;
}
.q-passage[hidden] {
  display: none;
}
.qp-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--soft);
  border: 0;
  color: var(--navy);
  font-size: 16px;
  text-align: start;
}
.qp-head b {
  flex: 1;
}
.qp-fold {
  transition: transform 0.2s;
}
.q-passage.folded .qp-fold {
  transform: rotate(-90deg);
}
.q-passage.folded .qp-text {
  display: none;
}
.qp-text {
  max-height: 320px;
  overflow-y: auto;
  padding: 10px 16px 12px;
  font-size: 17px;
  line-height: 1.6;
}
.qp-text p {
  margin: 0 0 10px;
}
.qp-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 2px solid var(--line);
}
.q-passage > .qp-audio:first-child {
  border-top: 0;
}
.qp-audio audio {
  flex: 1;
  min-width: 0;
  height: 40px;
}
.qp-left {
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}
.qp-ic {
  font-size: 20px;
}
