/* All styling for the Animator app. The .gleam files only attach class names. */

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

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

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

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* 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 {
  flex-shrink: 0;
  color: #e8d8b0;
  font-family: 'Georgia', serif;
  font-size: 16px;
  letter-spacing: 1px;
}

.drawing-select {
  flex: 1;
  min-width: 0;
  background: #2a2a4a;
  color: #e8d8b0;
  border: 1px solid #4a4a8a;
  border-radius: 4px;
  padding: 5px 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  cursor: pointer;
}
.drawing-select:hover { background: #34345a; }
.drawing-select:focus { outline: 1px solid #6a6aaa; }

/* 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;
  max-height: 220px;
  overflow-y: auto;
}
.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;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a14;
  container-type: size;
}

/* Shape and speed sliders, floating over the canvas's top-right corner.
   The reveal button owns the top-left. */
.controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(220px, calc(100% - 24px));
  padding: 10px 12px;
  border: 1px solid #3a3a5e;
  border-radius: 6px;
  background: rgba(18, 18, 42, 0.92);
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.control-label {
  flex-shrink: 0;
  color: #b8a888;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  width: 42px;
}

.control-value {
  flex-shrink: 0;
  color: #e8d8b0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  width: 32px;
  text-align: right;
}

.control-slider {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  accent-color: #8a8aca;
  cursor: pointer;
}

.control-actions {
  display: flex;
  gap: 6px;
}

.control-btn {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  padding: 5px 6px;
}

.control-select {
  flex: 1;
  min-width: 0;
  background: #2a2a4a;
  color: #e8d8b0;
  border: 1px solid #4a4a8a;
  border-radius: 4px;
  padding: 3px 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  cursor: pointer;
}
.control-select:hover { background: #34345a; }
.control-select:focus { outline: 1px solid #6a6aaa; }

/* A parse or evaluation failure, over the last good drawing. Sits at the
   bottom so it does not cover the reveal button at the top-left. */
.canvas-error {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  max-height: 40%;
  overflow: auto;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #a44;
  border-radius: 4px;
  background: rgba(20, 8, 12, 0.92);
  color: #ffb4b4;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 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);
}

/* ── In-page new-drawing dialog (fallback when window.prompt is suppressed) ── */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 6, 16, 0.68);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(340px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid #4a4a8a;
  border-radius: 6px;
  background: #1a1a3e;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.modal-title {
  color: #e8d8b0;
  font-family: 'Georgia', serif;
  font-size: 15px;
}

.modal-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #4a4a8a;
  border-radius: 4px;
  background: #0d0d1a;
  color: #e8d8b0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
}
.modal-input:focus {
  outline: 1px solid #8a8aca;
  border-color: #8a8aca;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  padding: 6px 12px;
}

.modal-btn-primary {
  background: #3a3a72;
  border-color: #6a6aba;
  color: #fff6dc;
}
.modal-btn-primary:hover {
  background: #4a4a8a;
}

