/* Equations inside the editor and in rendered content */

.lexxy-math {
  display: inline-block;
  padding: 0 0.1em;
  border-radius: 0.2em;
}

lexxy-editor .lexxy-math {
  cursor: pointer;
}

.lexxy-math--display {
  display: block;
  text-align: center;
  margin: 0.5em 0;
}

lexxy-editor .lexxy-math:hover {
  background-color: color-mix(in srgb, currentColor 8%, transparent);
  outline: 1px solid color-mix(in srgb, currentColor 20%, transparent);
}

lexxy-editor .lexxy-math.selected,
lexxy-editor [data-lexical-decorator="true"]:focus .lexxy-math {
  outline: 2px solid var(--lexxy-math-focus-color, #2563eb);
}

.lexxy-math--error {
  color: var(--lexxy-math-error-color, #b91c1c);
  font-family: monospace;
  outline: 1px dashed var(--lexxy-math-error-color, #b91c1c);
}

/* Equation editor dialog */

.lexxy-math-editor::backdrop {
  background: var(--lexxy-math-backdrop-color, rgba(0, 0, 0, 0.35));
}

.lexxy-math-editor {
  /* Restores the UA's `dialog:modal { margin: auto }` centring, which any host reset
     that zeroes margin on `*` (Tailwind preflight, normalize.css, Bootstrap reboot)
     overrides — author origin beats UA origin regardless of cascade layers. Do not remove. */
  margin: auto;
  min-width: min(28rem, 90vw);
  background: var(--lexxy-math-dialog-bg, Canvas);
  color: var(--lexxy-math-text-color, CanvasText);
  border: 1px solid var(--lexxy-math-dialog-border-color, #d4d4d8);
  border-radius: var(--lexxy-math-dialog-radius, 0.5rem);
  padding: 1rem;
  box-shadow: var(--lexxy-math-dialog-shadow, 0 10px 30px rgba(0, 0, 0, 0.15));
}

.lexxy-math-editor form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lexxy-math-editor__label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--lexxy-math-muted-color, #52525b);
}

.lexxy-math-editor textarea {
  font-family: ui-monospace, monospace;
  font-size: 0.95rem;
  padding: 0.5rem;
  background: var(--lexxy-math-input-bg, Field);
  color: var(--lexxy-math-input-text-color, FieldText);
  border: 1px solid var(--lexxy-math-input-border-color, #d4d4d8);
  border-radius: var(--lexxy-math-input-radius, 0.375rem);
  resize: vertical;
}

.lexxy-math-editor__preview {
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: 1px dashed var(--lexxy-math-input-border-color, #d4d4d8);
  border-radius: var(--lexxy-math-input-radius, 0.375rem);
  overflow-x: auto;
}

.lexxy-math-editor__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.lexxy-math-editor__display-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.lexxy-math-editor__actions {
  display: flex;
  gap: 0.5rem;
}

.lexxy-math-editor__actions button {
  padding: 0.35rem 0.9rem;
  border-radius: var(--lexxy-math-input-radius, 0.375rem);
  border: 1px solid var(--lexxy-math-input-border-color, #d4d4d8);
  background: var(--lexxy-math-dialog-bg, Canvas);
  color: var(--lexxy-math-text-color, CanvasText);
  cursor: pointer;
}

.lexxy-math-editor__actions button[data-behavior="confirm"] {
  background: var(--lexxy-math-focus-color, #2563eb);
  border-color: var(--lexxy-math-focus-color, #2563eb);
  color: var(--lexxy-math-focus-content-color, white);
}
