/* PBQ lab — styles for the five interactive widget types.
   Loads only on pbq.html, on top of site.css. Same palette, same rules:
   mobile-first, ≥44px tap targets, ≥16px reading text. */

.wrap-wide { max-width: 56rem; margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Question rail ---------- */

.pbq-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.4rem;
}

.rail-chip {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.rail-chip:hover { border-color: var(--teal); }
.rail-chip[aria-current="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}
.rail-chip.is-done-right {
  background: var(--right-bg);
  border-color: var(--teal);
  color: var(--teal-dark);
}
.rail-chip.is-done-partial {
  background: #fdf3e0;
  border-color: #c98a1b;
  color: #8a5c0a;
}
.rail-chip.is-done-right[aria-current="true"],
.rail-chip.is-done-partial[aria-current="true"] {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}
.rail-chip.is-pending {
  background: var(--off-white);
  border-style: dashed;
  color: #9aa3b5;
}
.rail-chip .chip-mark {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  font-size: 0.7rem;
  line-height: 1.05rem;
  text-align: center;
  background: var(--teal-dark);
  color: #fff;
}
.rail-chip.is-done-partial .chip-mark { background: #c98a1b; }

/* ---------- Stage card ---------- */

.pbq-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
}

.pbq-type-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--off-white);
  background: var(--navy);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.pbq-instruction {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}

/* ---------- Shared action row ---------- */

.pbq-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.1rem;
}
.btn-secondary {
  background: transparent;
  border: 2px solid var(--teal-dark);
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--radius);
  padding: 0.7rem 1.2rem;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--right-bg); }
.btn:disabled, .btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pbq-stage-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.pbq-stage-nav .stage-pos {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------- drag_match ---------- */

.dm-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) {
  .dm-grid { grid-template-columns: minmax(9rem, 1fr) 2fr; align-items: start; }
}

.dm-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-content: flex-start;
  padding: 0.75rem;
  background: var(--off-white);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  min-height: 3.4rem;
}
.dm-pool-label, .dm-targets-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin: 0 0 0.4rem;
}

.dm-chip {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--card);
  border: 1.5px solid var(--teal);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  min-height: 44px;
  cursor: grab;
  touch-action: manipulation;
}
.dm-chip.is-selected {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.dm-chip.is-ghost { opacity: 0.4; }

.dm-targets { display: grid; gap: 0.55rem; }

.dm-target {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  background: var(--card);
}
.dm-target.is-droppable { border-color: var(--teal); background: var(--right-bg); }
.dm-target .dm-target-label {
  flex: 1 1 12rem;
  font-size: 0.95rem;
  color: var(--ink);
}
.dm-well {
  flex: 0 0 auto;
  min-width: 5.5rem;
  min-height: 44px;
  border: 1.5px dashed var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem;
  font-size: 0.85rem;
  color: #9aa3b5;
}
.dm-well .dm-chip { cursor: pointer; }
button.dm-well {
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--off-white);
}
button.dm-well:hover,
button.dm-well:focus-visible {
  border-color: var(--teal);
  color: var(--teal-dark);
}
.dm-target.is-right { border-color: var(--teal); background: var(--right-bg); }
.dm-target.is-wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.dm-verdict { font-weight: 700; font-size: 0.9rem; }
.dm-target.is-right .dm-verdict { color: var(--teal-dark); }
.dm-target.is-wrong .dm-verdict { color: var(--wrong); }

/* ---------- order_sequence ---------- */

.seq-list { display: grid; gap: 0.55rem; margin: 0; padding: 0; list-style: none; }

.seq-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
}
.seq-row.is-dragging { opacity: 0.5; border-style: dashed; }
.seq-row.is-drop-above { box-shadow: 0 -3px 0 0 var(--teal); }
.seq-row.is-drop-below { box-shadow: 0 3px 0 0 var(--teal); }

.seq-num {
  flex: 0 0 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--off-white);
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.seq-text { flex: 1; font-size: 0.98rem; }
.seq-move { display: flex; flex-direction: column; gap: 0.2rem; }
.seq-move button {
  font: inherit;
  font-size: 0.8rem;
  line-height: 1;
  width: 2.2rem;
  height: 1.55rem;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: var(--off-white);
  color: var(--ink-soft);
  cursor: pointer;
}
.seq-move button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-dark); }
.seq-move button:disabled { opacity: 0.3; cursor: default; }

.seq-row.is-right { border-color: var(--teal); background: var(--right-bg); }
.seq-row.is-right .seq-num { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.seq-row.is-wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.seq-row.is-wrong .seq-num { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.seq-correct-pos {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--wrong);
  white-space: nowrap;
}

/* ---------- simulated_cli ---------- */

.cli-shell {
  background: var(--navy-deep);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.cli-titlebar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--navy);
  padding: 0.5rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #aab6cc;
}
.cli-titlebar .cli-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--navy-soft);
}
.cli-body {
  padding: 0.9rem 0.5rem 1rem;
  overflow-x: auto;
}
.cli-line {
  display: block;
  min-width: 100%;
  width: max-content;
  text-align: left;
  font-family: "Consolas", "Menlo", "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre;
  color: #d9e0ee;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  padding: 0.12rem 0.5rem;
  cursor: pointer;
}
.cli-line:hover:not(:disabled) { background: var(--navy-soft); border-left-color: var(--teal-bright); }
.cli-line:disabled { cursor: default; }
.cli-line.is-blank { pointer-events: none; }
.cli-line.is-picked {
  background: rgba(53, 208, 191, 0.18);
  border-left-color: var(--teal-bright);
  color: #fff;
}
.cli-line.is-miss { animation: cliMiss 0.5s; }
@keyframes cliMiss {
  0%, 100% { background: transparent; }
  30% { background: rgba(179, 55, 47, 0.45); }
}

