/* Quiz Editor (quiz.html). Builds on style.css and climb.css (the dialog and figure styles). */

.file-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

main.editor-main {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 16px;
  padding: 16px 24px 32px;
  align-items: start;
}

.pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}

.pane h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.stack {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 14px;
}

.stack input,
.stack textarea,
.stack select,
.choice-row input:not([type]) {
  font: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

/* LaTeX is easier to type and read in a fixed-width font. */
.question-form textarea,
.question-form input:not([type]) {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 14px;
}

textarea {
  resize: vertical;
}

.questions {
  margin: 4px 0 10px;
  padding-left: 26px;
  max-height: 52vh;
  overflow: auto;
}

.questions li + li {
  margin-top: 3px;
}

.question-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  font-size: 13px;
  min-height: 30px;
  background: transparent;
  border: 1px solid transparent;
}

.question-item[aria-current='true'] {
  border-color: var(--accent);
  background: var(--bg);
}

.q-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.q-problem {
  color: var(--error-text);
  font-weight: 700;
}

.problems-list {
  display: grid;
  gap: 4px;
  margin-top: 12px;
}

.problem-item {
  text-align: left;
  font-size: 13px;
  min-height: 0;
  background: var(--error-bg);
  color: var(--error-text);
  border-color: transparent;
}

.answer-fields {
  margin: 4px 0;
}

.choice-rows {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.choice-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
}

.figure-fields {
  margin-top: 12px;
}

.cheats {
  margin-top: 14px;
}

.cheats summary,
.json-view summary {
  cursor: pointer;
  font-weight: 600;
}

#cheats {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#cheats th,
#cheats td {
  border-top: 1px solid var(--border);
  padding: 6px 4px;
  text-align: left;
  vertical-align: middle;
}

#cheats th {
  font-weight: 600;
  white-space: nowrap;
}

#cheats code {
  display: block;
  font-size: 12px;
  overflow-wrap: anywhere;
}

#cheats code + code {
  margin-top: 4px;
}

.preview-card {
  width: auto;
  margin-bottom: 8px;
}

.json-view {
  margin-top: 12px;
}

.json-view textarea {
  width: 100%;
  min-height: 260px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px;
}

@media (max-width: 1150px) {
  main.editor-main {
    grid-template-columns: minmax(220px, 290px) 1fr;
  }
  .preview-pane {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  main.editor-main {
    grid-template-columns: 1fr;
    padding: 8px 16px 24px;
  }
  /* Name above, typed and drawn side by side. */
  #cheats tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 8px;
    border-top: 1px solid var(--border);
    padding: 6px 0;
  }
  #cheats th {
    grid-column: 1 / -1;
  }
  #cheats th,
  #cheats td {
    border-top: 0;
    padding: 2px 0;
  }
}

#cheats td div + div {
  margin-top: 6px;
}

/* Dialogs and link buttons shared by both editors: the World Editor's Generate,
   and the Share dialog of the World Editor and the Quiz Editor. */
.button-link {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.button-link[aria-disabled='true'] {
  opacity: 0.5;
  pointer-events: none;
}

.gen-dialog {
  max-width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 16px 20px;
}

.share-link {
  font: 12px/1.3 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  word-break: break-all;
  resize: vertical;
}

.gen-dialog::backdrop {
  background: rgba(10, 6, 20, 0.55);
}

.gen-dialog h2 {
  margin: 0 0 12px;
  font-size: 18px;
}
