/* ═══════════════════════════════════════════════════════════════════════
 * Drag-and-drop question component
 * Append to styles.css. Uses existing :root tokens (--green, --red, etc.)
 * ═══════════════════════════════════════════════════════════════════════ */

.dd-question {
  font-family: var(--font);
  color: var(--fg);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;  /* critical: prevents browser scrolling during touch-drag */
}

.dd-stem {
  font-size: 14px; line-height: 1.5;
  color: var(--fg-hi);
  margin-bottom: 16px;
  padding: 0 4px;
}

.dd-diagram-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px;
  margin-bottom: 16px;
}

.dd-diagram {
  display: block;
  width: 100%;
  max-height: 400px;
  height: auto;
}

/* ───── SVG zone styling ───── */
.dd-zone-rect {
  fill: var(--bg);
  stroke: var(--border-hi);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  transition: stroke 0.12s, fill 0.12s;
}
.dd-zone-hover .dd-zone-rect {
  stroke: var(--green);
  stroke-width: 2;
  stroke-dasharray: none;
  fill: var(--green-bg);
}
.dd-zone-correct .dd-zone-rect {
  stroke: var(--green);
  stroke-width: 2;
  stroke-dasharray: none;
}
.dd-zone-wrong .dd-zone-rect {
  stroke: var(--red);
  stroke-width: 2;
  stroke-dasharray: none;
}

.dd-zone-label {
  fill: var(--fg-dim);
  font-size: 11px;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
}
.dd-zone-correct .dd-zone-label { fill: var(--green); }
.dd-zone-wrong .dd-zone-label { fill: var(--red); }

/* ───── Items placed inside zones ───── */
.dd-zoneitem rect {
  fill: var(--surface);
  stroke: var(--border-hi);
  stroke-width: 1;
  cursor: grab;
}
.dd-zoneitem:active rect { cursor: grabbing; }
.dd-zoneitem-correct rect {
  fill: var(--green-bg);
  stroke: var(--green);
}
.dd-zoneitem-wrong rect {
  fill: var(--red-bg);
  stroke: var(--red);
}
.dd-zoneitem-text {
  fill: var(--fg-hi);
  font-size: 10px;
  font-family: var(--font);
  pointer-events: none;
}

/* ───── Item tray (below diagram) ───── */
.dd-tray {
  margin-bottom: 16px;
}
.dd-tray-label {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 0 4px;
}
.dd-tray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
  padding: 8px;
  border: 1px dashed var(--border-hi);
  border-radius: var(--r);
  background: var(--surface);
}
.dd-trayitem {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--fg-hi);
  cursor: grab;
  font-family: var(--font);
  /* min-height for touch targets — Apple HIG / WCAG */
  min-height: 28px;
  display: flex;
  align-items: center;
}
.dd-trayitem:active { cursor: grabbing; background: var(--surface); }
.dd-trayitem-dragging {
  opacity: 0.3;
}

/* ───── Floating ghost during drag ───── */
.dd-ghost {
  position: fixed;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: var(--bg);
  border: 1px solid var(--green);
  border-radius: var(--r);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--green);
  font-family: var(--font);
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  white-space: nowrap;
}

/* ───── Actions ───── */
.dd-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ───── Feedback after submission ───── */
.dd-feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-hi);
}
.dd-result {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.dd-result-pass { color: var(--green); }
.dd-result-partial { color: var(--fg-hi); }
.dd-result-fail { color: var(--red); }
.dd-exp {
  font-size: 13px;
  color: var(--fg);
  line-height: 1.55;
  margin: 8px 0;
}
.dd-wrongnote {
  font-size: 12px;
  color: var(--fg-dim);
  margin: 6px 0;
  line-height: 1.5;
  padding-left: 8px;
  border-left: 2px solid var(--red);
}
.dd-wrongnote strong {
  color: var(--red);
  font-weight: 600;
}

.dd-error {
  padding: 16px;
  border: 1px solid var(--red);
  border-radius: var(--r);
  color: var(--red);
  font-family: var(--font);
}

/* ───── Mobile pass ───── */
@media (max-width: 600px) {
  .dd-diagram-wrap { padding: 8px; }
  .dd-diagram { max-height: 320px; }
  .dd-tray-items { padding: 6px; }
  .dd-trayitem { padding: 10px 12px; font-size: 12px; min-height: 36px; }
  .dd-actions { flex-direction: column-reverse; }
  .dd-actions .btn { width: 100%; }
}
