/*
 * Matches design-codebase's DragDropQuiz (learn.$stepId.tsx): a "Word bank"
 * card of rounded-full pill tokens above the question, with each blank
 * rendered as its own rounded-full pill. Colors reuse the theme's own
 * --ldal-focus-* tokens (defined in focus-mode.css.j2's :root) instead of
 * hardcoded hex, so a palette change here stays in sync automatically; the
 * literal oklch() fallback on each var() is only for the unlikely case this
 * file loads without focus-mode.css.j2 on the page.
 */

.ldal-drag-drop-question {
  margin: 16px 0 20px;
  padding: 20px;
  border: 1px solid color-mix(in oklab, var(--ldal-focus-border, oklch(0.88 0.015 85)) 70%, transparent);
  border-radius: var(--ldal-focus-radius, 20px);
  background: var(--ldal-focus-card, oklch(1 0 0));
}

@media (min-width: 768px) {
  .ldal-drag-drop-question {
    padding: 24px;
  }
}

.ldal-drag-drop-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ldal-drag-drop-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ldal-focus-primary-deep, oklch(0.38 0.12 250));
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ldal-drag-drop-icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--ldal-focus-accent, oklch(0.72 0.18 55));
}

.ldal-drag-drop-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ldal-drag-drop-count {
  color: var(--ldal-focus-muted, oklch(0.5 0.03 250));
  font-size: 12px;
  line-height: 16px;
}

.ldal-drag-drop-instructions {
  margin: 6px 0 0;
  color: var(--ldal-focus-muted, oklch(0.5 0.03 250));
  font-size: 14px;
  line-height: 20px;
}

.ldal-answer-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.ldal-answer-token {
  min-height: 38px;
  margin: 0 !important;
  padding: 8px 16px !important;
  border: 2px solid color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 40%, transparent) !important;
  border-radius: 999px !important;
  background: color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 5%, transparent) !important;
  color: var(--ldal-focus-primary-deep, oklch(0.38 0.12 250)) !important;
  font: inherit !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 20px !important;
  cursor: grab;
  box-shadow: none !important;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease !important;
}

.ldal-answer-token:hover:not(:disabled),
.ldal-answer-token:focus-visible {
  border-color: var(--ldal-focus-primary, oklch(0.53 0.14 249)) !important;
  background: color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 10%, transparent) !important;
}

.ldal-answer-token:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 25%, transparent);
  outline-offset: 2px;
}

.ldal-answer-token:active {
  cursor: grabbing;
}

.ldal-answer-token.is-selected {
  border-color: var(--ldal-focus-primary, oklch(0.53 0.14 249)) !important;
  background: var(--ldal-focus-primary, oklch(0.53 0.14 249)) !important;
  color: var(--ldal-focus-bg, oklch(0.985 0.008 85)) !important;
}

/* Placed tokens stay visible but greyed and unusable, rather than
 * disappearing — matches design-codebase's opacity-50 "used" pill. */
.ldal-answer-token.is-used {
  border-color: color-mix(in oklab, var(--ldal-focus-border, oklch(0.88 0.015 85)) 60%, transparent) !important;
  background: color-mix(in oklab, var(--ldal-focus-secondary, oklch(0.94 0.02 85)) 60%, transparent) !important;
  color: var(--ldal-focus-muted, oklch(0.5 0.03 250)) !important;
  opacity: 0.5;
  cursor: not-allowed;
}

.ldal-answer-token.is-dragging {
  opacity: 0.4;
}

/* Each blank: a rounded-full pill wrapping the (readonly) native input, not
 * the old dashed box — .wpProQuiz_cloze already gives it
 * inline-flex/align-items/gap/font-size:0, so only box styling is added
 * here. */
.ldal-drop-target {
  min-width: 64px;
  padding: 4px 12px !important;
  border: 2px dashed var(--ldal-focus-border, oklch(0.88 0.015 85));
  border-radius: 999px;
  background: var(--ldal-focus-card, oklch(1 0 0));
  color: var(--ldal-focus-muted, oklch(0.5 0.03 250));
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.ldal-drop-target:hover {
  border-color: var(--ldal-focus-primary, oklch(0.53 0.14 249));
  background: color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 5%, transparent);
}

.ldal-drop-target:focus-within {
  border-color: var(--ldal-focus-primary, oklch(0.53 0.14 249));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 18%, transparent);
}

.ldal-drop-target.is-drag-over {
  border-style: solid;
  border-color: var(--ldal-focus-primary, oklch(0.53 0.14 249)) !important;
  background: color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 5%, transparent) !important;
}

/* Filled (has a value): solid primary border/tint, same look the
 * correct-after-check state below intentionally reuses. */
