/* All styling for the Animator app. Its code only attaches class names. */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

/* ── Layout: two columns ─────────────────────────────────────────────────── */

.app {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: #1a1a2e;
  color: #d4c5a0;
  font-family: system-ui, sans-serif;
  font-size: 14px;
}

/* Left column: the code editor. */
.code-col {
  width: 42%;
  min-width: 320px;
  max-width: 720px;
  flex-shrink: 0;
  display: flex;
  border-right: 1px solid #3a3a5e;
  background: #0f0f1e;
}

/* The code column stays in the DOM when collapsed, so CodeMirror keeps its
   state; hiding it gives the right column the full width. */
.app.code-hidden .code-col { display: none; }

/* A small emoji button (the code pane's collapse toggle, and the playback
   controls once they exist). */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2a2a4a;
  color: #d4c5a0;
  border: 1px solid #4a4a8a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 5px 8px;
}
.icon-btn:hover { background: #3a3a5e; }

/* ── Code panel (left column) ───────────────────────────────────────────── */

.code-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #1a1a3e;
  border-bottom: 1px solid #3a3a5e;
}
.code-title {
  color: #e8d8b0;
  font-family: 'Georgia', serif;
  font-size: 16px;
  letter-spacing: 1px;
}

/* Wrapper holding the editor. */
.code-editor-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
}
/* CodeMirror mount node: grows to fill the panel. */
.code-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  background: #0d0d1a;
}
.code-editor .cm-editor { width: 100%; height: 100%; }

/* Collapsible reference of the built-ins available to draw functions. */
.reference {
  margin: 8px 14px 0;
  border: 1px solid #3a3a5e;
  border-radius: 4px;
  background: #0d0d1a;
  overflow: hidden;
}
.reference-summary {
  padding: 6px 12px;
  cursor: pointer;
  color: #b8a888;
  font-family: monospace;
  font-size: 12px;
  user-select: none;
}
.reference-summary:hover { color: #e8d8b0; }
.reference-body {
  padding: 4px 12px 10px;
  border-top: 1px solid #3a3a5e;
}
.reference-group { margin-top: 8px; }
.reference-group-title {
  color: #8a8aca;
  font-family: monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.reference-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 1px 0;
}
.reference-sig {
  color: #89ddff;
  font-family: monospace;
  font-size: 12px;
  white-space: pre;
}
.reference-desc { color: #6a7a8a; font-size: 11px; }

/* ── Animation area (right column) ──────────────────────────────────────── */

.canvas-area {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a14;
  container-type: size;
}

/* The interpreter's List(Path) (or its error), shown as text before the
   animation pane is built. */
.output {
  align-self: stretch;
  margin: 0;
  padding: 16px;
  overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #cfe3ff;
  white-space: pre-wrap;
  word-break: break-word;
}
/* Leave room for the reveal button, which only overlays this pane while the
   code column is hidden. */
.app.code-hidden .output { padding-top: 48px; }

/* Button that reveals the code column again when it is hidden. */
.reveal-code {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
}

/* A centred square that fits the (possibly non-square) animation area. Give your
   <canvas> this class, so that drawings aren't stretched. */
.canvas {
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
}


/* The current error in the user's code, overlaid along the bottom of the
   animation pane while the last good drawing stays visible behind it. */
.error-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  margin: 0;
  padding: 10px 14px;
  max-height: 40%;
  overflow: auto;
  border-left: 3px solid #ff6b6b;
  border-radius: 4px;
  background: rgba(40, 10, 16, 0.92);
  color: #ffb3b3;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Right column: animation above, controls below ─────────────────────── */

.anim-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.anim-col .canvas-area { min-height: 0; }

/* The playback bar under the canvas. */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 10px 14px;
  background: #1a1a3e;
  border-top: 1px solid #3a3a5e;
}
.slider {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 180px;
}
.slider input[type="range"] {
  flex: 1;
  min-width: 80px;
  accent-color: #7fdbff;
}
.slider-label { color: #e8d8b0; }
.slider-value {
  min-width: 3.5em;
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #cfe3ff;
}

/* The drawing library's drop-down, at the start of the control bar. */
.drawing-select {
  background: #2a2a4a;
  color: #e8d8b0;
  border: 1px solid #4a4a8a;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  max-width: 180px;
  cursor: pointer;
}
.drawing-select:hover { background: #3a3a5e; }

/* ── Line Dodger (the game extension) ──────────────────────────────────── */

/* The animation canvas and the game's transparent overlay, stacked. */
.canvas-stack {
  position: relative;
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
}
.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.icon-btn.active {
  background: #4a3a1a;
  border-color: #ffd166;
}

/* Instructions / result, along the top of the animation pane. */
.game-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  max-width: calc(100% - 120px);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  background: rgba(26, 26, 62, 0.9);
  border: 1px solid #4a4a8a;
  color: #fff3c4;
}
.game-banner.lost { border-color: #ff5c7a; color: #ffc2cd; }
.game-banner.won { border-color: #5cff9d; color: #c9ffdf; }
