/* World Editor (world.html). Builds on style.css, climb.css (stage, touch buttons) and quiz.css (panes, stacks, problem items). */

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

.pane h2.sub {
  margin-top: 18px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
}

.palette button {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 4px 2px;
  font-size: 12px;
  line-height: 1.2;
  min-height: 0;
}

.palette canvas {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.palette button[aria-checked='true'],
.tools button[aria-checked='true'] {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.palette kbd {
  color: var(--muted);
  font-size: 11px;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

#block-help {
  min-height: 2.6em;
  font-size: 13px;
}

.zones {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 10px;
}

.zone {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.zone-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.zone input,
.zone select {
  font: inherit;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.zone .zone-name {
  flex: 1;
  font-weight: 600;
}

.zone input[type='number'] {
  width: 4.5em;
}

.zone .laser-times {
  padding-left: 22px;
}

.zone .buttons button {
  font-size: 13px;
  min-height: 0;
  padding: 4px 10px;
}

.zone-problem:empty {
  display: none;
}

.map-row {
  display: flex;
  gap: 8px;
}

.map-stage {
  flex: 1;
  height: min(78vh, 920px);
  min-height: 360px;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: var(--stage);
  touch-action: none;
  cursor: crosshair;
}

/* Over the start, a flag or the star with the Paint tool: a press drags it (map.ts). */
#map.grab {
  cursor: grab;
}

#map.grabbing {
  cursor: grabbing;
}

/* The touch buttons only while test-playing: otherwise a finger paints. */
.map-stage .touch:not(.on) {
  display: none;
}

#map:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.minimap {
  width: 44px;
  height: min(78vh, 920px);
  min-height: 360px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--stage);
  cursor: pointer;
  touch-action: none;
}

.empty-map {
  position: absolute;
  inset: 40% 24px auto;
  margin: 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--error-bg);
  color: var(--error-text);
  text-align: center;
}

.cursor-line {
  min-height: 1.4em;
  margin: 6px 0 0;
  font-size: 13px;
}

.play-bar {
  margin-top: 8px;
  align-items: center;
}

.route {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
}

.route.good {
  border-left: 4px solid #3ccf7e;
}

.route.bad {
  border-left: 4px solid var(--error-text);
}

.text-view textarea {
  width: 100%;
  min-height: 260px;
  font: 13px/1.25 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.text-view,
.legend {
  margin-top: 12px;
}

.legend-list {
  padding-left: 18px;
  font-size: 14px;
  display: grid;
  gap: 4px;
}

.legend-list code {
  font-weight: 700;
}

.gen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 12px;
}

.gen-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 4px 12px;
}

.gen-dialog fieldset {
  margin-bottom: 10px;
}

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

@media (max-width: 760px) {
  main.world-main {
    grid-template-columns: 1fr;
    padding: 8px 16px 24px;
  }
  /* The map first: it is what you work on. */
  .map-pane {
    order: -1;
  }
  .map-stage,
  .minimap {
    height: 66vh;
  }
  .minimap {
    width: 32px;
  }
}
