/* Question inputs (web/js/lesson/questions.js). Every rule sits under .q-input. Tokens come from styles.css. */

.q-input { margin: 6px 0 8px; font-size: var(--fs-2); }
.q-input button { font: inherit; color: inherit; margin: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.q-input button:focus-visible,
.q-input input:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.q-input .q-hint { margin: 0 0 10px; color: var(--ink-3); font-size: var(--fs-0); font-weight: 700; }
.q-input.is-locked button:not(.q-opt):not(.q-chip) { cursor: default; }

/* Choices: mcq, multi, truefalse */
.q-choices { display: flex; flex-direction: column; gap: 10px; }
.q-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 10px 16px;
  border: 2px solid var(--line); border-radius: var(--r-m); background: var(--card); box-shadow: var(--shadow-1);
  font-size: var(--fs-2); font-weight: 600; line-height: 1.3; text-align: left; cursor: pointer;
}
.q-opt:active { transform: scale(.99); }
.q-letter {
  flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink); font-size: var(--fs-1); font-weight: 800;
}
.q-opt.q-sel { border-color: var(--brand); background: var(--brand-soft); }
.q-opt.q-sel .q-letter { background: var(--brand); color: #fff; }
.q-tf-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.q-tf { justify-content: center; min-height: 84px; font-size: var(--fs-3); font-weight: 750; }

/* Typed answers: number, text */
.q-typed { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.q-line {
  width: 100%; max-width: 340px; min-height: 60px; padding: 10px 16px;
  border: 2px solid var(--line); border-radius: var(--r-m); background: var(--card); box-shadow: var(--shadow-1);
  font-size: var(--fs-3); font-weight: 650;
}
.q-line:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.q-units { font-size: var(--fs-3); font-weight: 700; color: var(--ink-2); }

/* Gaps */
.q-sentence { margin: 0; font-size: var(--fs-2); line-height: 2.5; }
.q-gap-in {
  display: inline-block; vertical-align: baseline; width: 8.5em; max-width: 100%; min-height: 48px; margin: 0 4px; padding: 4px 8px;
  border: 0; border-bottom: 3px solid var(--brand); border-radius: 10px 10px 0 0; background: var(--brand-soft);
  font-size: var(--fs-2); font-weight: 700; text-align: center;
}
.q-gap-in:focus { outline: none; background: #e3dbff; }
.q-slot {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: baseline;
  min-width: 7.5em; min-height: 48px; margin: 0 4px; padding: 4px 12px;
  border: 2px dashed var(--brand); border-radius: var(--r-s); background: var(--card);
  color: var(--brand-ink); font-size: var(--fs-2); font-weight: 700; cursor: pointer;
}
.q-slot.is-filled { border-style: solid; background: var(--brand-soft); }
.q-slot.q-sel { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 0 6px var(--accent); }
.q-bank { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.q-word {
  min-height: 48px; padding: 8px 18px; border: 2px solid var(--line); border-radius: var(--r-pill);
  background: var(--card); box-shadow: var(--shadow-1); font-size: var(--fs-1); font-weight: 700; cursor: pointer;
}
.q-word:disabled { opacity: .3; box-shadow: none; cursor: default; }

/* Word chips: order, group, label */
.q-chip {
  min-height: 48px; padding: 8px 18px; border: 2px solid var(--line); border-radius: var(--r-pill);
  background: var(--card); box-shadow: var(--shadow-1); font-size: var(--fs-1); font-weight: 700; line-height: 1.25;
  text-align: center; cursor: pointer;
}
.q-chip.is-placed { background: var(--brand-soft); border-color: #d6cbff; }
.q-chip.q-sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); box-shadow: 0 0 0 3px var(--brand-soft); }
.q-chip.is-used { opacity: .5; }
.q-tray { display: flex; flex-wrap: wrap; gap: 10px; }

/* Order */
.q-rows { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.q-row { display: flex; align-items: center; gap: 10px; }
.q-num {
  flex: 0 0 38px; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 800;
}
.q-blank { flex: 1; min-height: 52px; border: 2px dashed var(--line); border-radius: var(--r-m); }
.q-row .q-chip { flex: 1; }

/* Match */
.q-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.q-col { display: grid; gap: 10px; align-content: start; }
.q-card {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 60px; padding: 8px 12px; border: 2px solid var(--line); border-radius: var(--r-m);
  background: var(--card); box-shadow: var(--shadow-1); font-size: var(--fs-1); font-weight: 650; line-height: 1.25;
  text-align: left; cursor: pointer;
}
.q-card-text { min-width: 0; overflow-wrap: anywhere; }
.q-card.q-sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; box-shadow: 0 0 0 4px var(--brand-soft), var(--shadow-2); transform: translateY(-2px); }
.q-card.q-paired { border-color: var(--pair); background: var(--pair-soft); }
.q-link {
  position: absolute; top: -9px; right: -9px; display: grid; place-items: center;
  width: 26px; height: 26px; border: 2px solid #fff; border-radius: 50%; background: var(--pair); color: #fff;
}
.q-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Group */
.q-groups { display: grid; gap: 14px; }
.q-box {
  min-height: 110px; padding: 10px 12px 12px; border: 2px dashed #c9bff0; border-radius: var(--r-l);
  background: var(--card); cursor: pointer;
}
.q-box.q-target { border-color: var(--brand); background: var(--brand-soft); }
.q-box-head { margin-bottom: 8px; color: var(--brand-ink); font-size: var(--fs-1); font-weight: 800; }
.q-box-body { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; }

/* Highlight */
.q-instr { margin: 0 0 8px; color: var(--ink-2); font-size: var(--fs-1); font-weight: 700; }
.q-passage { margin: 0; font-size: var(--fs-3); line-height: 2.5; }
.q-token {
  display: inline-block; min-height: 46px; margin: 0; padding: 6px 6px; border: 0; border-radius: 6px 9px 7px 10px;
  background: transparent; font-size: inherit; line-height: 1.4; cursor: pointer;
}
.q-token.q-sel {
  background: linear-gradient(180deg, transparent 16%, #ffe48a 16%, #ffd23f 88%, transparent 88%);
}
.q-token:hover { background-color: #f1ecff; }
/* A row of numbers or short words: real tappable chips, not bare digits (26 Oct: "2 9 13" were 10 px targets). */
.q-passage.q-chips { display: flex; flex-wrap: wrap; gap: 10px; line-height: 1.4; }
.q-chips .q-token { min-width: 56px; padding: 8px 14px; border: 2px solid var(--line, #d9d3f0); border-radius: 12px; background: #fff; font-weight: 700; }
.q-chips .q-token.q-sel { background: #ffd23f; border-color: #e0a800; }

/* Label */
.q-art { position: relative; width: 100%; max-width: 520px; margin: 0 auto 14px; }
.q-art img {
  display: block; width: 100%; height: auto; border-radius: var(--r-m); background: #fff;
  user-select: none; -webkit-user-drag: none;
}
.q-marker {
  position: absolute; z-index: 2; transform: translate(-50%, -50%);
  display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
  border: 3px solid #fff; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: var(--fs-1); font-weight: 800; box-shadow: var(--shadow-2); cursor: pointer;
}
.q-marker.q-sel { background: var(--accent); color: var(--ink); box-shadow: 0 0 0 5px rgba(255, 176, 32, .4), var(--shadow-2); }
/* Tag hangs under its marker (or above it, for every other marker): centred, or pushed in from the
   left/right edge so it stays on the picture. */
.q-tag {
  position: absolute; z-index: 1; transform: translate(-50%, 30px); width: max-content; max-width: 50%;
  padding: 6px 12px; border: 2px solid var(--brand); border-radius: var(--r-pill); background: #fff; color: var(--brand-ink);
  font-size: var(--fs-0); font-weight: 700; line-height: 1.2; text-align: center; box-shadow: var(--shadow-1); cursor: pointer;
}
.q-tag.is-start { transform: translate(-24px, 30px); }
.q-tag.is-end { transform: translate(calc(-100% + 24px), 30px); }
.q-tag.is-above { transform: translate(-50%, calc(-100% - 30px)); }
.q-tag.is-above.is-start { transform: translate(-24px, calc(-100% - 30px)); }
.q-tag.is-above.is-end { transform: translate(calc(-100% + 24px), calc(-100% - 30px)); }
.q-labels { display: flex; flex-wrap: wrap; gap: 10px; }

/* Marks from showResult(). They come last so they beat the selection styles above. */
.q-input .q-ok { border-color: var(--good); background-color: var(--good-soft); }
.q-input .q-bad { border-color: var(--bad); background-color: var(--bad-soft); }
.q-input .q-miss { outline: 3px dashed var(--good); outline-offset: 3px; }
.q-opt.q-ok .q-letter { background: var(--good); color: #fff; }
.q-opt.q-bad .q-letter { background: var(--bad); color: #fff; }
.q-line.q-ok, .q-line.q-bad { font-weight: 700; }
.q-token.q-ok.q-sel { background: linear-gradient(180deg, transparent 16%, #b7ecc9 16%, #6fd39a 88%, transparent 88%); }
.q-token.q-bad { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.q-marker.q-ok { background: var(--good); }
.q-marker.q-bad { background: var(--bad); }
.q-tag.q-ok { color: var(--good); }
.q-tag.q-bad { color: var(--bad); }
.q-card.q-paired.q-ok, .q-card.q-paired.q-bad { background-color: var(--card); }
.q-card.q-paired.q-ok .q-link { background: var(--good); }
.q-card.q-paired.q-bad .q-link { background: var(--bad); }
.q-chip.q-ok { color: var(--good); }
.q-chip.q-bad { color: var(--bad); }


/* Label key under the picture (replaces tags on the picture, 19 Oct). */
.q-key { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 12px 0 4px; }
.q-key-row { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 12px 6px 6px; text-align: left;
  border: 2px dashed var(--line); border-radius: var(--r-pill); background: var(--card); cursor: pointer; font: inherit; }
.q-key-row.is-set { border-style: solid; border-color: var(--brand); background: var(--brand-soft); font-weight: 650; }
.q-key-row.q-sel { border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.q-key-num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--brand); color: #fff; font-weight: 800; }
.q-key-name { color: var(--ink-2); }
.q-key-row.is-set .q-key-name { color: var(--brand-ink); }
.q-key-row.q-ok { border-color: var(--good); background: var(--good-soft); }
.q-key-row.q-bad { border-color: var(--bad); background: var(--bad-soft); }
.q-marker.is-set { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--brand); }

/* Small see-through markers (19 Oct): the 48 px tap area stays, but only a 30 px dot is drawn, so the part being
   labelled stays visible underneath (big solid markers hid the chloroplast they pointed at). */
.q-marker { --dot: rgba(106, 76, 255, .78); background: radial-gradient(circle, var(--dot) 0 14px, #fff 14px 16px, transparent 16.5px);
  border: 0; box-shadow: none; font-size: 14px; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.q-marker.is-set { --dot: rgba(74, 47, 217, .9); box-shadow: none; }
.q-marker.q-sel { --dot: rgba(255, 176, 32, .95); background: radial-gradient(circle, var(--dot) 0 14px, #fff 14px 16px, rgba(255,176,32,.35) 16.5px 22px, transparent 22.5px); color: var(--ink); text-shadow: none; box-shadow: none; }
.q-marker.q-ok { --dot: rgba(22, 163, 74, .9); background: radial-gradient(circle, var(--dot) 0 14px, #fff 14px 16px, transparent 16.5px); }
.q-marker.q-bad { --dot: rgba(229, 72, 77, .9); background: radial-gradient(circle, var(--dot) 0 14px, #fff 14px 16px, transparent 16.5px); }

/* Marked number chips (after .q-token.q-ok / .q-bad above) */
.q-chips .q-token.q-ok.q-sel { background: #b7ecc9; border-color: var(--good); }
.q-chips .q-token.q-bad { border-color: var(--bad); }

/* table: a worksheet table with blanks */
.q-table-wrap { overflow-x: auto; }
.q-table { border-collapse: collapse; margin: 6px auto; font-size: var(--fs-2); background: #fff; }
.q-table th, .q-table td { border: 2px solid #d9d3f0; padding: 8px 14px; text-align: center; }
.q-table th { background: #f1edff; font-weight: 800; }
.q-table .q-cell-blank { padding: 4px 8px; }
.q-cell-in { width: 7em; margin: 0; }

/* numberline: tap a name, then tap the line */
.q-nl-wrap { display: grid; gap: 10px; }
.q-nl-pad { padding: 46px 28px 40px; background: #fff; border-radius: var(--r-m); }
.q-nl { position: relative; height: 40px; cursor: crosshair; touch-action: manipulation; }
.q-nl-line { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; background: #3b3355; border-radius: 2px; }
.q-nl-tick { position: absolute; top: 50%; width: 2px; height: 14px; margin: -7px 0 0 -1px; background: #3b3355; pointer-events: none; }
.q-nl-tick.is-major { height: 22px; margin-top: -11px; }
.q-nl-num { position: absolute; top: 26px; left: 50%; transform: translateX(-50%); font-size: var(--fs-1); font-weight: 700; white-space: nowrap; }
.q-nl-pt { position: absolute; bottom: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  border: 2px solid transparent; background: none; padding: 0 4px; border-radius: 8px; font: inherit; cursor: pointer; }
.q-nl-pt-name { font-weight: 800; color: var(--accent, #6c4cf1); font-size: var(--fs-2); }
.q-nl-arrow { color: var(--accent, #6c4cf1); line-height: 1; }
.q-nl-pt.q-sel { border-color: var(--accent, #6c4cf1); background: #f1edff; }
.q-nl-answers { display: flex; flex-wrap: wrap; gap: 14px; }
.q-nl-answer { display: flex; align-items: center; gap: 6px; font-size: var(--fs-2); }
.q-gap-in.q-gap-sup { width: 2.6em; min-height: 34px; font-size: .8em; vertical-align: super; margin: 0 2px 0 1px; padding: 2px 4px; }
.q-link-num { font-size: 14px; font-weight: 800; line-height: 1; }

@media (max-width: 480px) {
  .q-cols { gap: 8px; }
  .q-card { padding: 8px 10px; font-size: 14.5px; min-height: 54px; }
  .q-nl-pad { padding: 40px 14px 36px; }
  .q-opt { padding: 10px 12px; gap: 10px; }
  .q-key { grid-template-columns: 1fr; }
}
