/* =====================================================================
   Toy Tanks, the mission editor: the game's toy box (styles.css), the
   arena on one side and a toy-box label of tools on the other (on a
   phone, one under the other, the page scrolling).
   ===================================================================== */

body.editor { overflow-x: hidden; overflow-y: auto; padding: 56px 12px 28px; --stick: clamp(88px, 29vw, 116px); }
#ed { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 10px 20px; max-width: 1280px; margin: 0 auto; }
.ed-head { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 14px; }
.ed-title {
  font-weight: 400; font-size: 28px; line-height: 1.1; letter-spacing: 0.02em; color: var(--yellow); text-transform: uppercase;
  text-shadow: 0 3px 0 var(--red-deep), 0 5px 0 rgba(0, 0, 0, 0.25);
}
.ed-sub { font-size: 17px; color: var(--cream); }

/* ---- the arena --------------------------------------------------------------------- */
.ed-boardcol { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
#ed-board { display: block; border-radius: 6px; box-shadow: 0 6px 0 var(--navy), 0 10px 22px rgba(0, 0, 0, 0.35); touch-action: none; cursor: crosshair; }
body.testing #ed-board { cursor: none; }
.ed-status { min-height: 21px; max-width: 640px; font-size: 15px; line-height: 1.4; text-align: center; color: var(--cream); }
.ed-status.bad { color: var(--yellow); }
.ed-testbar { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--cream); }
.ed-testbar[hidden] { display: none; }
.ed-testbar .ghost { padding: 5px 16px; font-size: 15px; }
/* the sticks only while a test runs, and only on a touch screen (styles.css) */
body.editor:not(.testing) #pad { display: none; }
@media (hover: none) { body.editor.testing #pad { display: flex; } }

/* ---- the tools: a toy-box label ------------------------------------------------------ */
.ed-side {
  width: min(520px, 100%); display: flex; flex-direction: column; gap: 8px; color: var(--ink);
  background: var(--cream); border: 5px solid var(--yellow); border-radius: 16px; padding: 12px 14px 14px;
  box-shadow: 0 6px 0 var(--yellow-deep), 0 14px 30px rgba(0, 0, 0, 0.35);
}
/* (between a laptop and a phone: a narrower label beside a smaller arena) */
@media (min-width: 760px) and (max-width: 1099px) { .ed-side { width: 340px; } }
/* (a test plays in the arena: the tools wait) */
body.testing .ed-side { opacity: 0.55; pointer-events: none; }
.ed-side h2 { font-weight: 400; font-size: 20px; line-height: 1.15; color: var(--red); }
.ed-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 5px; }
.ed-palette button {
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; min-width: 0;
  font-family: var(--face); font-size: 12px; line-height: 1.2; color: var(--ink);
  background: #fff; border: 2px solid var(--blue); border-radius: 8px; padding: 3px 2px 2px; box-shadow: 0 2px 0 var(--blue-deep);
}
.ed-palette button canvas { display: block; width: 26px; height: 26px; }
.ed-palette button[aria-pressed="true"] { color: var(--cream); background: var(--blue); border-color: var(--blue-deep); }
.ed-palette button:focus-visible { outline: 3px solid var(--red); outline-offset: 1px; }
.ed-what { min-height: 36px; font-size: 13px; line-height: 1.4; color: var(--ink-dim); }
.ed-field { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.ed-field input {
  flex: 1; min-width: 0; font-family: var(--face); font-size: 15px; color: var(--ink);
  background: #fff; border: 2px solid var(--blue); border-radius: 8px; padding: 5px 8px;
}
.ed-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-row > * { flex: 1 1 auto; }
.ed-side .ghost, .ed-side .playbtn { font-size: 15px; padding: 7px 10px; border-radius: 10px; }
.ed-side .playbtn { width: auto; }
.ed-side button:disabled { opacity: 0.45; cursor: default; box-shadow: none; transform: none; }
.ed-saved { display: flex; flex-direction: column; gap: 5px; }
.ed-saved .empty { font-size: 13px; color: var(--ink-dim); }
.saved-item { display: flex; align-items: center; gap: 5px; }
.saved-item .nm { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item.editing .nm { color: var(--red); }
.saved-item button {
  cursor: pointer; font-family: var(--face); font-size: 13px; color: var(--blue-deep);
  background: #fff; border: 2px solid var(--blue); border-radius: 8px; padding: 2px 8px; box-shadow: 0 2px 0 var(--blue-deep);
}
.ed-back { display: block; margin-top: 4px; text-align: center; text-decoration: none; }

/* ---- export and import ------------------------------------------------------------------- */
#ed-io .card { width: min(560px, 100%); }
#ed-io textarea {
  display: block; width: 100%; height: 230px; margin-top: 10px; resize: vertical;
  font: 12px/1.35 Consolas, "Courier New", monospace; color: var(--ink);
  background: #fff; border: 2px solid var(--blue); border-radius: 8px; padding: 8px;
}
.ed-io-note { margin-top: 8px; font-size: 13px; line-height: 1.4; color: var(--ink-dim); }
.ed-io-note.bad { color: var(--red); }

@media (max-width: 520px) {
  body.editor { padding: 52px 8px 24px; }
  .ed-title { font-size: 22px; }
  .ed-sub { font-size: 15px; }
  .ed-status { font-size: 14px; }
  .ed-row > * { flex-basis: 40%; }
  #ed-io textarea { height: 180px; }
}
