/* ── JupyterBook Quiz Widget ──────────────────────────────────────── */

.jbq-ui {
  margin-top: 0.9rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid #aab4be;
  background: rgba(0,0,0,0.03);
  border-radius: 0 6px 6px 0;
}

/* ── String input ──────────────────────────────────────────────────── */
.jbq-string {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.jbq-string input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.35rem 0.6rem;
  font-size: 0.92rem;
  font-family: var(--pst-font-family-monospace, monospace);
  border: 1px solid #c5cdd6;
  border-radius: 4px;
  background: #fff;
  color: #111;
}

.jbq-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.6rem;
  font-size: 0.92rem;
  font-family: var(--pst-font-family-monospace, monospace);
  border: 1px solid #c5cdd6;
  border-radius: 4px;
  background: #fff;
  color: #111;
  resize: vertical;
  line-height: 1.45;
}

/* ── Multiple choice ───────────────────────────────────────────────── */
.jbq-mc {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* Hint label for tick-all-that-apply mode */
.jbq-mc-multi::before {
  content: "Select all that apply";
  display: block;
  font-size: 0.78rem;
  font-style: italic;
  color: #667;
  margin-bottom: 0.3rem;
}

.jbq-choice {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.5;
}

.jbq-choice input[type="radio"],
.jbq-choice input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Dropdown (select) ─────────────────────────────────────────────── */
.jbq-select {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.jbq-select-input {
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  border: 1px solid #c5cdd6;
  border-radius: 4px;
  background: #fff;
  color: #111;
  max-width: 32rem;
  cursor: pointer;
}

/* ── Button row ────────────────────────────────────────────────────── */
.jbq-btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

/* Shared button */
.jbq-ui button {
  padding: 0.35rem 0.9rem;
  font-size: 0.88rem;
  border: 1px solid #778;
  border-radius: 4px;
  background: #f5f6f7;
  cursor: pointer;
  white-space: nowrap;
}

.jbq-ui button:hover:not(:disabled) { background: #e8eaec; }
.jbq-ui button:disabled { opacity: 0.5; cursor: default; }

/* Reset button — appears in place of Check after a correct answer */
.jbq-reset-btn {
  background: transparent !important;
  border-color: #aab !important;
  color: #555 !important;
}
.jbq-reset-btn:hover { background: #f0f0f0 !important; }

/* "Show solution" is visually secondary */
.jbq-show-btn {
  background: transparent !important;
  border-color: #aab !important;
  color: #555 !important;
}
.jbq-show-btn:hover:not(:disabled) { background: #f0f0f0 !important; }

/* ── Feedback line ─────────────────────────────────────────────────── */
.jbq-feedback {
  width: 100%;
  font-size: 0.88rem;
  font-weight: 500;
  margin-top: 0.35rem;
  min-height: 1.2em;
}

.jbq-correct { color: #1e7e34; }
.jbq-wrong   { color: #b02020; }
.jbq-warn    { color: #856404; }

/* ── Solution reveal ───────────────────────────────────────────────── */
/* Outer wrapper — shared by both string and MC */
.jbq-solution-reveal {
  margin-top: 0.6rem;
  padding: 0.6rem 0.85rem;
  border-left: 3px solid #4a90d9;
  background: #eef4fb;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  color: #1a3a5c;
}

/* Inner cloned content (prose, code blocks, etc.) */
.jbq-solution-reveal pre {
  background: rgba(0,0,0,0.05);
  padding: 0.4rem 0.65rem;
  border-radius: 3px;
  overflow-x: auto;
  white-space: pre;
  font-family: var(--pst-font-family-monospace, monospace);
}

.jbq-solution-reveal p { margin: 0.4rem 0; }
.jbq-solution-reveal p:first-child { margin-top: 0; }
.jbq-solution-reveal p:last-child  { margin-bottom: 0; }

/* MC-specific inner content block (full solution body) */
.jbq-solution-mc-content {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(74,144,217,0.25);
}

/* Answer summary line at the bottom of MC reveal */
.jbq-answer-line {
  font-style: italic;
  font-size: 0.88rem;
  color: #1a3a5c;
  margin: 0 !important;
}

/* ── Dark mode ─────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  .jbq-ui {
    background: rgba(255,255,255,0.04);
    border-left-color: #556;
  }
  .jbq-string input[type="text"],
  .jbq-textarea {
    background: #1e2127;
    color: #d4d4d4;
    border-color: #444;
  }
  .jbq-select-input {
    background: #1e2127;
    color: #d4d4d4;
    border-color: #444;
  }
  .jbq-mc-multi::before { color: #99a; }
  .jbq-ui button {
    background: #2a2d35;
    color: #ccc;
    border-color: #555;
  }
  .jbq-ui button:hover:not(:disabled) { background: #33373f; }
  .jbq-show-btn,
  .jbq-reset-btn { color: #999 !important; border-color: #555 !important; }
  .jbq-show-btn:hover:not(:disabled),
  .jbq-reset-btn:hover  { background: #33373f !important; }
  .jbq-solution-reveal {
    background: #1a2535;
    border-left-color: #3a78c9;
    color: #a8c8f0;
  }
  .jbq-solution-reveal pre { background: rgba(255,255,255,0.06); }
  .jbq-answer-line { color: #a8c8f0; }
  .jbq-solution-mc-content { border-bottom-color: rgba(58,120,201,0.3); }
  .jbq-correct { color: #5cb85c; }
  .jbq-wrong   { color: #e06060; }
}
