/* The Create Fractal button on the menu, and the formula editor page.
   The page shell, button and input come from design/chrome.css. */

.create {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.create-btn {
  --wobble-scale: 1.04;
  --wobble-tilt: 1.5deg;
  padding: 0.7rem 1.4rem;
  font-family: var(--display);
  font-stretch: condensed;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

.create-btn:hover,
.create-btn:focus-visible {
  animation: wobble 900ms ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .create-btn:hover,
  .create-btn:focus-visible { animation: none; }
}

.editor {
  display: grid;
  align-content: start;
  gap: 2rem;
  width: 100%;
}

@media (min-width: 900px) {
  .editor {
    grid-template-columns: minmax(0, 60ch) minmax(0, 30rem);
    align-items: start;
  }
}

.editor-form {
  display: grid;
  align-content: start;
  gap: 0.6rem;
  min-width: 0;
  max-width: 60ch;
}

.editor-label {
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.editor-name {
  font-size: 1.05rem;
  padding: 0.6rem 0.7rem;
}

/* The formula's label, with the two buttons that write the line for you at
   the other end of the row. */
.editor-head {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.editor-head .editor-label {
  margin-right: auto;
}

.editor-make {
  padding: 0.2rem 0.7rem;
}

#make-help b {
  color: var(--ink);
  font-weight: 400;
}

/* The coloured line sits under a transparent input, which keeps the caret,
   the selection and the scroll. Both boxes take the same metrics so the two
   layers land character on character. */
.editor-field {
  position: relative;
}

.editor-input,
.editor-ink {
  font-family: var(--mono);
  font-size: 1.25rem;
  line-height: 1.4;
  padding: 0.6rem 0.7rem;
  font-variant-ligatures: none;
}

.editor-input {
  position: relative;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
}

.editor-input::selection {
  background: var(--select);
  color: transparent;
}

.editor-ink {
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  overflow: hidden;
  white-space: pre;
  pointer-events: none;
}

.tok-var { color: var(--syn-var); }
.tok-num { color: var(--syn-num); }
.tok-const { color: var(--syn-const); }
.tok-func { color: var(--syn-func); }
.tok-op { color: var(--syn-op); }
.tok-assign { color: var(--dim); }
.tok-index { color: var(--dim); }
.tok-bad { color: var(--syn-bad); }
.tok-nest-0 { color: var(--syn-nest-0); }
.tok-nest-1 { color: var(--syn-nest-1); }
.tok-nest-2 { color: var(--syn-nest-2); }
.tok-nest-3 { color: var(--syn-nest-3); }
.tok-nest-4 { color: var(--syn-nest-4); }
.tok-nest-5 { color: var(--syn-nest-5); }

.editor-seeds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.6rem 1rem;
  margin-top: 0.4rem;
}

.editor-seed {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.editor-seed .editor-input,
.editor-seed .editor-ink {
  font-size: 1.05rem;
}

.editor-var-head {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.editor-var-name {
  width: 2rem;
  flex: 0 0 auto;
  padding: 0.05rem 0.2rem;
  font-family: var(--mono);
  text-align: center;
  color: var(--syn-var);
  background: transparent;
  border-color: transparent;
}

.editor-var-name:hover { border-color: var(--line); }

.editor-var-drop {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--dim);
  border: 1px solid transparent;
  transition: color var(--motion), border-color var(--motion);
}

.editor-var-drop:hover,
.editor-var-drop:focus-visible {
  color: var(--magenta);
  border-color: var(--magenta);
}

.editor-add {
  margin: 0;
  justify-self: start;
}

.editor-help {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  color: var(--dim);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.editor-fixed {
  margin: 0.6rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  color: var(--dim);
}

.editor-preview {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  min-width: 0;
  max-width: 30rem;
  transition: opacity var(--motion);
}

.editor-preview.stale { opacity: 0.3; }

.preview-note {
  margin: 0;
  min-height: 1.4em;
  color: var(--dim);
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  .editor-preview { transition: none; }
}