.ldal-drop-target:has(.ldal-drop-input:not(:placeholder-shown)) {
  border-style: solid !important;
  border-color: var(--ldal-focus-primary, oklch(0.53 0.14 249)) !important;
  background: color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 10%, transparent) !important;
  color: var(--ldal-focus-primary-deep, oklch(0.38 0.12 250)) !important;
}

/* wpProQuiz adds these to the same .wpProQuiz_cloze element after "Check" —
 * .ldal-drop-target lives on that element too, so this is a compound
 * selector on one node, not a descendant match.
 *
 * A checked blank still HAS a value, so the "filled" rule above still
 * matches too — and its :has() argument (.ldal-drop-input +
 * :not(:placeholder-shown), 2 selectors) out-specifies a plain 2-class
 * compound like .wpProQuiz_answerIncorrect.ldal-drop-target (3 vs 2), so
 * without a boost the blue "filled" look would win over red "incorrect"
 * on a wrong-but-filled blank. .wpProQuiz_content/.learndash-wrapper add
 * two more classes here specifically to outrank that, not because the
 * ancestor match is otherwise needed. */
.learndash-wrapper .wpProQuiz_content .wpProQuiz_answerCorrect.ldal-drop-target {
  border-style: solid !important;
  border-color: var(--ldal-focus-primary, oklch(0.53 0.14 249)) !important;
  background: color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 10%, transparent) !important;
  color: var(--ldal-focus-primary-deep, oklch(0.38 0.12 250)) !important;
}

.learndash-wrapper .wpProQuiz_content .wpProQuiz_answerIncorrect.ldal-drop-target {
  border-style: solid !important;
  border-color: var(--ldal-focus-danger, oklch(0.55 0.22 27)) !important;
  background: color-mix(in oklab, var(--ldal-focus-danger, oklch(0.55 0.22 27)) 10%, transparent) !important;
  color: var(--ldal-focus-danger, oklch(0.55 0.22 27)) !important;
}

/* functions.php.j2's alert() override marks an empty required blank's
 * native <input> with .ldal-cloze-missing (accent border/background) —
 * color the whole pill, not just the small input box inside it, so the
 * highlight reads as one filled blank instead of a smaller square floating
 * inside a neutral dashed pill. */
.ldal-drop-target:has(.ldal-cloze-missing) {
  border-style: solid !important;
  border-color: var(--ldal-focus-accent, oklch(0.72 0.18 55)) !important;
  background: color-mix(in oklab, var(--ldal-focus-accent, oklch(0.72 0.18 55)) 12%, transparent) !important;
  color: var(--ldal-focus-accent-deep, oklch(0.45 0.15 55)) !important;
}

/* .wpProQuiz_content input[type="text"].ldal-cloze-missing (focus-mode.css)
 * is 4 classes/attributes + 1 type selector — input.ldal-drop-input alone
 * only TIES that (also 4+1), and a tie is resolved by stylesheet load
 * order, not something to rely on across two separate enqueued files.
 * Repeating .ldal-drop-input pushes the class count to 5, so this wins
 * outright regardless of load order — otherwise .ldal-cloze-missing's own
 * border-color/background can win instead, leaving the input showing its
 * own separate accent-colored box on top of the pill above. */
.learndash-wrapper .wpProQuiz_content .ldal-drop-target input.ldal-drop-input.ldal-drop-input {
  min-width: 24px;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: inherit;
  font-size: 14px !important;
  line-height: 20px !important;
  text-align: center !important;
  cursor: pointer;
}

.learndash-wrapper .wpProQuiz_content .ldal-drop-target .ldal-drop-input::placeholder {
  color: var(--ldal-focus-muted, oklch(0.5 0.03 250));
  opacity: 1;
}

/* A small inline "×" icon rather than a boxed button — hidden once there's
 * nothing to clear, and once the question has been checked. */
.ldal-clear-answer {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  min-height: 14px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: color-mix(in oklab, var(--ldal-focus-primary, oklch(0.53 0.14 249)) 70%, transparent) !important;
  box-shadow: none !important;
  cursor: pointer;
}

.ldal-clear-answer svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ldal-clear-answer:hover,
.ldal-clear-answer:focus-visible {
  color: var(--ldal-focus-danger, oklch(0.55 0.22 27)) !important;
  outline: none;
}

.ldal-drop-target:not(:has(.ldal-drop-input:not(:placeholder-shown))) .ldal-clear-answer {
  display: none !important;
}

.wpProQuiz_answerCorrect .ldal-clear-answer,
.wpProQuiz_answerIncorrect .ldal-clear-answer {
  display: none !important;
}

.ldal-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 600px) {
  .ldal-answer-token {
    min-height: 40px;
  }

  .ldal-drop-target {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ldal-drop-target,
  .ldal-answer-token {
    transition: none;
  }
}