.cli-hint {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--teal-dark);
  margin: 0 0 0.75rem;
}
.cli-hint.is-miss { color: var(--wrong); }

.cli-options { display: grid; gap: 0.6rem; }
.cli-options .q-opt { font-size: 0.98rem; }

/* ---------- simulated_config ---------- */

.cfg-panel {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.cfg-titlebar {
  background: var(--navy);
  color: var(--off-white);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.6rem 1rem;
}
.cfg-field {
  border: none;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 0.9rem 1rem 1rem;
}
.cfg-field:last-of-type { border-bottom: none; }
.cfg-field legend {
  float: left; /* keeps legend inside the fieldset flow */
  width: 100%;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--navy);
  padding: 0 0 0.55rem;
}
.cfg-options { display: flex; flex-wrap: wrap; gap: 0.45rem; clear: both; }
.cfg-opt { position: relative; }
.cfg-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.cfg-opt label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--off-white);
  cursor: pointer;
}
.cfg-opt input:checked + label {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.cfg-opt input:focus-visible + label { outline: 2px solid var(--teal-dark); outline-offset: 2px; }
.cfg-field.is-right legend::after {
  content: " ✓ correct";
  color: var(--teal-dark);
  font-size: 0.85rem;
}
.cfg-field.is-wrong legend::after {
  content: " ✗ incorrect";
  color: var(--wrong);
  font-size: 0.85rem;
}
.cfg-field.is-right { background: var(--right-bg); }
.cfg-field.is-wrong { background: var(--wrong-bg); }
.cfg-field.is-locked .cfg-opt label { cursor: default; opacity: 0.75; }
.cfg-field.is-locked .cfg-opt input:checked + label { opacity: 1; }
.cfg-correct-note { font-size: 0.88rem; font-weight: 600; color: var(--teal-dark); margin: 0.5rem 0 0; clear: both; }

/* ---------- identify_label ---------- */

.idl-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.idl-prompt .idl-find {
  font-weight: 700;
  color: var(--navy);
  font-size: 1.02rem;
}
.idl-prompt .idl-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.idl-feedback {
  min-height: 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.5rem 0 0;
}
.idl-feedback.is-hit { color: var(--teal-dark); }
.idl-feedback.is-miss { color: var(--wrong); }

.idl-figure {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--line);
  cursor: crosshair;
  line-height: 0;
}
.idl-figure img { width: 100%; height: auto; display: block; }
.idl-figure.is-locked { cursor: default; }

.idl-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--teal-dark);
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.45rem;
  text-align: center;
  pointer-events: none;
}
.idl-marker.is-revealed { background: var(--wrong); }

.idl-region {
  position: absolute;
  border: 2.5px solid var(--teal-bright);
  border-radius: 6px;
  background: rgba(53, 208, 191, 0.14);
  pointer-events: none;
}
.idl-region .idl-region-num {
  position: absolute;
  top: -0.05rem;
  left: -0.05rem;
  background: var(--teal-dark);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.22rem 0.42rem;
  border-radius: 0 0 6px 0;
}

.idl-figure:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 2px; }

.idl-cursor {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  border: 2.5px dashed var(--teal-bright);
  background: rgba(53, 208, 191, 0.18);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.idl-ripple {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 3px solid var(--wrong);
  pointer-events: none;
  animation: idlRipple 0.55s ease-out forwards;
}
@keyframes idlRipple {
  from { opacity: 0.95; transform: translate(-50%, -50%) scale(0.35); }
  to   { opacity: 0;    transform: translate(-50%, -50%) scale(1.25); }
}

.idl-labels-done { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.idl-label-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  background: var(--off-white);
}
.idl-label-pill.is-hit { border-color: var(--teal); background: var(--right-bg); color: var(--teal-dark); }
.idl-label-pill.is-missed { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }
.idl-label-pill.is-active { border-color: var(--navy); background: var(--navy); color: #fff; }

/* Pending (missing/mismatched diagram) state */
.pbq-pending {
  background: var(--off-white);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--ink-soft);
}
.pbq-pending strong { color: var(--navy); }

/* ---------- Results + explanation ---------- */

.pbq-result {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
}

.pbq-score {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 1rem;
}
.pbq-score.is-right { color: var(--teal-dark); }
.pbq-score.is-partial { color: #8a5c0a; }
.pbq-score.is-wrong { color: var(--wrong); }

.pbq-summary {
  background: var(--right-bg);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0 0 1.1rem;
  font-size: 1rem;
  color: var(--ink);
}
.pbq-summary strong { color: var(--navy); }

.pbq-breakdown { display: grid; gap: 0.65rem; }
.pbq-why {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.98rem;
  color: var(--ink-soft);
  margin: 0;
}
.pbq-why .why-chip {
  flex: 0 0 1.35rem;
  height: 1.35rem;
  margin-top: 0.15rem;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}
.pbq-why .why-chip.is-right { background: var(--right-bg); color: var(--teal-dark); border: 1.5px solid var(--teal); }
.pbq-why .why-chip.is-wrong { background: var(--wrong-bg); color: var(--wrong); border: 1.5px solid var(--wrong); }
.pbq-why .why-chip.is-neutral { background: var(--off-white); color: var(--ink-soft); border: 1.5px solid var(--line); }
.pbq-why strong { color: var(--navy); }

.pbq-load-error { color: var(--wrong); font-weight: 600; }
